fix bug on balancePage

pull/69/head
Titouan LOUVET 2 years ago
parent 4118ac9d6a
commit df186a2c68

@ -18,7 +18,6 @@
Title="Solde"
ContentTemplate="{DataTemplate balance:BalancePage}"
Route="balance"
BindingContextChanged="ShellContent_BindingContextChanged"
Icon="{StaticResource HomeIcon}"/>
<ShellContent

@ -27,8 +27,4 @@ public partial class AppShell : Shell
Routing.RegisterRoute("consultant/createcustomer", typeof(CreateCustomerPage));
}
void ShellContent_BindingContextChanged(System.Object sender, System.EventArgs e)
{
BindingContext = Mgr.SelectedAccount;
}
}

@ -56,6 +56,7 @@ namespace Banquale.Stub
Customer1.AccountsList.Add(Account1);
Customer1.AccountsList.Add(Account2);
Customer2.AccountsList.Add(Account3);
CustomersList.Add(Customer1);

@ -3,7 +3,14 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Banquale.Views.Balance.BalancePage"
xmlns:local="clr-namespace:Banquale.Views.Balance"
Shell.NavBarIsVisible="False">
xmlns:conv="clr-namespace:Banquale.Views.Converters"
Shell.NavBarIsVisible="False"
Shell.TabBarIsVisible="True">
<ContentPage.Resources>
<conv:Bool2ColorConverters x:Key="bool2ColorConverters"/>
<conv:Int2StringConverters x:Key="int2StringConverters"/>
</ContentPage.Resources>
<Grid RowDefinitions="auto, auto, *" x:Name="Grid">
@ -63,8 +70,58 @@
Grid.Row="1"
HeightRequest="1"/>
<local:BalanceView
Grid.Row="2"/>
<!--<local:BalanceView
Grid.Row="2"
x:Name="balanceViewContainer"/>-->
<VerticalStackLayout Grid.Row="2">
<ListView ItemsSource="{Binding TransactionsList}"
SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid
ColumnDefinitions="40, 3*, *"
Margin="20, 5, 20, 5"
HorizontalOptions="Fill">
<Grid.GestureRecognizers>
<TapGestureRecognizer
Tapped="Transaction_Clicked"
NumberOfTapsRequired="1" />
</Grid.GestureRecognizers>
<Label
Text="{Binding Date, StringFormat='{0:ddd dd MMM yyyy}'}"
Grid.Column="1"
VerticalOptions="Center"
Margin="10, 0, 0, 0"/>
<Label
Text="{Binding Sum, StringFormat='{0} €'}"
Grid.Column="2"
TextColor="{Binding Type, Converter={StaticResource bool2ColorConverters}}"
VerticalOptions="Center"
HorizontalOptions="End"
Margin="0, 0, 20, 0"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</VerticalStackLayout>
</Grid>
</ContentPage>

@ -8,15 +8,29 @@ public partial class BalancePage : ContentPage
{
public Manager Mgr => (App.Current as App).MyManager;
//private BalanceView MybalanceView;
public BalancePage()
{
InitializeComponent();
BindingContext = Mgr.SelectedAccount;
//MybalanceView = balanceViewContainer.FindByName<BalanceView>("balanceViewContainer");
}
public void RefreshPage()
{
BindingContext = Mgr.SelectedAccount;
//MybalanceView.RefreshView();
}
public async void Transaction_Clicked(Object sender, EventArgs e)
{
var selectedItem = (sender as Grid)?.BindingContext as Transaction;
if (selectedItem != null)
{
Mgr.SelectedTransaction = selectedItem;
await Navigation.PushModalAsync(new TransactionsPage());
}
}
}

@ -24,4 +24,11 @@ public partial class BalanceView : ContentView
await Navigation.PushModalAsync(new TransactionsPage());
}
}
public void RefreshView()
{
BindingContext = Mgr.SelectedAccount;
}
}

@ -4,7 +4,8 @@
xmlns:local="clr-namespace:Banquale.Views"
x:Class="Banquale.Views.SwitchAccountPage"
Title="SwitchAccountPage"
Shell.NavBarIsVisible="False">
Shell.NavBarIsVisible="False"
Shell.TabBarIsVisible="False">
<VerticalStackLayout

@ -27,8 +27,9 @@ public partial class SwitchAccountPage : ContentPage
}
else
{
//BalancePage.re
await Shell.Current.GoToAsync("//balance");
var balancePage = Shell.Current.CurrentPage as BalancePage;
balancePage?.RefreshPage();
}
}

Loading…
Cancel
Save