category management
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using Billing.Themes;
|
||||
using Billing.UI;
|
||||
using System.Globalization;
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
|
||||
@ -8,29 +9,20 @@ 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));
|
||||
private static readonly BindableProperty PrimaryColorProperty = BindableProperty.Create(nameof(PrimaryColor), typeof(string), typeof(SettingPage));
|
||||
|
||||
public string Version => (string)GetValue(VersionProperty);
|
||||
public byte Red
|
||||
public string PrimaryColor
|
||||
{
|
||||
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);
|
||||
get => (string)GetValue(PrimaryColorProperty);
|
||||
set => SetValue(PrimaryColorProperty, value);
|
||||
}
|
||||
|
||||
public Command CategoryCommand { get; }
|
||||
|
||||
public SettingPage()
|
||||
{
|
||||
CategoryCommand = new Command(OnCategoryCommand);
|
||||
InitializeComponent();
|
||||
|
||||
var (main, build) = Definition.GetVersion();
|
||||
@ -42,20 +34,35 @@ namespace Billing.Views
|
||||
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);
|
||||
var colorString = Preferences.Get(Definition.PrimaryColorKey, Helper.DEFAULT_COLOR);
|
||||
PrimaryColor = Helper.WrapColorString(colorString);
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
base.OnDisappearing();
|
||||
|
||||
var color = Color.FromRgb(Red, Green, Blue);
|
||||
Preferences.Set(Definition.PrimaryColorKey, color.ToHex());
|
||||
Light.Instance.RefreshColor(color);
|
||||
var color = PrimaryColor;
|
||||
Preferences.Set(Definition.PrimaryColorKey, color);
|
||||
Light.Instance.RefreshColor(Color.FromHex(color));
|
||||
}
|
||||
|
||||
private async void OnCategoryCommand()
|
||||
{
|
||||
if (Tap.IsBusy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (Tap.Start())
|
||||
{
|
||||
var page = new CategoryPage();
|
||||
await Navigation.PushAsync(page);
|
||||
}
|
||||
}
|
||||
|
||||
private void ColorPicker_ColorChanged(object sender, Color e)
|
||||
{
|
||||
PrimaryColor = Helper.WrapColorString(e.ToHex());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user