public LabeledDetailCell() { Label = new Label { LineBreakMode = LineBreakMode.TailTruncation, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }; Detail = new Label { FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), LineBreakMode = LineBreakMode.TailTruncation, Style = (Style)Application.Current.Resources["text-muted"] }; Button = new ExtendedButton { WidthRequest = 60 }; var grid = new Grid { ColumnSpacing = 0, RowSpacing = 0, Padding = new Thickness(15, 3, 0, 3) }; grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(60, GridUnitType.Absolute) }); grid.Children.Add(Label, 0, 0); grid.Children.Add(Detail, 0, 1); grid.Children.Add(Button, 1, 0); Grid.SetRowSpan(Button, 2); if (Device.OS == TargetPlatform.Android) { Label.TextColor = Color.Black; } View = grid; }
public LabeledDetailCell() { Label = new Label { LineBreakMode = LineBreakMode.TailTruncation, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }; Detail = new Label { FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), LineBreakMode = LineBreakMode.TailTruncation, Style = (Style)Application.Current.Resources["text-muted"] }; var labelDetailStackLayout = new StackLayout { HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Children = { Label, Detail }, Padding = Device.OnPlatform( iOS: new Thickness(15, 5, 5, 5), Android: new Thickness(15, 0, 5, 5), WinPhone: new Thickness(15, 5, 5, 5)), Spacing = 0 }; Button = new ExtendedButton { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.CenterAndExpand, WidthRequest = 50 }; var containerStackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { labelDetailStackLayout, Button } }; if (Device.OS == TargetPlatform.Android) { Label.TextColor = Color.Black; } View = containerStackLayout; }
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 MemoryContentView() { _memoryService = Resolver.Resolve <IMemoryService>(); var grid = new Grid { Padding = 5, BackgroundColor = Color.White, RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto } }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = GridLength.Star }, new ColumnDefinition { Width = GridLength.Star } } }; grid.Children.Add(new Label { Text = "Used Memory:" }, 0, 0); grid.Children.Add(new Label { Text = "Free Memory:" }, 0, 1); grid.Children.Add(new Label { Text = "Heap Memory:" }, 0, 2); grid.Children.Add(new Label { Text = "Max Memory:" }, 0, 3); grid.Children.Add(new Label { Text = "% Used Heap:" }, 0, 4); grid.Children.Add(new Label { Text = "% Used Max:" }, 0, 5); UsedMemory = new Label { Text = "Used Memory:", HorizontalTextAlignment = TextAlignment.End }; FreeMemory = new Label { Text = "Free Memory:", HorizontalTextAlignment = TextAlignment.End }; HeapMemory = new Label { Text = "Heap Memory:", HorizontalTextAlignment = TextAlignment.End }; MaxMemory = new Label { Text = "Max Memory:", HorizontalTextAlignment = TextAlignment.End }; HeapUsage = new Label { Text = "% Used Heap:", HorizontalTextAlignment = TextAlignment.End }; TotalUsage = new Label { Text = "% Used Max:", HorizontalTextAlignment = TextAlignment.End }; grid.Children.Add(UsedMemory, 1, 0); grid.Children.Add(FreeMemory, 1, 1); grid.Children.Add(HeapMemory, 1, 2); grid.Children.Add(MaxMemory, 1, 3); grid.Children.Add(HeapUsage, 1, 4); grid.Children.Add(TotalUsage, 1, 5); var button = new ExtendedButton { Text = "Refresh", BackgroundColor = Color.Transparent }; button.Clicked += Button_Clicked; grid.Children.Add(button, 0, 6); Grid.SetColumnSpan(button, 2); Content = grid; RefreshScreen(); }
public LabeledDetailCell() { Icon = new CachedImage { WidthRequest = 20, HeightRequest = 20, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, ErrorPlaceholder = "login.png", CacheDuration = TimeSpan.FromDays(30), BitmapOptimizations = true }; Label = new Label { LineBreakMode = LineBreakMode.TailTruncation, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }; Detail = new Label { FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), LineBreakMode = LineBreakMode.TailTruncation, Style = (Style)Application.Current.Resources["text-muted"] }; LabelIcon = new CachedImage { WidthRequest = 16, HeightRequest = 16, HorizontalOptions = LayoutOptions.Start, Margin = new Thickness(5, 0, 0, 0) }; LabelIcon2 = new CachedImage { WidthRequest = 16, HeightRequest = 16, HorizontalOptions = LayoutOptions.Start, Margin = new Thickness(5, 0, 0, 0) }; Button = new ExtendedButton { WidthRequest = 60 }; var grid = new Grid { ColumnSpacing = 0, RowSpacing = 0, Padding = new Thickness(3, 3, 0, 3) }; grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(40, GridUnitType.Absolute) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(60, GridUnitType.Absolute) }); grid.Children.Add(Icon, 0, 0); grid.Children.Add(Label, 1, 0); grid.Children.Add(Detail, 1, 1); grid.Children.Add(LabelIcon, 2, 0); grid.Children.Add(LabelIcon2, 3, 0); grid.Children.Add(Button, 4, 0); Grid.SetRowSpan(Icon, 2); Grid.SetRowSpan(Button, 2); Grid.SetColumnSpan(Detail, 3); if (Device.RuntimePlatform == Device.Android) { Label.TextColor = Color.Black; } View = grid; }
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; }
public FormEntryCell( string labelText, Keyboard entryKeyboard = null, bool isPassword = false, VisualElement nextElement = null, bool useLabelAsPlaceholder = false, string imageSource = null, Thickness?containerPadding = null, bool useButton = false) { 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; } 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); if (useButton) { Button = new ExtendedButton(); imageStackLayout.Children.Add(Button); if (Device.OS == TargetPlatform.Android) { Button.Padding = new Thickness(0); Button.BackgroundColor = Color.Transparent; } } Tapped += FormEntryCell_Tapped; View = imageStackLayout; }