diff --git a/RightToAskClient/RightToAskClient.Maui/AppShell.xaml b/RightToAskClient/RightToAskClient.Maui/AppShell.xaml index 0018b61e..f0a9ea5d 100644 --- a/RightToAskClient/RightToAskClient.Maui/AppShell.xaml +++ b/RightToAskClient/RightToAskClient.Maui/AppShell.xaml @@ -1,14 +1,154 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RightToAskClient/RightToAskClient.Maui/AppShell.xaml.cs b/RightToAskClient/RightToAskClient.Maui/AppShell.xaml.cs index c0f939fb..05ee6c40 100644 --- a/RightToAskClient/RightToAskClient.Maui/AppShell.xaml.cs +++ b/RightToAskClient/RightToAskClient.Maui/AppShell.xaml.cs @@ -1,10 +1,45 @@ -namespace RightToAskClient.Maui +using System; +using System.Diagnostics; +using RightToAskClient.Maui.Models; +using RightToAskClient.Maui.ViewModels; +using Microsoft.Maui.Controls; +using Microsoft.Maui; + +namespace RightToAskClient.Maui.Views { - public partial class AppShell : Shell + public partial class AppShell : Microsoft.Maui.Controls.Shell { public AppShell() { InitializeComponent(); + Routing.RegisterRoute(nameof(QuestionAskerPage), typeof(QuestionAskerPage)); + Routing.RegisterRoute(nameof(QuestionDetailPage), typeof(QuestionDetailPage)); + Routing.RegisterRoute(nameof(RegisterAccountPage), typeof(RegisterAccountPage)); + Routing.RegisterRoute(nameof(FindMPsPage), typeof(FindMPsPage)); + Routing.RegisterRoute(nameof(OtherUserProfilePage), typeof(OtherUserProfilePage)); + Routing.RegisterRoute(nameof(QuestionAnswererPage), typeof(QuestionAnswererPage)); + Routing.RegisterRoute(nameof(AdvancedSearchFiltersPage), typeof(AdvancedSearchFiltersPage)); + Routing.RegisterRoute(nameof(MPRegistrationVerificationPage), typeof(MPRegistrationVerificationPage)); + Routing.RegisterRoute(nameof(HowAnsweredOptionPage), typeof(HowAnsweredOptionPage)); + Routing.RegisterRoute(nameof(QuestionBackgroundPage), typeof(QuestionBackgroundPage)); + Routing.RegisterRoute(nameof(SelectableListPage), typeof(SelectableListPage)); + Routing.RegisterRoute(nameof(ReportQuestionPage), typeof(ReportQuestionPage)); + Routing.RegisterRoute(nameof(CodeOfConductPage), typeof(CodeOfConductPage)); + // Routing.RegisterRoute(nameof(FindMPsPage), typeof(FindMPsPage)); + } + + protected override void OnNavigating(ShellNavigatingEventArgs args) + { + base.OnNavigating(args); + if (args.Target.Location.OriginalString.ToLower().Contains("account")) + { + AccountPageExchanger.Registration = IndividualParticipant.getInstance().ProfileData.RegistrationInfo; + } + + if (args.Target.Location.OriginalString.ToLower().Contains("readingpagebyquestionwriter")) + { + ReadingPageExchanger.ByQuestionWriter = true; + } } } } \ No newline at end of file diff --git a/RightToAskClient/RightToAskClient.Maui/Helpers/HyperLinkSpan.cs b/RightToAskClient/RightToAskClient.Maui/Helpers/HyperLinkSpan.cs new file mode 100644 index 00000000..c88a335f --- /dev/null +++ b/RightToAskClient/RightToAskClient.Maui/Helpers/HyperLinkSpan.cs @@ -0,0 +1,40 @@ +using Android.Content.Res; +using RightToAskClient.Maui.Resx; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RightToAskClient.Maui.Helpers +{ + //https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/label?view=net-maui-8.0#create-a-hyperlink + public class HyperlinkSpan : Span + { + public static readonly BindableProperty UrlProperty = + BindableProperty.Create(nameof(Url), typeof(string), typeof(HyperlinkSpan), null); + + public string Url + { + get { return (string)GetValue(UrlProperty); } + set { SetValue(UrlProperty, value); } + } + + public HyperlinkSpan() + { + TextDecorations = TextDecorations.Underline; + TextColor = (Color)Application.Current.Resources["UrlTextColorLightMode"]; + GestureRecognizers.Add(new TapGestureRecognizer + { + // Launcher.OpenAsync is provided by Essentials. + Command = new Command(async () => await OpenUrl(Url)) + }); + } + + //TODO: test on real device + public async Task OpenUrl(string url) + { + await Launcher.OpenAsync(url); + } + } +} diff --git a/RightToAskClient/RightToAskClient.Maui/Helpers/NavigationUtils.cs b/RightToAskClient/RightToAskClient.Maui/Helpers/NavigationUtils.cs index 5c4240e3..c3c04b30 100644 --- a/RightToAskClient/RightToAskClient.Maui/Helpers/NavigationUtils.cs +++ b/RightToAskClient/RightToAskClient.Maui/Helpers/NavigationUtils.cs @@ -7,6 +7,7 @@ using CommunityToolkit.Maui.Extensions; using Microsoft.Maui.Controls; using Microsoft.Maui; +using CommunityToolkit.Maui.Views; /* This class contains some utilities for popping up and using pages, which may be accessed * at any time by the app, for example the pages for finding your MP, which needs to be @@ -94,14 +95,14 @@ public static async Task DoRegistrationCheck(Registration registration, string c AppResources.OKText, false); //TODO: - //var popupResult = await App.Current.MainPage.Navigation.ShowPopupAsync(popup); - //if (popup.HasApproved(popupResult)) - //{ - // var registerAccountFlow = new CodeOfConductPage(registration); - // await Application.Current.MainPage.Navigation.PushAsync(registerAccountFlow); - // // var registerAccountPage = new RegisterAccountPage(registration); - // // await Application.Current.MainPage.Navigation.PushAsync(registerAccountPage); - //} + var popupResult = await App.Current.MainPage.ShowPopupAsync(popup); + if (popup.HasApproved(popupResult)) + { + var registerAccountFlow = new CodeOfConductPage(registration); + await Application.Current.MainPage.Navigation.PushAsync(registerAccountFlow); + // var registerAccountPage = new RegisterAccountPage(registration); + // await Application.Current.MainPage.Navigation.PushAsync(registerAccountPage); + } } } } \ No newline at end of file diff --git a/RightToAskClient/RightToAskClient.Maui/MainPage.xaml b/RightToAskClient/RightToAskClient.Maui/MainPage.xaml index 5c179bdb..02f5df05 100644 --- a/RightToAskClient/RightToAskClient.Maui/MainPage.xaml +++ b/RightToAskClient/RightToAskClient.Maui/MainPage.xaml @@ -6,27 +6,28 @@ xmlns:local="clr-namespace:RightToAskClient.Maui" xmlns:helpers="clr-namespace:RightToAskClient.Maui.Helpers;assembly=RightToAskClient.Maui" x:Class="RightToAskClient.Maui.MainPage" - Title="{StaticResource ApplicationTitle}" + xmlns:strings="clr-namespace:RightToAskClient.Maui.Resx" + Title="{x:Static strings:AppResources.ApplicationTitle}" Shell.FlyoutBehavior="Flyout" x:DataType="vm:MainPageViewModel"> - + IconImageSource="help_75.png" Priority="0" /> -