Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit ee25cd5

Browse files
[C] Obsolete TargetPlatform
1 parent df67dff commit ee25cd5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+572
-284
lines changed

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla22229.xaml.cs

+12-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@ public partial class Bugzilla22229 : TabbedPage
1919
public Bugzilla22229()
2020
{
2121
InitializeComponent();
22-
_prefix = Device.OnPlatform(
23-
iOS: "Images/",
24-
Android: "",
25-
WinPhone: "Assets/"
26-
);
22+
switch (Device.RuntimePlatform) {
23+
case Device.iOS:
24+
_prefix = "Images/";
25+
break;
26+
case Device.Android:
27+
_prefix = "";
28+
break;
29+
case Device.Windows:
30+
case Device.WinPhone:
31+
_prefix = "Assets/";
32+
break;
33+
}
2734
InitializeActionBar();
2835
}
2936

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla26868.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ protected override void Init ()
3030

3131
var listView = new ListView {
3232
IsGroupingEnabled = true,
33-
GroupDisplayBinding = new Binding ("GroupName"),
34-
GroupShortNameBinding = new Binding ("GroupName"),
35-
HasUnevenRows = Device.OnPlatform (Android: true, WinPhone: false, iOS: false),
33+
GroupDisplayBinding = new Binding("GroupName"),
34+
GroupShortNameBinding = new Binding("GroupName"),
35+
HasUnevenRows = Device.RuntimePlatform == Device.Android,
3636

3737
ItemTemplate = itemTemplate,
3838
GroupHeaderTemplate = groupHeaderTemplate,

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla34632.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class Bugzilla34632 : TestMasterDetailPage
1616
{
1717
protected override void Init ()
1818
{
19-
if (Device.OS == TargetPlatform.Windows)
19+
if (Device.RuntimePlatform == Device.Windows)
2020
MasterBehavior = MasterBehavior.Split;
2121
else
2222
MasterBehavior = MasterBehavior.SplitOnLandscape;

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42069.cs

+10-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@ protected override void Init()
1919

2020
if (!Application.Current.Resources.ContainsKey("SomeSmallImage"))
2121
{
22-
var smallImage = new OnPlatform<ImageSource> {
23-
Android = ImageSource.FromFile("coffee.png"),
24-
WinPhone = ImageSource.FromFile("bank.png"),
25-
iOS = ImageSource.FromFile("coffee.png")
26-
};
22+
ImageSource smallImage;
23+
switch (Device.RuntimePlatform) {
24+
default:
25+
smallImage = "coffee.png";
26+
break;
27+
case Device.WinPhone:
28+
case Device.Windows:
29+
smallImage = "bank.png";
30+
break;
31+
}
2732

2833
Application.Current.Resources.Add("SomeSmallImage", smallImage);
2934
}

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/DefaultColorToggleTest.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ static ContentPage TimePickerPage()
324324

325325
return new ContentPage {
326326
Title = "TimePicker",
327-
Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, Device.OnPlatform(00, 0, 0)),
327+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0),
328328
Content = new StackLayout {
329329
VerticalOptions = LayoutOptions.Fill,
330330
HorizontalOptions = LayoutOptions.Fill,
@@ -389,7 +389,7 @@ static ContentPage DatePickerPage()
389389

390390
return new ContentPage {
391391
Title = "DatePicker",
392-
Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, Device.OnPlatform(00, 0, 0)),
392+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0),
393393
Content = new StackLayout {
394394
VerticalOptions = LayoutOptions.Fill,
395395
HorizontalOptions = LayoutOptions.Fill,
@@ -457,7 +457,7 @@ static ContentPage PickerPage()
457457

458458
return new ContentPage {
459459
Title = "Picker",
460-
Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, Device.OnPlatform(00, 0, 0)),
460+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0),
461461
Content = new StackLayout {
462462
VerticalOptions = LayoutOptions.Fill,
463463
HorizontalOptions = LayoutOptions.Fill,

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/ImageLoadingErrorHandling.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected override void Init()
3131

3232
Grid fakeUri = CreateTest(() => image.Source = ImageSource.FromUri(new Uri("http://not.real")),
3333
"Non-existent URI",
34-
Device.OS == TargetPlatform.Windows && Device.Idiom == TargetIdiom.Phone
34+
Device.RuntimePlatform == Device.Windows && Device.Idiom == TargetIdiom.Phone
3535
? "Clicking this button should display an alert dialog. The error message should include the text 'NotFound'."
3636
: "Clicking this button should display an alert dialog. The error message should include the text 'the server name or address could not be resolved'.");
3737

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1075.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public Issue1075 ()
7777
};
7878

7979
// Accomodate iPhone status bar.
80-
Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 0);
80+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 0) : new Thickness(10, 0);
8181

