WIP: more pages + reflection fix for navigation

This commit is contained in:
Ray committed 2021-08-05 00:50:48 +01:00
1 parent 8d69e7ffab
commit 1c14530139
15 files changed
+249 -57

No files matched your search

@@ -24,7 +24,7 @@ namespace MobileApp1.Views
{
isBusy = value;
LoginPage cp = ContentViewHelper.GetParentElement<LoginPage>(this);
LoginPage cp = (LoginPage)ContentViewHelper.GetParentElement<LoginPage>(this);
if (cp != null)
{
cp.IsBusy = value;
@@ -69,16 +69,15 @@ namespace MobileApp1.Views
this.IsBusy = false;
//ContentViewHelper.SetMainPage(this, new AppShell());
//await cp.DisplayAlert("Clicked", "Login", "OK");
if (result.IsSuccess)
{
/// part 2
}
ContentViewHelper.SetMainPage(this, new MainPage());
});
}
@@ -24,7 +24,7 @@ namespace MobileApp1.Views
{
isBusy = value;
LoginPage cp = ContentViewHelper.GetParentElement<LoginPage>(this);
LoginPage cp = (LoginPage)ContentViewHelper.GetParentElement<LoginPage>(this);
if (cp != null)
{
cp.IsBusy = value;
+2 -2
View File
@@ -26,10 +26,10 @@
<ListView.ItemsSource>
<x:Array Type="{x:Type models:FlyoutPageItem}">
<models:FlyoutPageItem Title="Home" Icon="home.png" TargetType="{x:Type views:HomePage}" />
<models:FlyoutPageItem Title="My Stuff" Icon="layers.png" TargetType="{x:Type views:BlankPage}" />
<models:FlyoutPageItem Title="My Stuff" Icon="layers.png" TargetType="{x:Type views:MyStuffPage}" />
<models:FlyoutPageItem Title="Settings" Icon="settings.png" TargetType="{x:Type views:SettingsPage}" />
<models:FlyoutPageItem Title="About" Icon="help.png" TargetType="{x:Type views:AboutPage}" />
<models:FlyoutPageItem Title="Logout" Icon="logout.png" TargetType="{x:Type views:BlankPage}" />
<models:FlyoutPageItem Title="Logout" Icon="logout.png" TargetType="{x:Type views:LogoutPage}" />
</x:Array>
</ListView.ItemsSource>
<ListView.ItemTemplate>
+1 -1
View File
@@ -17,7 +17,7 @@ namespace MobileApp1.Views
{
await Task.Run(() =>
{
ContentPageHelper.SetDetailPage(this, typeof(BlankPage));
ContentPageHelper.SetDetailPage(this, typeof(MyStuffPage));
});
}
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:views="clr-namespace:MobileApp1.Views"
x:Class="MobileApp1.Views.LogoutPage"
Title="Logout">
<ContentPage.Content>
<ScrollView>
<StackLayout Margin="20">
<views:CompanyHeaderView />
<Label Text="Logout" FontSize="Body" />
<Label Text="Logout of your account." />
<Label Text="" Margin="0, 0, 0, 10" />
<Button x:Name="button1" Margin="0, 20, 0, 0" Text="Logout" Clicked="button1_Clicked" ></Button>
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>
+25
View File
@@ -0,0 +1,25 @@
using System;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace MobileApp1.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class LogoutPage : ContentPage
{
public LogoutPage()
{
InitializeComponent();
}
private async void button1_Clicked(object sender, EventArgs e)
{
await Task.Run(() =>
{
ContentPageHelper.SetMainPage(this, new LoginPage());
});
}
}
}
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MobileApp1.Views.BlankPage"
x:Class="MobileApp1.Views.MyStuffPage"
xmlns:views="clr-namespace:MobileApp1.Views"
Title="Blank">
Title="My Stuff">
<ContentPage.Content>
<StackLayout Margin="20">
<views:CompanyHeaderView />
@@ -3,9 +3,9 @@ using Xamarin.Forms;
namespace MobileApp1.Views
{
public partial class BlankPage : ContentPage
public partial class MyStuffPage : ContentPage
{
public BlankPage()
public MyStuffPage()
{
InitializeComponent();
+21 -11
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:views="clr-namespace:MobileApp1.Views"
x:Class="MobileApp1.Views.SettingsPage"
Title="Settings">
<ContentPage.Content>
@@ -14,19 +14,31 @@
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Text="CheckBox Setting" VerticalTextAlignment="Center" />
<CheckBox Grid.Row="0" Grid.Column="1" HorizontalOptions="EndAndExpand" />
<CheckBox Grid.Row="0" Grid.Column="1" x:Name="checkBox1" HorizontalOptions="EndAndExpand" />
<Label Grid.Row="1" Grid.Column="0" Text="Switch Setting" VerticalTextAlignment="Center" />
<Switch Grid.Row="1" Grid.Column="1" HorizontalOptions="EndAndExpand" />
<Switch Grid.Row="1" Grid.Column="1" x:Name="switchBox1" HorizontalOptions="EndAndExpand" />
<Label Grid.Row="2" Grid.Column="0" Text="Date Setting" VerticalTextAlignment="Center" />
<DatePicker Grid.Row="2" Grid.Column="1" HorizontalOptions="EndAndExpand" Format="dd/MM/yyyy" />
<DatePicker Grid.Row="2" Grid.Column="1" x:Name="datePicker1" HorizontalOptions="EndAndExpand" Format="dd/MM/yyyy" />
<Label Grid.Row="3" Grid.Column="0" Text="TextBox Setting" VerticalTextAlignment="Center" />
<Entry Grid.Row="3" Grid.Column="1" HorizontalOptions="EndAndExpand" />
<Label Grid.Row="3" Grid.Column="0" Text="Time Setting" VerticalTextAlignment="Center" />
<TimePicker Grid.Row="3" Grid.Column="1" x:Name="timePicker1" HorizontalOptions="EndAndExpand" Format="HH:mm" />
<!--<Label Grid.Row="3" Grid.Column="0" Text="TextBox Setting" VerticalTextAlignment="Center" />
<Entry Grid.Row="3" Grid.Column="1" HorizontalOptions="EndAndExpand" />-->
<Label Grid.Row="4" Grid.Column="0" Text="Picker Setting" VerticalTextAlignment="Center" />
<Picker Grid.Row="4" Grid.Column="1" HorizontalOptions="EndAndExpand" MinimumWidthRequest="100" />
<Picker Grid.Row="5" Grid.Column="1" x:Name="pickerBox1" HorizontalOptions="FillAndExpand">
<Picker.Items>
<x:String></x:String>
<x:String>One</x:String>
<x:String>Two</x:String>
<x:String>Three</x:String>
<x:String>Four</x:String>
<x:String>Five</x:String>
</Picker.Items>
</Picker>
<!--<Label Grid.Row="5" Grid.Column="0" Text="TextBox Setting" VerticalTextAlignment="Center" />
<RadioButton Grid.Row="5" Grid.Column="1" HorizontalOptions="EndAndExpand" />-->
@@ -37,13 +49,11 @@
<!--<Label Grid.Row="5" Grid.Column="0" Text="TextBox Setting" VerticalTextAlignment="Center" />
<Stepper Grid.Row="5" Grid.Column="1" HorizontalOptions="EndAndExpand" MinimumWidthRequest="100" />-->
<Label Grid.Row="5" Grid.Column="0" Text="Time Setting" VerticalTextAlignment="Center" />
<TimePicker Grid.Row="5" Grid.Column="1" HorizontalOptions="EndAndExpand" Format="HH:mm" />
</Grid>
<Button x:Name="button1" Margin="0, 20, 0, 0" Text="Save" Clicked="button1_Clicked"></Button>
<Button x:Name="button1" Margin="0, 20, 0, 0" Text="Save"></Button>
<views:LoadingIndicatorView x:Name="loadingIndicatorView1" Margin="0, 20, 0, 0" />
</StackLayout>
</ScrollView>
+71 -4
View File
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
@@ -12,9 +8,80 @@ namespace MobileApp1.Views
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SettingsPage : ContentPage
{
protected bool isBusy = false;
public SettingsPage()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
if (pickerBox1.Items.Count > 0) pickerBox1.SelectedIndex = 0;
}
private bool IsBusy
{
get => isBusy;
set
{
isBusy = value;
Device.BeginInvokeOnMainThread(() =>
{
loadingIndicatorView1.IsRunning = value;
checkBox1.IsEnabled = switchBox1.IsEnabled = datePicker1.IsEnabled = pickerBox1.IsEnabled = timePicker1.IsEnabled = !value;
button1.IsEnabled = !value;
});
}
}
private async void button1_Clicked(object sender, EventArgs e)
{
await Task.Run(() =>
{
//if (this.Parent == null)
//{
// return;
//}
//ContentPage cp = ContentViewHelper.GetContentPage(this);
//if (cp == null)
//{
// return;
//}
//App ap = ContentViewHelper.GetApp(this);
//if (ap == null)
//{
// return;
//}
this.IsBusy = true;
//ServiceResult result = ap.CorporationService.Login(textbox1.Text, textbox2.Text);
loadingIndicatorView1.Message = "Saved";
Device.BeginInvokeOnMainThread(() =>
{
DisplayAlert("Settings", "Saved", "OK");
});
this.IsBusy = false;
//ContentViewHelper.SetMainPage(this, new AppShell());
//if (result.IsSuccess)
//{
//}
});
}
}
}