Scaffold ScrollViewRenderer

This commit is contained in:
Frank A. Krueger 2018-04-15 19:29:58 -07:00
parent f309cb9247
commit 95b76f3783
No known key found for this signature in database
GPG Key ID: 0471C67474FFE664
3 changed files with 48 additions and 13 deletions

View File

@ -16,23 +16,24 @@ using Xamarin.Forms;
[assembly: ExportRenderer (typeof (Label), typeof (LabelRenderer))] [assembly: ExportRenderer (typeof (Label), typeof (LabelRenderer))]
[assembly: ExportRenderer (typeof (LinkLabel), typeof (LinkLabelRenderer))] [assembly: ExportRenderer (typeof (LinkLabel), typeof (LinkLabelRenderer))]
[assembly: ExportRenderer (typeof (LinkView), typeof (LinkViewRenderer))] [assembly: ExportRenderer (typeof (LinkView), typeof (LinkViewRenderer))]
[assembly: ExportRenderer(typeof(Picker), typeof(PickerRenderer))] [assembly: ExportRenderer (typeof (Picker), typeof (PickerRenderer))]
[assembly: ExportRenderer(typeof(ListView), typeof(ListViewRenderer))] [assembly: ExportRenderer (typeof (ListView), typeof (ListViewRenderer))]
[assembly: ExportRenderer (typeof (ProgressBar), typeof (ProgressBarRenderer))] [assembly: ExportRenderer (typeof (ProgressBar), typeof (ProgressBarRenderer))]
[assembly: ExportRenderer (typeof (ScrollView), typeof (ScrollViewRenderer))]
[assembly: ExportRenderer (typeof (SearchBar), typeof (SearchBarRenderer))] [assembly: ExportRenderer (typeof (SearchBar), typeof (SearchBarRenderer))]
[assembly: ExportRenderer(typeof(Slider), typeof(SliderRenderer))] [assembly: ExportRenderer (typeof (Slider), typeof (SliderRenderer))]
[assembly: ExportRenderer (typeof (Switch), typeof (SwitchRenderer))] [assembly: ExportRenderer (typeof (Switch), typeof (SwitchRenderer))]
[assembly: ExportRenderer (typeof (TimePicker), typeof (TimePickerRenderer))] [assembly: ExportRenderer (typeof (TimePicker), typeof (TimePickerRenderer))]
[assembly: ExportRenderer(typeof(WebView), typeof(WebViewRenderer))] [assembly: ExportRenderer (typeof (WebView), typeof (WebViewRenderer))]
[assembly: ExportImageSourceHandler (typeof (FileImageSource), typeof (FileImageSourceHandler))] [assembly: ExportImageSourceHandler (typeof (FileImageSource), typeof (FileImageSourceHandler))]
[assembly: ExportImageSourceHandler (typeof (StreamImageSource), typeof (StreamImagesourceHandler))] [assembly: ExportImageSourceHandler (typeof (StreamImageSource), typeof (StreamImagesourceHandler))]
[assembly: ExportImageSourceHandler (typeof (UriImageSource), typeof (ImageLoaderSourceHandler))] [assembly: ExportImageSourceHandler (typeof (UriImageSource), typeof (ImageLoaderSourceHandler))]
[assembly: ExportCell(typeof(Cell), typeof(CellRenderer))] [assembly: ExportCell (typeof (Cell), typeof (CellRenderer))]
[assembly: ExportCell(typeof(EntryCell), typeof(EntryCellRenderer))] [assembly: ExportCell (typeof (EntryCell), typeof (EntryCellRenderer))]
[assembly: ExportCell(typeof(ImageCell), typeof(ImageCellRenderer))] [assembly: ExportCell (typeof (ImageCell), typeof (ImageCellRenderer))]
[assembly: ExportCell(typeof(SwitchCell), typeof(SwitchCellRenderer))] [assembly: ExportCell (typeof (SwitchCell), typeof (SwitchCellRenderer))]
[assembly: ExportCell(typeof(TextCell), typeof(TextCellRenderer))] [assembly: ExportCell (typeof (TextCell), typeof (TextCellRenderer))]
[assembly: ExportCell(typeof(ViewCell), typeof(ViewCellRenderer))] [assembly: ExportCell (typeof (ViewCell), typeof (ViewCellRenderer))]
namespace Ooui.Forms namespace Ooui.Forms
{ {
[AttributeUsage (AttributeTargets.Assembly, AllowMultiple = true)] [AttributeUsage (AttributeTargets.Assembly, AllowMultiple = true)]
@ -44,10 +45,10 @@ namespace Ooui.Forms
} }
} }
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] [AttributeUsage (AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class ExportCellAttribute : HandlerAttribute public sealed class ExportCellAttribute : HandlerAttribute
{ {
public ExportCellAttribute(Type handler, Type target) : base(handler, target) public ExportCellAttribute (Type handler, Type target) : base (handler, target)
{ {
} }
} }

View File

@ -0,0 +1,22 @@
using System;
using System.ComponentModel;
using Ooui.Forms.Extensions;
using Xamarin.Forms;
namespace Ooui.Forms.Renderers
{
public class ScrollViewRenderer : ViewRenderer<ScrollView, Div>
{
protected override void OnElementChanged (ElementChangedEventArgs<ScrollView> e)
{
base.OnElementChanged (e);
this.Style.Overflow = "scroll";
}
protected override void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged (sender, e);
}
}
}

View File

@ -23,6 +23,18 @@ namespace Samples
row1.Children.Add (new Label { Text = longText, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.End }); row1.Children.Add (new Label { Text = longText, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.End });
rows.Children.Add (row1); rows.Children.Add (row1);
var row0s = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.Azure };
row0s.Children.Add (new Label { Text = shortText, LineBreakMode = LineBreakMode.WordWrap, WidthRequest = 100 });
row0s.Children.Add (new Label { Text = mediumText, LineBreakMode = LineBreakMode.WordWrap, WidthRequest = 100 });
row0s.Children.Add (new Label { Text = longText, LineBreakMode = LineBreakMode.WordWrap, WidthRequest = 100 });
rows.Children.Add (new ScrollView { Content = row0s });
var row1s = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.GhostWhite };
row1s.Children.Add (new Label { Text = shortText, FontAttributes = FontAttributes.Bold, WidthRequest = 100, HorizontalOptions = LayoutOptions.Start });
row1s.Children.Add (new Label { Text = mediumText, FontAttributes = FontAttributes.Bold, WidthRequest = 100, HorizontalOptions = LayoutOptions.FillAndExpand });
row1s.Children.Add (new Label { Text = longText, FontAttributes = FontAttributes.Bold, WidthRequest = 100, HorizontalOptions = LayoutOptions.End });
rows.Children.Add (new ScrollView { Content = row1s });
var row2 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.Azure }; var row2 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.Azure };
row2.Children.Add (new Entry { Text = shortText, FontSize = 8, VerticalOptions = LayoutOptions.Center }); row2.Children.Add (new Entry { Text = shortText, FontSize = 8, VerticalOptions = LayoutOptions.Center });
row2.Children.Add (new Entry { Text = shortText, FontSize = 16, VerticalOptions = LayoutOptions.Center }); row2.Children.Add (new Entry { Text = shortText, FontSize = 16, VerticalOptions = LayoutOptions.Center });
@ -49,7 +61,7 @@ namespace Samples
row5.Children.Add (new Button { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }); row5.Children.Add (new Button { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold });
rows.Children.Add (row5); rows.Children.Add (row5);
var row6 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.GhostWhite }; var row6 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.Azure };
row6.Children.Add (new DatePicker { VerticalOptions = LayoutOptions.Center }); row6.Children.Add (new DatePicker { VerticalOptions = LayoutOptions.Center });
row6.Children.Add (new TimePicker { VerticalOptions = LayoutOptions.Center }); row6.Children.Add (new TimePicker { VerticalOptions = LayoutOptions.Center });
rows.Children.Add (row6); rows.Children.Add (row6);