Ooui-tws-port/Samples/SamplePicker.cs

56 lines
1.4 KiB
C#
Raw Normal View History

2018-09-02 04:56:35 +00:00
using System.Collections.Generic;
using System.Linq;
using Ooui;
using Ooui.Forms;
using Xamarin.Forms;
using Element = Ooui.Element;
namespace Samples
{
2019-03-21 22:01:16 +00:00
public class SamplePicker : ISample
2018-09-02 04:56:35 +00:00
{
private readonly IEnumerable<ISample> _samplePages;
2019-03-21 22:01:16 +00:00
public SamplePicker(IEnumerable<ISample> samplePages)
2018-09-02 04:56:35 +00:00
{
_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()
{
2023-03-17 08:08:32 +00:00
PageExtensions.Ui.Publish(Path,CreateElement);
2018-09-02 04:56:35 +00:00
}
}
}