Merge pull request #195 from mallibone/master
Compile warnings and sample improvements
This commit is contained in:
commit
3db746929b
|
@ -1,11 +1,14 @@
|
||||||
using System;
|
using System;
|
||||||
|
using Ooui;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
using Color = Xamarin.Forms.Color;
|
||||||
|
|
||||||
namespace Samples
|
namespace Samples
|
||||||
{
|
{
|
||||||
public class BoxViewClockSample : ISample
|
public class BoxViewClockSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms BoxViewClock";
|
public string Title => "Xamarin.Forms BoxViewClock";
|
||||||
|
public string Path => "/box-view-clock";
|
||||||
|
|
||||||
BoxViewClockPage page;
|
BoxViewClockPage page;
|
||||||
|
|
||||||
|
@ -20,6 +23,11 @@ namespace Samples
|
||||||
return page.GetOouiElement ();
|
return page.GetOouiElement ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Publish()
|
||||||
|
{
|
||||||
|
UI.Publish(Path, CreateElement);
|
||||||
|
}
|
||||||
|
|
||||||
class BoxViewClockPage : ContentPage
|
class BoxViewClockPage : ContentPage
|
||||||
{
|
{
|
||||||
// Structure for storing information about the three hands.
|
// Structure for storing information about the three hands.
|
||||||
|
|
|
@ -164,7 +164,7 @@ namespace BugSweeper
|
||||||
{
|
{
|
||||||
#if FIX_WINPHONE_BUTTON
|
#if FIX_WINPHONE_BUTTON
|
||||||
|
|
||||||
if (Device.OS == TargetPlatform.WinPhone && !((Button)sender).IsEnabled)
|
if (Device.RuntimePlatform == Device.UWP && !((Button)sender).IsEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace BugSweeper
|
||||||
this.Col = col;
|
this.Col = col;
|
||||||
|
|
||||||
this.BackgroundColor = Color.Yellow;
|
this.BackgroundColor = Color.Yellow;
|
||||||
this.OutlineColor = Color.Blue;
|
this.BorderColor = Color.Blue;
|
||||||
this.Padding = 2;
|
this.Padding = 2;
|
||||||
|
|
||||||
label = new Label {
|
label = new Label {
|
||||||
|
@ -64,7 +64,7 @@ namespace BugSweeper
|
||||||
|
|
||||||
#if FIX_WINDOWS_DOUBLE_TAPS
|
#if FIX_WINDOWS_DOUBLE_TAPS
|
||||||
|
|
||||||
if (Device.OS != TargetPlatform.Windows && Device.OS != TargetPlatform.WinPhone) {
|
if (Device.RuntimePlatform != Device.UWP) {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ namespace BugSweeper
|
||||||
|
|
||||||
#if FIX_WINDOWS_PHONE_NULL_CONTENT
|
#if FIX_WINDOWS_PHONE_NULL_CONTENT
|
||||||
|
|
||||||
if (Device.OS == TargetPlatform.WinPhone || Device.OS == TargetPlatform.Windows) {
|
if (Device.RuntimePlatform == Device.UWP) {
|
||||||
this.Content = new Label { Text = " " };
|
this.Content = new Label { Text = " " };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ namespace BugSweeper
|
||||||
|
|
||||||
#if FIX_WINDOWS_DOUBLE_TAPS
|
#if FIX_WINDOWS_DOUBLE_TAPS
|
||||||
|
|
||||||
if (Device.OS == TargetPlatform.Windows || Device.OS == TargetPlatform.WinPhone) {
|
if (Device.RuntimePlatform == Device.UWP) {
|
||||||
if (lastTapSingle && DateTime.Now - lastTapTime < TimeSpan.FromMilliseconds (500)) {
|
if (lastTapSingle && DateTime.Now - lastTapTime < TimeSpan.FromMilliseconds (500)) {
|
||||||
OnDoubleTap (sender, args);
|
OnDoubleTap (sender, args);
|
||||||
lastTapSingle = false;
|
lastTapSingle = false;
|
||||||
|
|
|
@ -6,11 +6,17 @@ namespace Samples
|
||||||
public class BugSweeperSample : ISample
|
public class BugSweeperSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms BugSweeper";
|
public string Title => "Xamarin.Forms BugSweeper";
|
||||||
|
public string Path => "/bugsweeper";
|
||||||
|
|
||||||
public Ooui.Element CreateElement ()
|
public Ooui.Element CreateElement ()
|
||||||
{
|
{
|
||||||
var page = new BugSweeper.BugSweeperPage ();
|
var page = new BugSweeper.BugSweeperPage ();
|
||||||
return page.GetOouiElement ();
|
return page.GetOouiElement ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Publish()
|
||||||
|
{
|
||||||
|
UI.Publish(Path, CreateElement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Samples
|
||||||
public class ButtonSample : ISample
|
public class ButtonSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Button Counter";
|
public string Title => "Button Counter";
|
||||||
|
public string Path => "/shared-button";
|
||||||
|
|
||||||
Button MakeButton ()
|
Button MakeButton ()
|
||||||
{
|
{
|
||||||
|
@ -25,7 +26,7 @@ namespace Samples
|
||||||
{
|
{
|
||||||
var b = MakeButton ();
|
var b = MakeButton ();
|
||||||
|
|
||||||
UI.Publish ("/shared-button", b);
|
UI.Publish (Path, b);
|
||||||
UI.Publish ("/button", MakeButton);
|
UI.Publish ("/button", MakeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,22 @@
|
||||||
using Ooui;
|
using Ooui;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Samples
|
namespace Samples
|
||||||
{
|
{
|
||||||
public class ButtonXamlSample : ISample
|
public class ButtonXamlSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms Button XAML";
|
public string Title => "Xamarin.Forms Button XAML";
|
||||||
|
public string Path => "buttons";
|
||||||
public Ooui.Element CreateElement ()
|
|
||||||
{
|
public Ooui.Element CreateElement ()
|
||||||
|
{
|
||||||
var page = new ButtonXaml.ButtonXamlPage ();
|
var page = new ButtonXaml.ButtonXamlPage ();
|
||||||
return page.GetOouiElement ();
|
return page.GetOouiElement ();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
public void Publish()
|
||||||
|
{
|
||||||
|
UI.Publish(Path, CreateElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace Samples
|
||||||
public class DisplayAlertSample : ISample
|
public class DisplayAlertSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms DisplayAlert";
|
public string Title => "Xamarin.Forms DisplayAlert";
|
||||||
|
public string Path => "/display-alert";
|
||||||
|
|
||||||
public Ooui.Element CreateElement ()
|
public Ooui.Element CreateElement ()
|
||||||
{
|
{
|
||||||
|
@ -16,7 +17,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish ()
|
public void Publish ()
|
||||||
{
|
{
|
||||||
UI.Publish ("/display-alert", CreateElement);
|
UI.Publish (Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Samples
|
||||||
public class DotMatrixClockSample : ISample
|
public class DotMatrixClockSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms DoMatrixClock";
|
public string Title => "Xamarin.Forms DoMatrixClock";
|
||||||
|
public string Path => "/dotmatrixclock";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -15,7 +16,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish("/dotmatrixclock", CreateElement);
|
UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,11 @@ namespace Samples
|
||||||
public class DrawSample : ISample
|
public class DrawSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Drawing";
|
public string Title => "Drawing";
|
||||||
|
public string Path => "/draw";
|
||||||
|
|
||||||
public void Publish ()
|
public void Publish ()
|
||||||
{
|
{
|
||||||
UI.Publish ("/draw", CreateElement ());
|
UI.Publish (Path, CreateElement ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element CreateElement ()
|
public Element CreateElement ()
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Samples
|
||||||
public class EditorSample : ISample
|
public class EditorSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms Editor Sample";
|
public string Title => "Xamarin.Forms Editor Sample";
|
||||||
|
public string Path => "/editor";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -40,7 +41,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish("/editor", CreateElement);
|
UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,16 @@ using Ooui;
|
||||||
|
|
||||||
namespace Samples
|
namespace Samples
|
||||||
{
|
{
|
||||||
public class FilesSample //: ISample
|
public class FilesSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Upload files";
|
public string Title => "Upload files";
|
||||||
|
public string Path => "/files";
|
||||||
|
|
||||||
public void Publish ()
|
public void Publish ()
|
||||||
{
|
{
|
||||||
var app = CreateElement ();
|
var app = CreateElement ();
|
||||||
|
|
||||||
UI.Publish ("/files", app);
|
UI.Publish (Path, app);
|
||||||
|
|
||||||
UI.PublishCustomResponse ("/files/upload", HandleUpload);
|
UI.PublishCustomResponse ("/files/upload", HandleUpload);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ namespace Samples
|
||||||
public interface ISample
|
public interface ISample
|
||||||
{
|
{
|
||||||
string Title { get; }
|
string Title { get; }
|
||||||
|
string Path { get; }
|
||||||
Element CreateElement ();
|
Element CreateElement ();
|
||||||
|
void Publish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ namespace Samples
|
||||||
class EntryListViewSample : ISample
|
class EntryListViewSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms Basic Entry ListView Sample";
|
public string Title => "Xamarin.Forms Basic Entry ListView Sample";
|
||||||
|
public string Path => "/entry-listview";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -91,13 +92,14 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish("/entry-listview", CreateElement);
|
UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SwitchListViewSample : ISample
|
class SwitchListViewSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms Basic Switch ListView Sample";
|
public string Title => "Xamarin.Forms Basic Switch ListView Sample";
|
||||||
|
public string Path => "/switch-listview";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -130,7 +132,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish("/switch-listview", CreateElement);
|
UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace Samples
|
||||||
public class MonkeysSample : ISample
|
public class MonkeysSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms Monkeys";
|
public string Title => "Xamarin.Forms Monkeys";
|
||||||
|
public string Path => "/monkeys";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -18,7 +19,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish("/monkeys", CreateElement);
|
UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace Samples.Navigation
|
||||||
public class NavigationSample : ISample
|
public class NavigationSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms Navigation XAML";
|
public string Title => "Xamarin.Forms Navigation XAML";
|
||||||
|
public string Path => "navigation-sample";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -14,5 +15,10 @@ namespace Samples.Navigation
|
||||||
var root = new NavigationPage(page);
|
var root = new NavigationPage(page);
|
||||||
return root.GetOouiElement();
|
return root.GetOouiElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Publish()
|
||||||
|
{
|
||||||
|
UI.Publish(Path, CreateElement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,9 @@ namespace Samples
|
||||||
private Xamarin.Forms.Picker _picker;
|
private Xamarin.Forms.Picker _picker;
|
||||||
|
|
||||||
public string Title => "Xamarin.Forms Picker Sample";
|
public string Title => "Xamarin.Forms Picker Sample";
|
||||||
|
public string Path => "/picker";
|
||||||
|
|
||||||
List<string> myItems = new List<string>
|
List<string> myItems = new List<string>
|
||||||
{
|
{
|
||||||
"red",
|
"red",
|
||||||
"green",
|
"green",
|
||||||
|
@ -69,7 +70,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish("/picker", CreateElement);
|
UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Ooui;
|
using Ooui;
|
||||||
|
|
||||||
namespace Samples
|
namespace Samples
|
||||||
|
@ -25,27 +26,39 @@ namespace Samples
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new EntryListViewSample().Publish();
|
var samples = new List<ISample>
|
||||||
new ButtonSample ().Publish ();
|
{
|
||||||
new TodoSample ().Publish ();
|
new EntryListViewSample(),
|
||||||
new DrawSample ().Publish ();
|
new ButtonSample (),
|
||||||
new FilesSample ().Publish ();
|
new TodoSample (),
|
||||||
new DisplayAlertSample ().Publish ();
|
new DrawSample (),
|
||||||
new DotMatrixClockSample().Publish();
|
new FilesSample(),
|
||||||
new EditorSample().Publish();
|
new DisplayAlertSample (),
|
||||||
new MonkeysSample().Publish();
|
new DotMatrixClockSample(),
|
||||||
new RefreshListViewSample ().Publish ();
|
new EditorSample(),
|
||||||
new SearchBarSample().Publish();
|
new MonkeysSample(),
|
||||||
new SliderSample().Publish();
|
new BugSweeperSample(),
|
||||||
new SwitchListViewSample().Publish();
|
new RefreshListViewSample (),
|
||||||
new TimePickerSample().Publish();
|
new SearchBarSample(),
|
||||||
new TipCalcSample().Publish();
|
new SliderSample(),
|
||||||
new WeatherAppSample().Publish();
|
new SwitchListViewSample(),
|
||||||
new XuzzleSample().Publish();
|
new TimePickerSample(),
|
||||||
new WebViewSample().Publish();
|
new TipCalcSample(),
|
||||||
new PickerSample().Publish();
|
new WeatherAppSample(),
|
||||||
|
new XuzzleSample(),
|
||||||
|
new WebViewSample(),
|
||||||
|
new PickerSample(),
|
||||||
|
};
|
||||||
|
|
||||||
UI.Present ("/display-alert");
|
foreach (var sample in samples)
|
||||||
|
{
|
||||||
|
sample.Publish();
|
||||||
|
}
|
||||||
|
|
||||||
|
var samplePage = new SamplePickerSample(samples);
|
||||||
|
samplePage.Publish();
|
||||||
|
|
||||||
|
UI.Present (samplePage.Path);
|
||||||
|
|
||||||
Console.ReadLine ();
|
Console.ReadLine ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Samples
|
||||||
public class RefreshListViewSample : ISample
|
public class RefreshListViewSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms RefreshListView";
|
public string Title => "Xamarin.Forms RefreshListView";
|
||||||
|
public string Path => "/refreshlistview";
|
||||||
|
|
||||||
public Ooui.Element CreateElement ()
|
public Ooui.Element CreateElement ()
|
||||||
{
|
{
|
||||||
|
@ -15,7 +16,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish ()
|
public void Publish ()
|
||||||
{
|
{
|
||||||
UI.Publish ("/refreshlistview", CreateElement);
|
UI.Publish (Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Ooui;
|
||||||
|
using Ooui.Forms;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Element = Ooui.Element;
|
||||||
|
|
||||||
|
namespace Samples
|
||||||
|
{
|
||||||
|
public class SamplePickerSample : ISample
|
||||||
|
{
|
||||||
|
private readonly IEnumerable<ISample> _samplePages;
|
||||||
|
|
||||||
|
public SamplePickerSample(IEnumerable<ISample> samplePages)
|
||||||
|
{
|
||||||
|
_samplePages = samplePages.OrderBy(s => s.Title);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Title => "Ooui samples - choose your demo";
|
||||||
|
public string Path => "/sample-picker";
|
||||||
|
public Element CreateElement()
|
||||||
|
{
|
||||||
|
var panel = new StackLayout();
|
||||||
|
|
||||||
|
var titleLabel = new Xamarin.Forms.Label
|
||||||
|
{
|
||||||
|
Text = "Choose a sample",
|
||||||
|
FontSize = 24,
|
||||||
|
FontAttributes = FontAttributes.Bold,
|
||||||
|
};
|
||||||
|
panel.Children.Add(titleLabel);
|
||||||
|
|
||||||
|
foreach (var samplePage in _samplePages)
|
||||||
|
{
|
||||||
|
panel.Children.Add(new LinkLabel {Text = samplePage.Title.Replace("Xamarin.Forms ", ""), HRef = samplePage.Path});
|
||||||
|
}
|
||||||
|
|
||||||
|
var page = new ContentPage
|
||||||
|
{
|
||||||
|
Title = Title,
|
||||||
|
Padding = new Thickness(16),
|
||||||
|
Content = panel
|
||||||
|
};
|
||||||
|
|
||||||
|
return page.GetOouiElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Publish()
|
||||||
|
{
|
||||||
|
UI.Publish(Path, CreateElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ namespace Samples
|
||||||
private Xamarin.Forms.Label _resultsLabel;
|
private Xamarin.Forms.Label _resultsLabel;
|
||||||
|
|
||||||
public string Title => "Xamarin.Forms SearchBar";
|
public string Title => "Xamarin.Forms SearchBar";
|
||||||
|
public string Path => "/searchbar";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -108,7 +109,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish("/searchbar", CreateElement);
|
UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace Samples
|
||||||
private Xamarin.Forms.Label _label;
|
private Xamarin.Forms.Label _label;
|
||||||
|
|
||||||
public string Title => "Xamarin.Forms Slider Sample";
|
public string Title => "Xamarin.Forms Slider Sample";
|
||||||
|
public string Path => "/slider";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -53,7 +54,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish("/slider", CreateElement);
|
UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace Samples
|
||||||
public class SwitchErrorSample : ISample
|
public class SwitchErrorSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms Switch Error";
|
public string Title => "Xamarin.Forms Switch Error";
|
||||||
|
public string Path => "/switch";
|
||||||
|
|
||||||
public Ooui.Element CreateElement ()
|
public Ooui.Element CreateElement ()
|
||||||
{
|
{
|
||||||
|
@ -34,7 +35,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish ("/switch", CreateElement);
|
UI.Publish (Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Samples
|
||||||
public class TimePickerSample : ISample
|
public class TimePickerSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms TimePicker Sample";
|
public string Title => "Xamarin.Forms TimePicker Sample";
|
||||||
|
public string Path => "/timepicker";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -33,7 +34,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish("/timepicker", CreateElement);
|
UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Samples
|
||||||
public class TipCalcSample : ISample
|
public class TipCalcSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms TipCalc";
|
public string Title => "Xamarin.Forms TipCalc";
|
||||||
|
public string Path => "/tipcalc";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -15,7 +16,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish("/tipcalc", CreateElement);
|
UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace Samples
|
||||||
public class TodoSample : ISample
|
public class TodoSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Todo List";
|
public string Title => "Todo List";
|
||||||
|
public string Path => "/todo";
|
||||||
|
|
||||||
class Item : ListItem
|
class Item : ListItem
|
||||||
{
|
{
|
||||||
|
@ -112,7 +113,7 @@ namespace Samples
|
||||||
{
|
{
|
||||||
var b = MakeTodo ();
|
var b = MakeTodo ();
|
||||||
|
|
||||||
UI.Publish ("/todo", MakeTodo);
|
UI.Publish (Path, MakeTodo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element CreateElement ()
|
public Element CreateElement ()
|
||||||
|
|
|
@ -16,11 +16,13 @@ namespace WeatherApp
|
||||||
|
|
||||||
if (results["weather"] != null)
|
if (results["weather"] != null)
|
||||||
{
|
{
|
||||||
|
string tempUnit = GetTempUnit(units);
|
||||||
|
string speedUnit = GetSpeedUnit(units);
|
||||||
Weather weather = new Weather
|
Weather weather = new Weather
|
||||||
{
|
{
|
||||||
Title = (string)results["name"],
|
Title = (string)results["name"],
|
||||||
Temperature = (string)results["main"]["temp"] + " F",
|
Temperature = (string)results["main"]["temp"] + tempUnit,
|
||||||
Wind = (string)results["wind"]["speed"] + " mph",
|
Wind = (string)results["wind"]["speed"] + speedUnit,
|
||||||
Humidity = (string)results["main"]["humidity"] + " %",
|
Humidity = (string)results["main"]["humidity"] + " %",
|
||||||
Visibility = (string)results["weather"][0]["main"]
|
Visibility = (string)results["weather"][0]["main"]
|
||||||
};
|
};
|
||||||
|
@ -37,5 +39,29 @@ namespace WeatherApp
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetSpeedUnit(string units)
|
||||||
|
{
|
||||||
|
switch (units)
|
||||||
|
{
|
||||||
|
case "imperial":
|
||||||
|
return " mph";
|
||||||
|
default:
|
||||||
|
return " kph";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetTempUnit(string units)
|
||||||
|
{
|
||||||
|
switch (units)
|
||||||
|
{
|
||||||
|
case "metric":
|
||||||
|
return " °C";
|
||||||
|
case "imperial":
|
||||||
|
return " °F";
|
||||||
|
default:
|
||||||
|
return " °K";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
namespace WeatherApp
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace WeatherApp
|
||||||
{
|
{
|
||||||
public class Weather
|
public class Weather
|
||||||
{
|
{
|
||||||
|
@ -9,6 +11,7 @@
|
||||||
public string Visibility { get; set; }
|
public string Visibility { get; set; }
|
||||||
public string Sunrise { get; set; }
|
public string Sunrise { get; set; }
|
||||||
public string Sunset { get; set; }
|
public string Sunset { get; set; }
|
||||||
|
public List<string> UnitOfMeasures { get; set; }
|
||||||
|
|
||||||
public Weather()
|
public Weather()
|
||||||
{
|
{
|
||||||
|
@ -21,6 +24,7 @@
|
||||||
this.Visibility = " ";
|
this.Visibility = " ";
|
||||||
this.Sunrise = " ";
|
this.Sunrise = " ";
|
||||||
this.Sunset = " ";
|
this.Sunset = " ";
|
||||||
|
this.UnitOfMeasures = new List<string>{"kelvin", "metric", "imperial"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
<Label x:Name="zipCodeLabel" Text="Zip Code" Style="{StaticResource labelStyle}" />
|
<Label x:Name="zipCodeLabel" Text="Zip Code" Style="{StaticResource labelStyle}" />
|
||||||
<Entry x:Name="zipCodeEntry" />
|
<Entry x:Name="zipCodeEntry" />
|
||||||
<Label x:Name="unitOfMeasureLabel" Text="Unit Of Measure" Style="{StaticResource labelStyle}" />
|
<Label x:Name="unitOfMeasureLabel" Text="Unit Of Measure" Style="{StaticResource labelStyle}" />
|
||||||
<Entry x:Name="unitOfMeasure" Placeholder="kelvin (default), metric, imperial"/>
|
<Picker x:Name="unitOfMeasure" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<StackLayout Padding="0,0,0,10" VerticalOptions="End">
|
<StackLayout Padding="0,0,0,10" VerticalOptions="End">
|
||||||
<Button x:Name="getWeatherBtn" Text="Get Weather" WidthRequest="185" BorderWidth="1" >
|
<Button x:Name="getWeatherBtn" Text="Get Weather" WidthRequest="185" BorderWidth="1" >
|
||||||
|
|
|
@ -12,14 +12,18 @@ namespace WeatherApp
|
||||||
getWeatherBtn.Clicked += GetWeatherBtn_Clicked;
|
getWeatherBtn.Clicked += GetWeatherBtn_Clicked;
|
||||||
|
|
||||||
//Set the default binding to a default object for now
|
//Set the default binding to a default object for now
|
||||||
this.BindingContext = new Weather();
|
this.BindingContext = Weather;
|
||||||
|
unitOfMeasure.ItemsSource = Weather.UnitOfMeasures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Weather Weather { get; } = new Weather();
|
||||||
|
|
||||||
private async void GetWeatherBtn_Clicked(object sender, EventArgs e)
|
private async void GetWeatherBtn_Clicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrEmpty(zipCodeEntry.Text))
|
if (!String.IsNullOrEmpty(zipCodeEntry.Text))
|
||||||
{
|
{
|
||||||
Weather weather = await Core.GetWeather(zipCodeEntry.Text, unitOfMeasure.Text);
|
|
||||||
|
Weather weather = await Core.GetWeather(zipCodeEntry.Text, (string)unitOfMeasure.SelectedItem);
|
||||||
if (weather != null)
|
if (weather != null)
|
||||||
{
|
{
|
||||||
this.BindingContext = weather;
|
this.BindingContext = weather;
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Samples
|
||||||
public class WeatherAppSample : ISample
|
public class WeatherAppSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms WeatherApp";
|
public string Title => "Xamarin.Forms WeatherApp";
|
||||||
|
public string Path => "/weatherapp";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -15,7 +16,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish("/weatherapp", CreateElement);
|
UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Samples
|
||||||
public class WebViewSample : ISample
|
public class WebViewSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms WebView Sample";
|
public string Title => "Xamarin.Forms WebView Sample";
|
||||||
|
public string Path => "/webview";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -35,7 +36,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish("/webview", CreateElement);
|
UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Samples
|
||||||
public class WrappingTextSample : ISample
|
public class WrappingTextSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms Wrapping Text";
|
public string Title => "Xamarin.Forms Wrapping Text";
|
||||||
|
public string Path => "/wrapping";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -82,7 +83,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
Ooui.UI.Publish("/wrapping", CreateElement);
|
Ooui.UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
const string shortText = "Lorem ipsum dolor sit amet.";
|
const string shortText = "Lorem ipsum dolor sit amet.";
|
||||||
|
|
|
@ -1,19 +1,28 @@
|
||||||
using System;
|
using Ooui;
|
||||||
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Xamarin.Forms.Xaml;
|
using Xamarin.Forms.Xaml;
|
||||||
|
using Color = Xamarin.Forms.Color;
|
||||||
|
using Label = Xamarin.Forms.Label;
|
||||||
|
|
||||||
namespace Samples
|
namespace Samples
|
||||||
{
|
{
|
||||||
public class XamlPreviewPageSample : ISample
|
public class XamlPreviewPageSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms XAML Editor";
|
public string Title => "Xamarin.Forms XAML Editor";
|
||||||
|
public string Path => "/xaml-editor";
|
||||||
|
|
||||||
public Ooui.Element CreateElement ()
|
public Ooui.Element CreateElement ()
|
||||||
{
|
{
|
||||||
var page = new XamlEditorPage ();
|
var page = new XamlEditorPage ();
|
||||||
return page.GetOouiElement ();
|
return page.GetOouiElement ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Publish()
|
||||||
|
{
|
||||||
|
UI.Publish(Path, CreateElement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class XamlEditorPage : ContentPage
|
public partial class XamlEditorPage : ContentPage
|
||||||
|
@ -107,7 +116,8 @@ namespace Samples
|
||||||
catch (OperationCanceledException) {
|
catch (OperationCanceledException) {
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
results.Content = new Label {
|
results.Content = new Label
|
||||||
|
{
|
||||||
TextColor = Color.DarkRed,
|
TextColor = Color.DarkRed,
|
||||||
FontSize = 12,
|
FontSize = 12,
|
||||||
Text = ex.ToString (),
|
Text = ex.ToString (),
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Xuzzle
|
||||||
this.Padding = new Thickness(3);
|
this.Padding = new Thickness(3);
|
||||||
this.Content = new Frame
|
this.Content = new Frame
|
||||||
{
|
{
|
||||||
OutlineColor = Color.Accent,
|
BorderColor = Color.Accent,
|
||||||
Padding = new Thickness(5, 10, 5, 0),
|
Padding = new Thickness(5, 10, 5, 0),
|
||||||
Content = new StackLayout
|
Content = new StackLayout
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Samples
|
||||||
public class XuzzleSample : ISample
|
public class XuzzleSample : ISample
|
||||||
{
|
{
|
||||||
public string Title => "Xamarin.Forms Xuzzle";
|
public string Title => "Xamarin.Forms Xuzzle";
|
||||||
|
public string Path => "/xuzzle";
|
||||||
|
|
||||||
public Ooui.Element CreateElement()
|
public Ooui.Element CreateElement()
|
||||||
{
|
{
|
||||||
|
@ -15,7 +16,7 @@ namespace Samples
|
||||||
|
|
||||||
public void Publish()
|
public void Publish()
|
||||||
{
|
{
|
||||||
UI.Publish("/xuzzle", CreateElement);
|
UI.Publish(Path, CreateElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue