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 @@ - +