basic logic
This commit is contained in:
@ -2,12 +2,44 @@
|
||||
<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.AccountPage"
|
||||
Title="{r:Text Accounts}">
|
||||
<StackLayout>
|
||||
<Label Text="Welcome to Account Page!"
|
||||
VerticalOptions="CenterAndExpand"
|
||||
HorizontalOptions="CenterAndExpand" />
|
||||
</StackLayout>
|
||||
x:Name="accountPage"
|
||||
x:DataType="v:AccountPage"
|
||||
Title="{r:Text Accounts}"
|
||||
BindingContext="{x:Reference accountPage}">
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ui:MoneyConverter x:Key="moneyConverter"/>
|
||||
</ContentPage.Resources>
|
||||
|
||||
<ContentPage.ToolbarItems>
|
||||
<ToolbarItem Order="Primary" IconImageSource="plus.png" Command="{Binding AddAccount}"/>
|
||||
</ContentPage.ToolbarItems>
|
||||
|
||||
<ScrollView>
|
||||
<StackLayout>
|
||||
<Grid HeightRequest="100" BackgroundColor="{DynamicResource PromptBackgroundColor}" ColumnDefinitions="Auto, *">
|
||||
<!--<Grid.Effects>
|
||||
<ui:ShadowEffect Offect="0, 3" Color="Black" Opacity=".4"/>
|
||||
</Grid.Effects>-->
|
||||
<StackLayout VerticalOptions="Center" Margin="20, 0" Spacing="0">
|
||||
<Label FontSize="Small" Text="{r:Text Balance}"/>
|
||||
<Label FontSize="24" FontFamily="{DynamicResource RobotoCondensedFontBold}"
|
||||
Text="{Binding Balance, Converter={StaticResource moneyConverter}}"/>
|
||||
</StackLayout>
|
||||
<Grid Grid.Column="1" Margin="20, 0" VerticalOptions="Center" HorizontalOptions="End"
|
||||
ColumnDefinitions="Auto, Auto" RowDefinitions="Auto, Auto">
|
||||
<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}}"/>
|
||||
<Label Grid.Row="1" FontSize="Small" HorizontalOptions="End" Text="{r:Text Liability}"/>
|
||||
<Label Grid.Row="1" Grid.Column="1" FontSize="Small" Margin="10, 0, 0, 0" HorizontalOptions="End"
|
||||
TextColor="{DynamicResource RedColor}"
|
||||
Text="{Binding Liability, Converter={StaticResource moneyConverter}}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</ui:BillingPage>
|
@ -1,11 +1,44 @@
|
||||
using Billing.UI;
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Billing.Views;
|
||||
|
||||
public partial class AccountPage : BillingPage
|
||||
{
|
||||
private static readonly BindableProperty BalanceProperty = BindableProperty.Create(nameof(Balance), typeof(decimal), typeof(AccountPage));
|
||||
private static readonly BindableProperty AssetProperty = BindableProperty.Create(nameof(Asset), typeof(decimal), typeof(AccountPage));
|
||||
private static readonly BindableProperty LiabilityProperty = BindableProperty.Create(nameof(Liability), typeof(decimal), typeof(AccountPage));
|
||||
|
||||
public decimal Balance => (decimal)GetValue(BalanceProperty);
|
||||
public decimal Asset => (decimal)GetValue(AssetProperty);
|
||||
public decimal Liability => (decimal)GetValue(LiabilityProperty);
|
||||
|
||||
public Command AddAccount { get; }
|
||||
|
||||
public AccountPage()
|
||||
{
|
||||
AddAccount = new Command(OnAddAccount);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void OnAddAccount()
|
||||
{
|
||||
if (Tap.IsBusy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (Tap.Start())
|
||||
{
|
||||
var page = new AddAccountPage();
|
||||
page.AccountChecked += AccountChecked;
|
||||
await Navigation.PushAsync(page);
|
||||
}
|
||||
}
|
||||
|
||||
private void AccountChecked(object sender, AccountEventArgs e)
|
||||
{
|
||||
Helper.Debug(e.Account.ToString());
|
||||
}
|
||||
}
|
||||
|
40
Billing.Shared/Views/AddAccountPage.xaml
Normal file
40
Billing.Shared/Views/AddAccountPage.xaml
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<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.AddAccountPage"
|
||||
x:Name="addAccountPage"
|
||||
x:DataType="v:AddAccountPage"
|
||||
Title="{r:Text AddAccount}"
|
||||
BindingContext="{x:Reference addAccountPage}">
|
||||
|
||||
<ContentPage.ToolbarItems>
|
||||
<ToolbarItem Order="Primary" IconImageSource="check.png" Command="{Binding CheckAccount}"/>
|
||||
</ContentPage.ToolbarItems>
|
||||
|
||||
<ContentPage.Content>
|
||||
<TableView Intent="Settings">
|
||||
<TableSection>
|
||||
<ui:OptionEntryCell Title="{r:Text AccountName}"
|
||||
Text="{Binding AccountName, Mode=TwoWay}"
|
||||
Keyboard="Text" Placeholder="{r:Text AccountNamePlaceholder}"/>
|
||||
<ui:OptionTextCell Title="{r:Text Icon}"
|
||||
Detail="{Binding AccountIcon}"/>
|
||||
</TableSection>
|
||||
<TableSection>
|
||||
<ui:OptionEntryCell Title="{r:Text Balance}"
|
||||
Text="{Binding Balance, Mode=TwoWay}"
|
||||
Keyboard="Numeric" Placeholder="{r:Text BalancePlaceholder}"/>
|
||||
<ui:OptionTextCell Title="{r:Text Currency}"
|
||||
Detail="{r:Text CNY}"/>
|
||||
</TableSection>
|
||||
<TableSection>
|
||||
<ui:OptionEntryCell Title="{r:Text Memo}"
|
||||
Text="{Binding Memo, Mode=TwoWay}"
|
||||
Keyboard="Plain" Placeholder="{r:Text MemoPlaceholder}"/>
|
||||
</TableSection>
|
||||
</TableView>
|
||||
</ContentPage.Content>
|
||||
</ui:BillingPage>
|
86
Billing.Shared/Views/AddAccountPage.xaml.cs
Normal file
86
Billing.Shared/Views/AddAccountPage.xaml.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using Billing.Models;
|
||||
using Billing.UI;
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Billing.Views;
|
||||
|
||||
public partial class AddAccountPage : BillingPage
|
||||
{
|
||||
private static readonly BindableProperty AccountNameProperty = BindableProperty.Create(nameof(AccountName), typeof(string), typeof(AddAccountPage));
|
||||
private static readonly BindableProperty AccountIconProperty = BindableProperty.Create(nameof(AccountIcon), typeof(string), typeof(AddAccountPage));
|
||||
private static readonly BindableProperty CategoryProperty = BindableProperty.Create(nameof(Category), typeof(string), typeof(AddAccountPage));
|
||||
private static readonly BindableProperty BalanceProperty = BindableProperty.Create(nameof(Balance), typeof(decimal), typeof(AddAccountPage));
|
||||
private static readonly BindableProperty MemoProperty = BindableProperty.Create(nameof(Memo), typeof(string), typeof(AddAccountPage));
|
||||
|
||||
public string AccountName
|
||||
{
|
||||
get => (string)GetValue(AccountNameProperty);
|
||||
set => SetValue(AccountNameProperty, value);
|
||||
}
|
||||
public string AccountIcon
|
||||
{
|
||||
get => (string)GetValue(AccountIconProperty);
|
||||
set => SetValue(AccountIconProperty, value);
|
||||
}
|
||||
public string Category
|
||||
{
|
||||
get => (string)GetValue(CategoryProperty);
|
||||
set => SetValue(CategoryProperty, value);
|
||||
}
|
||||
public decimal Balance
|
||||
{
|
||||
get => (decimal)GetValue(BalanceProperty);
|
||||
set => SetValue(BalanceProperty, value);
|
||||
}
|
||||
public string Memo
|
||||
{
|
||||
get => (string)GetValue(MemoProperty);
|
||||
set => SetValue(MemoProperty, value);
|
||||
}
|
||||
|
||||
private readonly Account account;
|
||||
|
||||
public Command CheckAccount { get; }
|
||||
|
||||
public event EventHandler<AccountEventArgs> AccountChecked;
|
||||
|
||||
public AddAccountPage()
|
||||
{
|
||||
CheckAccount = new Command(OnCheckAccount);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public AddAccountPage(Account account)
|
||||
{
|
||||
this.account = account;
|
||||
AccountName = account.Name;
|
||||
AccountIcon = account.Icon;
|
||||
Category = account.Category.ToString();
|
||||
Balance = account.Balance;
|
||||
Memo = account.Memo;
|
||||
CheckAccount = new Command(OnCheckAccount);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnCheckAccount()
|
||||
{
|
||||
AccountChecked?.Invoke(this, new AccountEventArgs
|
||||
{
|
||||
Account = new Account
|
||||
{
|
||||
Id = account?.Id ?? -1,
|
||||
Name = AccountName,
|
||||
Icon = AccountIcon,
|
||||
//Category = Category,
|
||||
Balance = Balance,
|
||||
Memo = Memo
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class AccountEventArgs : EventArgs
|
||||
{
|
||||
public Account Account { get; set; }
|
||||
}
|
@ -39,7 +39,7 @@
|
||||
<StackLayout.GestureRecognizers>
|
||||
<TapGestureRecognizer Command="{Binding AddBilling}"/>
|
||||
</StackLayout.GestureRecognizers>
|
||||
<Label Text="{r:Text Memo}" TextColor="{DynamicResource PrimaryColor}"
|
||||
<Label Text="{r:Text TapToMemo}" TextColor="{DynamicResource PrimaryColor}"
|
||||
VerticalOptions="Center"/>
|
||||
<!--<Label Style="{DynamicResource IconLightStyle}"
|
||||
Text="{x:Static local:Definition.IconRight}"
|
||||
|
Reference in New Issue
Block a user