From 5b954ac4415cfb3b73a26fdad1289c0ad0c75ea1 Mon Sep 17 00:00:00 2001 From: gaoyuan Date: Mon, 28 Feb 2022 23:05:21 +0800 Subject: [PATCH] category selector --- Billing.Shared/UI/ItemSelectPage.cs | 63 ++++++++++++------ Billing.Shared/UI/OptionsCells.cs | 4 +- Billing.Shared/Views/AccountPage.xaml | 2 +- Billing.Shared/Views/AccountPage.xaml.cs | 1 - Billing.Shared/Views/AddAccountPage.xaml.cs | 17 +++-- .../Resources/drawable-mdpi/coins.png | Bin 0 -> 986 bytes .../Resources/drawable-mdpi/creditcard.png | Bin 339 -> 339 bytes .../Resources/drawable-mdpi/debitcard.png | Bin 0 -> 481 bytes .../Resources/drawable-xhdpi/coins.png | Bin 0 -> 2119 bytes .../Resources/drawable-xhdpi/creditcard.png | Bin 462 -> 563 bytes .../Resources/drawable-xhdpi/debitcard.png | Bin 0 -> 890 bytes .../Resources/drawable-xxhdpi/coins.png | Bin 0 -> 2959 bytes .../Resources/drawable-xxhdpi/creditcard.png | Bin 858 -> 858 bytes .../Resources/drawable-xxhdpi/debitcard.png | Bin 0 -> 1121 bytes .../Resources/drawable/coins.png | Bin 0 -> 1388 bytes .../Resources/drawable/creditcard.png | Bin 491 -> 491 bytes .../Resources/drawable/debitcard.png | Bin 0 -> 600 bytes Billing/Billing.iOS/Billing.iOS.csproj | 9 +++ .../Renderers/TintImageRenderer.cs | 17 ++++- Billing/Billing.iOS/Resources/coins.png | Bin 0 -> 986 bytes Billing/Billing.iOS/Resources/coins@2x.png | Bin 0 -> 2119 bytes Billing/Billing.iOS/Resources/coins@3x.png | Bin 0 -> 2959 bytes Billing/Billing.iOS/Resources/creditcard.png | Bin 339 -> 339 bytes .../Billing.iOS/Resources/creditcard@2x.png | Bin 462 -> 563 bytes .../Billing.iOS/Resources/creditcard@3x.png | Bin 858 -> 858 bytes Billing/Billing.iOS/Resources/debitcard.png | Bin 0 -> 481 bytes .../Billing.iOS/Resources/debitcard@2x.png | Bin 0 -> 890 bytes .../Billing.iOS/Resources/debitcard@3x.png | Bin 0 -> 1121 bytes 28 files changed, 81 insertions(+), 32 deletions(-) create mode 100644 Billing/Billing.Android/Resources/drawable-mdpi/coins.png create mode 100644 Billing/Billing.Android/Resources/drawable-mdpi/debitcard.png create mode 100644 Billing/Billing.Android/Resources/drawable-xhdpi/coins.png create mode 100644 Billing/Billing.Android/Resources/drawable-xhdpi/debitcard.png create mode 100644 Billing/Billing.Android/Resources/drawable-xxhdpi/coins.png create mode 100644 Billing/Billing.Android/Resources/drawable-xxhdpi/debitcard.png create mode 100644 Billing/Billing.Android/Resources/drawable/coins.png create mode 100644 Billing/Billing.Android/Resources/drawable/debitcard.png create mode 100644 Billing/Billing.iOS/Resources/coins.png create mode 100644 Billing/Billing.iOS/Resources/coins@2x.png create mode 100644 Billing/Billing.iOS/Resources/coins@3x.png create mode 100644 Billing/Billing.iOS/Resources/debitcard.png create mode 100644 Billing/Billing.iOS/Resources/debitcard@2x.png create mode 100644 Billing/Billing.iOS/Resources/debitcard@3x.png diff --git a/Billing.Shared/UI/ItemSelectPage.cs b/Billing.Shared/UI/ItemSelectPage.cs index 12c7446..52d86f3 100644 --- a/Billing.Shared/UI/ItemSelectPage.cs +++ b/Billing.Shared/UI/ItemSelectPage.cs @@ -1,44 +1,63 @@ using Billing.Themes; +using System; using System.Collections; - +using System.Collections.Generic; using Xamarin.Forms; namespace Billing.UI { - public class ItemSelectPage : ContentPage + public class ItemSelectPage : ContentPage { - public ItemSelectPage(IList source) + public event EventHandler ItemTapped; + + public ItemSelectPage(IEnumerable source) { - Content = new ListView + var content = new ListView { ItemsSource = source, - ItemTemplate = new DataTemplate(() => new StackLayout + ItemTemplate = new DataTemplate(() => new ViewCell { - Orientation = StackOrientation.Horizontal, - Padding = new Thickness(20, 0), - Spacing = 10, - Children = + View = new StackLayout { - new Image + Orientation = StackOrientation.Horizontal, + Padding = new Thickness(20, 0), + Spacing = 10, + Children = { - WidthRequest = 22, - HeightRequest = 22, - Aspect = Aspect.AspectFit, - VerticalOptions = LayoutOptions.Center - } - .Binding(Image.SourceProperty, "Icon"), + new Image + { + WidthRequest = 22, + HeightRequest = 22, + Aspect = Aspect.AspectFit, + VerticalOptions = LayoutOptions.Center + } + .Binding(Image.SourceProperty, "Icon"), - new Label - { - VerticalOptions = LayoutOptions.Center, - LineBreakMode = LineBreakMode.TailTruncation + new Label + { + VerticalOptions = LayoutOptions.Center, + LineBreakMode = LineBreakMode.TailTruncation + } + .Binding(Label.TextProperty, "Name") + .DynamicResource(Label.TextColorProperty, BaseTheme.TextColor) } - .Binding(Label.TextProperty, "Name") - .DynamicResource(Label.TextColorProperty, BaseTheme.TextColor) } }) } .DynamicResource(BackgroundColorProperty, BaseTheme.WindowBackgroundColor); + + // events + content.ItemTapped += List_ItemTapped; + + Content = content; + } + + private void List_ItemTapped(object sender, ItemTappedEventArgs e) + { + if (e.Item is T t) + { + ItemTapped?.Invoke(this, t); + } } } diff --git a/Billing.Shared/UI/OptionsCells.cs b/Billing.Shared/UI/OptionsCells.cs index a71167c..10a664c 100644 --- a/Billing.Shared/UI/OptionsCells.cs +++ b/Billing.Shared/UI/OptionsCells.cs @@ -46,7 +46,7 @@ namespace Billing.UI }, Children = { - new Image + new TintImage { WidthRequest = 20, HeightRequest = 20, @@ -93,7 +93,7 @@ namespace Billing.UI }, Children = { - new Image + new TintImage { WidthRequest = 20, HeightRequest = 20, diff --git a/Billing.Shared/Views/AccountPage.xaml b/Billing.Shared/Views/AccountPage.xaml index 86fb32c..268e29a 100644 --- a/Billing.Shared/Views/AccountPage.xaml +++ b/Billing.Shared/Views/AccountPage.xaml @@ -54,7 +54,7 @@ - +