category selector

This commit is contained in:
gaoyuan
2022-02-28 23:05:21 +08:00
parent 589c7514f2
commit 5b954ac441
28 changed files with 81 additions and 32 deletions

View File

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

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Billing.Models;
using Billing.UI;

View File

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