From ef5e91aad12d110dea270856f3a33b8ab7e2bd22 Mon Sep 17 00:00:00 2001 From: Tsanie Lily Date: Thu, 17 Mar 2022 20:29:27 +0800 Subject: [PATCH] feature: shortcut --- Billing.Shared/App.cs | 13 +++++- Billing.Shared/MainShell.xaml.cs | 3 ++ Billing.Shared/SplashPage.xaml.cs | 2 +- Billing.Shared/Store/StoreHelper.cs | 4 +- Billing.Shared/Views/AddBillPage.xaml.cs | 1 + Billing.Shared/Views/RankPage.xaml | 15 +++--- .../Billing.Android/Billing.Android.csproj | 4 +- Billing/Billing.Android/MainActivity.cs | 19 +++++++- .../Properties/AndroidManifest.xml | 2 +- .../Resources/Resource.designer.cs | 46 +++++++++++-------- .../Resources/values-zh-rCN/strings.xml | 1 + .../Resources/values/strings.xml | 1 + .../Resources/xml/shortcuts.xml | 6 +++ Billing/Billing.Android/SplashActivity.cs | 3 ++ Billing/Billing.iOS/AppDelegate.cs | 21 ++++++++- .../Billing.iOS/Base.lproj/InfoPlist.strings | 1 + Billing/Billing.iOS/Info.plist | 11 +++++ .../zh-Hans.lproj/InfoPlist.strings | 1 + 18 files changed, 118 insertions(+), 36 deletions(-) create mode 100644 Billing/Billing.Android/Resources/xml/shortcuts.xml diff --git a/Billing.Shared/App.cs b/Billing.Shared/App.cs index dc9cd94..cc0fd7f 100644 --- a/Billing.Shared/App.cs +++ b/Billing.Shared/App.cs @@ -13,6 +13,7 @@ namespace Billing { public class App : Application { + internal const string NewBillAction = "/newbill"; private const string SaveLocationKey = nameof(SaveLocationKey); public static AppTheme CurrentTheme { get; private set; } @@ -21,17 +22,27 @@ namespace Billing public static List Accounts => accounts ??= new List(); public static List Categories => categories ??= new List(); public static bool SaveLocation => saveLocation; + public static string MainRoute => mainRoute; private static List bills; private static List accounts; private static List categories; private static bool saveLocation; + private static string mainRoute; private string initialUrl; public App(string url = null) { - initialUrl = url; + if (url == NewBillAction) + { + mainRoute = "//Bills/Details"; + } + else + { + mainRoute = "//Bills"; + initialUrl = url; + } CurrentCulture = new PlatformCulture(); InitResources(); diff --git a/Billing.Shared/MainShell.xaml.cs b/Billing.Shared/MainShell.xaml.cs index 8146bcc..d571a06 100644 --- a/Billing.Shared/MainShell.xaml.cs +++ b/Billing.Shared/MainShell.xaml.cs @@ -1,3 +1,4 @@ +using Billing.Views; using Xamarin.Forms; namespace Billing @@ -6,6 +7,8 @@ namespace Billing { public MainShell() { + Routing.RegisterRoute("Bills/Details", typeof(AddBillPage)); + InitializeComponent(); } } diff --git a/Billing.Shared/SplashPage.xaml.cs b/Billing.Shared/SplashPage.xaml.cs index 1533529..0837cb4 100644 --- a/Billing.Shared/SplashPage.xaml.cs +++ b/Billing.Shared/SplashPage.xaml.cs @@ -14,7 +14,7 @@ namespace Billing { await App.InitializeData(); - await Shell.Current.GoToAsync("//Bills"); + await Shell.Current.GoToAsync(App.MainRoute); } } } diff --git a/Billing.Shared/Store/StoreHelper.cs b/Billing.Shared/Store/StoreHelper.cs index 7457b32..c115d50 100644 --- a/Billing.Shared/Store/StoreHelper.cs +++ b/Billing.Shared/Store/StoreHelper.cs @@ -38,6 +38,7 @@ namespace Billing.Store catch (Exception ex) { Helper.Error("database.close", ex); + return false; } try { @@ -54,12 +55,13 @@ namespace Billing.Store SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.SharedCache); + return true; } catch (Exception ex) { Helper.Error("database.connect", ex); + return false; } - return true; } public static readonly AsyncLazy Instance = new(async () => diff --git a/Billing.Shared/Views/AddBillPage.xaml.cs b/Billing.Shared/Views/AddBillPage.xaml.cs index 480ace3..6b328ec 100644 --- a/Billing.Shared/Views/AddBillPage.xaml.cs +++ b/Billing.Shared/Views/AddBillPage.xaml.cs @@ -70,6 +70,7 @@ namespace Billing.Views private CancellationTokenSource tokenSource; private Location location; + public AddBillPage() : this(DateTime.Today) { } public AddBillPage(DateTime date) { createDate = date; diff --git a/Billing.Shared/Views/RankPage.xaml b/Billing.Shared/Views/RankPage.xaml index e53e388..7797798 100644 --- a/Billing.Shared/Views/RankPage.xaml +++ b/Billing.Shared/Views/RankPage.xaml @@ -13,25 +13,24 @@ Shell.TabBarIsVisible="True"> - + - - - +