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<T> : ContentPage { - public ItemSelectPage(IList source) + public event EventHandler<T> ItemTapped; + + public ItemSelectPage(IEnumerable<T> 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 @@ </ui:GroupStackLayout.GroupHeaderTemplate> <ui:GroupStackLayout.ItemTemplate> <DataTemplate x:DataType="m:Account"> - <StackLayout Orientation="Horizontal" Padding="20, 0" HeightRequest="44" Spacing="10"> + <StackLayout Orientation="Horizontal" Padding="20, 0, 10, 0" HeightRequest="44" Spacing="10"> <Image Source="{Binding Icon}" HeightRequest="20" VerticalOptions="Center"/> <Label Text="{Binding Name}" TextColor="{DynamicResource TextColor}" HorizontalOptions="FillAndExpand" VerticalOptions="Center" diff --git a/Billing.Shared/Views/AccountPage.xaml.cs b/Billing.Shared/Views/AccountPage.xaml.cs index 1c843dd..7d130fd 100644 --- a/Billing.Shared/Views/AccountPage.xaml.cs +++ b/Billing.Shared/Views/AccountPage.xaml.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Linq; using Billing.Models; using Billing.UI; diff --git a/Billing.Shared/Views/AddAccountPage.xaml.cs b/Billing.Shared/Views/AddAccountPage.xaml.cs index 87e93a6..9edb48e 100644 --- a/Billing.Shared/Views/AddAccountPage.xaml.cs +++ b/Billing.Shared/Views/AddAccountPage.xaml.cs @@ -108,15 +108,24 @@ namespace Billing.Views } using (Tap.Start()) { - await Navigation.PushAsync(new ItemSelectPage(new List<SelectItem<AccountCategory>> + var source = new List<SelectItem<AccountCategory>> { new() { Icon = "sackdollar", Value = AccountCategory.Cash, Name = Resource.Cash }, new() { Icon = "creditcard", Value = AccountCategory.CreditCard, Name = Resource.CreditCard }, - new() { Icon = "", Value = AccountCategory.DebitCard, Name = Resource.DebitCard }, - new() { Icon = "", Value = AccountCategory.ElecAccount, Name = Resource.ElecAccount } - })); + new() { Icon = "debitcard", Value = AccountCategory.DebitCard, Name = Resource.DebitCard }, + new() { Icon = "coins", Value = AccountCategory.ElecAccount, Name = Resource.ElecAccount } + }; + var page = new ItemSelectPage<SelectItem<AccountCategory>>(source); + page.ItemTapped += Category_ItemTapped; + await Navigation.PushAsync(page); } } + + private async void Category_ItemTapped(object sender, SelectItem<AccountCategory> e) + { + Category = e.Value; + await Navigation.PopAsync(); + } } public class AccountEventArgs : EventArgs diff --git a/Billing/Billing.Android/Resources/drawable-mdpi/coins.png b/Billing/Billing.Android/Resources/drawable-mdpi/coins.png new file mode 100644 index 0000000..f6abe30 Binary files /dev/null and b/Billing/Billing.Android/Resources/drawable-mdpi/coins.png differ diff --git a/Billing/Billing.Android/Resources/drawable-mdpi/creditcard.png b/Billing/Billing.Android/Resources/drawable-mdpi/creditcard.png index 948d197..5e602c2 100644 Binary files a/Billing/Billing.Android/Resources/drawable-mdpi/creditcard.png and b/Billing/Billing.Android/Resources/drawable-mdpi/creditcard.png differ diff --git a/Billing/Billing.Android/Resources/drawable-mdpi/debitcard.png b/Billing/Billing.Android/Resources/drawable-mdpi/debitcard.png new file mode 100644 index 0000000..1d1f5d6 Binary files /dev/null and b/Billing/Billing.Android/Resources/drawable-mdpi/debitcard.png differ diff --git a/Billing/Billing.Android/Resources/drawable-xhdpi/coins.png b/Billing/Billing.Android/Resources/drawable-xhdpi/coins.png new file mode 100644 index 0000000..0635d24 Binary files /dev/null and b/Billing/Billing.Android/Resources/drawable-xhdpi/coins.png differ diff --git a/Billing/Billing.Android/Resources/drawable-xhdpi/creditcard.png b/Billing/Billing.Android/Resources/drawable-xhdpi/creditcard.png index 8bf47e4..c6734c3 100644 Binary files a/Billing/Billing.Android/Resources/drawable-xhdpi/creditcard.png and b/Billing/Billing.Android/Resources/drawable-xhdpi/creditcard.png differ diff --git a/Billing/Billing.Android/Resources/drawable-xhdpi/debitcard.png b/Billing/Billing.Android/Resources/drawable-xhdpi/debitcard.png new file mode 100644 index 0000000..e4bc074 Binary files /dev/null and b/Billing/Billing.Android/Resources/drawable-xhdpi/debitcard.png differ diff --git a/Billing/Billing.Android/Resources/drawable-xxhdpi/coins.png b/Billing/Billing.Android/Resources/drawable-xxhdpi/coins.png new file mode 100644 index 0000000..7bfc9d3 Binary files /dev/null and b/Billing/Billing.Android/Resources/drawable-xxhdpi/coins.png differ diff --git a/Billing/Billing.Android/Resources/drawable-xxhdpi/creditcard.png b/Billing/Billing.Android/Resources/drawable-xxhdpi/creditcard.png index d8f2b29..78ef833 100644 Binary files a/Billing/Billing.Android/Resources/drawable-xxhdpi/creditcard.png and b/Billing/Billing.Android/Resources/drawable-xxhdpi/creditcard.png differ diff --git a/Billing/Billing.Android/Resources/drawable-xxhdpi/debitcard.png b/Billing/Billing.Android/Resources/drawable-xxhdpi/debitcard.png new file mode 100644 index 0000000..abecc2e Binary files /dev/null and b/Billing/Billing.Android/Resources/drawable-xxhdpi/debitcard.png differ diff --git a/Billing/Billing.Android/Resources/drawable/coins.png b/Billing/Billing.Android/Resources/drawable/coins.png new file mode 100644 index 0000000..3341355 Binary files /dev/null and b/Billing/Billing.Android/Resources/drawable/coins.png differ diff --git a/Billing/Billing.Android/Resources/drawable/creditcard.png b/Billing/Billing.Android/Resources/drawable/creditcard.png index e40b05d..45bd13c 100644 Binary files a/Billing/Billing.Android/Resources/drawable/creditcard.png and b/Billing/Billing.Android/Resources/drawable/creditcard.png differ diff --git a/Billing/Billing.Android/Resources/drawable/debitcard.png b/Billing/Billing.Android/Resources/drawable/debitcard.png new file mode 100644 index 0000000..07c718d Binary files /dev/null and b/Billing/Billing.Android/Resources/drawable/debitcard.png differ diff --git a/Billing/Billing.iOS/Billing.iOS.csproj b/Billing/Billing.iOS/Billing.iOS.csproj index aa89e9d..794c770 100644 --- a/Billing/Billing.iOS/Billing.iOS.csproj +++ b/Billing/Billing.iOS/Billing.iOS.csproj @@ -97,6 +97,15 @@ <BundleResource Include="Resources\sackdollar.png" /> <BundleResource Include="Resources\sackdollar%402x.png" /> <BundleResource Include="Resources\sackdollar%403x.png" /> + <BundleResource Include="Resources\creditcard.png" /> + <BundleResource Include="Resources\creditcard%402x.png" /> + <BundleResource Include="Resources\creditcard%403x.png" /> + <BundleResource Include="Resources\debitcard.png" /> + <BundleResource Include="Resources\debitcard%402x.png" /> + <BundleResource Include="Resources\debitcard%403x.png" /> + <BundleResource Include="Resources\coins.png" /> + <BundleResource Include="Resources\coins%402x.png" /> + <BundleResource Include="Resources\coins%403x.png" /> </ItemGroup> <ItemGroup> <ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json"> diff --git a/Billing/Billing.iOS/Renderers/TintImageRenderer.cs b/Billing/Billing.iOS/Renderers/TintImageRenderer.cs index 242cc35..bf380c2 100644 --- a/Billing/Billing.iOS/Renderers/TintImageRenderer.cs +++ b/Billing/Billing.iOS/Renderers/TintImageRenderer.cs @@ -14,7 +14,16 @@ namespace Billing.iOS.Renderers { base.OnElementPropertyChanged(sender, e); - if (e.PropertyName == nameof(TintImage.PrimaryColor) && Control != null && Element is TintImage image) + if (Control == null) + { + return; + } + + if (e.PropertyName == nameof(Image.Source)) + { + Control.Image = Control.Image.ImageWithRenderingMode(UIKit.UIImageRenderingMode.AlwaysTemplate); + } + else if (e.PropertyName == nameof(TintImage.PrimaryColor) && Element is TintImage image) { Control.TintColor = image.PrimaryColor?.ToUIColor(); } @@ -25,7 +34,11 @@ namespace Billing.iOS.Renderers if (Control != null && Element is TintImage image) { - Control.TintColor = image.PrimaryColor?.ToUIColor(); + if (Control.Image != null) + { + Control.Image = Control.Image.ImageWithRenderingMode(UIKit.UIImageRenderingMode.AlwaysTemplate); + Control.TintColor = image.PrimaryColor?.ToUIColor(); + } } } } diff --git a/Billing/Billing.iOS/Resources/coins.png b/Billing/Billing.iOS/Resources/coins.png new file mode 100644 index 0000000..f6abe30 Binary files /dev/null and b/Billing/Billing.iOS/Resources/coins.png differ diff --git a/Billing/Billing.iOS/Resources/coins@2x.png b/Billing/Billing.iOS/Resources/coins@2x.png new file mode 100644 index 0000000..0635d24 Binary files /dev/null and b/Billing/Billing.iOS/Resources/coins@2x.png differ diff --git a/Billing/Billing.iOS/Resources/coins@3x.png b/Billing/Billing.iOS/Resources/coins@3x.png new file mode 100644 index 0000000..7bfc9d3 Binary files /dev/null and b/Billing/Billing.iOS/Resources/coins@3x.png differ diff --git a/Billing/Billing.iOS/Resources/creditcard.png b/Billing/Billing.iOS/Resources/creditcard.png index 948d197..5e602c2 100644 Binary files a/Billing/Billing.iOS/Resources/creditcard.png and b/Billing/Billing.iOS/Resources/creditcard.png differ diff --git a/Billing/Billing.iOS/Resources/creditcard@2x.png b/Billing/Billing.iOS/Resources/creditcard@2x.png index 8bf47e4..c6734c3 100644 Binary files a/Billing/Billing.iOS/Resources/creditcard@2x.png and b/Billing/Billing.iOS/Resources/creditcard@2x.png differ diff --git a/Billing/Billing.iOS/Resources/creditcard@3x.png b/Billing/Billing.iOS/Resources/creditcard@3x.png index d8f2b29..78ef833 100644 Binary files a/Billing/Billing.iOS/Resources/creditcard@3x.png and b/Billing/Billing.iOS/Resources/creditcard@3x.png differ diff --git a/Billing/Billing.iOS/Resources/debitcard.png b/Billing/Billing.iOS/Resources/debitcard.png new file mode 100644 index 0000000..1d1f5d6 Binary files /dev/null and b/Billing/Billing.iOS/Resources/debitcard.png differ diff --git a/Billing/Billing.iOS/Resources/debitcard@2x.png b/Billing/Billing.iOS/Resources/debitcard@2x.png new file mode 100644 index 0000000..e4bc074 Binary files /dev/null and b/Billing/Billing.iOS/Resources/debitcard@2x.png differ diff --git a/Billing/Billing.iOS/Resources/debitcard@3x.png b/Billing/Billing.iOS/Resources/debitcard@3x.png new file mode 100644 index 0000000..abecc2e Binary files /dev/null and b/Billing/Billing.iOS/Resources/debitcard@3x.png differ