WIP: page setup minus my-stuff
This commit is contained in:
parent
d302425b88
commit
8d69e7ffab
@ -1,45 +1,69 @@
|
||||
using Xamarin.Forms;
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace MobileApp1.Views
|
||||
{
|
||||
public class ContentPageHelper
|
||||
{
|
||||
|
||||
public static App GetApp(ContentPage view)
|
||||
public static App GetApp(ContentPage view) => GetParentElement<App>(view);
|
||||
|
||||
public static Application GetApplication(ContentPage view) => GetParentElement<Application>(view);
|
||||
|
||||
public static MainPage GetMainPage(ContentPage view) => GetParentElement<MainPage>(view);
|
||||
|
||||
public static T GetParentElement<T>(ContentPage view)
|
||||
{
|
||||
if (view == null) return null;
|
||||
if (view == null) return default(T);
|
||||
|
||||
Element item = view.Parent;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (item == null) break;
|
||||
if (item is App) break;
|
||||
if (item is T) break;
|
||||
|
||||
item = item.Parent;
|
||||
}
|
||||
|
||||
return (item as App);
|
||||
}
|
||||
|
||||
public static Application GetApplication(ContentPage view)
|
||||
try
|
||||
{
|
||||
if (view == null) return null;
|
||||
|
||||
Element item = view.Parent;
|
||||
|
||||
while (true)
|
||||
return (T)Convert.ChangeType(item, typeof(T));
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
if (item == null) break;
|
||||
if (item is Application) break;
|
||||
|
||||
item = item.Parent;
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
return (item as Application);
|
||||
public static void SetDetailPage(ContentPage view, Type pageType, bool useNavigationPage = true) => SetDetailPage(view, (Page)Activator.CreateInstance(pageType), useNavigationPage);
|
||||
|
||||
public static void SetDetailPage(ContentPage view, Page page, bool useNavigationPage = true)
|
||||
{
|
||||
if (view == null) return;
|
||||
if (view.Parent == null) return;
|
||||
if (page == null) return;
|
||||
|
||||
MainPage rs = GetMainPage(view);
|
||||
if (rs == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public static void SetMainPage(ContentPage view, Page page)
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
if (useNavigationPage)
|
||||
{
|
||||
rs.Detail = new NavigationPage(page);
|
||||
}
|
||||
else
|
||||
{
|
||||
rs.Detail = page;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void SetMainPage(ContentPage view, Page page, bool useNavigationPage = false)
|
||||
{
|
||||
if (view == null) return;
|
||||
if (view.Parent == null) return;
|
||||
@ -51,9 +75,18 @@ namespace MobileApp1.Views
|
||||
return;
|
||||
}
|
||||
|
||||
//rs.MainPage = new NavigationPage(new PasswordResetPage());
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
if (useNavigationPage)
|
||||
{
|
||||
rs.MainPage = new NavigationPage(page);
|
||||
}
|
||||
else
|
||||
{
|
||||
rs.MainPage = page;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static async void PushMainPageNavigation(ContentPage view, Page page)
|
||||
{
|
||||
|
@ -6,24 +6,13 @@ namespace MobileApp1.Views
|
||||
public class ContentViewHelper
|
||||
{
|
||||
|
||||
public static ContentPage GetContentPage(ContentView view)
|
||||
{
|
||||
if (view == null) return null;
|
||||
public static App GetApp(ContentView view) => GetParentElement<App>(view);
|
||||
|
||||
Element item = view.Parent;
|
||||
public static Application GetApplication(ContentView view) => GetParentElement<Application>(view);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (item == null) break;
|
||||
if (item is ContentPage) break;
|
||||
public static ContentPage GetContentPage(ContentView view) => GetParentElement<ContentPage>(view);
|
||||
|
||||
item = item.Parent;
|
||||
}
|
||||
|
||||
return (item as ContentPage);
|
||||
}
|
||||
|
||||
public static T GetContentPage<T>(ContentView view)
|
||||
public static T GetParentElement<T>(ContentView view)
|
||||
{
|
||||
if (view == null) return default(T);
|
||||
|
||||
@ -47,40 +36,6 @@ namespace MobileApp1.Views
|
||||
}
|
||||
}
|
||||
|
||||
public static App GetApp(ContentView view)
|
||||
{
|
||||
if (view == null) return null;
|
||||
|
||||
Element item = view.Parent;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (item == null) break;
|
||||
if (item is App) break;
|
||||
|
||||
item = item.Parent;
|
||||
}
|
||||
|
||||
return (item as App);
|
||||
}
|
||||
|
||||
public static Application GetApplication(ContentView 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 void SetMainPage(ContentView view, Page page)
|
||||
{
|
||||
if (view == null) return;
|
||||
|
@ -59,9 +59,15 @@
|
||||
<Compile Update="Views\Content\Login\LoginView.xaml.cs">
|
||||
<DependentUpon>LoginView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Views\HomePage.xaml.cs">
|
||||
<DependentUpon>HomePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Views\AboutPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="Views\FlyoutMenuPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
@ -74,5 +80,11 @@
|
||||
<EmbeddedResource Update="Views\MainPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="Views\HomePage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="Views\SettingsPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Project>
|
12
MobileApp1/Views/AboutPage.xaml
Normal file
12
MobileApp1/Views/AboutPage.xaml
Normal file
@ -0,0 +1,12 @@
|
||||
<?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.AboutPage"
|
||||
Title="About">
|
||||
<ContentPage.Content>
|
||||
<StackLayout Margin="20">
|
||||
<views:AboutView />
|
||||
</StackLayout>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
20
MobileApp1/Views/AboutPage.xaml.cs
Normal file
20
MobileApp1/Views/AboutPage.xaml.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace MobileApp1.Views
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class AboutPage : ContentPage
|
||||
{
|
||||
public AboutPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ namespace MobileApp1.Views
|
||||
{
|
||||
isBusy = value;
|
||||
|
||||
LoginPage cp = ContentViewHelper.GetContentPage<LoginPage>(this);
|
||||
LoginPage cp = ContentViewHelper.GetParentElement<LoginPage>(this);
|
||||
if (cp != null)
|
||||
{
|
||||
cp.IsBusy = value;
|
||||
|
@ -24,7 +24,7 @@ namespace MobileApp1.Views
|
||||
{
|
||||
isBusy = value;
|
||||
|
||||
LoginPage cp = ContentViewHelper.GetContentPage<LoginPage>(this);
|
||||
LoginPage cp = ContentViewHelper.GetParentElement<LoginPage>(this);
|
||||
if (cp != null)
|
||||
{
|
||||
cp.IsBusy = value;
|
||||
|
@ -10,30 +10,56 @@
|
||||
<StackLayout>
|
||||
<Image Source="company_logo.png" WidthRequest="{OnPlatform iOS=180, Android=180}" HorizontalOptions="Center" Margin="0, 0, 0, 20" />
|
||||
|
||||
<ListView x:Name="listView" x:FieldModifier="Public">
|
||||
<ListView x:Name="listView1">
|
||||
<!--<ListView.Footer>
|
||||
<StackLayout VerticalOptions="Start">
|
||||
<Grid Padding="5, 10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Grid.Row="0" Grid.Column="0" Source="logout.png" Margin="3" />
|
||||
<Label Grid.Row="0" Grid.Column="1" Text="Logout" />
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
</ListView.Footer>-->
|
||||
<ListView.ItemsSource>
|
||||
<x:Array Type="{x:Type models:FlyoutPageItem}">
|
||||
<models:FlyoutPageItem Title="Home" Icon="home.png" TargetType="{x:Type views:BlankPage}" />
|
||||
<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="Settings" Icon="settings.png" TargetType="{x:Type views:BlankPage}" />
|
||||
<models:FlyoutPageItem Title="About" Icon="help.png" TargetType="{x:Type views:BlankPage}" />
|
||||
<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}" />
|
||||
</x:Array>
|
||||
</ListView.ItemsSource>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<Grid Padding="5, 10">
|
||||
<Grid Padding="5, 10, 5, 10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Source="{Binding Icon}" />
|
||||
<Image Grid.Column="0" Source="{Binding Icon}" />
|
||||
<Label Grid.Column="1" Text="{Binding Title}" />
|
||||
</Grid>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
|
||||
<!--<ListView x:Name="listView" x:FieldModifier="Public" VerticalOptions="Start">
|
||||
<StackLayout>
|
||||
<Grid Padding="5, 10" VerticalOptions="Start">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Grid.Column="0" Source="logout.png" />
|
||||
<Label Grid.Column="1" Text="Logout" />
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
</ListView>-->
|
||||
|
||||
</StackLayout>
|
||||
</ContentPage>
|
||||
|
@ -1,4 +1,6 @@
|
||||
using Xamarin.Forms;
|
||||
using MobileApp1.Models;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace MobileApp1.Views
|
||||
@ -9,6 +11,37 @@ namespace MobileApp1.Views
|
||||
public FlyoutMenuPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
listView1.ItemSelected += listView1_ItemSelected;
|
||||
}
|
||||
|
||||
private async void listView1_ItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var item = e.SelectedItem as FlyoutPageItem;
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MainPage mainPage = ContentPageHelper.GetMainPage(this);
|
||||
if (mainPage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ContentPageHelper.SetDetailPage(this, item.TargetType);
|
||||
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
listView1.SelectedItem = null;
|
||||
|
||||
mainPage.IsPresented = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
29
MobileApp1/Views/HomePage.xaml
Normal file
29
MobileApp1/Views/HomePage.xaml
Normal file
@ -0,0 +1,29 @@
|
||||
<?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.HomePage"
|
||||
Title="Home">
|
||||
<ContentPage.Content>
|
||||
<ScrollView>
|
||||
<StackLayout Margin="20">
|
||||
<views:CompanyHeaderView />
|
||||
|
||||
<Label Text="Welcome to XYZ" FontSize="Body" />
|
||||
<Label x:Name="label1" Text="Hi, John." />
|
||||
<Label Text="" Margin="0, 0, 0, 10" />
|
||||
|
||||
<Label Text="Notices" FontSize="Body" />
|
||||
<Label x:Name="label2" Text="You have no notices" />
|
||||
<Label Text="" Margin="0, 0, 0, 10" />
|
||||
|
||||
<Label Text="Messages" FontSize="Body" />
|
||||
<Label x:Name="label3" Text="You have no messages" />
|
||||
<Label Text="" Margin="0, 0, 0, 10" />
|
||||
|
||||
<Button x:Name="button1" Margin="0, 20, 0, 0" Text="Let's Get Started" Clicked="button1_Clicked" ></Button>
|
||||
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
25
MobileApp1/Views/HomePage.xaml.cs
Normal file
25
MobileApp1/Views/HomePage.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 HomePage : ContentPage
|
||||
{
|
||||
public HomePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void button1_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
ContentPageHelper.SetDetailPage(this, typeof(BlankPage));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
<FlyoutPage.Detail>
|
||||
<NavigationPage>
|
||||
<x:Arguments>
|
||||
<views:BlankPage />
|
||||
<views:HomePage />
|
||||
</x:Arguments>
|
||||
</NavigationPage>
|
||||
</FlyoutPage.Detail>
|
||||
|
@ -1,6 +1,4 @@
|
||||
using MobileApp1.Models;
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace MobileApp1.Views
|
||||
@ -11,36 +9,6 @@ namespace MobileApp1.Views
|
||||
public MainPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
flyoutPage.listView.ItemSelected += listView1_OnItemSelected;
|
||||
}
|
||||
|
||||
//private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
//{
|
||||
// var item = e.SelectedItem as MainPageFlyoutMenuItem;
|
||||
// if (item == null)
|
||||
// return;
|
||||
|
||||
// var page = (Page)Activator.CreateInstance(item.TargetType);
|
||||
// page.Title = item.Title;
|
||||
|
||||
// Detail = new NavigationPage(page);
|
||||
// IsPresented = false;
|
||||
|
||||
// FlyoutPage.ListView.SelectedItem = null;
|
||||
//}
|
||||
|
||||
private void listView1_OnItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
{
|
||||
var item = e.SelectedItem as FlyoutPageItem;
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType));
|
||||
flyoutPage.listView.SelectedItem = null;
|
||||
IsPresented = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
51
MobileApp1/Views/SettingsPage.xaml
Normal file
51
MobileApp1/Views/SettingsPage.xaml
Normal file
@ -0,0 +1,51 @@
|
||||
<?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.SettingsPage"
|
||||
Title="Settings">
|
||||
<ContentPage.Content>
|
||||
<ScrollView>
|
||||
<StackLayout Margin="20">
|
||||
<Grid Padding="0, 0, 0, 10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Grid.Row="0" Grid.Column="0" Text="CheckBox Setting" VerticalTextAlignment="Center" />
|
||||
<CheckBox Grid.Row="0" Grid.Column="1" HorizontalOptions="EndAndExpand" />
|
||||
|
||||
<Label Grid.Row="1" Grid.Column="0" Text="Switch Setting" VerticalTextAlignment="Center" />
|
||||
<Switch Grid.Row="1" Grid.Column="1" 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" />
|
||||
|
||||
<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" />
|
||||
|
||||
<!--<Label Grid.Row="5" Grid.Column="0" Text="TextBox Setting" VerticalTextAlignment="Center" />
|
||||
<RadioButton Grid.Row="5" Grid.Column="1" HorizontalOptions="EndAndExpand" />-->
|
||||
|
||||
<!--<Label Grid.Row="6" Grid.Column="0" Text="TextBox Setting" VerticalTextAlignment="Center" />
|
||||
<Slider Grid.Row="6" Grid.Column="1" HorizontalOptions="FillAndExpand" Minimum="0" Maximum="100" />-->
|
||||
|
||||
<!--<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"></Button>
|
||||
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
20
MobileApp1/Views/SettingsPage.xaml.cs
Normal file
20
MobileApp1/Views/SettingsPage.xaml.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace MobileApp1.Views
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class SettingsPage : ContentPage
|
||||
{
|
||||
public SettingsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user