first test-flight version
This commit is contained in:
@@ -27,7 +27,7 @@ namespace Billing
|
||||
InitResources();
|
||||
|
||||
MainPage = new MainShell();
|
||||
Shell.Current.GoToAsync("//Bills");
|
||||
Shell.Current.GoToAsync("//Settings");
|
||||
}
|
||||
|
||||
public static void WriteAccounts() => StoreHelper.WriteAccounts(accounts);
|
||||
@@ -37,14 +37,13 @@ namespace Billing
|
||||
protected override void OnStart()
|
||||
{
|
||||
Helper.Debug($"personal folder: {StoreHelper.PersonalFolder}");
|
||||
Helper.Debug($"cache folder: {StoreHelper.CacheFolder}");
|
||||
Helper.Debug($"cache folder: {StoreHelper.CacheFolder}");
|
||||
|
||||
accounts = StoreHelper.GetAccounts();
|
||||
categories = StoreHelper.GetCategories();
|
||||
bills = StoreHelper.GetBills();
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
accounts = StoreHelper.GetAccounts();
|
||||
categories = StoreHelper.GetCategories();
|
||||
bills = StoreHelper.GetBills();
|
||||
});
|
||||
Shell.Current.GoToAsync("//Bills");
|
||||
}
|
||||
|
||||
protected override void OnResume()
|
||||
|
@@ -10,6 +10,10 @@ namespace Billing.Languages
|
||||
internal class Resource
|
||||
{
|
||||
public static string Ok => Text(nameof(Ok));
|
||||
public static string Yes => Text(nameof(Yes));
|
||||
public static string No => Text(nameof(No));
|
||||
public static string ConfirmDeleteAccount => Text(nameof(ConfirmDeleteAccount));
|
||||
public static string ConfirmDeleteBill => Text(nameof(ConfirmDeleteBill));
|
||||
public static string TitleDateFormat => Text(nameof(TitleDateFormat));
|
||||
public static string Cash => Text(nameof(Cash));
|
||||
public static string CreditCard => Text(nameof(CreditCard));
|
||||
@@ -23,6 +27,20 @@ namespace Billing.Languages
|
||||
public static string NeedAccount => Text(nameof(NeedAccount));
|
||||
public static string AmountRequired => Text(nameof(AmountRequired));
|
||||
|
||||
#region Categories
|
||||
public static string Clothing => Text(nameof(Clothing));
|
||||
public static string Food => Text(nameof(Food));
|
||||
public static string Drinks => Text(nameof(Drinks));
|
||||
public static string Daily => Text(nameof(Daily));
|
||||
public static string Trans => Text(nameof(Trans));
|
||||
public static string Entertainment => Text(nameof(Entertainment));
|
||||
public static string Learn => Text(nameof(Learn));
|
||||
public static string Medical => Text(nameof(Medical));
|
||||
public static string Salary => Text(nameof(Salary));
|
||||
public static string Earnings => Text(nameof(Earnings));
|
||||
public static string Bonus => Text(nameof(Bonus));
|
||||
#endregion
|
||||
|
||||
static readonly Dictionary<string, LanguageResource> dict = new();
|
||||
|
||||
public static string Text(string name, params object[] args)
|
||||
|
@@ -1,6 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<Ok>OK</Ok>
|
||||
<About>About</About>
|
||||
<Version>Version</Version>
|
||||
<Preference>Preference</Preference>
|
||||
<PrimaryColor>Primary Color</PrimaryColor>
|
||||
<Accounts>Accounts</Accounts>
|
||||
<Bills>Bills</Bills>
|
||||
<Settings>Settings</Settings>
|
||||
@@ -44,4 +48,21 @@
|
||||
<Store>Store</Store>
|
||||
<NeedAccount>Please create an account first.</NeedAccount>
|
||||
<AmountRequired>Please enter the amount.</AmountRequired>
|
||||
<Income>Income</Income>
|
||||
<Spending>Spending</Spending>
|
||||
<Clothing>Clothing</Clothing>
|
||||
<Food>Food</Food>
|
||||
<Drinks>Drinks</Drinks>
|
||||
<Daily>Daily</Daily>
|
||||
<Trans>Transportation</Trans>
|
||||
<Entertainment>Entertainment</Entertainment>
|
||||
<Learn>Learn</Learn>
|
||||
<Medical>Medical</Medical>
|
||||
<Salary>Salary</Salary>
|
||||
<Earnings>Earnings</Earnings>
|
||||
<Bonus>Bonus</Bonus>
|
||||
<Yes>Yes</Yes>
|
||||
<No>No</No>
|
||||
<ConfirmDeleteAccount>Are you sure you want to delete the account?</ConfirmDeleteAccount>
|
||||
<ConfirmDeleteBill>Are you sure you want to delete the billing?</ConfirmDeleteBill>
|
||||
</root>
|
@@ -1,6 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<Ok>确定</Ok>
|
||||
<About>关于</About>
|
||||
<Version>版本号</Version>
|
||||
<Preference>偏好</Preference>
|
||||
<PrimaryColor>主要配色</PrimaryColor>
|
||||
<Accounts>账户</Accounts>
|
||||
<Bills>账单</Bills>
|
||||
<Settings>设置</Settings>
|
||||
@@ -44,4 +48,21 @@
|
||||
<Store>店铺</Store>
|
||||
<NeedAccount>请先创建一个资金账户。</NeedAccount>
|
||||
<AmountRequired>请输入金额。</AmountRequired>
|
||||
<Income>收入</Income>
|
||||
<Spending>支出</Spending>
|
||||
<Clothing>衣物</Clothing>
|
||||
<Food>食品</Food>
|
||||
<Drinks>饮料</Drinks>
|
||||
<Daily>日常</Daily>
|
||||
<Trans>交通</Trans>
|
||||
<Entertainment>娱乐</Entertainment>
|
||||
<Learn>学习</Learn>
|
||||
<Medical>医疗</Medical>
|
||||
<Salary>工资</Salary>
|
||||
<Earnings>收益</Earnings>
|
||||
<Bonus>奖金</Bonus>
|
||||
<Yes>是</Yes>
|
||||
<No>否</No>
|
||||
<ConfirmDeleteAccount>是否确认删除该账户?</ConfirmDeleteAccount>
|
||||
<ConfirmDeleteBill>是否确认删除该账单?</ConfirmDeleteBill>
|
||||
</root>
|
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using Billing.Models;
|
||||
using Billing.UI;
|
||||
using Xamarin.Essentials;
|
||||
using Resource = Billing.Languages.Resource;
|
||||
|
||||
namespace Billing.Store
|
||||
{
|
||||
@@ -59,11 +60,18 @@ namespace Billing.Store
|
||||
list = new List<Category>
|
||||
{
|
||||
// TODO: sample categories
|
||||
new() { Id = 0, Name = "早餐", Icon = "face" },
|
||||
new() { Id = 1, Name = "轻轨", Icon = "" },
|
||||
new() { Id = 2, Name = "公交车", Icon = "" },
|
||||
new() { Id = 3, Name = "出租车", Icon = "" },
|
||||
new() { Id = 4, Type = CategoryType.Income, Name = "投资", Icon = "#brand#btc" }
|
||||
new() { Id = 1, Name = Resource.Clothing, Icon = "clothes" },
|
||||
new() { Id = 2, Name = Resource.Food, Icon = "food" },
|
||||
new() { Id = 3, Name = Resource.Drinks, Icon = "drink" },
|
||||
new() { Id = 4, Name = Resource.Daily, Icon = "daily" },
|
||||
new() { Id = 5, Name = Resource.Trans, Icon = "trans" },
|
||||
new() { Id = 6, Name = Resource.Entertainment, Icon = "face" },
|
||||
new() { Id = 7, Name = Resource.Learn, Icon = "learn" },
|
||||
new() { Id = 8, Name = Resource.Medical, Icon = "medical" },
|
||||
|
||||
new() { Id = 9, Type = CategoryType.Income, Name = Resource.Salary, Icon = "#brand#buffer" },
|
||||
new() { Id = 10, Type = CategoryType.Income, Name = Resource.Earnings, Icon = "#brand#btc" },
|
||||
new() { Id = 20, Type = CategoryType.Income, Name = Resource.Bonus, Icon = "dollar" }
|
||||
};
|
||||
Task.Run(() => WriteCategoriesInternal(list));
|
||||
}
|
||||
|
@@ -62,10 +62,26 @@ namespace Billing.Themes
|
||||
{
|
||||
Setters =
|
||||
{
|
||||
new Setter { Property = Editor.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(Entry)) },
|
||||
new Setter { Property = Editor.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(Editor)) },
|
||||
new Setter { Property = Editor.FontFamilyProperty, Value = robotoRegularFontFamily }
|
||||
}
|
||||
});
|
||||
Add(new Style(typeof(OptionDatePicker))
|
||||
{
|
||||
Setters =
|
||||
{
|
||||
new Setter { Property = DatePicker.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(DatePicker)) },
|
||||
new Setter { Property = DatePicker.FontFamilyProperty, Value = robotoRegularFontFamily }
|
||||
}
|
||||
});
|
||||
Add(new Style(typeof(OptionTimePicker))
|
||||
{
|
||||
Setters =
|
||||
{
|
||||
new Setter { Property = TimePicker.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, typeof(TimePicker)) },
|
||||
new Setter { Property = TimePicker.FontFamilyProperty, Value = robotoRegularFontFamily }
|
||||
}
|
||||
});
|
||||
Add(new Style(typeof(Button))
|
||||
{
|
||||
Setters =
|
||||
|
@@ -1,4 +1,6 @@
|
||||
using Xamarin.Forms;
|
||||
using Billing.UI;
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Billing.Themes
|
||||
{
|
||||
@@ -8,11 +10,25 @@ namespace Billing.Themes
|
||||
|
||||
public static Light Instance => _instance ??= new Light();
|
||||
|
||||
protected override Color PrimaryMauiColor => Color.FromRgb(0x18, 0x31, 0x53);
|
||||
private Color primaryColor;
|
||||
|
||||
protected override Color PrimaryMauiColor => primaryColor;
|
||||
protected override Color SecondaryMauiColor => Color.White;
|
||||
|
||||
public Light()
|
||||
{
|
||||
var color = Preferences.Get(Definition.PrimaryColorKey, "#183153");
|
||||
primaryColor = Color.FromHex(color);
|
||||
|
||||
InitColors();
|
||||
InitResources();
|
||||
}
|
||||
|
||||
public void RefreshColor(Color primary)
|
||||
{
|
||||
primaryColor = primary;
|
||||
Clear();
|
||||
|
||||
InitColors();
|
||||
InitResources();
|
||||
}
|
||||
@@ -35,7 +51,7 @@ namespace Billing.Themes
|
||||
Setters =
|
||||
{
|
||||
new Setter { Property = Shell.TabBarBackgroundColorProperty, Value = Color.White },
|
||||
new Setter { Property = Shell.TabBarTitleColorProperty, Value = PrimaryMauiColor },
|
||||
new Setter { Property = Shell.TabBarTitleColorProperty, Value = primaryColor },
|
||||
new Setter { Property = Shell.TabBarUnselectedColorProperty, Value = Color.FromRgb(0x82, 0x82, 0x82) }
|
||||
}
|
||||
});
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using Billing.Languages;
|
||||
using Billing.Models;
|
||||
using Billing.Themes;
|
||||
using Billing.Views;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -26,9 +25,26 @@ namespace Billing.UI
|
||||
}
|
||||
}
|
||||
|
||||
public class NegativeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool b)
|
||||
{
|
||||
return !b;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class MoneyConverter : IValueConverter
|
||||
{
|
||||
public bool MarkVisible { get; set; } = true;
|
||||
public bool MarkVisible { get; set; }
|
||||
public bool Absolute { get; set; }
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
@@ -89,14 +105,13 @@ namespace Billing.UI
|
||||
}
|
||||
}
|
||||
|
||||
public class UIBillConverter : IValueConverter
|
||||
public class TimeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is UIBill bill)
|
||||
if (value is DateTime time)
|
||||
{
|
||||
var time = bill.DateCreation.ToString("HH:mm");
|
||||
return $"{time} ({bill.Wallet})";
|
||||
return time.ToString("HH:mm");
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
@@ -152,6 +167,7 @@ namespace Billing.UI
|
||||
{ "appstore", "\uf370" },
|
||||
{ "apple-pay", "\uf416" },
|
||||
{ "btc", "\uf15a" },
|
||||
{ "buffer", "\uf837" },
|
||||
{ "jcb", "\uf24b" },
|
||||
{ "master-card", "\uf1f1" },
|
||||
{ "visa", "\uf1f0" },
|
||||
|
@@ -29,4 +29,35 @@ namespace Billing.UI
|
||||
LongPressed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public class LongPressGrid : Grid
|
||||
{
|
||||
public static readonly BindableProperty LongCommandProperty = BindableProperty.Create(nameof(LongCommand), typeof(Command), typeof(LongPressGrid));
|
||||
public static readonly BindableProperty LongCommandParameterProperty = BindableProperty.Create(nameof(LongCommandParameter), typeof(object), typeof(LongPressGrid));
|
||||
|
||||
public Command LongCommand
|
||||
{
|
||||
get => (Command)GetValue(LongCommandProperty);
|
||||
set => SetValue(LongCommandProperty, value);
|
||||
}
|
||||
public object LongCommandParameter
|
||||
{
|
||||
get => GetValue(LongCommandParameterProperty);
|
||||
set => SetValue(LongCommandParameterProperty, value);
|
||||
}
|
||||
|
||||
public void TriggerLongPress()
|
||||
{
|
||||
var command = LongCommand;
|
||||
if (command == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var parameter = LongCommandParameter;
|
||||
if (command.CanExecute(parameter))
|
||||
{
|
||||
command.Execute(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -11,6 +11,8 @@ namespace Billing.UI
|
||||
{
|
||||
public static partial class Definition
|
||||
{
|
||||
public static string PrimaryColorKey = "PrimaryColor";
|
||||
public static partial (string main, long build) GetVersion();
|
||||
public static partial string GetCascadiaRegularFontFamily();
|
||||
public static partial string GetCascadiaBoldFontFamily();
|
||||
public static partial string GetRobotoCondensedRegularFontFamily();
|
||||
@@ -84,6 +86,13 @@ namespace Billing.UI
|
||||
{
|
||||
await page.DisplayAlert(title ?? page.Title, message, Resource.Ok);
|
||||
}
|
||||
|
||||
public static async Task<bool> ShowConfirm(this Page page, string message)
|
||||
{
|
||||
var yes = Resource.Yes;
|
||||
var result = await page.DisplayActionSheet(message, Resource.No, yes);
|
||||
return result == yes;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ModelExtensionHelper
|
||||
|
@@ -182,7 +182,7 @@ namespace Billing.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
lastHeight = rowHeight + spacing;
|
||||
lastHeight += rowHeight + spacing;
|
||||
}
|
||||
}
|
||||
lastSizeRequest = new SizeRequest(new Size(widthConstraint, lastHeight));
|
||||
|
@@ -11,6 +11,7 @@ namespace Billing.UI
|
||||
|
||||
public ItemSelectPage(IEnumerable<T> source)
|
||||
{
|
||||
var iconConverter = new IconConverter();
|
||||
var content = new ListView
|
||||
{
|
||||
ItemsSource = source,
|
||||
@@ -30,7 +31,7 @@ namespace Billing.UI
|
||||
Aspect = Aspect.AspectFit,
|
||||
VerticalOptions = LayoutOptions.Center
|
||||
}
|
||||
.Binding(Image.SourceProperty, "Icon"),
|
||||
.Binding(Image.SourceProperty, "Icon", converter: iconConverter),
|
||||
|
||||
new Label
|
||||
{
|
||||
@@ -51,11 +52,12 @@ namespace Billing.UI
|
||||
Content = content;
|
||||
}
|
||||
|
||||
private void List_ItemTapped(object sender, ItemTappedEventArgs e)
|
||||
private async void List_ItemTapped(object sender, ItemTappedEventArgs e)
|
||||
{
|
||||
if (e.Item is T t)
|
||||
{
|
||||
ItemTapped?.Invoke(this, t);
|
||||
await Navigation.PopAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,8 @@ namespace Billing.UI
|
||||
{
|
||||
public class OptionEntry : Entry { }
|
||||
public class OptionEditor : Editor { }
|
||||
public class OptionDatePicker : DatePicker { }
|
||||
public class OptionTimePicker : TimePicker { }
|
||||
|
||||
public abstract class OptionCell : ViewCell
|
||||
{
|
||||
@@ -163,7 +165,6 @@ namespace Billing.UI
|
||||
{
|
||||
new Label
|
||||
{
|
||||
HorizontalOptions = LayoutOptions.End,
|
||||
VerticalOptions = LayoutOptions.Center
|
||||
}
|
||||
.Binding(Label.TextProperty, nameof(Detail))
|
||||
@@ -207,7 +208,6 @@ namespace Billing.UI
|
||||
{
|
||||
WidthRequest = 26,
|
||||
HeightRequest = 20,
|
||||
HorizontalOptions = LayoutOptions.End,
|
||||
VerticalOptions = LayoutOptions.Center,
|
||||
Margin = new Thickness(6, 0)
|
||||
}
|
||||
@@ -248,6 +248,46 @@ namespace Billing.UI
|
||||
.Binding(Switch.IsToggledProperty, nameof(IsToggled), mode: BindingMode.TwoWay);
|
||||
}
|
||||
|
||||
public class OptionDatePickerCell : OptionCell
|
||||
{
|
||||
public static readonly BindableProperty DateProperty = BindableProperty.Create(nameof(Date), typeof(DateTime), typeof(OptionDatePickerCell));
|
||||
|
||||
public DateTime Date
|
||||
{
|
||||
get => (DateTime)GetValue(DateProperty);
|
||||
set => SetValue(DateProperty, value);
|
||||
}
|
||||
|
||||
protected override View Content => new OptionDatePicker
|
||||
{
|
||||
HorizontalOptions = LayoutOptions.End,
|
||||
VerticalOptions = LayoutOptions.Center
|
||||
}
|
||||
.Binding(DatePicker.DateProperty, nameof(Date), mode: BindingMode.TwoWay)
|
||||
.DynamicResource(DatePicker.TextColorProperty, BaseTheme.TextColor)
|
||||
.DynamicResource(VisualElement.BackgroundColorProperty, BaseTheme.OptionTintColor);
|
||||
}
|
||||
|
||||
public class OptionTimePickerCell : OptionCell
|
||||
{
|
||||
public static readonly BindableProperty TimeProperty = BindableProperty.Create(nameof(Time), typeof(TimeSpan), typeof(OptionTimePickerCell));
|
||||
|
||||
public TimeSpan Time
|
||||
{
|
||||
get => (TimeSpan)GetValue(TimeProperty);
|
||||
set => SetValue(TimeProperty, value);
|
||||
}
|
||||
|
||||
protected override View Content => new OptionTimePicker
|
||||
{
|
||||
HorizontalOptions = LayoutOptions.End,
|
||||
VerticalOptions = LayoutOptions.Center
|
||||
}
|
||||
.Binding(TimePicker.TimeProperty, nameof(Time), mode: BindingMode.TwoWay)
|
||||
.DynamicResource(TimePicker.TextColorProperty, BaseTheme.TextColor)
|
||||
.DynamicResource(VisualElement.BackgroundColorProperty, BaseTheme.OptionTintColor);
|
||||
}
|
||||
|
||||
public class OptionEntryCell : OptionCell
|
||||
{
|
||||
public static readonly BindableProperty TextProperty = BindableProperty.Create(nameof(Text), typeof(string), typeof(OptionEntryCell));
|
||||
|
@@ -13,7 +13,6 @@
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ui:MoneyConverter x:Key="moneyConverter"/>
|
||||
<ui:MoneyConverter x:Key="money2Converter" MarkVisible="False"/>
|
||||
<ui:AccountCategoryConverter x:Key="categoryConverter"/>
|
||||
<ui:IconConverter x:Key="iconConverter"/>
|
||||
</ContentPage.Resources>
|
||||
@@ -34,7 +33,7 @@
|
||||
Text="{Binding Balance, Converter={StaticResource moneyConverter}}"/>
|
||||
</StackLayout>
|
||||
<Grid Grid.Column="1" Margin="20, 0" VerticalOptions="Center" HorizontalOptions="End"
|
||||
ColumnDefinitions="Auto, Auto" RowDefinitions="Auto, Auto">
|
||||
ColumnDefinitions="Auto, Auto" RowDefinitions="Auto, Auto" IsVisible="False">
|
||||
<Label FontSize="Small" HorizontalOptions="End" Text="{r:Text Assets}"/>
|
||||
<Label Grid.Column="1" FontSize="Small" Margin="10, 0, 0, 0" HorizontalOptions="End"
|
||||
Text="{Binding Asset, Converter={StaticResource moneyConverter}}"/>
|
||||
@@ -44,20 +43,22 @@
|
||||
Text="{Binding Liability, Converter={StaticResource moneyConverter}}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ui:GroupStackLayout x:Name="groupLayout" ItemsSource="{Binding Accounts}" Margin="0, 10, 0, 0">
|
||||
<ui:GroupStackLayout x:Name="groupLayout" ItemsSource="{Binding Accounts}" Margin="0, 10, 0, 0" GroupHeight="40">
|
||||
<ui:GroupStackLayout.GroupHeaderTemplate>
|
||||
<DataTemplate x:DataType="v:AccountGrouping">
|
||||
<StackLayout Orientation="Horizontal" Padding="10, 0">
|
||||
<StackLayout Orientation="Horizontal" Padding="10, 0" VerticalOptions="End">
|
||||
<Label Text="{Binding Key, Converter={StaticResource categoryConverter}}"
|
||||
TextColor="{DynamicResource SecondaryTextColor}"/>
|
||||
<Label Text="{Binding Balance, Converter={StaticResource money2Converter}}"
|
||||
<Label Text="{Binding Balance, Converter={StaticResource moneyConverter}}"
|
||||
Margin="10, 0" TextColor="{DynamicResource SecondaryTextColor}"/>
|
||||
</StackLayout>
|
||||
</DataTemplate>
|
||||
</ui:GroupStackLayout.GroupHeaderTemplate>
|
||||
<ui:GroupStackLayout.ItemTemplate>
|
||||
<DataTemplate x:DataType="m:Account">
|
||||
<Grid Padding="20, 0, 10, 0" ColumnSpacing="10" ColumnDefinitions="Auto, *, Auto, Auto">
|
||||
<ui:LongPressGrid Padding="20, 0, 10, 0" ColumnSpacing="10" ColumnDefinitions="Auto, *, Auto, Auto"
|
||||
LongCommand="{Binding DeleteAccount, Source={x:Reference accountPage}}"
|
||||
LongCommandParameter="{Binding .}">
|
||||
<Grid.GestureRecognizers>
|
||||
<TapGestureRecognizer Command="{Binding EditAccount, Source={x:Reference accountPage}}"
|
||||
CommandParameter="{Binding .}"/>
|
||||
@@ -67,11 +68,11 @@
|
||||
<Label Grid.Column="1" Text="{Binding Name}" TextColor="{DynamicResource TextColor}"
|
||||
HorizontalOptions="FillAndExpand" VerticalOptions="Center"
|
||||
FontSize="Default" FontAttributes="Bold"/>
|
||||
<Label Grid.Column="2" Text="{Binding Balance, Converter={StaticResource money2Converter}}"
|
||||
<Label Grid.Column="2" Text="{Binding Balance, Converter={StaticResource moneyConverter}}"
|
||||
TextColor="{DynamicResource SecondaryTextColor}"
|
||||
VerticalOptions="Center"/>
|
||||
<ui:TintImage Grid.Column="3" Source="right.png" HeightRequest="20"/>
|
||||
</Grid>
|
||||
</ui:LongPressGrid>
|
||||
</DataTemplate>
|
||||
</ui:GroupStackLayout.ItemTemplate>
|
||||
</ui:GroupStackLayout>
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Billing.Languages;
|
||||
using Billing.Models;
|
||||
using Billing.UI;
|
||||
using Xamarin.Forms;
|
||||
@@ -20,6 +21,7 @@ namespace Billing.Views
|
||||
public List<AccountGrouping> Accounts => (List<AccountGrouping>)GetValue(AccountsProperty);
|
||||
|
||||
public Command EditAccount { get; }
|
||||
public Command DeleteAccount { get; }
|
||||
|
||||
private readonly List<AccountGrouping> accounts = new();
|
||||
private bool initialized;
|
||||
@@ -27,6 +29,7 @@ namespace Billing.Views
|
||||
public AccountPage()
|
||||
{
|
||||
EditAccount = new Command(OnEditAccount);
|
||||
DeleteAccount = new Command(OnDeleteAccount);
|
||||
SetValue(AccountsProperty, accounts);
|
||||
|
||||
InitializeComponent();
|
||||
@@ -34,7 +37,7 @@ namespace Billing.Views
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
if (!initialized)
|
||||
if (!initialized || accounts.Count == 0)
|
||||
{
|
||||
initialized = true;
|
||||
accounts.Clear();
|
||||
@@ -52,6 +55,12 @@ namespace Billing.Views
|
||||
}
|
||||
}
|
||||
groupLayout.Refresh(accounts);
|
||||
RefreshBalance();
|
||||
}
|
||||
|
||||
private void RefreshBalance()
|
||||
{
|
||||
SetValue(BalanceProperty, App.Accounts.Sum(a => a.Balance));
|
||||
}
|
||||
|
||||
private void AddToAccountGroup(Account account)
|
||||
@@ -94,6 +103,35 @@ namespace Billing.Views
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnDeleteAccount(object o)
|
||||
{
|
||||
if (Tap.IsBusy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (Tap.Start())
|
||||
{
|
||||
if (o is Account account)
|
||||
{
|
||||
var result = await this.ShowConfirm(Resource.ConfirmDeleteAccount);
|
||||
if (result)
|
||||
{
|
||||
var group = accounts.FirstOrDefault(a => a.Key == account.Category);
|
||||
if (group == null)
|
||||
{
|
||||
Helper.Error("account.delete", "unexpected deleting account, cannot find the current category");
|
||||
return;
|
||||
}
|
||||
group.Remove(account);
|
||||
groupLayout.Refresh(accounts);
|
||||
RefreshBalance();
|
||||
|
||||
_ = Task.Run(App.WriteAccounts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AccountChecked(object sender, AccountEventArgs e)
|
||||
{
|
||||
if (e.Account.Id < 0)
|
||||
@@ -102,6 +140,7 @@ namespace Billing.Views
|
||||
AddToAccountGroup(e.Account);
|
||||
}
|
||||
groupLayout.Refresh(accounts);
|
||||
RefreshBalance();
|
||||
|
||||
Task.Run(App.WriteAccounts);
|
||||
}
|
||||
|
@@ -152,10 +152,9 @@ namespace Billing.Views
|
||||
}
|
||||
}
|
||||
|
||||
private async void Category_ItemTapped(object sender, SelectItem<AccountCategory> e)
|
||||
private void Category_ItemTapped(object sender, SelectItem<AccountCategory> e)
|
||||
{
|
||||
Category = e.Value;
|
||||
await Navigation.PopAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -39,9 +39,11 @@
|
||||
<ui:OptionEntryCell Height="44" Icon="online.png"
|
||||
Title="{r:Text Store}"
|
||||
Text="{Binding Store, Mode=TwoWay}"/>
|
||||
<ui:OptionSelectCell Height="44" Icon="bars.png"
|
||||
Title="{r:Text CreatedTime}"
|
||||
Detail="{Binding CreatedTime}"/>
|
||||
<ui:OptionDatePickerCell Height="44" Icon="bars.png"
|
||||
Title="{r:Text CreatedTime}"
|
||||
Date="{Binding CreatedDate, Mode=TwoWay}"/>
|
||||
<ui:OptionTimePickerCell Height="44"
|
||||
Time="{Binding CreatedTime, Mode=TwoWay}"/>
|
||||
</TableSection>
|
||||
<TableSection>
|
||||
<TableSection.Title>
|
||||
|
@@ -15,7 +15,8 @@ namespace Billing.Views
|
||||
private static readonly BindableProperty CategoryNameProperty = BindableProperty.Create(nameof(CategoryName), typeof(string), typeof(AddBillPage));
|
||||
private static readonly BindableProperty WalletNameProperty = BindableProperty.Create(nameof(WalletName), typeof(string), typeof(AddBillPage));
|
||||
private static readonly BindableProperty StoreProperty = BindableProperty.Create(nameof(Store), typeof(string), typeof(AddBillPage));
|
||||
private static readonly BindableProperty CreatedTimeProperty = BindableProperty.Create(nameof(CreatedTime), typeof(DateTime), typeof(AddBillPage));
|
||||
private static readonly BindableProperty CreatedDateProperty = BindableProperty.Create(nameof(CreatedDate), typeof(DateTime), typeof(AddBillPage));
|
||||
private static readonly BindableProperty CreatedTimeProperty = BindableProperty.Create(nameof(CreatedTime), typeof(TimeSpan), typeof(AddBillPage));
|
||||
private static readonly BindableProperty NoteProperty = BindableProperty.Create(nameof(Note), typeof(string), typeof(AddBillPage));
|
||||
|
||||
public string Amount
|
||||
@@ -35,9 +36,14 @@ namespace Billing.Views
|
||||
get => (string)GetValue(StoreProperty);
|
||||
set => SetValue(StoreProperty, value);
|
||||
}
|
||||
public DateTime CreatedTime
|
||||
public DateTime CreatedDate
|
||||
{
|
||||
get => (DateTime)GetValue(CreatedTimeProperty);
|
||||
get => (DateTime)GetValue(CreatedDateProperty);
|
||||
set => SetValue(CreatedDateProperty, value);
|
||||
}
|
||||
public TimeSpan CreatedTime
|
||||
{
|
||||
get => (TimeSpan)GetValue(CreatedTimeProperty);
|
||||
set => SetValue(CreatedTimeProperty, value);
|
||||
}
|
||||
public string Note
|
||||
@@ -86,14 +92,15 @@ namespace Billing.Views
|
||||
{
|
||||
if (bill != null)
|
||||
{
|
||||
Amount = bill.Amount.ToString(CultureInfo.InvariantCulture);
|
||||
Amount = Math.Abs(bill.Amount).ToString(CultureInfo.InvariantCulture);
|
||||
Name = bill.Name;
|
||||
walletId = bill.WalletId;
|
||||
categoryId = bill.CategoryId;
|
||||
SetValue(WalletNameProperty, App.Accounts.FirstOrDefault(a => a.Id == walletId)?.Name);
|
||||
SetValue(CategoryNameProperty, App.Categories.FirstOrDefault(c => c.Id == categoryId)?.Name);
|
||||
Store = bill.Store;
|
||||
CreatedTime = bill.CreateTime;
|
||||
CreatedDate = bill.CreateTime.Date;
|
||||
CreatedTime = bill.CreateTime.TimeOfDay;
|
||||
Note = bill.Note;
|
||||
}
|
||||
else
|
||||
@@ -104,7 +111,8 @@ namespace Billing.Views
|
||||
var firstCategory = App.Categories.First();
|
||||
categoryId = firstCategory.Id;
|
||||
SetValue(CategoryNameProperty, firstCategory.Name);
|
||||
CreatedTime = createDate.Date.Add(DateTime.Now.TimeOfDay);
|
||||
CreatedDate = createDate.Date;
|
||||
CreatedTime = DateTime.Now.TimeOfDay;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,13 +140,18 @@ namespace Billing.Views
|
||||
amount *= -1;
|
||||
}
|
||||
await Navigation.PopAsync();
|
||||
var name = Name;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
name = category.Name;
|
||||
}
|
||||
if (bill != null)
|
||||
{
|
||||
bill.Amount = amount;
|
||||
bill.Name = Name;
|
||||
bill.Name = name;
|
||||
bill.CategoryId = categoryId;
|
||||
bill.WalletId = walletId;
|
||||
bill.CreateTime = CreatedTime;
|
||||
bill.CreateTime = CreatedDate.Date.Add(CreatedTime);
|
||||
bill.Store = Store;
|
||||
bill.Note = Note;
|
||||
}
|
||||
@@ -146,24 +159,66 @@ namespace Billing.Views
|
||||
{
|
||||
Id = -1,
|
||||
Amount = amount,
|
||||
Name = Name,
|
||||
Name = name,
|
||||
CategoryId = categoryId,
|
||||
WalletId = walletId,
|
||||
CreateTime = CreatedTime,
|
||||
CreateTime = CreatedDate.Date.Add(CreatedTime),
|
||||
Store = Store,
|
||||
Note = Note
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSelectCategory()
|
||||
private async void OnSelectCategory()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnSelectWallet()
|
||||
if (Tap.IsBusy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (Tap.Start())
|
||||
{
|
||||
var source = App.Categories.Select(c => new SelectItem<int>
|
||||
{
|
||||
Value = c.Id,
|
||||
Name = c.Name,
|
||||
Icon = c.Icon
|
||||
});
|
||||
var page = new ItemSelectPage<SelectItem<int>>(source);
|
||||
page.ItemTapped += Category_ItemTapped;
|
||||
await Navigation.PushAsync(page);
|
||||
}
|
||||
}
|
||||
|
||||
private void Category_ItemTapped(object sender, SelectItem<int> category)
|
||||
{
|
||||
categoryId = category.Value;
|
||||
SetValue(CategoryNameProperty, category.Name);
|
||||
}
|
||||
|
||||
private async void OnSelectWallet()
|
||||
{
|
||||
|
||||
}
|
||||
if (Tap.IsBusy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (Tap.Start())
|
||||
{
|
||||
var source = App.Accounts.Select(a => new SelectItem<int>
|
||||
{
|
||||
Value = a.Id,
|
||||
Name = a.Name,
|
||||
Icon = a.Icon
|
||||
});
|
||||
var page = new ItemSelectPage<SelectItem<int>>(source);
|
||||
page.ItemTapped += Wallet_ItemTapped;
|
||||
await Navigation.PushAsync(page);
|
||||
}
|
||||
}
|
||||
|
||||
private void Wallet_ItemTapped(object sender, SelectItem<int> account)
|
||||
{
|
||||
walletId = account.Value;
|
||||
SetValue(WalletNameProperty, account.Name);
|
||||
}
|
||||
}
|
||||
}
|
@@ -12,9 +12,11 @@
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ui:TitleDateConverter x:Key="titleDateConverter"/>
|
||||
<ui:MoneyConverter x:Key="moneyConverter" MarkVisible="False" Absolute="True"/>
|
||||
<ui:NegativeConverter x:Key="negativeConverter"/>
|
||||
<ui:MoneyConverter x:Key="moneyConverter" Absolute="True"/>
|
||||
<ui:MoneyConverter x:Key="moneyRawConverter"/>
|
||||
<ui:BalanceColorConverter x:Key="colorConverter"/>
|
||||
<ui:UIBillConverter x:Key="billConverter"/>
|
||||
<ui:TimeConverter x:Key="timeConverter"/>
|
||||
<ui:IconConverter x:Key="iconConverter"/>
|
||||
</ContentPage.Resources>
|
||||
|
||||
@@ -36,28 +38,51 @@
|
||||
|
||||
<Grid RowDefinitions="Auto, Auto, *">
|
||||
<ui:BillingDate x:Name="billingDate" SelectedDate="{Binding SelectedDate}" DateSelected="OnDateSelected"/>
|
||||
<Grid Grid.Row="1" Padding="8" ColumnSpacing="8" ColumnDefinitions="Auto, *, Auto"
|
||||
BackgroundColor="{DynamicResource PromptBackgroundColor}">
|
||||
<ui:TintImage Source="bars.png" WidthRequest="23" HeightRequest="23"/>
|
||||
<Label Grid.Column="1" Text="{r:Text NoRecords}" TextColor="{DynamicResource TextColor}"
|
||||
VerticalOptions="Center"/>
|
||||
<StackLayout Grid.Column="2" Orientation="Horizontal" Spacing="6">
|
||||
<Grid Grid.Row="1" Padding="8" ColumnSpacing="8" ColumnDefinitions="*, Auto"
|
||||
BackgroundColor="{DynamicResource PromptBackgroundColor}"
|
||||
IsVisible="{Binding NoBills}">
|
||||
<Label Text="{r:Text NoRecords}" TextColor="{DynamicResource TextColor}"
|
||||
VerticalOptions="Center" FontSize="12"/>
|
||||
<StackLayout Grid.Column="1" Orientation="Horizontal" Spacing="6">
|
||||
<StackLayout.GestureRecognizers>
|
||||
<TapGestureRecognizer Command="{Binding EditBilling}"/>
|
||||
</StackLayout.GestureRecognizers>
|
||||
<Label Text="{r:Text TapToMemo}" TextColor="{DynamicResource PrimaryColor}"
|
||||
VerticalOptions="Center"/>
|
||||
VerticalOptions="Center" FontSize="12"/>
|
||||
<ui:TintImage Source="right.png" WidthRequest="24" HeightRequest="24"/>
|
||||
</StackLayout>
|
||||
</Grid>
|
||||
<Grid Grid.Row="1" Padding="8" ColumnSpacing="8" ColumnDefinitions="*, Auto" HeightRequest="24"
|
||||
BackgroundColor="{DynamicResource PromptBackgroundColor}"
|
||||
IsVisible="{Binding NoBills, Converter={StaticResource negativeConverter}}">
|
||||
<StackLayout Grid.Column="1" Orientation="Horizontal" Spacing="6">
|
||||
<Label Text="{r:Text Income}" TextColor="{DynamicResource GreenColor}"
|
||||
VerticalOptions="Center" FontSize="12"/>
|
||||
<Label Text="{Binding Income, Converter={StaticResource moneyConverter}}"
|
||||
TextColor="{DynamicResource TextColor}"
|
||||
VerticalOptions="Center" FontSize="12"/>
|
||||
<Label Text="{r:Text Spending}" TextColor="{DynamicResource RedColor}"
|
||||
VerticalOptions="Center" FontSize="12" Margin="10, 0, 0, 0"/>
|
||||
<Label Text="{Binding Spending, Converter={StaticResource moneyConverter}}"
|
||||
TextColor="{DynamicResource TextColor}"
|
||||
VerticalOptions="Center" FontSize="12"/>
|
||||
<Label Text="{r:Text Balance}"
|
||||
VerticalOptions="Center" FontSize="12" Margin="10, 0, 0, 0"/>
|
||||
<Label Text="{Binding Balance, Converter={StaticResource moneyRawConverter}}"
|
||||
TextColor="{DynamicResource TextColor}"
|
||||
VerticalOptions="Center" FontSize="12"/>
|
||||
</StackLayout>
|
||||
</Grid>
|
||||
<!-- bill list -->
|
||||
<ScrollView Grid.Row="2">
|
||||
<ui:GroupStackLayout x:Name="billsLayout" ItemsSource="{Binding Bills}"
|
||||
Margin="0, 10, 0, 0" RowHeight="50">
|
||||
<ui:GroupStackLayout.ItemTemplate>
|
||||
<DataTemplate x:DataType="v:UIBill">
|
||||
<Grid Padding="20, 0, 10, 0" ColumnSpacing="10"
|
||||
ColumnDefinitions="Auto, *, Auto" RowDefinitions="Auto, Auto">
|
||||
<ui:LongPressGrid Padding="20, 0" ColumnSpacing="10"
|
||||
ColumnDefinitions="Auto, *, Auto" RowDefinitions="Auto, Auto"
|
||||
LongCommand="{Binding DeleteBilling, Source={x:Reference billPage}}"
|
||||
LongCommandParameter="{Binding .}">
|
||||
<Grid.GestureRecognizers>
|
||||
<TapGestureRecognizer Command="{Binding EditBilling, Source={x:Reference billPage}}"
|
||||
CommandParameter="{Binding .}"/>
|
||||
@@ -70,10 +95,13 @@
|
||||
<Label Grid.Column="2" Text="{Binding Amount, Converter={StaticResource moneyConverter}}"
|
||||
TextColor="{Binding Amount, Converter={StaticResource colorConverter}}"
|
||||
VerticalOptions="Center"/>
|
||||
<Label Grid.Row="1" Grid.Column="1" Text="{Binding ., Converter={StaticResource billConverter}}"
|
||||
FontSize="10"
|
||||
TextColor="{DynamicResource SecondaryTextColor}"/>
|
||||
</Grid>
|
||||
<StackLayout Grid.Row="1" Grid.Column="1" Spacing="6" Orientation="Horizontal">
|
||||
<Label Text="{Binding DateCreation, Converter={StaticResource timeConverter}}"
|
||||
FontSize="10" TextColor="{DynamicResource SecondaryTextColor}"/>
|
||||
<Label Text="{Binding Wallet}"
|
||||
FontSize="10" TextColor="{DynamicResource SecondaryTextColor}"/>
|
||||
</StackLayout>
|
||||
</ui:LongPressGrid>
|
||||
</DataTemplate>
|
||||
</ui:GroupStackLayout.ItemTemplate>
|
||||
</ui:GroupStackLayout>
|
||||
|
@@ -13,6 +13,10 @@ namespace Billing.Views
|
||||
{
|
||||
private static readonly BindableProperty SelectedDateProperty = BindableProperty.Create(nameof(SelectedDate), typeof(DateTime), typeof(BillPage));
|
||||
private static readonly BindableProperty BillsProperty = BindableProperty.Create(nameof(Bills), typeof(List<UIBill>), typeof(BillPage));
|
||||
private static readonly BindableProperty NoBillsProperty = BindableProperty.Create(nameof(NoBills), typeof(bool), typeof(BillPage));
|
||||
private static readonly BindableProperty IncomeProperty = BindableProperty.Create(nameof(Income), typeof(decimal), typeof(BillPage));
|
||||
private static readonly BindableProperty SpendingProperty = BindableProperty.Create(nameof(Spending), typeof(decimal), typeof(BillPage));
|
||||
private static readonly BindableProperty BalanceProperty = BindableProperty.Create(nameof(Balance), typeof(decimal), typeof(BillPage));
|
||||
|
||||
public DateTime SelectedDate
|
||||
{
|
||||
@@ -24,12 +28,18 @@ namespace Billing.Views
|
||||
get => (List<UIBill>)GetValue(BillsProperty);
|
||||
set => SetValue(BillsProperty, value);
|
||||
}
|
||||
public bool NoBills => (bool)GetValue(NoBillsProperty);
|
||||
public decimal Income => (decimal)GetValue(IncomeProperty);
|
||||
public decimal Spending => (decimal)GetValue(SpendingProperty);
|
||||
public decimal Balance => (decimal)GetValue(BalanceProperty);
|
||||
|
||||
public Command EditBilling { get; }
|
||||
public Command DeleteBilling { get; }
|
||||
|
||||
public BillPage()
|
||||
{
|
||||
EditBilling = new Command(OnEditBilling);
|
||||
DeleteBilling = new Command(OnDeleteBilling);
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
@@ -45,6 +55,17 @@ namespace Billing.Views
|
||||
b.CreateTime.Month == e.Date.Month &&
|
||||
b.CreateTime.Day == e.Date.Day);
|
||||
Bills = new List<UIBill>(bills.Select(b => WrapBill(b)));
|
||||
RefreshBalance(Bills);
|
||||
}
|
||||
|
||||
private void RefreshBalance(List<UIBill> bills)
|
||||
{
|
||||
SetValue(NoBillsProperty, bills.Count == 0);
|
||||
var income = bills.Where(b => b.Amount > 0).Sum(b => b.Amount);
|
||||
var spending = -bills.Where(b => b.Amount < 0).Sum(b => b.Amount);
|
||||
SetValue(IncomeProperty, income);
|
||||
SetValue(SpendingProperty, spending);
|
||||
SetValue(BalanceProperty, income - spending);
|
||||
}
|
||||
|
||||
private UIBill WrapBill(Bill b)
|
||||
@@ -101,6 +122,31 @@ namespace Billing.Views
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnDeleteBilling(object o)
|
||||
{
|
||||
if (Tap.IsBusy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (Tap.Start())
|
||||
{
|
||||
if (o is UIBill bill)
|
||||
{
|
||||
var result = await this.ShowConfirm(Resource.ConfirmDeleteBill);
|
||||
if (result)
|
||||
{
|
||||
var bills = Bills;
|
||||
bills.Remove(bill);
|
||||
App.Bills.Remove(bill.Bill);
|
||||
billsLayout.Refresh(bills);
|
||||
RefreshBalance(bills);
|
||||
|
||||
_ = Task.Run(App.WriteBills);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBillChecked(object sender, Bill e)
|
||||
{
|
||||
if (e.Id < 0)
|
||||
@@ -127,6 +173,7 @@ namespace Billing.Views
|
||||
UpdateBill(bill);
|
||||
}
|
||||
}
|
||||
RefreshBalance(Bills);
|
||||
|
||||
Task.Run(App.WriteBills);
|
||||
}
|
||||
|
@@ -40,7 +40,11 @@ namespace Billing.Views
|
||||
new() { Icon = BaseModel.ICON_DEFAULT },
|
||||
new() { Icon = "wallet" },
|
||||
new() { Icon = "creditcard" },
|
||||
new() { Icon = "debitcard" }
|
||||
new() { Icon = "debitcard" },
|
||||
new() { Icon = "cmb" },
|
||||
new() { Icon = "rcb" },
|
||||
new() { Icon = "yuebao" },
|
||||
new() { Icon = "zhaozhaoying" }
|
||||
};
|
||||
source.AddRange(IconConverter.IconPreset.Select(icon => new BillingIcon { Icon = $"#brand#{icon.Key}" }));
|
||||
foreach (var icon in source)
|
||||
|
@@ -2,12 +2,27 @@
|
||||
<ui:BillingPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:r="clr-namespace:Billing.Languages"
|
||||
xmlns:ui="clr-namespace:Billing.UI"
|
||||
xmlns:v="clr-namespace:Billing.Views"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Billing.Views.SettingPage"
|
||||
Title="{r:Text Settings}">
|
||||
<StackLayout>
|
||||
<Label Text="Welcome to Settings Page!"
|
||||
VerticalOptions="CenterAndExpand"
|
||||
HorizontalOptions="CenterAndExpand" />
|
||||
</StackLayout>
|
||||
x:Name="settingPage"
|
||||
x:DataType="v:SettingPage"
|
||||
Title="{r:Text Settings}"
|
||||
BindingContext="{x:Reference settingPage}">
|
||||
|
||||
<TableView Intent="Settings" RowHeight="44">
|
||||
<TableSection Title="{r:Text About}">
|
||||
<ui:OptionTextCell Title="{r:Text Version}"
|
||||
Detail="{Binding Version}"/>
|
||||
</TableSection>
|
||||
<TableSection Title="{r:Text Preference}">
|
||||
<ui:OptionEntryCell Title="{r:Text PrimaryColor}"
|
||||
Text="{Binding Red, Mode=TwoWay}"
|
||||
Keyboard="Numeric"/>
|
||||
<ui:OptionEntryCell Text="{Binding Green, Mode=TwoWay}"
|
||||
Keyboard="Numeric"/>
|
||||
<ui:OptionEntryCell Text="{Binding Blue, Mode=TwoWay}"
|
||||
Keyboard="Numeric"/>
|
||||
</TableSection>
|
||||
</TableView>
|
||||
</ui:BillingPage>
|
@@ -1,12 +1,61 @@
|
||||
using Billing.Themes;
|
||||
using Billing.UI;
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
|
||||
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 RedProperty = BindableProperty.Create(nameof(Red), typeof(byte), typeof(SettingPage));
|
||||
private static readonly BindableProperty GreenProperty = BindableProperty.Create(nameof(Green), typeof(byte), typeof(SettingPage));
|
||||
private static readonly BindableProperty BlueProperty = BindableProperty.Create(nameof(Blue), typeof(byte), typeof(SettingPage));
|
||||
|
||||
public string Version => (string)GetValue(VersionProperty);
|
||||
public byte Red
|
||||
{
|
||||
get => (byte)GetValue(RedProperty);
|
||||
set => SetValue(RedProperty, value);
|
||||
}
|
||||
public byte Green
|
||||
{
|
||||
get => (byte)GetValue(GreenProperty);
|
||||
set => SetValue(GreenProperty, value);
|
||||
}
|
||||
public byte Blue
|
||||
{
|
||||
get => (byte)GetValue(BlueProperty);
|
||||
set => SetValue(BlueProperty, value);
|
||||
}
|
||||
|
||||
public SettingPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var (main, build) = Definition.GetVersion();
|
||||
SetValue(VersionProperty, $"{main} ({build})");
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
|
||||
//SetValue(VersionProperty, $"{AppInfo.VersionString} ({AppInfo.BuildString})");
|
||||
var colorString = Preferences.Get(Definition.PrimaryColorKey, "#183153");
|
||||
var color = Color.FromHex(colorString);
|
||||
Red = (byte)(color.R * 255);
|
||||
Green = (byte)(color.G * 255);
|
||||
Blue = (byte)(color.B * 255);
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
base.OnDisappearing();
|
||||
|
||||
var color = Color.FromRgb(Red, Green, Blue);
|
||||
Preferences.Set(Definition.PrimaryColorKey, color.ToHex());
|
||||
Light.Instance.RefreshColor(color);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user