private static Cell GetButtonRow(ButtonRow buttonRow, double topMargin) { CustomViewCell cell = new CustomViewCell() { ShowSelection = false }; Button rowButton = new Button { HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center, BackgroundColor = Color.Transparent, BorderColor = CustomColors.LinkBlueColor, BorderWidth = 1, CornerRadius = 6, #if __IOS_ HeightRequest = 30, #else HeightRequest = 32, #endif // #if __IOS_ WidthRequest = 150, Text = buttonRow.Text, FontSize = PlatformsConstants.TableViewFieldEntryFontSize, TextColor = CustomColors.LinkBlueColor, }; rowButton.Clicked += (sender, e) => buttonRow.RowTappedAction?.Invoke(e); Grid grid = new Grid { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Margin = new Thickness(15, topMargin, 0, 10), RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, }, ColumnDefinitions = { new ColumnDefinition { Width = GridLength.Star }, } }; grid.Children.Add(rowButton, 0, 0); cell.View = grid; return(cell); }
private static Cell GetNotesRow(NotesRow notesRow) { Label label = new Label { Text = notesRow.Title.ToUpper(), HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center, TextColor = CustomColors.LightSharkonColor, FontSize = PlatformsConstants.TableViewFieldLabelFontSize, Margin = new Thickness(0, 5, 0, 0), }; Editor editor = new Editor() { Text = notesRow.Text, Keyboard = Keyboard.Default, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Start, HeightRequest = 75, Margin = new Thickness(0, -5, 0, 0), FontSize = PlatformsConstants.TableViewFieldEntryFontSize, }; StackLayout stackLayout = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Margin = new Thickness(15, 0, 15, 0), Spacing = 7, Children = { label, editor, }, }; CustomViewCell viewCell = new CustomViewCell() { View = stackLayout, ShowSelection = false }; editor.TextChanged += (sender, e) => notesRow.TextChangedAction?.Invoke(sender, e); editor.Focused += (sender, e) => notesRow.OnFocusAction?.Invoke(e); editor.Unfocused += (sender, e) => notesRow.OnUnfocusAction?.Invoke(e); return(viewCell); }
protected override void OnCellPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnCellPropertyChanged(sender, e); if (e.PropertyName == "IsSelected") { isSelected = !isSelected; if (isSelected) { CustomViewCell customViewCell = sender as CustomViewCell; unchangedCell.SetBackgroundColor(customViewCell.SelectedBackgroundColor.ToAndroid()); } else { unchangedCell.SetBackground(unselectedBackground); } } }
private void SetStyle(CustomViewCell formsCell) { //added this code as sometimes on tap, the separator disappears, if style is updated before tap animation finishes //https://stackoverflow.com/questions/25613117/how-do-you-prevent-uitableviewcellselectionstylenone-from-removing-cell-separato Device.StartTimer(TimeSpan.FromMilliseconds(50), () => { Device.BeginInvokeOnMainThread(() => { if (formsCell.AllowHighlight) { _nativeCell.SelectionStyle = UITableViewCellSelectionStyle.Default; } else { _nativeCell.SelectionStyle = UITableViewCellSelectionStyle.None; } }); return(false); }); }
public void UpdateCell(CustomViewCell cell) { Console.WriteLine(cell.View); }
public NativeAndroidCell(Context context, CustomViewCell cell) : base(context) { Console.WriteLine("Hello there native android cell."); }
void ConfigureScreen() { NavBar = BaseContentPage.Instance.ConfigureNavBar("Adicionar carro", true); SearchEntry = new RoundedBorderedEntry() { CenteredPlaceholder = true, PlaceholderColor = ColorPalette.DarkBlue, Placeholder = "Qual a marca do seu carro?".ToUpper(), FontAttributes = FontAttributes.Bold, FontSize = 15, TextColor = ColorPalette.DarkBlue, BorderColor = ColorPalette.DarkBlue, BorderWidth = App.ScreenWidth / 72, HorizontalOptions = LayoutOptions.FillAndExpand, }; SearchIcon = new Icon() { HeightRequest = 25, WidthRequest = 25, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.StartAndExpand, Margin = new Thickness(15, 0, 0, 0), Color = ColorPalette.DarkBlue, FileName = "search.svg", }; SearchIcon.SetBinding(VisualElement.IsVisibleProperty, new Binding(nameof(SearchEntry.Text), source: SearchEntry, converter: new ValueConverter((text) => string.IsNullOrWhiteSpace((string)text)))); SearchGrid = new Grid() { HorizontalOptions = LayoutOptions.FillAndExpand, Margin = new Thickness(20, 30, 20, 30), }; SearchGrid.RowDefinitions.Add(new RowDefinition()); SearchGrid.ColumnDefinitions.Add(new ColumnDefinition()); Label textSubtitleLabel = new Label() { Text = "Marcas populares", FontSize = 14, TextColor = ColorPalette.Gray, Margin = new Thickness(20, 0, 0, 0), HorizontalOptions = LayoutOptions.FillAndExpand }; RoundedBorderedLabel subtitleLabel = new RoundedBorderedLabel(textSubtitleLabel, Color.Transparent, 0, ColorPalette.ExtraLightGray, new Thickness(0, 5), 0) { HorizontalOptions = LayoutOptions.FillAndExpand }; subtitleLabel.Content.HorizontalOptions = subtitleLabel.HorizontalOptions; int counter = 0; optionsList = new CarSelectionList() { ItemsSource = ViewModel.BrandOptions, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, ItemTemplate = new DataTemplate(() => { var option = ViewModel.BrandOptions[counter]; CustomLabel label = new CustomLabel() { VerticalTextAlignment = TextAlignment.Center, CustomPadding = new Thickness(10, 0, 0, 0), Text = option.Name, FontSize = 16, TextColor = option == ViewModel.SelectedBrand ? ColorPalette.Pink : ColorPalette.Gray, FontAttributes = FontAttributes.Bold, BackgroundColor = Color.White }; CustomViewCell cell = new CustomViewCell(label) { View = label, SelectedTextColor = ColorPalette.Pink, NormalTextColor = label.TextColor, }; counter++; return(cell); }) }; optionsList.SetBinding(ListView.SelectedItemProperty, new Binding(nameof(ViewModel.SelectedBrand))); //optionsList.ItemTapped += ViewModel.OnItemTapped; if (App.IsAndroidSDKBelowMarshmallow) { optionsList.ItemSelected += (sender, args) => { ViewModel.SelectedBrand = args.SelectedItem as CarFilterInfo; optionsList.Layout(optionsList.Bounds); } } ; Button confirmatioButton = new Button() { BackgroundColor = ColorPalette.LightBlue, TextColor = Color.White, FontAttributes = FontAttributes.Bold, Text = "Continuar".ToUpper(), //Margin = new Thickness(50, 0, 50, 30), FontSize = 18, VerticalOptions = LayoutOptions.End, //Padding = new Thickness(10), BorderRadius = 18, Margin = 10, HeightRequest = 55, Command = ViewModel.SelectOption }; Children.Clear(); Children.Add(NavBar); Children.Add(SearchEntry); Children.Add(SearchGrid); Children.Add(subtitleLabel); Children.Add(optionsList); Children.Add(confirmatioButton); SearchEntry.SizeChanged += OnSearchSizeChanged; SearchEntry.Completed += OnTextChanged; }
public SwipeRecogniserDelegate(CustomViewCell customViewCell) { this.customViewCell = customViewCell; }
private static Cell GetEntryRow(EditorRow editorRow) { Grid grid = new Grid() { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Margin = new Thickness(15, 0, 15, 0), RowDefinitions = { new RowDefinition { Height = PlatformsConstants.RowHeight }, }, }; Label label = new Label { Text = editorRow.Title.ToUpper(), HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, TextColor = CustomColors.LinkBlueColor, FontSize = PlatformsConstants.TableViewFieldLabelFontSize, }; CustomEntry entry = new CustomEntry { Text = editorRow.Text, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, Keyboard = editorRow.Keyboard, TextColor = CustomColors.DarkSharkonColor, FontSize = PlatformsConstants.TableViewFieldEntryFontSize, }; if (label.Text.Contains("EMAIL")) { entry.ValidationRegex = new Regex(@"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase | RegexOptions.Compiled); } StackLayout stackLayout = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 7, Children = { label, entry, }, }; grid.Children.Add(stackLayout, 0, 0); CustomViewCell viewCell = new CustomViewCell() { View = grid, ShowSelection = false }; TapGestureRecognizer labelTapGestureRecognizer = new TapGestureRecognizer() { Command = new Command((obj) => editorRow.RowTappedAction?.Invoke(null)), NumberOfTapsRequired = 1, }; label.GestureRecognizers.Add(labelTapGestureRecognizer); entry.Focused += (sender, e) => editorRow.OnFocusAction?.Invoke(e); entry.Unfocused += (sender, e) => editorRow.OnUnfocusAction?.Invoke(e); entry.TextChanged += (sender, e) => editorRow.TextChangedAction?.Invoke(sender, e); return(viewCell); }
private static Cell GetPickerRow(PickerRow pickerRow) { Grid grid = new Grid() { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Margin = new Thickness(15, 0, 15, 0), RowDefinitions = { new RowDefinition { Height = PlatformsConstants.RowHeight }, }, }; Label label = new Label { Text = pickerRow.Title.ToUpper(), HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, TextColor = CustomColors.LightSharkonColor, FontSize = PlatformsConstants.TableViewFieldLabelFontSize, }; Label pickerLabel = new Label { Text = pickerRow.Title.ToUpper(), HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, TextColor = CustomColors.LightSharkonColor, FontSize = PlatformsConstants.TableViewFieldLabelFontSize, }; Picker picker = new Picker() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, TextColor = CustomColors.DarkSharkonColor, }; picker.ItemsSource = pickerRow.Items.DisplayItems; if (pickerRow.SelectedIndex == -1) { picker.SelectedIndex = 0; } else { picker.SelectedIndex = pickerRow.SelectedIndex; } picker.SelectedIndexChanged += (sender, e) => pickerRow.SelectedIndexChanged?.Invoke(sender, e); CustomEntry newFieldEntry = new CustomEntry() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, Placeholder = "New " + pickerRow.Title, TextColor = CustomColors.DarkSharkonColor, FontSize = PlatformsConstants.TableViewFieldEntryFontSize, }; Image deleteFieldButton = new Image { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, Source = deleteImageSource, Aspect = Aspect.AspectFill, WidthRequest = 24, HeightRequest = 24, }; StackLayout editStack = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(0, -5, 0, 0), Children = { newFieldEntry, deleteFieldButton, }, }; StackLayout pickerStack = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 7, IsVisible = false, Children = { pickerLabel, editStack, }, }; StackLayout stackLayout = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 7, Children = { label, picker, }, }; grid.Children.Add(stackLayout, 0, 0); grid.Children.Add(pickerStack, 0, 0); picker.SelectedIndexChanged += (sender, e) => { if (picker.SelectedIndex != -1 && picker.SelectedIndex == picker.Items.Count - 1) { Device.BeginInvokeOnMainThread(() => { pickerStack.IsVisible = true; stackLayout.IsVisible = false; newFieldEntry.Focus(); Action <object, EventArgs> CompletedAction = ((obj, eventArgs) => { if (!String.IsNullOrEmpty(newFieldEntry.Text)) { pickerRow.Items.AddItem(newFieldEntry.Text); picker.ItemsSource = pickerRow.Items.DisplayItems; picker.SelectedIndex = picker.Items.Count - 2; } else { if (pickerRow.SelectedIndex == -1) { picker.SelectedIndex = 0; } else { picker.SelectedIndex = pickerRow.SelectedIndex; } } stackLayout.IsVisible = true; pickerStack.IsVisible = false; picker.Focus(); }); newFieldEntry.Completed += (obj, eventArgs) => CompletedAction(obj, eventArgs); deleteFieldButton.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { if (pickerRow.SelectedIndex == -1) { picker.SelectedIndex = 0; } else { picker.SelectedIndex = pickerRow.SelectedIndex; } newFieldEntry.Unfocus(); stackLayout.IsVisible = true; pickerStack.IsVisible = false; picker.Focus(); }) }); }); } }; CustomViewCell viewCell = new CustomViewCell() { View = grid, ShowSelection = false }; return(viewCell); }