first test-flight version

This commit is contained in:
2022-03-03 15:10:36 +08:00
parent 9929eee056
commit 25191127f3
116 changed files with 1124 additions and 173 deletions

View File

@ -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);
}
}
}