summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls
diff options
context:
space:
mode:
authorPaul DiPietro <pauldipietro@users.noreply.github.com>2016-10-20 15:01:50 -0500
committerGitHub <noreply@github.com>2016-10-20 15:01:50 -0500
commit4042f39f0007dd80f6ca3f8273e4cc155cf8123c (patch)
tree4d9a282508d809645d1c00b05f3d2376c61c1330 /Xamarin.Forms.Controls
parentd24f3e5438c300242d553e81817b57045f00bf4f (diff)
downloadxamarin-forms-4042f39f0007dd80f6ca3f8273e4cc155cf8123c.tar.gz
xamarin-forms-4042f39f0007dd80f6ca3f8273e4cc155cf8123c.tar.bz2
xamarin-forms-4042f39f0007dd80f6ca3f8273e4cc155cf8123c.zip
[Android] Add Platform Specific features for setting TabbedPage swipe paging and OffscreenPageLimit (#409)
* [Android] Add Platform Specific feature for setting TabbedPage swipe paging * [Android] Add Platform Specific feature for OffscreenPageLimit * Update docs
Diffstat (limited to 'Xamarin.Forms.Controls')
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGalleries/TabbedPageAndroid.cs72
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGallery.cs5
-rw-r--r--Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj1
3 files changed, 77 insertions, 1 deletions
diff --git a/Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGalleries/TabbedPageAndroid.cs b/Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGalleries/TabbedPageAndroid.cs
new file mode 100644
index 00000000..ab1904a4
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGalleries/TabbedPageAndroid.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+using Xamarin.Forms.PlatformConfiguration;
+using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
+
+namespace Xamarin.Forms.Controls.GalleryPages.PlatformSpecificsGalleries
+{
+ public class TabbedPageAndroid : TabbedPage
+ {
+ public TabbedPageAndroid(ICommand restore)
+ {
+ Children.Add(CreateFirstPage(restore));
+ Children.Add(CreateAdditonalPage());
+ Children.Add(CreateAdditonalPage());
+ Children.Add(CreateAdditonalPage());
+ Children.Add(CreateAdditonalPage());
+ On<Android>().SetOffscreenPageLimitProperty(2);
+ }
+
+ ContentPage CreateFirstPage(ICommand restore)
+ {
+ var page = new ContentPage { Title = "Content Page Title" };
+ var offscreenPageLimit = new Label();
+ var content = new StackLayout
+ {
+ VerticalOptions = LayoutOptions.Fill,
+ HorizontalOptions = LayoutOptions.Fill,
+ Children =
+ {
+ new Button
+ {
+ Text = "Click to Toggle Swipe Paging",
+ Command = new Command(() => On<Android>().SetIsSwipePagingEnabled(!On<Android>().IsSwipePagingEnabled()))
+ },
+ offscreenPageLimit
+ }
+ };
+
+ var restoreButton = new Button { Text = "Back To Gallery" };
+ restoreButton.Clicked += (sender, args) => restore.Execute(null);
+ content.Children.Add(restoreButton);
+
+ page.Content = content;
+
+ return page;
+ }
+
+ static Page CreateAdditonalPage()
+ {
+ var cp = new ContentPage { Title = "Additional Page" };
+
+ cp.Content = new StackLayout
+ {
+ VerticalOptions = LayoutOptions.Fill,
+ HorizontalOptions = LayoutOptions.Fill,
+ Children =
+ {
+ new Entry
+ {
+ Placeholder = "Enter some text"
+ }
+ }
+ };
+
+ return cp;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGallery.cs b/Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGallery.cs
index 67465da1..1bca68bb 100644
--- a/Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGallery.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGallery.cs
@@ -14,6 +14,7 @@ namespace Xamarin.Forms.Controls
var navpageiOSButton = new Button() { Text = "Navigation Page (iOS)" };
var viselemiOSButton = new Button() { Text = "Visual Element (iOS)" };
var appAndroidButton = new Button() { Text = "Application (Android)" };
+ var tbAndroidButton = new Button { Text = "TabbedPage (Android)" };
mdpWindowsButton.Clicked += (sender, args) => { SetRoot(new MasterDetailPageWindows(new Command(RestoreOriginal))); };
npWindowsButton.Clicked += (sender, args) => { SetRoot(new NavigationPageWindows(new Command(RestoreOriginal))); };
@@ -21,10 +22,12 @@ namespace Xamarin.Forms.Controls
navpageiOSButton.Clicked += (sender, args) => { SetRoot(NavigationPageiOS.Create(new Command(RestoreOriginal))); };
viselemiOSButton.Clicked += (sender, args) => { SetRoot(new VisualElementiOS(new Command(RestoreOriginal))); };
appAndroidButton.Clicked += (sender, args) => { SetRoot(new ApplicationAndroid(new Command(RestoreOriginal))); };
+ tbAndroidButton.Clicked += (sender, args) => { SetRoot(new TabbedPageAndroid(new Command(RestoreOriginal))); };
+
Content = new StackLayout
{
- Children = { mdpWindowsButton, npWindowsButton, tbWindowsButton, navpageiOSButton, viselemiOSButton, appAndroidButton }
+ Children = { mdpWindowsButton, npWindowsButton, tbWindowsButton, navpageiOSButton, viselemiOSButton, appAndroidButton, tbAndroidButton }
};
}
diff --git a/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj b/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj
index b85020ba..b1568398 100644
--- a/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj
+++ b/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj
@@ -106,6 +106,7 @@
<Compile Include="GalleryPages\PlatformSpecificsGalleries\NavigationPageiOS.cs" />
<Compile Include="GalleryPages\PlatformSpecificsGalleries\NavigationPageWindows.cs" />
<Compile Include="GalleryPages\PlatformSpecificsGalleries\ApplicationAndroid.cs" />
+ <Compile Include="GalleryPages\PlatformSpecificsGalleries\TabbedPageAndroid.cs" />
<Compile Include="GalleryPages\PlatformSpecificsGalleries\TabbedPageWindows.cs" />
<Compile Include="GalleryPages\PlatformSpecificsGalleries\VisualElementiOS.cs" />
<Compile Include="GalleryPages\PlatformSpecificsGalleries\WindowsPlatformSpecificsGalleryHelpers.cs" />