8282
// Build the page.
8383
Content = new StackLayout

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1461.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public Issue1461Page (MasterBehavior state, bool? initState)
220220
Master = new ContentPage {
221221
Title = string.Format ("Master sample for {0}", state),
222222
Icon = "bank.png",
223-
Padding = Device.OnPlatform (new Thickness (5, 60, 5, 5), 5, 5),
223+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(5, 60, 5, 5) : new Thickness(5),
224224
Content =
225225
new StackLayout { Children = {
226226
new Label {

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1769.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public SwitchDemoPage()
6363
};
6464

6565
// Accomodate iPhone status bar.
66-
Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
66+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 5) : new Thickness(10, 0, 10, 5);
6767

6868
// Build the page.
6969
Content = new StackLayout

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue194.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public Issue194 ()
4747
Title = "Page 9"
4848
};
4949

50-
Device.OnPlatform (iOS: () => {
50+
if (Device.RuntimePlatform == Device.iOS) {
5151
// Create an overflow amount of tabs depending on device
5252
if (Device.Idiom == TargetIdiom.Tablet) {
5353
Children.Add (pageOne);
@@ -67,7 +67,7 @@ public Issue194 ()
6767
Children.Add (pageFive);
6868
Children.Add (pageSix);
6969
}
70-
});
70+
}
7171
}
7272
}
7373
}

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2259.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected override void Init ()
130130
listView.ScrollTo (person, ScrollToPosition.End, true);
131131
};
132132

133-
Padding = new Thickness (10, Device.OnPlatform (20, 0, 0), 10, 5);
133+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 5) : new Thickness(10, 0, 10, 5);
134134

135135
Content = new StackLayout {
136136
Orientation = StackOrientation.Vertical,

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2357.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public CustomWebView (WebViewViewModel webViewViewModel) : this ()
138138

139139
static void WebView_OnNavigating (object sender, WebNavigatingEventArgs e)
140140
{
141-
Debug.WriteLine ("OS: " + Device.OS + " Current Url: " + GetSourceUrl (((WebView)sender).Source) + "Destination Url: " + e.Url + " " + DateTime.Now);
141+
Debug.WriteLine ("OS: " + Device.RuntimePlatform + " Current Url: " + GetSourceUrl (((WebView)sender).Source) + "Destination Url: " + e.Url + " " + DateTime.Now);
142142

143143
if (e.Url.IsValidAbsoluteUrl ()) {
144144
var destinationUri = new Uri (e.Url);

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2597.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ public Issue2597()
4040
};
4141

4242
// Accomodate iPhone status bar.
43-
Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10,
44-
5);
43+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 5) : new Thickness(10, 0, 10, 5);
4544

4645
// Build the page.
4746
Content = new StackLayout

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2634.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,10 @@ public AddPatientView ()
235235
Forms.Constraint.RelativeToParent ((parent) =>
236236
parent.Height));
237237

238-
rl.Children.Add (addFrame,
239-
Forms.Constraint.RelativeToParent ((parent) =>
240-
(parent.Width * .25) / 2),
241-
Forms.Constraint.Constant (Device.OnPlatform (60, 40, 40)),
242-
Forms.Constraint.RelativeToParent ((parent) =>
243-
parent.Width * .75));
238+
rl.Children.Add(addFrame,
239+
Forms.Constraint.RelativeToParent((parent) => (parent.Width * .25) / 2),
240+
Forms.Constraint.Constant(Device.RuntimePlatform == Device.iOS ? 60 : 40),
241+
Forms.Constraint.RelativeToParent((parent) => parent.Width * .75));
244242

