From 8ba6f4bf858c92c1d3b73cacf45b1cb7a67b6e72 Mon Sep 17 00:00:00 2001 From: tsanie Date: Tue, 15 Mar 2022 20:12:40 +0800 Subject: [PATCH] fix issue --- Billing.Shared/App.cs | 4 +-- Billing.Shared/Store/StoreHelper.cs | 13 ++++++++-- Billing.Shared/Views/AccountPage.xaml.cs | 11 +++++++++ Billing.Shared/Views/BillPage.xaml.cs | 12 ++++++--- Billing.Shared/Views/RankPage.xaml.cs | 5 ++++ Billing.Shared/Views/SettingPage.xaml.cs | 6 +++++ Billing/Billing.iOS/AppDelegate.cs | 1 - Billing/Billing.iOS/Info.plist | 31 +++++++++++++++++++++--- 8 files changed, 70 insertions(+), 13 deletions(-) diff --git a/Billing.Shared/App.cs b/Billing.Shared/App.cs index 3f52985..cf65162 100644 --- a/Billing.Shared/App.cs +++ b/Billing.Shared/App.cs @@ -85,7 +85,7 @@ namespace Billing public static bool OpenUrl(Uri uri) { - if (uri == null) + if (uri == null || !uri.IsFile) { return true; } @@ -96,7 +96,7 @@ namespace Billing Task.Run(async () => { var result = await StoreHelper.ReloadDatabase(url); - //if (result) + if (result) { await InitializeData(); diff --git a/Billing.Shared/Store/StoreHelper.cs b/Billing.Shared/Store/StoreHelper.cs index 9fdc98b..7457b32 100644 --- a/Billing.Shared/Store/StoreHelper.cs +++ b/Billing.Shared/Store/StoreHelper.cs @@ -17,7 +17,7 @@ namespace Billing.Store public static string DatabasePath => Path.Combine(PersonalFolder, dbfile); #region Sqlite3 - private const string dbfile = "data.db3"; + private const string dbfile = ".master.db3"; private static SQLiteAsyncConnection database; #endregion @@ -42,6 +42,7 @@ namespace Billing.Store try { File.Copy(file, path, true); + File.Delete(file); } catch (Exception ex) { @@ -167,7 +168,15 @@ namespace Billing.Store public static async Task GetLogsCount() { await Instance; - return await database.ExecuteScalarAsync("SELECT COUNT(Id) FROM [Logs]"); + try + { + return await database.ExecuteScalarAsync("SELECT COUNT(Id) FROM [Logs]"); + } + catch (SQLiteException) + { + await database.CreateTableAsync(); + return 0; + } } public static async Task SaveLogItemAsync(Logs log) { diff --git a/Billing.Shared/Views/AccountPage.xaml.cs b/Billing.Shared/Views/AccountPage.xaml.cs index db6df89..7060784 100644 --- a/Billing.Shared/Views/AccountPage.xaml.cs +++ b/Billing.Shared/Views/AccountPage.xaml.cs @@ -50,6 +50,17 @@ namespace Billing.Views groupLayout.Refresh(accounts); } + protected override void OnRefresh() + { + accounts.Clear(); + foreach (var account in App.Accounts) + { + AddToAccountGroup(account); + } + RefreshBalance(true); + groupLayout.Refresh(accounts); + } + private void RefreshBalance(bool calc = false) { if (calc) diff --git a/Billing.Shared/Views/BillPage.xaml.cs b/Billing.Shared/Views/BillPage.xaml.cs index d08cdc6..388b4eb 100644 --- a/Billing.Shared/Views/BillPage.xaml.cs +++ b/Billing.Shared/Views/BillPage.xaml.cs @@ -60,19 +60,23 @@ namespace Billing.Views billingDate.SetDateTime(DateTime.Today); } - private void OnDateSelected(object sender, DateEventArgs e) + protected override void OnRefresh() { - SelectedDate = e.Date; - Task.Run(() => { - var bills = App.Bills.Where(b => Helper.IsSameDay(b.CreateTime, e.Date)); + var bills = App.Bills.Where(b => Helper.IsSameDay(b.CreateTime, SelectedDate)); Bills = new List(bills.OrderBy(b => b.CreateTime).Select(b => Helper.WrapBill(b))); RefreshBalance(Bills); MainThread.BeginInvokeOnMainThread(async () => await scrollView.ScrollToAsync(0, 0, true)); }); } + private void OnDateSelected(object sender, DateEventArgs e) + { + SelectedDate = e.Date; + OnRefresh(); + } + private void RefreshBalance(List bills) { SetValue(NoBillsProperty, bills.Count == 0); diff --git a/Billing.Shared/Views/RankPage.xaml.cs b/Billing.Shared/Views/RankPage.xaml.cs index 0852d22..ab5d808 100644 --- a/Billing.Shared/Views/RankPage.xaml.cs +++ b/Billing.Shared/Views/RankPage.xaml.cs @@ -229,6 +229,11 @@ namespace Billing.Views } } + protected override void OnRefresh() + { + OnDateChanged(this); + } + private void OnDateTypeCommand(DateType index) { if (index < DateType.Monthly || index > DateType.Total) diff --git a/Billing.Shared/Views/SettingPage.xaml.cs b/Billing.Shared/Views/SettingPage.xaml.cs index bcdcff4..af4d834 100644 --- a/Billing.Shared/Views/SettingPage.xaml.cs +++ b/Billing.Shared/Views/SettingPage.xaml.cs @@ -59,6 +59,12 @@ namespace Billing.Views //Light.Instance.RefreshColor(Color.FromHex(color)); } + protected override async void OnRefresh() + { + var count = await StoreHelper.GetLogsCount(); + SetValue(ManyRecordsProperty, string.Format(Resource.ManyRecords, count)); + } + private async void OnShareCommand() { if (Tap.IsBusy) diff --git a/Billing/Billing.iOS/AppDelegate.cs b/Billing/Billing.iOS/AppDelegate.cs index 3d37e98..76aab35 100644 --- a/Billing/Billing.iOS/AppDelegate.cs +++ b/Billing/Billing.iOS/AppDelegate.cs @@ -1,6 +1,5 @@ using Foundation; using UIKit; -using Xamarin.Essentials; namespace Billing.iOS { diff --git a/Billing/Billing.iOS/Info.plist b/Billing/Billing.iOS/Info.plist index 3177a54..63c422b 100644 --- a/Billing/Billing.iOS/Info.plist +++ b/Billing/Billing.iOS/Info.plist @@ -45,9 +45,10 @@ CFBundleTypeName - Master SQLite file + SQLite Database LSItemContentTypes + org.tsanie.billing.db3 public.database CFBundleTypeIconFiles @@ -55,18 +56,40 @@ Assets.xcassets/AppIcon.appiconset/Icon180 LSHandlerRank - Default + Alternate + + + UTExportedTypeDeclarations + + + UTTypeConformsTo + + public.data + + UTTypeDescription + SQLite Database + UTTypeIdentifier + org.tsanie.billing.db3 + UTTypeTagSpecification + + public.filename-extension + db3 + public.mime-type + application/vnd.sqlite3 + CFBundleVersion 13 CFBundleShortVersionString 1.1.315 - LSSupportsOpeningDocumentsInPlace - LSApplicationQueriesSchemes mailto + UIFileSharingEnabled + + LSSupportsOpeningDocumentsInPlace +