allow to select a date & fix issue
This commit is contained in:
@ -28,9 +28,9 @@
|
||||
<!--<Grid.Effects>
|
||||
<ui:ShadowEffect Offect="0, 3" Color="Black" Opacity=".4"/>
|
||||
</Grid.Effects>-->
|
||||
<StackLayout VerticalOptions="Center" Margin="20, 0" Spacing="0">
|
||||
<StackLayout VerticalOptions="Center" Margin="20, 0" Spacing="4">
|
||||
<Label FontSize="Small" Text="{r:Text Balance}"/>
|
||||
<Label FontSize="24" FontFamily="{DynamicResource FontBold}"
|
||||
<Label FontSize="24" FontFamily="{DynamicResource FontSemiBold}"
|
||||
Text="{Binding Balance, Converter={StaticResource moneyConverter}}"/>
|
||||
</StackLayout>
|
||||
<Grid Grid.Column="1" Margin="20, 0" VerticalOptions="Center" HorizontalOptions="End"
|
||||
|
@ -40,7 +40,7 @@
|
||||
Text="{Binding TintColorString, Mode=TwoWay}"/>
|
||||
<ViewCell Height="120">
|
||||
<Grid BackgroundColor="{DynamicResource OptionTintColor}"
|
||||
ColumnDefinitions=".3*, .7*" Padding="10">
|
||||
ColumnDefinitions=".35*, .65*" Padding="10">
|
||||
<ui:ColorPicker Grid.Column="1" ColorChanged="ColorPicker_ColorChanged"/>
|
||||
</Grid>
|
||||
</ViewCell>
|
||||
|
@ -3,6 +3,7 @@
|
||||
xmlns:r="clr-namespace:Billing.Languages"
|
||||
xmlns:ui="clr-namespace:Billing.UI"
|
||||
xmlns:v="clr-namespace:Billing.Views"
|
||||
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Billing.Views.BillPage"
|
||||
x:DataType="v:BillPage"
|
||||
@ -22,23 +23,34 @@
|
||||
</ContentPage.Resources>
|
||||
|
||||
<Shell.TitleView>
|
||||
<Grid ColumnSpacing="16" ColumnDefinitions="20, *">
|
||||
<ui:TintImage Source="calendar.png" WidthRequest="20" HeightRequest="20" VerticalOptions="Center"/>
|
||||
<ui:LongPressGrid Grid.Column="1" HorizontalOptions="{OnPlatform iOS=Center, Android=Start}"
|
||||
<Grid ColumnSpacing="16">
|
||||
<DatePicker x:Name="titleDatePicker" IsVisible="False" Date="{Binding SelectedDate, Mode=TwoWay}"
|
||||
ios:DatePicker.UpdateMode="WhenFinished"
|
||||
DateSelected="TitlePicker_DateSelected"/>
|
||||
<ui:LongPressGrid HorizontalOptions="{OnPlatform iOS=Center, Android=Start}" Padding="30, 0, 0, 0"
|
||||
VerticalOptions="Center" LongCommand="{Binding TitleLongPressed}">
|
||||
<Label Text="{Binding SelectedDate, Converter={StaticResource titleDateConverter}}"
|
||||
TextColor="{DynamicResource PrimaryColor}"
|
||||
FontAttributes="Bold" FontSize="20"/>
|
||||
FontSize="{OnPlatform Android=20, iOS=18}">
|
||||
<Label.FontFamily>
|
||||
<OnPlatform x:TypeArguments="x:String"
|
||||
Android="OpenSans-SemiBold.ttf#OpenSans-SemiBold"
|
||||
iOS="OpenSans-Bold"/>
|
||||
</Label.FontFamily>
|
||||
</Label>
|
||||
</ui:LongPressGrid>
|
||||
<ui:TintImageButton Source="calendar.png" WidthRequest="20" HeightRequest="20"
|
||||
VerticalOptions="Center" HorizontalOptions="Start"
|
||||
Command="{Binding TitleDateTap}"/>
|
||||
</Grid>
|
||||
</Shell.TitleView>
|
||||
|
||||
<ContentPage.ToolbarItems>
|
||||
<ToolbarItem Order="Primary" IconImageSource="plus.png" Command="{Binding EditBilling}"/>
|
||||
<ToolbarItem Order="Primary" Priority="1" IconImageSource="plus.png" Command="{Binding EditBilling}"/>
|
||||
</ContentPage.ToolbarItems>
|
||||
|
||||
<Grid RowDefinitions="Auto, Auto, *">
|
||||
<ui:BillingDate x:Name="billingDate" SelectedDate="{Binding SelectedDate}" DateSelected="OnDateSelected"/>
|
||||
<ui:BillingDate x:Name="billingDate" DateSelected="OnDateSelected"/>
|
||||
<Grid Grid.Row="1" Padding="8" ColumnSpacing="8" ColumnDefinitions="*, Auto"
|
||||
BackgroundColor="{DynamicResource PromptBackgroundColor}"
|
||||
IsVisible="{Binding NoBills}">
|
||||
|
@ -1,4 +1,3 @@
|
||||
using Billing.Languages;
|
||||
using Billing.Models;
|
||||
using Billing.UI;
|
||||
using System;
|
||||
@ -13,12 +12,19 @@ namespace Billing.Views
|
||||
{
|
||||
public partial class BillPage : BillingPage
|
||||
{
|
||||
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));
|
||||
private static readonly DateTime dateNow = DateTime.Today;
|
||||
|
||||
private static readonly BindableProperty SelectedDateProperty = Helper.Create<DateTime, BillPage>(nameof(SelectedDate), defaultValue: dateNow, propertyChanged: OnSelectedDateChanged);
|
||||
private static readonly BindableProperty BillsProperty = Helper.Create<List<UIBill>, BillPage>(nameof(Bills));
|
||||
private static readonly BindableProperty NoBillsProperty = Helper.Create<bool, BillPage>(nameof(NoBills));
|
||||
private static readonly BindableProperty IncomeProperty = Helper.Create<decimal, BillPage>(nameof(Income));
|
||||
private static readonly BindableProperty SpendingProperty = Helper.Create<decimal, BillPage>(nameof(Spending));
|
||||
private static readonly BindableProperty BalanceProperty = Helper.Create<decimal, BillPage>(nameof(Balance));
|
||||
|
||||
private static void OnSelectedDateChanged(BillPage page, DateTime old, DateTime @new)
|
||||
{
|
||||
page.titleDatePicker.Unfocus();
|
||||
}
|
||||
|
||||
public DateTime SelectedDate
|
||||
{
|
||||
@ -35,20 +41,21 @@ namespace Billing.Views
|
||||
public decimal Spending => (decimal)GetValue(SpendingProperty);
|
||||
public decimal Balance => (decimal)GetValue(BalanceProperty);
|
||||
|
||||
public Command TitleDateTap { get; }
|
||||
public Command TitleLongPressed { get; }
|
||||
public Command EditBilling { get; }
|
||||
public Command DeleteBilling { get; }
|
||||
|
||||
public BillPage()
|
||||
{
|
||||
TitleDateTap = new Command(OnTitleDateTapped);
|
||||
TitleLongPressed = new Command(OnTitleDateLongPressed);
|
||||
EditBilling = new Command(OnEditBilling);
|
||||
DeleteBilling = new Command(OnDeleteBilling);
|
||||
|
||||
SelectedDate = DateTime.Now;
|
||||
InitializeComponent();
|
||||
|
||||
billingDate.SetDateTime(DateTime.Now);
|
||||
billingDate.SetDateTime(dateNow);
|
||||
}
|
||||
|
||||
private void OnDateSelected(object sender, DateEventArgs e)
|
||||
@ -57,10 +64,7 @@ namespace Billing.Views
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var bills = App.Bills.Where(b =>
|
||||
b.CreateTime.Year == e.Date.Year &&
|
||||
b.CreateTime.Month == e.Date.Month &&
|
||||
b.CreateTime.Day == e.Date.Day);
|
||||
var bills = App.Bills.Where(b => Helper.IsSameDay(b.CreateTime, e.Date));
|
||||
Bills = new List<UIBill>(bills.OrderBy(b => b.CreateTime).Select(b => WrapBill(b)));
|
||||
RefreshBalance(Bills);
|
||||
MainThread.BeginInvokeOnMainThread(async () => await scrollView.ScrollToAsync(0, 0, true));
|
||||
@ -98,9 +102,19 @@ namespace Billing.Views
|
||||
bill.Wallet = App.Accounts.FirstOrDefault(a => a.Id == bill.Bill.WalletId)?.Name;
|
||||
}
|
||||
|
||||
private void OnTitleDateTapped()
|
||||
{
|
||||
titleDatePicker.Focus();
|
||||
}
|
||||
|
||||
private void TitlePicker_DateSelected(object sender, DateChangedEventArgs e)
|
||||
{
|
||||
billingDate.SetDateTime(e.NewDate);
|
||||
}
|
||||
|
||||
private void OnTitleDateLongPressed()
|
||||
{
|
||||
billingDate.SetDateTime(DateTime.Now);
|
||||
billingDate.SetDateTime(DateTime.Today);
|
||||
}
|
||||
|
||||
private async void OnEditBilling(object o)
|
||||
|
@ -32,7 +32,7 @@
|
||||
CommandParameter="{Binding .}"/>
|
||||
</Grid.GestureRecognizers>
|
||||
<ui:TintImage Source="{Binding Icon, Converter={StaticResource iconConverter}}"
|
||||
PrimaryColor="{Binding TintColor}"
|
||||
ui:TintHelper.TintColor="{Binding TintColor}"
|
||||
WidthRequest="26" HeightRequest="20" VerticalOptions="Center"/>
|
||||
<Label Grid.Column="1" Text="{Binding Name}" TextColor="{DynamicResource TextColor}"
|
||||
HorizontalOptions="FillAndExpand" VerticalOptions="Center"
|
||||
|
@ -36,7 +36,7 @@
|
||||
CommandParameter="{Binding .}"/>
|
||||
</Grid.GestureRecognizers>
|
||||
<ui:TintImage Source="{Binding Icon, Converter={StaticResource iconConverter}}"
|
||||
PrimaryColor="{Binding TintColor}"
|
||||
ui:TintHelper.TintColor="{Binding TintColor}"
|
||||
WidthRequest="26" HeightRequest="20" VerticalOptions="Center"/>
|
||||
<Label Grid.Column="1" Text="{Binding Name}" TextColor="{DynamicResource TextColor}"
|
||||
HorizontalOptions="FillAndExpand" VerticalOptions="Center"
|
||||
@ -58,7 +58,7 @@
|
||||
CommandParameter="{Binding .}"/>
|
||||
</Grid.GestureRecognizers>
|
||||
<ui:TintImage Source="{Binding Icon, Converter={StaticResource iconConverter}}"
|
||||
PrimaryColor="{Binding TintColor}"
|
||||
ui:TintHelper.TintColor="{Binding TintColor}"
|
||||
WidthRequest="26" HeightRequest="20" VerticalOptions="Center"/>
|
||||
<Label Grid.Column="1" Text="{Binding Name}" TextColor="{DynamicResource TextColor}"
|
||||
HorizontalOptions="FillAndExpand" VerticalOptions="Center"
|
||||
|
@ -27,7 +27,7 @@
|
||||
Keyboard="Text"/>
|
||||
<ViewCell Height="120">
|
||||
<Grid BackgroundColor="{DynamicResource OptionTintColor}"
|
||||
ColumnDefinitions=".3*, .7*" Padding="10">
|
||||
ColumnDefinitions=".35*, .65*" Padding="10">
|
||||
<!--<Label Text="" LineBreakMode="TailTruncation"
|
||||
VerticalOptions="Center"
|
||||
TextColor="{DynamicResource TextColor}"/>-->
|
||||
|
Reference in New Issue
Block a user