245243
Content = rl;
246244
}

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2961.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public SliderMenuPage ()
144144
Children = { logoImg }
145145
};
146146

147-
var paddingTop = Device.OnPlatform (40, 2, 2);
147+
var paddingTop = Device.RuntimePlatform == Device.iOS ? 40 : 2;
148148
Content = new StackLayout {
149149
Spacing = 0,
150150
BackgroundColor = Color.FromHex ("1e1e1e"),

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2976.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ public NativeListPage ()
7373

7474
// The root page of your application
7575
Content = new StackLayout {
76-
Padding = new Thickness (0, Device.OnPlatform(20,0,0), 0, 0),
76+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0),
7777
Children = {
7878
new Label {
7979
#pragma warning disable 618
8080
XAlign = TextAlignment.Center,
8181
#pragma warning restore 618
82-
Text = Device.OnPlatform("Custom renderer UITableView","Custom renderer ListView","Custom renderer todo")
82+
Text = Device.RuntimePlatform == Device.iOS ? "Custom renderer UITableView" : Device.RuntimePlatform == Device.Android ? "Custom renderer ListView" : "Custom renderer todo"
8383
},
84-
fasterListView
84+
fasterListView
8585
}
8686
};
8787
}
@@ -143,7 +143,7 @@ public XamarinFormsPage ()
143143
};
144144

