diff --git a/Billing.Shared/Languages/en.xml b/Billing.Shared/Languages/en.xml index 2d98e07..7bc6922 100644 --- a/Billing.Shared/Languages/en.xml +++ b/Billing.Shared/Languages/en.xml @@ -20,6 +20,14 @@ Click here to record MM/dd/yyyy MM/dd + To + Monthly + Today + Past Month + Past Quarter + Past Six Months + Past Year + Total Balance Assets Liability diff --git a/Billing.Shared/Languages/zh-CN.xml b/Billing.Shared/Languages/zh-CN.xml index 47fd503..1dab13b 100644 --- a/Billing.Shared/Languages/zh-CN.xml +++ b/Billing.Shared/Languages/zh-CN.xml @@ -20,6 +20,14 @@ 点此记录 yyyy年MM月dd日 MM月dd日 + + 当月 + 今日 + 一个月 + 一个季度 + 六个月 + 一年 + 全部 余额 资产 负债 diff --git a/Billing.Shared/UI/BillingPage.cs b/Billing.Shared/UI/BillingPage.cs index a5d6743..fd3178c 100644 --- a/Billing.Shared/UI/BillingPage.cs +++ b/Billing.Shared/UI/BillingPage.cs @@ -8,6 +8,8 @@ namespace Billing.UI { public event EventHandler Loaded; + private bool loaded; + public BillingPage() { SetDynamicResource(BackgroundColorProperty, BaseTheme.WindowBackgroundColor); @@ -18,5 +20,14 @@ namespace Billing.UI { Loaded?.Invoke(this, EventArgs.Empty); } + + public void TriggerLoad() + { + if (!loaded) + { + loaded = true; + OnLoaded(); + } + } } } \ No newline at end of file diff --git a/Billing.Shared/UI/ColorPicker.cs b/Billing.Shared/UI/ColorPicker.cs index 4f18de6..93be0f8 100644 --- a/Billing.Shared/UI/ColorPicker.cs +++ b/Billing.Shared/UI/ColorPicker.cs @@ -8,15 +8,19 @@ namespace Billing.UI { public class ColorPicker : SKCanvasView { - public static readonly BindableProperty ColorProperty = BindableProperty.Create(nameof(Color), typeof(Color), typeof(ColorPicker)); + public static readonly BindableProperty ColorProperty = Helper.Create(nameof(Color)); + public static readonly BindableProperty CommandProperty = Helper.Create(nameof(Command)); public Color Color { get => (Color)GetValue(ColorProperty); set => SetValue(ColorProperty, value); } - - public event EventHandler ColorChanged; + public Command Command + { + get => (Command)GetValue(CommandProperty); + set => SetValue(CommandProperty, value); + } private SKPoint? lastTouch; @@ -116,7 +120,7 @@ namespace Billing.UI var color = touchColor.ToFormsColor(); Color = color; - ColorChanged?.Invoke(this, color); + Command?.Execute(color); } } @@ -126,8 +130,8 @@ namespace Billing.UI lastTouch = e.Location; var size = CanvasSize; - if ((e.Location.X > 0 && e.Location.X < size.Width) && - (e.Location.Y > 0 && e.Location.Y < size.Height)) + if (e.Location.X > 0 && e.Location.X < size.Width && + e.Location.Y > 0 && e.Location.Y < size.Height) { e.Handled = true; InvalidateSurface(); diff --git a/Billing.Shared/UI/Definition.cs b/Billing.Shared/UI/Definition.cs index 9f82ad7..e3928c6 100644 --- a/Billing.Shared/UI/Definition.cs +++ b/Billing.Shared/UI/Definition.cs @@ -92,6 +92,12 @@ namespace Billing.UI var result = await page.DisplayActionSheet(message, Resource.No, yes); return result == yes; } + + public static DateTime LastMoment(this DateTime date) + { + // add 23:59:59.999... + return date.AddTicks(863999999999); + } } public static class ModelExtensionHelper diff --git a/Billing.Shared/Views/AddAccountPage.xaml.cs b/Billing.Shared/Views/AddAccountPage.xaml.cs index 91241a7..8a3f463 100644 --- a/Billing.Shared/Views/AddAccountPage.xaml.cs +++ b/Billing.Shared/Views/AddAccountPage.xaml.cs @@ -73,15 +73,9 @@ namespace Billing.Views InitializeComponent(); } - private bool focused; - public override void OnLoaded() { - if (!focused) - { - focused = true; - editorName.SetFocus(); - } + editorName.SetFocus(); } private async void OnCheckAccount() diff --git a/Billing.Shared/Views/AddBillPage.xaml.cs b/Billing.Shared/Views/AddBillPage.xaml.cs index f58b780..f87aa2d 100644 --- a/Billing.Shared/Views/AddBillPage.xaml.cs +++ b/Billing.Shared/Views/AddBillPage.xaml.cs @@ -116,15 +116,9 @@ namespace Billing.Views } } - private bool focused; - public override void OnLoaded() { - if (!focused) - { - focused = true; - editorAmount.SetFocus(); - } + editorAmount.SetFocus(); } private async void OnCheckBill() diff --git a/Billing.Shared/Views/AddCategoryPage.xaml b/Billing.Shared/Views/AddCategoryPage.xaml index d44b12b..41c6c18 100644 --- a/Billing.Shared/Views/AddCategoryPage.xaml +++ b/Billing.Shared/Views/AddCategoryPage.xaml @@ -41,7 +41,7 @@ - + diff --git a/Billing.Shared/Views/AddCategoryPage.xaml.cs b/Billing.Shared/Views/AddCategoryPage.xaml.cs index d80e05e..9b9f108 100644 --- a/Billing.Shared/Views/AddCategoryPage.xaml.cs +++ b/Billing.Shared/Views/AddCategoryPage.xaml.cs @@ -38,6 +38,7 @@ namespace Billing.Views public Command CheckCategory { get; } public Command SelectIcon { get; } + public Command ColorPickerCommand { get; } public event EventHandler CategoryChecked; @@ -73,25 +74,23 @@ namespace Billing.Views CheckCategory = new Command(OnCheckCategory); SelectIcon = new Command(OnSelectIcon); + ColorPickerCommand = new Command(OnColorPickerCommand); InitializeComponent(); } - private bool focused; - public override void OnLoaded() { - if (!focused) - { - focused = true; - editorName.SetFocus(); - } + editorName.SetFocus(); } - private void ColorPicker_ColorChanged(object sender, Color e) + private void OnColorPickerCommand(object o) { - TintColor = e; - TintColorString = Helper.WrapColorString(e.ToHex()); + if (o is Color color) + { + TintColor = color; + TintColorString = Helper.WrapColorString(color.ToHex()); + } } private async void OnCheckCategory() diff --git a/Billing.Shared/Views/BillPage.xaml.cs b/Billing.Shared/Views/BillPage.xaml.cs index aa77ef3..9f08a56 100644 --- a/Billing.Shared/Views/BillPage.xaml.cs +++ b/Billing.Shared/Views/BillPage.xaml.cs @@ -44,8 +44,6 @@ namespace Billing.Views public Command EditBilling { get; } public Command DeleteBilling { get; } - private bool initialized; - public BillPage() { TitleDateTap = new Command(OnTitleDateTapped); @@ -58,11 +56,7 @@ namespace Billing.Views public override void OnLoaded() { - if (!initialized) - { - initialized = true; - billingDate.SetDateTime(DateTime.Today); - } + billingDate.SetDateTime(DateTime.Today); } private void OnDateSelected(object sender, DateEventArgs e) diff --git a/Billing.Shared/Views/RankPage.xaml b/Billing.Shared/Views/RankPage.xaml index ebf656b..d82f46a 100644 --- a/Billing.Shared/Views/RankPage.xaml +++ b/Billing.Shared/Views/RankPage.xaml @@ -4,6 +4,7 @@ xmlns:ui="clr-namespace:Billing.UI" xmlns:v="clr-namespace:Billing.Views" xmlns:chart="clr-namespace:Microcharts.Forms;assembly=Microcharts.Forms" + xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Billing.Views.RankPage" x:Name="rankPage" @@ -13,7 +14,7 @@ - + + + - + @@ -48,7 +52,7 @@ + - + - diff --git a/Billing.Shared/Views/SettingPage.xaml.cs b/Billing.Shared/Views/SettingPage.xaml.cs index c5b99f8..a9daa0c 100644 --- a/Billing.Shared/Views/SettingPage.xaml.cs +++ b/Billing.Shared/Views/SettingPage.xaml.cs @@ -1,6 +1,5 @@ using Billing.Themes; using Billing.UI; -using System.Globalization; using Xamarin.Essentials; using Xamarin.Forms; @@ -8,8 +7,8 @@ namespace Billing.Views { public partial class SettingPage : BillingPage { - private static readonly BindableProperty VersionProperty = BindableProperty.Create(nameof(Version), typeof(string), typeof(SettingPage)); - private static readonly BindableProperty PrimaryColorProperty = BindableProperty.Create(nameof(PrimaryColor), typeof(string), typeof(SettingPage)); + private static readonly BindableProperty VersionProperty = Helper.Create(nameof(Version)); + private static readonly BindableProperty PrimaryColorProperty = Helper.Create(nameof(PrimaryColor)); public string Version => (string)GetValue(VersionProperty); public string PrimaryColor @@ -19,10 +18,12 @@ namespace Billing.Views } public Command CategoryCommand { get; } + public Command ColorPickerCommand { get; } public SettingPage() { CategoryCommand = new Command(OnCategoryCommand); + ColorPickerCommand = new Command(OnColorPickerCommand); InitializeComponent(); var (main, build) = Definition.GetVersion(); @@ -60,9 +61,12 @@ namespace Billing.Views } } - private void ColorPicker_ColorChanged(object sender, Color e) + private void OnColorPickerCommand(object o) { - PrimaryColor = Helper.WrapColorString(e.ToHex()); + if (o is Color color) + { + PrimaryColor = Helper.WrapColorString(color.ToHex()); + } } } } \ No newline at end of file diff --git a/Billing/Billing.Android/Renderers/BillingPageRenderer.cs b/Billing/Billing.Android/Renderers/BillingPageRenderer.cs index 93554ef..2321d54 100644 --- a/Billing/Billing.Android/Renderers/BillingPageRenderer.cs +++ b/Billing/Billing.Android/Renderers/BillingPageRenderer.cs @@ -18,7 +18,7 @@ namespace Billing.Droid.Renderers base.OnAttachedToWindow(); if (Element is BillingPage page) { - page.OnLoaded(); + page.TriggerLoad(); } } } diff --git a/Billing/Billing.Android/Renderers/OptionDatePickerRenderer.cs b/Billing/Billing.Android/Renderers/OptionDatePickerRenderer.cs index 360611e..9e6b310 100644 --- a/Billing/Billing.Android/Renderers/OptionDatePickerRenderer.cs +++ b/Billing/Billing.Android/Renderers/OptionDatePickerRenderer.cs @@ -18,10 +18,12 @@ namespace Billing.Droid.Renderers { base.OnElementChanged(e); - if (e.NewElement != null) + var control = Control; + if (e.NewElement != null && control != null) { var drawable = new ColorDrawable(e.NewElement.BackgroundColor.ToAndroid()); - Control.SetBackground(drawable); + control.SetBackground(drawable); + control.Gravity = Android.Views.GravityFlags.CenterHorizontal; } } } diff --git a/Billing/Billing.iOS/Renderers/BillingPageRenderer.cs b/Billing/Billing.iOS/Renderers/BillingPageRenderer.cs index 2d2a141..308217a 100644 --- a/Billing/Billing.iOS/Renderers/BillingPageRenderer.cs +++ b/Billing/Billing.iOS/Renderers/BillingPageRenderer.cs @@ -55,7 +55,7 @@ namespace Billing.iOS.Renderers base.ViewDidAppear(animated); if (Element is BillingPage page) { - page.OnLoaded(); + page.TriggerLoad(); } } } diff --git a/Billing/Billing.iOS/Renderers/OptionDatePickerRenderer.cs b/Billing/Billing.iOS/Renderers/OptionDatePickerRenderer.cs index edaed5a..f78fee9 100644 --- a/Billing/Billing.iOS/Renderers/OptionDatePickerRenderer.cs +++ b/Billing/Billing.iOS/Renderers/OptionDatePickerRenderer.cs @@ -14,9 +14,10 @@ namespace Billing.iOS.Renderers base.OnElementChanged(e); var control = Control; - if (control != null) + if (e.NewElement != null && control != null) { control.BorderStyle = UITextBorderStyle.None; + control.TextAlignment = UITextAlignment.Center; } } }