public FormEditorCell(Keyboard entryKeyboard = null, double?height = null) { Editor = new ExtendedEditor { Keyboard = entryKeyboard, HasBorder = false, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Editor)) }; if (height.HasValue) { Editor.HeightRequest = height.Value; } var stackLayout = new StackLayout { Padding = new Thickness(15, 10) }; stackLayout.Children.Add(Editor); Tapped += FormEditorCell_Tapped; Editor.AdjustMarginsForDevice(); stackLayout.AdjustPaddingForDevice(); View = stackLayout; }
public SliderViewCell( ToolsPasswordGeneratorPage page, IPasswordGenerationService passwordGenerationService, ISettings settings) { _page = page; _passwordGenerationService = passwordGenerationService; _settings = settings; var label = new Label { FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Text = AppResources.Length, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.CenterAndExpand }; LengthSlider = new Slider(5, 64, _settings.GetValueOrDefault(Constants.PasswordGeneratorLength, 10)) { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, MaximumTrackColor = Color.LightGray, MinimumTrackColor = Color.LightGray, }; Value = new Label { FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.CenterAndExpand, Style = (Style)Application.Current.Resources["text-muted"], FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", Windows: "Courier"), }; Value.SetBinding(Label.TextProperty, nameof(PasswordGeneratorPageModel.Length)); var stackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, Spacing = 15, Children = { label, LengthSlider, Value }, Padding = Helpers.OnPlatform( iOS: new Thickness(15, 8), Android: new Thickness(16, 10), Windows: new Thickness(15, 8)) }; stackLayout.AdjustPaddingForDevice(); if (Device.RuntimePlatform == Device.Android) { label.TextColor = Color.Black; } View = stackLayout; }
public SliderViewCell( ToolsPasswordGeneratorPage page, IPasswordGenerationService passwordGenerationService, ISettings settings) { _page = page; _passwordGenerationService = passwordGenerationService; _settings = settings; var label = new Label { FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Text = "Length", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.CenterAndExpand }; LengthSlider = new Slider(5, 64, _settings.GetValueOrDefault(Constants.PasswordGeneratorLength, 10)) { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; Value = new Label { FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.CenterAndExpand, Style = (Style)Application.Current.Resources["text-muted"] }; Value.SetBinding <PasswordGeneratorPageModel>(Label.TextProperty, m => m.Length); LengthSlider.ValueChanged += Slider_ValueChanged; var stackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, Spacing = 15, Children = { label, LengthSlider, Value }, Padding = Device.OnPlatform( iOS: new Thickness(15, 8), Android: new Thickness(16, 10), WinPhone: new Thickness(15, 8)) }; stackLayout.AdjustPaddingForDevice(); if (Device.OS == TargetPlatform.Android) { label.TextColor = Color.Black; } View = stackLayout; }
public ToolsViewCell(string labelText, string detailText, string imageSource) { var label = new Label { FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), LineBreakMode = LineBreakMode.TailTruncation, Text = labelText }; var detail = new Label { FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), LineBreakMode = LineBreakMode.WordWrap, Style = (Style)Application.Current.Resources["text-muted"], Text = detailText }; if (Device.OS == TargetPlatform.Android) { label.TextColor = Color.Black; } var labelDetailStackLayout = new StackLayout { HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Children = { label, detail }, Spacing = 0 }; var image = new Image { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.FillAndExpand, Source = imageSource, Margin = new Thickness(0, 0, 10, 0) }; var containerStackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { image, labelDetailStackLayout }, Padding = Device.OnPlatform( iOS: new Thickness(15, 25), Android: new Thickness(15, 20), WinPhone: new Thickness(15, 25)) }; containerStackLayout.AdjustPaddingForDevice(); ShowDisclousure = true; View = containerStackLayout; }
public StepperCell(string labelText, double value, double min, double max, double increment, Action changed = null) { _changedAction = changed; Label = new Label { Text = labelText, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.CenterAndExpand, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }; StepperValueLabel = new Label { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalTextAlignment = TextAlignment.Start, Text = value.ToString(), Style = (Style)Application.Current.Resources["text-muted"], FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }; Stepper = new Stepper { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.CenterAndExpand, Minimum = min, Maximum = max, Increment = increment, Value = value }; var stackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { Label, StepperValueLabel, Stepper }, Spacing = 15, Padding = Helpers.OnPlatform( iOS: new Thickness(15, 8), Android: new Thickness(15, 2), Windows: new Thickness(15, 8)) }; if (Device.RuntimePlatform == Device.Android) { Label.TextColor = Color.Black; } stackLayout.AdjustPaddingForDevice(); View = stackLayout; }
public FormPickerCell(string labelText, string[] pickerItems) { Label = new Label { Text = labelText, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), TextColor = Color.FromHex("777777") }; Picker = new ExtendedPicker { HasBorder = false }; foreach (var item in pickerItems) { Picker.Items.Add(item); } Picker.SelectedIndex = 0; var stackLayout = new StackLayout { Padding = new Thickness(15, 10), VerticalOptions = LayoutOptions.CenterAndExpand }; stackLayout.Children.Add(Label); stackLayout.Children.Add(Picker); if (Device.OS == TargetPlatform.Android) { stackLayout.Spacing = 0; } Picker.AdjustMarginsForDevice(); stackLayout.AdjustPaddingForDevice(); Tapped += FormPickerCell_Tapped; View = stackLayout; }
public FormSwitchCell(string labelText, string button1 = null) { Label = new Label { Text = labelText, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, TextColor = Color.Black, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), }; Switch = new Switch { VerticalOptions = LayoutOptions.Center }; var stackLayout = new StackLayout { Padding = new Thickness(15, 5), Orientation = StackOrientation.Horizontal, Children = { Label, Switch } }; stackLayout.AdjustPaddingForDevice(); if (!string.IsNullOrWhiteSpace(button1)) { Button1 = new ExtendedButton { Image = button1 }; stackLayout.Children.Add(Button1); Button1.BackgroundColor = Color.Transparent; Button1.Padding = new Thickness(0); Button1.WidthRequest = 40; Button1.VerticalOptions = LayoutOptions.FillAndExpand; } View = stackLayout; }
public LabeledValueCell( string labelText = null, string valueText = null, string button1Text = null, string button2Text = null) { var containerStackLayout = new StackLayout { Padding = new Thickness(15, 10), Orientation = StackOrientation.Horizontal }; var labelValueStackLayout = new StackLayout { HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; if (labelText != null) { Label = new Label { Text = labelText, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"] }; labelValueStackLayout.Children.Add(Label); } Value = new Label { Text = valueText, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), LineBreakMode = LineBreakMode.TailTruncation }; if (Device.OS == TargetPlatform.Android) { Value.TextColor = Color.Black; } labelValueStackLayout.Children.Add(Value); containerStackLayout.Children.Add(labelValueStackLayout); var buttonStackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.CenterAndExpand }; if (button1Text != null) { Button1 = new ExtendedButton { Text = button1Text, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(0) }; buttonStackLayout.Children.Add(Button1); } if (button2Text != null) { Button2 = new ExtendedButton { Text = button2Text, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(0) }; buttonStackLayout.Children.Add(Button2); } if (Device.OS == TargetPlatform.Android) { buttonStackLayout.Spacing = 5; if (Button1 != null) { Button1.Padding = new Thickness(0); Button1.BackgroundColor = Color.Transparent; } if (Button2 != null) { Button2.Padding = new Thickness(0); Button2.BackgroundColor = Color.Transparent; } containerStackLayout.AdjustPaddingForDevice(); } containerStackLayout.Children.Add(buttonStackLayout); View = containerStackLayout; }
public FormEntryCell( string labelText, Keyboard entryKeyboard = null, bool isPassword = false, VisualElement nextElement = null, bool useLabelAsPlaceholder = false, string imageSource = null, Thickness?containerPadding = null, string button1 = null, string button2 = null) { if (!useLabelAsPlaceholder) { Label = new Label { Text = labelText, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"], HorizontalOptions = LayoutOptions.FillAndExpand }; } Entry = new ExtendedEntry { Keyboard = entryKeyboard, HasBorder = false, IsPassword = isPassword, AllowClear = true, HorizontalOptions = LayoutOptions.FillAndExpand, WidthRequest = 1, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Entry)) }; if (useLabelAsPlaceholder) { Entry.Placeholder = labelText; } NextElement = nextElement; var imageStackLayout = new StackLayout { Padding = containerPadding ?? new Thickness(15, 10), Orientation = StackOrientation.Horizontal, Spacing = 10, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; if (imageSource != null) { _tgr = new TapGestureRecognizer(); var theImage = new CachedImage { Source = imageSource, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, WidthRequest = 18, HeightRequest = 18 }; theImage.GestureRecognizers.Add(_tgr); imageStackLayout.Children.Add(theImage); } var formStackLayout = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; if (!useLabelAsPlaceholder) { formStackLayout.Children.Add(Label); } formStackLayout.Children.Add(Entry); imageStackLayout.Children.Add(formStackLayout); if (!string.IsNullOrWhiteSpace(button1) || !string.IsNullOrWhiteSpace(button2)) { _buttonStackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.CenterAndExpand, Spacing = 5 }; imageStackLayout.Children.Add(_buttonStackLayout); if (!string.IsNullOrWhiteSpace(button1)) { Button1 = new ExtendedButton { Image = button1 }; _buttonStackLayout.Children.Add(Button1); Button1.Padding = new Thickness(0); Button1.BackgroundColor = Color.Transparent; Button1.VerticalOptions = LayoutOptions.End; } if (!string.IsNullOrWhiteSpace(button2)) { Button2 = new ExtendedButton { Image = button2 }; _buttonStackLayout.Children.Add(Button2); Button2.Padding = new Thickness(0); Button2.BackgroundColor = Color.Transparent; Button2.VerticalOptions = LayoutOptions.End; } } if (Device.RuntimePlatform == Device.Android) { var deviceInfo = Resolver.Resolve <IDeviceInfoService>(); if (useLabelAsPlaceholder) { if (deviceInfo.Version < 21) { Entry.Margin = new Thickness(-9, 1, -9, 0); } else if (deviceInfo.Version == 21) { Entry.Margin = new Thickness(0, 4, 0, -4); } } else { Entry.AdjustMarginsForDevice(); } if (containerPadding == null) { imageStackLayout.AdjustPaddingForDevice(); } } else if (Device.RuntimePlatform == Device.UWP) { if (_buttonStackLayout != null) { _buttonStackLayout.Spacing = 0; } } View = imageStackLayout; }
public FormEntryCell( string labelText, Keyboard entryKeyboard = null, bool IsPassword = false, VisualElement nextElement = null, bool useLabelAsPlaceholder = false, string imageSource = null, Thickness?containerPadding = null) { if (!useLabelAsPlaceholder) { Label = new Label { Text = labelText, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"], HorizontalOptions = LayoutOptions.FillAndExpand }; } Entry = new ExtendedEntry { Keyboard = entryKeyboard, HasBorder = false, IsPassword = IsPassword, AllowClear = true, HorizontalOptions = LayoutOptions.FillAndExpand, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Entry)) }; if (useLabelAsPlaceholder) { Entry.Placeholder = labelText; } if (nextElement != null) { Entry.ReturnType = Enums.ReturnType.Next; Entry.Completed += (object sender, EventArgs e) => { nextElement.Focus(); }; } var imageStackLayout = new StackLayout { Padding = containerPadding ?? new Thickness(15, 10), Orientation = StackOrientation.Horizontal, Spacing = 10, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; if (imageSource != null) { var tgr = new TapGestureRecognizer(); tgr.Tapped += Tgr_Tapped; var theImage = new Image { Source = imageSource, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center }; theImage.GestureRecognizers.Add(tgr); imageStackLayout.Children.Add(theImage); } var formStackLayout = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; if (Device.OS == TargetPlatform.Android) { var deviceInfo = Resolver.Resolve <IDeviceInfoService>(); if (useLabelAsPlaceholder) { if (deviceInfo.Version < 21) { Entry.Margin = new Thickness(-9, 1, -9, 0); } else if (deviceInfo.Version == 21) { Entry.Margin = new Thickness(0, 4, 0, -4); } } else { Entry.AdjustMarginsForDevice(); } if (containerPadding == null) { imageStackLayout.AdjustPaddingForDevice(); } } if (!useLabelAsPlaceholder) { formStackLayout.Children.Add(Label); } formStackLayout.Children.Add(Entry); imageStackLayout.Children.Add(formStackLayout); Tapped += FormEntryCell_Tapped; View = imageStackLayout; }
public LabeledValueCell( string labelText = null, string valueText = null, string button1Image = null, string button2Image = null, string subText = null) { var containerStackLayout = new StackLayout { Padding = new Thickness(15, 10), Orientation = StackOrientation.Horizontal }; var labelValueStackLayout = new StackLayout { HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; if (labelText != null) { Label = new Label { Text = labelText, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"] }; labelValueStackLayout.Children.Add(Label); } Value = new Label { Text = valueText, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), LineBreakMode = LineBreakMode.TailTruncation }; if (Device.RuntimePlatform == Device.Android) { Value.TextColor = Color.Black; } labelValueStackLayout.Children.Add(Value); containerStackLayout.Children.Add(labelValueStackLayout); var buttonStackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.CenterAndExpand, Spacing = 5 }; if (subText != null) { Sub = new Label { FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center }; buttonStackLayout.Children.Add(Sub); } if (button1Image != null) { Button1 = new ExtendedButton { Image = button1Image, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.FillAndExpand, Margin = new Thickness(0), Padding = new Thickness(0), BackgroundColor = Color.Transparent, WidthRequest = 40 }; buttonStackLayout.Children.Add(Button1); } if (button2Image != null) { Button2 = new ExtendedButton { Image = button2Image, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.FillAndExpand, Margin = new Thickness(0), Padding = new Thickness(0), BackgroundColor = Color.Transparent, WidthRequest = 40 }; buttonStackLayout.Children.Add(Button2); } if (Device.RuntimePlatform == Device.Android) { containerStackLayout.AdjustPaddingForDevice(); } else if (Device.RuntimePlatform == Device.UWP) { buttonStackLayout.Spacing = 0; if (Button1 != null) { Button1.BackgroundColor = Color.Transparent; } if (Button2 != null) { Button2.BackgroundColor = Color.Transparent; } } if (Sub != null && Button1 != null) { Sub.Margin = new Thickness(0, 0, 10, 0); } containerStackLayout.Children.Add(buttonStackLayout); View = containerStackLayout; }