summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-01-12 21:05:41 +0100
committerJason Smith <jason.smith@xamarin.com>2017-01-12 12:05:41 -0800
commitb6cb64e4930de9b16309f2d30c6bb0a2177048fd (patch)
treeae15f36d3e0e60cac6305f90520ad778de9c6ee3 /Xamarin.Forms.Controls
parent3af99cbbe145a876cc9839af0adead83695b5445 (diff)
downloadxamarin-forms-b6cb64e4930de9b16309f2d30c6bb0a2177048fd.tar.gz
xamarin-forms-b6cb64e4930de9b16309f2d30c6bb0a2177048fd.tar.bz2
xamarin-forms-b6cb64e4930de9b16309f2d30c6bb0a2177048fd.zip
[C] new OnPlatform mechanism (#658)
* [C] Obsolete TargetPlatform * [Xaml] support and test the new syntax * blind fix windows platforms
Diffstat (limited to 'Xamarin.Forms.Controls')
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs7
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs15
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs7
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs7
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs14
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs7
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ProductViewCell.cs2
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs7
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellTablePage.cs7
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellListPage.cs7
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellTablePage.cs7
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ViewCellGallery.cs7
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/FrameGallery.cs2
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/LabelGallery.cs22
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ListViewDemoPage.cs3
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/MapGallery.cs7
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/StackLayoutGallery.cs7
-rw-r--r--Xamarin.Forms.Controls/HanselForms/TwitterPage.xaml.cs10
-rw-r--r--Xamarin.Forms.Controls/TestCases.cs16
19 files changed, 77 insertions, 84 deletions
diff --git a/Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs b/Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs
index 23a2035a..4c588ab9 100644
--- a/Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs
@@ -87,11 +87,8 @@ namespace Xamarin.Forms.Controls
{
public AbsoluteLayoutGallery ()
{
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet) {
- Padding = new Thickness (0, 0, 0, 60);
- }
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(0, 0, 0, 60);
BindingContext = new AbsolutePositioningExplorationViewModel ();
var absLayout = new AbsoluteLayout {
diff --git a/Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs b/Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs
index 0558b192..896085a3 100644
--- a/Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs
@@ -31,8 +31,21 @@ namespace Xamarin.Forms.Controls
var click = new Button { Text = "Click Button" };
var rotate = new Button { Text = "Rotate Button" };
var transparent = new Button { Text = "Transparent Button" };
+ string fontName;
+ switch (Device.RuntimePlatform) {
+ default:
+ case Device.iOS:
+ fontName = "Georgia";
+ break;
+ case Device.Android:
+ fontName = "sans-serif-light";
+ break;
+ case Device.WinPhone:
+ case Device.Windows:
+ fontName = "Comic Sans MS";
+ break;
+ }
- var fontName = Device.OnPlatform ("Georgia", "sans-serif-light", "Comic Sans MS");
var font = Font.OfSize (fontName, NamedSize.Medium);
var themedButton = new Button {
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs
index 89740fb5..0a9c21b4 100644
--- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs
@@ -18,11 +18,8 @@ namespace Xamarin.Forms.Controls
{
Title = "EntryCell List Gallery - Legacy";
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet) {
- Padding = new Thickness (0, 0, 0, 60);
- }
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(0, 0, 0, 60);
var dataTemplate = new DataTemplate (typeof(EntryCell));
dataTemplate.SetBinding (EntryCell.LabelProperty, new Binding ("Label"));
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs
index c37dd441..f3fe5e57 100644
--- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs
@@ -6,11 +6,8 @@ namespace Xamarin.Forms.Controls
{
Title = "EntryCell Table Gallery - Legacy";
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet) {
- Padding = new Thickness (0, 0, 0, 60);
- }
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(0, 0, 0, 60);
int timesEntered = 1;
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs
index 62ec6940..1071505c 100644
--- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs
@@ -21,11 +21,8 @@ namespace Xamarin.Forms.Controls
{
Title = "ImageCell List Gallery - Legacy";
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet) {
- Padding = new Thickness (0, 0, 0, 60);
- }
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(0, 0, 0, 60);
var dataTemplate = new DataTemplate (typeof (ImageCell));
var stringToImageSourceConverter = new GenericValueConverter (
@@ -73,11 +70,8 @@ namespace Xamarin.Forms.Controls
{
public UrlImageCellListPage()
{
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet) {
- Padding = new Thickness (0, 0, 0, 60);
- }
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(0, 0, 0, 60);
var dataTemplate = new DataTemplate (typeof (ImageCell));
var stringToImageSourceConverter = new GenericValueConverter (
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs
index 2b941bfd..988c8a7f 100644
--- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs
@@ -7,11 +7,8 @@ namespace Xamarin.Forms.Controls
{
Title = "ImageCell Table Gallery - Legacy";
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet) {
- Padding = new Thickness (0, 0, 0, 60);
- }
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(0, 0, 0, 60);
var tableSection = new TableSection ("Section One") {
new ImageCell { Text = "Text 1", ImageSource = new FileImageSource { File = "crimson.jpg" } },
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ProductViewCell.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ProductViewCell.cs
index 5973ebab..e0b4b9df 100644
--- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ProductViewCell.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ProductViewCell.cs
@@ -20,7 +20,7 @@ namespace Xamarin.Forms.Controls
var frame = new Frame {
Content = _stack,
- BackgroundColor = Device.OnPlatform (iOS: new Color (1), Android: new Color (0.2), WinPhone: new Color (0.2))
+ BackgroundColor = new[] { Device.Android, Device.Windows, Device.WinPhone }.Contains(Device.RuntimePlatform) ? new Color(0.2) : new Color(1)
};
_timeLabel = new Label {
Text = text
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs
index 799d6989..0d336b34 100644
--- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs
@@ -16,11 +16,8 @@ namespace Xamarin.Forms.Controls
{
Title = "SwitchCell List Gallery - Legacy";
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet) {
- Padding = new Thickness (0, 0, 0, 60);
- }
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(0, 0, 0, 60);
var dataTemplate = new DataTemplate (typeof (SwitchCell)) {
Bindings = {
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellTablePage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellTablePage.cs
index a0deb8e6..5a92ed4b 100644
--- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellTablePage.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellTablePage.cs
@@ -6,11 +6,8 @@ namespace Xamarin.Forms.Controls
{
Title = "SwitchCell Table Gallery - Legacy";
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet) {
- Padding = new Thickness (0, 0, 0, 60);
- }
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(0, 0, 0, 60);
var tableSection = new TableSection ("Section One") {
new SwitchCell { Text = "text 1", On = true },
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellListPage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellListPage.cs
index 2b2761e7..e2f071b6 100644
--- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellListPage.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellListPage.cs
@@ -17,11 +17,8 @@ namespace Xamarin.Forms.Controls
{
Title = "TextCell List Gallery - Legacy";
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet) {
- Padding = new Thickness (0, 0, 0, 60);
- }
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(0, 0, 0, 60);
var label = new Label { Text = "Not Selected" };
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellTablePage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellTablePage.cs
index b9cc0cf3..fa1697b1 100644
--- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellTablePage.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellTablePage.cs
@@ -7,11 +7,8 @@ namespace Xamarin.Forms.Controls
{
Title = "TextCell Table Gallery - Legacy";
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet) {
- Padding = new Thickness (0, 0, 0, 60);
- }
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(0, 0, 0, 60);
var tableSection = new TableSection ("Section One") {
new TextCell { Text = "Text 1" },
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ViewCellGallery.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ViewCellGallery.cs
index 099a786a..f256abeb 100644
--- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ViewCellGallery.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ViewCellGallery.cs
@@ -31,11 +31,8 @@ namespace Xamarin.Forms.Controls
{
public UrlImageViewCellListPage()
{
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet) {
- Padding = new Thickness (0, 0, 0, 60);
- }
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(0, 0, 0, 60);
var stringToImageSourceConverter = new GenericValueConverter (
obj => new UriImageSource() {
diff --git a/Xamarin.Forms.Controls/GalleryPages/FrameGallery.cs b/Xamarin.Forms.Controls/GalleryPages/FrameGallery.cs
index ee7c1822..653ecdae 100644
--- a/Xamarin.Forms.Controls/GalleryPages/FrameGallery.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/FrameGallery.cs
@@ -22,7 +22,7 @@ namespace Xamarin.Forms.Controls
Content = new Button {
Text = "Framous!"
},
- BackgroundColor = Device.OnPlatform (iOS: new Color (1), Android: new Color (0), WinPhone: new Color (0)),
+ BackgroundColor = new[] { Device.Android, Device.Windows, Device.WinPhone }.Contains(Device.RuntimePlatform) ? new Color(0) : new Color(1),
VerticalOptions = LayoutOptions.FillAndExpand
};
diff --git a/Xamarin.Forms.Controls/GalleryPages/LabelGallery.cs b/Xamarin.Forms.Controls/GalleryPages/LabelGallery.cs
index c40d7ae4..4ae44ba6 100644
--- a/Xamarin.Forms.Controls/GalleryPages/LabelGallery.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/LabelGallery.cs
@@ -72,8 +72,20 @@ namespace Xamarin.Forms.Controls
#pragma warning disable 618
bolditalic.Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold | FontAttributes.Italic);
#pragma warning restore 618
-
- var fontName = Device.OnPlatform ("Georgia", "sans-serif-light", "Comic Sans MS");
+ string fontName;
+ switch (Device.RuntimePlatform) {
+ default:
+ case Device.iOS:
+ fontName = "Georgia";
+ break;
+ case Device.Android:
+ fontName = "sans-serif-light";
+ break;
+ case Device.WinPhone:
+ case Device.Windows:
+ fontName = "Comic Sans MS";
+ break;
+ }
var font = Font.OfSize (fontName, NamedSize.Medium);
#pragma warning disable 618
customFont.Font = font;
@@ -113,10 +125,8 @@ namespace Xamarin.Forms.Controls
Thickness padding = new Thickness (20);
// Padding Adjust for iPad
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet)
- padding = new Thickness (20, 20, 20, 60);
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(20, 20, 20, 60);
Content = new ScrollView {
Content = new StackLayout {
diff --git a/Xamarin.Forms.Controls/GalleryPages/ListViewDemoPage.cs b/Xamarin.Forms.Controls/GalleryPages/ListViewDemoPage.cs
index 370fb6d9..efbc57cf 100644
--- a/Xamarin.Forms.Controls/GalleryPages/ListViewDemoPage.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/ListViewDemoPage.cs
@@ -225,8 +225,7 @@ namespace Xamarin.Forms.Controls
};
// Accomodate iPhone status bar.
- Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
-
+ Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 5) : new Thickness(10, 0, 10, 5);
// Build the page.
Content = new StackLayout
{
diff --git a/Xamarin.Forms.Controls/GalleryPages/MapGallery.cs b/Xamarin.Forms.Controls/GalleryPages/MapGallery.cs
index dd283c3a..0488cc27 100644
--- a/Xamarin.Forms.Controls/GalleryPages/MapGallery.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/MapGallery.cs
@@ -14,11 +14,8 @@ namespace Xamarin.Forms.Controls
public MapGallery ()
{
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet) {
- Padding = new Thickness (0, 0, 0, 60);
- }
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(0, 0, 0, 60);
var map = MakeMap ();
diff --git a/Xamarin.Forms.Controls/GalleryPages/StackLayoutGallery.cs b/Xamarin.Forms.Controls/GalleryPages/StackLayoutGallery.cs
index b08b5f35..7a985653 100644
--- a/Xamarin.Forms.Controls/GalleryPages/StackLayoutGallery.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/StackLayoutGallery.cs
@@ -10,11 +10,8 @@ namespace Xamarin.Forms.Controls
{
public StackLayoutGallery ()
{
- Device.OnPlatform (iOS: () => {
- if (Device.Idiom == TargetIdiom.Tablet) {
- Padding = new Thickness (0, 0, 0, 60);
- }
- });
+ if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
+ Padding = new Thickness(0, 0, 0, 60);
var stack = new StackLayout { Orientation = StackOrientation.Vertical };
Button b1 = new Button { Text = "Boring", HeightRequest = 500, MinimumHeightRequest = 50 };
diff --git a/Xamarin.Forms.Controls/HanselForms/TwitterPage.xaml.cs b/Xamarin.Forms.Controls/HanselForms/TwitterPage.xaml.cs
index 40e488e4..6568dca7 100644
--- a/Xamarin.Forms.Controls/HanselForms/TwitterPage.xaml.cs
+++ b/Xamarin.Forms.Controls/HanselForms/TwitterPage.xaml.cs
@@ -119,11 +119,11 @@ namespace Xamarin.Forms.Controls
// Tweets.Add(tweet);
//}
- if (Device.OS == TargetPlatform.iOS)
- {
- // only does anything on iOS, for the Watch
- // DependencyService.Get<ITweetStore>().Save(tweets);
- }
+ //if (Device.OS == TargetPlatform.iOS)
+ //{
+ // // only does anything on iOS, for the Watch
+ // // DependencyService.Get<ITweetStore>().Save(tweets);
+ //}
diff --git a/Xamarin.Forms.Controls/TestCases.cs b/Xamarin.Forms.Controls/TestCases.cs
index fc601024..d05b0a0e 100644
--- a/Xamarin.Forms.Controls/TestCases.cs
+++ b/Xamarin.Forms.Controls/TestCases.cs
@@ -204,9 +204,19 @@ namespace Xamarin.Forms.Controls
rootLayout.Children.Add (searchButton);
rootLayout.Children.Add (new TestCaseScreen ());
- return new NavigationPage (testCasesRoot) {
- Title = Device.OnPlatform ("Test Cases", "Test Cases", "Tests")
- };
+ var page = new NavigationPage(testCasesRoot);
+ switch (Device.RuntimePlatform) {
+ case Device.iOS:
+ case Device.Android:
+ default:
+ page.Title = "Test Cases";
+ break;
+ case Device.WinPhone:
+ case Device.Windows:
+ page.Title = "Tests";
+ break;
+ }
+ return page;
}
}