WIP: more pages + reflection fix for navigation
This commit is contained in:
parent
8d69e7ffab
commit
1c14530139
@ -17,8 +17,8 @@ namespace MobileApp1
|
|||||||
|
|
||||||
//MainPage = new AppShell();
|
//MainPage = new AppShell();
|
||||||
|
|
||||||
//MainPage = new NavigationPage(new LoginPage());
|
MainPage = new NavigationPage(new LoginPage());
|
||||||
MainPage = new MainPage();
|
//MainPage = new MainPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnStart()
|
protected override void OnStart()
|
||||||
|
@ -6,13 +6,43 @@ namespace MobileApp1.Views
|
|||||||
public class ContentPageHelper
|
public class ContentPageHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
public static App GetApp(ContentPage view) => GetParentElement<App>(view);
|
public static App GetApp(ContentPage view) => (App)GetParentElement<App>(view);
|
||||||
|
//{
|
||||||
|
// if (view == null) return null;
|
||||||
|
|
||||||
public static Application GetApplication(ContentPage view) => GetParentElement<Application>(view);
|
// Element item = view.Parent;
|
||||||
|
|
||||||
public static MainPage GetMainPage(ContentPage view) => GetParentElement<MainPage>(view);
|
// while (true)
|
||||||
|
// {
|
||||||
|
// if (item == null) break;
|
||||||
|
// if (item is App) break;
|
||||||
|
|
||||||
public static T GetParentElement<T>(ContentPage view)
|
// item = item.Parent;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return (item as App);
|
||||||
|
//}
|
||||||
|
|
||||||
|
public static Application GetApplication(ContentPage view) => (Application)GetParentElement<Application>(view);
|
||||||
|
//{
|
||||||
|
// if (view == null) return null;
|
||||||
|
|
||||||
|
// Element item = view.Parent;
|
||||||
|
|
||||||
|
// while (true)
|
||||||
|
// {
|
||||||
|
// if (item == null) break;
|
||||||
|
// if (item is Application) break;
|
||||||
|
|
||||||
|
// item = item.Parent;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return (item as Application);
|
||||||
|
// }
|
||||||
|
|
||||||
|
public static MainPage GetMainPage(ContentPage view) => (MainPage)GetParentElement<MainPage>(view);
|
||||||
|
|
||||||
|
public static object GetParentElement<T>(ContentPage view)
|
||||||
{
|
{
|
||||||
if (view == null) return default(T);
|
if (view == null) return default(T);
|
||||||
|
|
||||||
@ -26,14 +56,16 @@ namespace MobileApp1.Views
|
|||||||
item = item.Parent;
|
item = item.Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
return (T)Convert.ChangeType(item, typeof(T));
|
// return (T)Convert.ChangeType(item, typeof(T));
|
||||||
}
|
//}
|
||||||
catch (InvalidCastException)
|
//catch (InvalidCastException)
|
||||||
{
|
//{
|
||||||
return default(T);
|
// return default(T);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetDetailPage(ContentPage view, Type pageType, bool useNavigationPage = true) => SetDetailPage(view, (Page)Activator.CreateInstance(pageType), useNavigationPage);
|
public static void SetDetailPage(ContentPage view, Type pageType, bool useNavigationPage = true) => SetDetailPage(view, (Page)Activator.CreateInstance(pageType), useNavigationPage);
|
||||||
|
@ -6,13 +6,43 @@ namespace MobileApp1.Views
|
|||||||
public class ContentViewHelper
|
public class ContentViewHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
public static App GetApp(ContentView view) => GetParentElement<App>(view);
|
public static App GetApp(ContentView view) => (App)GetParentElement<App>(view);
|
||||||
|
//{
|
||||||
|
// if (view == null) return null;
|
||||||
|
|
||||||
public static Application GetApplication(ContentView view) => GetParentElement<Application>(view);
|
// Element item = view.Parent;
|
||||||
|
|
||||||
public static ContentPage GetContentPage(ContentView view) => GetParentElement<ContentPage>(view);
|
// while (true)
|
||||||
|
// {
|
||||||
|
// if (item == null) break;
|
||||||
|
// if (item is App) break;
|
||||||
|
|
||||||
public static T GetParentElement<T>(ContentView view)
|
// item = item.Parent;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return (item as App);
|
||||||
|
//}
|
||||||
|
|
||||||
|
public static Application GetApplication(ContentView view) => (Application)GetParentElement<Application>(view);
|
||||||
|
//{
|
||||||
|
// if (view == null) return null;
|
||||||
|
|
||||||
|
// Element item = view.Parent;
|
||||||
|
|
||||||
|
// while (true)
|
||||||
|
// {
|
||||||
|
// if (item == null) break;
|
||||||
|
// if (item is Application) break;
|
||||||
|
|
||||||
|
// item = item.Parent;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return (item as Application);
|
||||||
|
//}
|
||||||
|
|
||||||
|
public static ContentPage GetContentPage(ContentView view) => (ContentPage)GetParentElement<ContentPage>(view);
|
||||||
|
|
||||||
|
public static object GetParentElement<T>(ContentView view)
|
||||||
{
|
{
|
||||||
if (view == null) return default(T);
|
if (view == null) return default(T);
|
||||||
|
|
||||||
@ -26,14 +56,16 @@ namespace MobileApp1.Views
|
|||||||
item = item.Parent;
|
item = item.Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
return (T)Convert.ChangeType(item, typeof(T));
|
// return (T)Convert.ChangeType(item, typeof(T));
|
||||||
}
|
//}
|
||||||
catch (InvalidCastException)
|
//catch (InvalidCastException)
|
||||||
{
|
//{
|
||||||
return default(T);
|
// return default(T);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetMainPage(ContentView view, Page page)
|
public static void SetMainPage(ContentView view, Page page)
|
||||||
|
@ -35,14 +35,20 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Update="Views\AboutPage.xaml.cs">
|
||||||
|
<DependentUpon>AboutPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Update="Views\Content\LoadingIndicatorView.xaml.cs">
|
<Compile Update="Views\Content\LoadingIndicatorView.xaml.cs">
|
||||||
<DependentUpon>LoadingIndicatorView.xaml</DependentUpon>
|
<DependentUpon>LoadingIndicatorView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Views\Content\CompanyHeaderView.xaml.cs">
|
<Compile Update="Views\Content\CompanyHeaderView.xaml.cs">
|
||||||
<DependentUpon>CompanyHeaderView.xaml</DependentUpon>
|
<DependentUpon>CompanyHeaderView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Views\BlankPage.xaml.cs">
|
<Compile Update="Views\LogoutPage.xaml.cs">
|
||||||
<DependentUpon>BlankPage.xaml</DependentUpon>
|
<DependentUpon>LogoutPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="Views\MyStuffPage.xaml.cs">
|
||||||
|
<DependentUpon>MyStuffPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Views\PasswordResetPage.xaml.cs">
|
<Compile Update="Views\PasswordResetPage.xaml.cs">
|
||||||
<DependentUpon>PasswordResetPage.xaml</DependentUpon>
|
<DependentUpon>PasswordResetPage.xaml</DependentUpon>
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
public ServiceResult Logout()
|
public ServiceResult Logout()
|
||||||
{
|
{
|
||||||
System.Threading.Thread.Sleep(6000);
|
System.Threading.Thread.Sleep(2000);
|
||||||
|
|
||||||
this.DisplayName = string.Empty;
|
this.DisplayName = string.Empty;
|
||||||
this.IsLoggedIn = false;
|
this.IsLoggedIn = false;
|
||||||
@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
public ServiceResult RequestPasswordReset(string username)
|
public ServiceResult RequestPasswordReset(string username)
|
||||||
{
|
{
|
||||||
System.Threading.Thread.Sleep(6000);
|
System.Threading.Thread.Sleep(2000);
|
||||||
|
|
||||||
this.DisplayName = string.Empty;
|
this.DisplayName = string.Empty;
|
||||||
this.IsLoggedIn = false;
|
this.IsLoggedIn = false;
|
||||||
|
@ -24,7 +24,7 @@ namespace MobileApp1.Views
|
|||||||
{
|
{
|
||||||
isBusy = value;
|
isBusy = value;
|
||||||
|
|
||||||
LoginPage cp = ContentViewHelper.GetParentElement<LoginPage>(this);
|
LoginPage cp = (LoginPage)ContentViewHelper.GetParentElement<LoginPage>(this);
|
||||||
if (cp != null)
|
if (cp != null)
|
||||||
{
|
{
|
||||||
cp.IsBusy = value;
|
cp.IsBusy = value;
|
||||||
@ -69,16 +69,15 @@ namespace MobileApp1.Views
|
|||||||
|
|
||||||
this.IsBusy = false;
|
this.IsBusy = false;
|
||||||
|
|
||||||
//ContentViewHelper.SetMainPage(this, new AppShell());
|
|
||||||
|
|
||||||
//await cp.DisplayAlert("Clicked", "Login", "OK");
|
//await cp.DisplayAlert("Clicked", "Login", "OK");
|
||||||
|
|
||||||
|
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
/// part 2
|
/// part 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContentViewHelper.SetMainPage(this, new MainPage());
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace MobileApp1.Views
|
|||||||
{
|
{
|
||||||
isBusy = value;
|
isBusy = value;
|
||||||
|
|
||||||
LoginPage cp = ContentViewHelper.GetParentElement<LoginPage>(this);
|
LoginPage cp = (LoginPage)ContentViewHelper.GetParentElement<LoginPage>(this);
|
||||||
if (cp != null)
|
if (cp != null)
|
||||||
{
|
{
|
||||||
cp.IsBusy = value;
|
cp.IsBusy = value;
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
<ListView.ItemsSource>
|
<ListView.ItemsSource>
|
||||||
<x:Array Type="{x:Type models:FlyoutPageItem}">
|
<x:Array Type="{x:Type models:FlyoutPageItem}">
|
||||||
<models:FlyoutPageItem Title="Home" Icon="home.png" TargetType="{x:Type views:HomePage}" />
|
<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="Settings" Icon="settings.png" TargetType="{x:Type views:SettingsPage}" />
|
||||||
<models:FlyoutPageItem Title="About" Icon="help.png" TargetType="{x:Type views:AboutPage}" />
|
<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>
|
</x:Array>
|
||||||
</ListView.ItemsSource>
|
</ListView.ItemsSource>
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
|
@ -17,7 +17,7 @@ namespace MobileApp1.Views
|
|||||||
{
|
{
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
ContentPageHelper.SetDetailPage(this, typeof(BlankPage));
|
ContentPageHelper.SetDetailPage(this, typeof(MyStuffPage));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
MobileApp1/Views/LogoutPage.xaml
Normal file
21
MobileApp1/Views/LogoutPage.xaml
Normal 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
MobileApp1/Views/LogoutPage.xaml.cs
Normal file
25
MobileApp1/Views/LogoutPage.xaml.cs
Normal 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" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
<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"
|
||||||
x:Class="MobileApp1.Views.BlankPage"
|
x:Class="MobileApp1.Views.MyStuffPage"
|
||||||
xmlns:views="clr-namespace:MobileApp1.Views"
|
xmlns:views="clr-namespace:MobileApp1.Views"
|
||||||
Title="Blank">
|
Title="My Stuff">
|
||||||
<ContentPage.Content>
|
<ContentPage.Content>
|
||||||
<StackLayout Margin="20">
|
<StackLayout Margin="20">
|
||||||
<views:CompanyHeaderView />
|
<views:CompanyHeaderView />
|
@ -3,9 +3,9 @@ using Xamarin.Forms;
|
|||||||
|
|
||||||
namespace MobileApp1.Views
|
namespace MobileApp1.Views
|
||||||
{
|
{
|
||||||
public partial class BlankPage : ContentPage
|
public partial class MyStuffPage : ContentPage
|
||||||
{
|
{
|
||||||
public BlankPage()
|
public MyStuffPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage
|
<ContentPage
|
||||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
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"
|
x:Class="MobileApp1.Views.SettingsPage"
|
||||||
Title="Settings">
|
Title="Settings">
|
||||||
<ContentPage.Content>
|
<ContentPage.Content>
|
||||||
@ -14,19 +14,31 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Label Grid.Row="0" Grid.Column="0" Text="CheckBox Setting" VerticalTextAlignment="Center" />
|
<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" />
|
<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" />
|
<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" />
|
<Label Grid.Row="3" Grid.Column="0" Text="Time Setting" VerticalTextAlignment="Center" />
|
||||||
<Entry Grid.Row="3" Grid.Column="1" HorizontalOptions="EndAndExpand" />
|
<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" />
|
<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" />
|
<!--<Label Grid.Row="5" Grid.Column="0" Text="TextBox Setting" VerticalTextAlignment="Center" />
|
||||||
<RadioButton Grid.Row="5" Grid.Column="1" HorizontalOptions="EndAndExpand" />-->
|
<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" />
|
<!--<Label Grid.Row="5" Grid.Column="0" Text="TextBox Setting" VerticalTextAlignment="Center" />
|
||||||
<Stepper Grid.Row="5" Grid.Column="1" HorizontalOptions="EndAndExpand" MinimumWidthRequest="100" />-->
|
<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>
|
</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>
|
</StackLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Xamarin.Forms.Xaml;
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
@ -12,9 +8,80 @@ namespace MobileApp1.Views
|
|||||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
public partial class SettingsPage : ContentPage
|
public partial class SettingsPage : ContentPage
|
||||||
{
|
{
|
||||||
|
protected bool isBusy = false;
|
||||||
|
|
||||||
public SettingsPage()
|
public SettingsPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
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)
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user