145145
Content = new StackLayout {
146-
Padding = new Thickness (5, Device.OnPlatform(20,0,0), 5, 0),
146+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(5, 20, 5, 0) : new Thickness(5,0),
147147
Children = {
148148
new Label {
149149
#pragma warning disable 618
@@ -185,7 +185,7 @@ public XamarinFormsNativeCellPage ()
185185
};
186186

187187
Content = new StackLayout {
188-
Padding = new Thickness (0, Device.OnPlatform(20,0,0), 0, 0),
188+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0),
189189
Children = {
190190
new Label {
191191
#pragma warning disable 618
@@ -250,7 +250,7 @@ public DetailPage (object detail)
250250
b.Clicked += (sender, e) => Navigation.PopModalAsync();
251251

252252
Content = new StackLayout {
253-
Padding = new Thickness (0, Device.OnPlatform(20,0,0), 0, 0),
253+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0),
254254
HorizontalOptions = LayoutOptions.Center,
255255
VerticalOptions = LayoutOptions.Center,
256256
Children = {
@@ -289,13 +289,13 @@ public NativeListViewPage2 ()
289289

290290
// The root page of your application
291291
Content = new StackLayout {
292-
Padding = new Thickness (0, Device.OnPlatform(20,0,0), 0, 0),
292+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0),
293293
Children = {
294294
new Label {
295295
#pragma warning disable 618
296296
XAlign = TextAlignment.Center,
297297
#pragma warning restore 618
298-
Text = Device.OnPlatform("Custom UITableView+UICell","Custom ListView+Cell","Custom renderer todo")
298+
Text = Device.RuntimePlatform == Device.iOS ? "Custom UITableView+UICell" : Device.RuntimePlatform == Device.Android ? "Custom ListView+Cell" : "Custom renderer todo"
299299
},
300300
nativeListView2
301301
}

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2987.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected override void Init ()
2222
Debug.WriteLine ("Date changed");
2323
};
2424

25-
Padding = new Thickness (10, Device.OnPlatform (20, 0, 0), 10, 5);
25+
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 5) : new Thickness(10, 0, 10, 5);
2626

2727
layout = new AbsoluteLayout {
2828
VerticalOptions = LayoutOptions.FillAndExpand,

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue773.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ public CannotScrollRepro ()
162162

163163
layout.Children.Add (label);
164164

165-
layout.Children.Add (new ScrollView {
165+
layout.Children.Add(new ScrollView {
166166
BackgroundColor = Color.Aqua,
167167
Orientation = ScrollOrientation.Horizontal,
168-
HeightRequest = Device.OnPlatform (44, 44, 80),
168+
HeightRequest = Device.RuntimePlatform == Device.Windows || Device.RuntimePlatform == Device.WinPhone ? 80 : 44,
169169
Content = buttonStack
170170
});
171171

Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,8 @@ public class AbsoluteLayoutGallery : ContentPage
8787
{
8888
public AbsoluteLayoutGallery ()
8989
{
90-
Device.OnPlatform (iOS: () => {
91-
if (Device.Idiom == TargetIdiom.Tablet) {
92-
Padding = new Thickness (0, 0, 0, 60);
93-
}
94-
});
90+
if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
91+
Padding = new Thickness(0, 0, 0, 60);
9592

9693
BindingContext = new AbsolutePositioningExplorationViewModel ();
9794
var absLayout = new AbsoluteLayout {

Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs

+14-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,21 @@ public ButtonGallery ()
3131
var click = new Button { Text = "Click Button" };
3232
var rotate = new Button { Text = "Rotate Button" };
3333
var transparent = new Button { Text = "Transparent Button" };
34+
string fontName;
35+
switch (Device.RuntimePlatform) {
36+
default:
37+
case Device.iOS:
38+
fontName = "Georgia";
39+
break;
40+
case Device.Android:
41+
fontName = "sans-serif-light";
42+
break;
43+
case Device.WinPhone:
44+
case Device.Windows:
45+
fontName = "Comic Sans MS";
46+
break;
47+
}
3448

35-
var fontName = Device.OnPlatform ("Georgia", "sans-serif-light", "Comic Sans MS");
3649
var font = Font.OfSize (fontName, NamedSize.Medium);
3750

3851
var themedButton = new Button {

Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ public EntryCellListPage ()
1818
{
1919
Title = "EntryCell List Gallery - Legacy";
2020

21-
Device.OnPlatform (iOS: () => {
22-
if (Device.Idiom == TargetIdiom.Tablet) {
23-
Padding = new Thickness (0, 0, 0, 60);
24-
}
25-
});
21+
if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
22+
Padding = new Thickness(0, 0, 0, 60);
2623

2724
var dataTemplate = new DataTemplate (typeof(EntryCell));
2825
dataTemplate.SetBinding (EntryCell.LabelProperty, new Binding ("Label"));

Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ public EntryCellTablePage ()
66
{
77
Title = "EntryCell Table Gallery - Legacy";
88

9-
Device.OnPlatform (iOS: () => {
10-
if (Device.Idiom == TargetIdiom.Tablet) {
11-
Padding = new Thickness (0, 0, 0, 60);
12-
}
13-
});
9+
if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
10+
Padding = new Thickness(0, 0, 0, 60);
1411

1512
int timesEntered = 1;
1613

Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs

+4-10
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ public ImageCellListPage ()
2121
{
2222
Title = "ImageCell List Gallery - Legacy";
2323

24-
Device.OnPlatform (iOS: () => {
25-
if (Device.Idiom == TargetIdiom.Tablet) {
26-
Padding = new Thickness (0, 0, 0, 60);
27-
}
28-
});
24+
if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
25+
Padding = new Thickness(0, 0, 0, 60);
2926

3027
var dataTemplate = new DataTemplate (typeof (ImageCell));
3128
var stringToImageSourceConverter = new GenericValueConverter (
@@ -73,11 +70,8 @@ public class UrlImageCellListPage : ContentPage
7370
{
7471
public UrlImageCellListPage()
7572
{
76-
Device.OnPlatform (iOS: () => {
77-
if (Device.Idiom == TargetIdiom.Tablet) {
78-
Padding = new Thickness (0, 0, 0, 60);
79-
}
80-
});
73+
if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
74+
Padding = new Thickness(0, 0, 0, 60);
8175

8276
var dataTemplate = new DataTemplate (typeof (ImageCell));
8377
var stringToImageSourceConverter = new GenericValueConverter (

Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ public ImageCellTablePage ()
77
{
88
Title = "ImageCell Table Gallery - Legacy";
99

10-
Device.OnPlatform (iOS: () => {
11-
if (Device.Idiom == TargetIdiom.Tablet) {
12-
Padding = new Thickness (0, 0, 0, 60);
13-
}
14-
});
10+
if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
11+
Padding = new Thickness(0, 0, 0, 60);
1512

1613
var tableSection = new TableSection ("Section One") {
1714
new ImageCell { Text = "Text 1", ImageSource = new FileImageSource { File = "crimson.jpg" } },

0 commit comments

Comments
 (0)