public IconEntry() { InitializeComponent(); EntryField.BindingContext = this; EntryField.Focused += async(s, a) => { HiddenBottomBorder.BackgroundColor = AccentColor; if (string.IsNullOrEmpty(EntryField.Text)) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200) ); } else { await HiddenBottomBorder.LayoutTo(new Rectangle( BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height ), 200); } }; EntryField.Unfocused += async(s, a) => { if (string.IsNullOrEmpty(EntryField.Text)) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 200) ); } else { await HiddenBottomBorder.LayoutTo(new Rectangle( BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height ), 200); } }; }
public MaterialDatePicker() { InitializeComponent(); EntryField.BindingContext = this; BottomBorder.BackgroundColor = DefaultColor; EntryField.Focused += (s, a) => { Device.BeginInvokeOnMainThread(() => { EntryField.Unfocus(); Picker.Focus(); }); }; Picker.Focused += async(s, a) => { HiddenBottomBorder.BackgroundColor = AccentColor; HiddenLabel.TextColor = AccentColor; HiddenLabel.IsVisible = true; if (string.IsNullOrEmpty(EntryField.Text)) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200), HiddenLabel.FadeTo(1, 60), HiddenLabel.TranslateTo(HiddenLabel.TranslationX, EntryField.Y - EntryField.Height + 4, 200, Easing.BounceIn) ); EntryField.Placeholder = null; } else { await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200); } }; Picker.Unfocused += async(s, a) => { if (IsValid) { HiddenLabel.TextColor = DefaultColor; } Picker_DateSelected(s, new DateChangedEventArgs(Picker.Date, Picker.Date)); if (string.IsNullOrEmpty(EntryField.Text)) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 200), HiddenLabel.FadeTo(0, 180), HiddenLabel.TranslateTo(HiddenLabel.TranslationX, EntryField.Y, 200, Easing.BounceIn) ); EntryField.Placeholder = Placeholder; } else { await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 200); } }; Picker.DateSelected += Picker_DateSelected; }
public MaterialEntry() { InitializeComponent(); floatingLabelEntry.PlaceholderToTitleAsync += (sender, e) => HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200); floatingLabelEntry.TitleToPlaceholderAsync += (sender, e) => HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 200); }
public MaterialPicker() { InitializeComponent(); Picker.BindingContext = this; BottomBorder.BackgroundColor = DefaultColor; // TODO: Possible memory leak? Picker.SelectedIndexChanged += (sender, e) => { SelectedIndexChangedCommand?.Execute(Picker.SelectedItem); SelectedIndexChanged?.Invoke(sender, e); }; Picker.Focused += async(s, a) => { HiddenBottomBorder.BackgroundColor = AccentColor; HiddenLabel.TextColor = AccentColor; HiddenLabel.IsVisible = true; if (Picker.SelectedItem == null) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200), HiddenLabel.FadeTo(1, 60), HiddenLabel.TranslateTo(HiddenLabel.TranslationX, Picker.Y - Picker.Height + 4, 200, Easing.BounceIn) ); Picker.Title = null; } else { await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200); } }; Picker.Unfocused += async(s, a) => { EntryUnfocused?.Invoke(this, a); HiddenLabel.TextColor = DefaultColor; if (Picker.SelectedItem == null) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 200), HiddenLabel.FadeTo(0, 180), HiddenLabel.TranslateTo(HiddenLabel.TranslationX, Picker.Y, 200, Easing.BounceIn) ); Picker.Title = Placeholder; } else { await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 200); } }; }
public MaterialTimePicker() { InitializeComponent(); EntryField.BindingContext = this; EntryField.Focused += (s, a) => { EntryField.Unfocus(); Picker.Focus(); }; Picker.Focused += async(s, a) => { HiddenBottomBorder.BackgroundColor = AccentColor; HiddenLabel.TextColor = AccentColor; HiddenLabel.IsVisible = true; if (string.IsNullOrEmpty(EntryField.Text)) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200), HiddenLabel.FadeTo(1, 60), HiddenLabel.TranslateTo(HiddenLabel.TranslationX, EntryField.Y - EntryField.Height + 4, 200, Easing.BounceIn) ); EntryField.Placeholder = null; } else { await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200); } }; Picker.Unfocused += async(s, a) => { HiddenLabel.TextColor = Color.Gray; if (Time == null) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 200), HiddenLabel.FadeTo(0, 180), HiddenLabel.TranslateTo(HiddenLabel.TranslationX, EntryField.Y, 200, Easing.BounceIn) ); EntryField.Placeholder = Placeholder; } else { await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 200); } }; Picker.PropertyChanged += Picker_PropertyChanged;; }
public FloatingEntry() { InitializeComponent(); EntryField.BindingContext = this; EntryField.PlaceholderColor = Color.White; EntryField.Focused += async(s, a) => { HiddenBottomBorder.BackgroundColor = AccentColor; EntryField.TextColor = HiddenLabel.TextColor = AccentColor; HiddenLabel.IsVisible = true; if (string.IsNullOrEmpty(EntryField.Text)) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height + 2), 200), HiddenLabel.FadeTo(1, 120), HiddenLabel.TranslateTo(HiddenLabel.TranslationX - 13, EntryField.Y - EntryField.Height + 4, 200, Easing.BounceIn) ); EntryField.Placeholder = null; } else { await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200); } }; EntryField.Unfocused += async(s, a) => { if (string.IsNullOrEmpty(EntryField.Text)) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height + 2), 200), HiddenLabel.FadeTo(0, 180), HiddenLabel.TranslateTo(HiddenLabel.TranslationX + 13, EntryField.Y, 50, Easing.BounceIn) ); EntryField.Placeholder = Placeholder; } else { await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 100); } //HiddenLabel.TextColor = Color.Gray; }; }
public MaterialPicker() { InitializeComponent(); Picker.BindingContext = this; Picker.Focused += async(s, a) => { HiddenBottomBorder.BackgroundColor = AccentColor; HiddenLabel.TextColor = AccentColor; HiddenLabel.IsVisible = true; if (Picker.SelectedItem == null) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200), HiddenLabel.FadeTo(1, 60), HiddenLabel.TranslateTo(HiddenLabel.TranslationX, Picker.Y - Picker.Height + 4, 200, Easing.BounceIn) ); Picker.Title = null; } else { await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200); } }; Picker.Unfocused += async(s, a) => { HiddenLabel.TextColor = Color.Gray; if (Picker.SelectedItem == null) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 200), HiddenLabel.FadeTo(0, 180), HiddenLabel.TranslateTo(HiddenLabel.TranslationX, Picker.Y, 200, Easing.BounceIn) ); Picker.Title = Placeholder; } else { await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 200); } }; }
async Task TitleToPlaceholder() { if (Animated) { await Task.WhenAll( PlaceholderLabel.TranslateTo(10, 0, 100), PlaceholderLabel.SizeTo(PlaceholderLabel.FontSize, PLACEHOLDER_FONT_SIZE, (t) => PlaceholderLabel.FontSize = t, 100, Easing.BounceIn), HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 200), PlaceholderLabel.ColorTo(ActiveTextColor, DefaultTextColor, (c) => PlaceholderLabel.TextColor = c, 100), Grid.MarginTo(Grid.Margin, new Thickness(0, 0, 0, 0), (m) => Grid.Margin = m, 100)); } else { PlaceholderLabel.TranslationX = 10; PlaceholderLabel.TranslationY = 0; PlaceholderLabel.FontSize = PLACEHOLDER_FONT_SIZE; HiddenBottomBorder.WidthRequest = 0; Grid.Margin = new Thickness(0, 0, 0, 0); } }
async Task PlaceholderToTitle() { if (Animated) { await Task.WhenAll( PlaceholderLabel.TranslateTo(0, BorderlessEntry.Y - PlaceholderLabel.Height, 100), PlaceholderLabel.SizeTo(PlaceholderLabel.FontSize, TITLE_FONT_SIZE, (t) => PlaceholderLabel.FontSize = t, 100, Easing.BounceIn), HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200), PlaceholderLabel.ColorTo(DefaultTextColor, ActiveTextColor, (c) => PlaceholderLabel.TextColor = c, 100), Grid.MarginTo(Grid.Margin, new Thickness(0, 15, 0, 0), (m) => Grid.Margin = m, 100)); } else { PlaceholderLabel.TranslationX = 0; PlaceholderLabel.TranslationY = BorderlessEntry.Y - PlaceholderLabel.Height; PlaceholderLabel.FontSize = TITLE_FONT_SIZE; HiddenBottomBorder.WidthRequest = BottomBorder.Width; Grid.Margin = new Thickness(0, 15, 0, 0); } }
private async Task CalculateLayoutUnfocused() { HiddenLabel.TextColor = Color.Gray; if (string.IsNullOrEmpty(EntryField.Text)) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 200), HiddenLabel.FadeTo(0, 180), HiddenLabel.TranslateTo(HiddenLabel.TranslationX, EntryField.Y, 200, Easing.BounceIn) ); EntryField.Placeholder = Placeholder; } else { HiddenLabel.IsVisible = true; await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 200); } }
/// <summary> /// Calculates the layout when focused. Includes running the animation to update the bottom border color and the floating label /// </summary> private async Task CalculateLayoutFocused() { HiddenLabel.IsVisible = true; HiddenLabel.TextColor = AccentColor; HiddenBottomBorder.BackgroundColor = AccentColor; if (string.IsNullOrEmpty(EntryField.Text)) { // animate both at the same time await Task.WhenAll( HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200), HiddenLabel.FadeTo(1, 60), HiddenLabel.TranslateTo(HiddenLabel.TranslationX, EntryField.Y - EntryField.Height + 4, 200, Easing.BounceIn) ); EntryField.Placeholder = null; } else { await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200); } }
public DarkEditor() { InitializeComponent(); EntryField.BindingContext = this; EntryField.Focused += async(s, a) => { HiddenBottomBorder.BackgroundColor = AccentColor; EntryField.TextColor = HiddenLabel.TextColor = AccentColor; HiddenLabel.IsVisible = true; if (string.IsNullOrEmpty(EntryField.Text)) { //Here we give animation on label position, label fading and box view. await Task.WhenAll(HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height + 2), 200), HiddenLabel.FadeTo(1, 100), HiddenLabel.TranslateTo(HiddenLabel.TranslationX - 25, EntryField.Y - EntryField.Height, 200, Easing.BounceIn)); EntryField.Placeholder = null; } else { await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, BottomBorder.Width, BottomBorder.Height), 200); } }; EntryField.Unfocused += async(s, a) => { if (string.IsNullOrEmpty(EntryField.Text)) { await Task.WhenAll(HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height + 2), 200), HiddenLabel.FadeTo(0, 120), HiddenLabel.TranslateTo(HiddenLabel.TranslationX + 25, EntryField.Y, 50, Easing.BounceIn)); EntryField.Placeholder = Placeholder; } else { await HiddenBottomBorder.LayoutTo(new Rectangle(BottomBorder.X, BottomBorder.Y, 0, BottomBorder.Height), 100); } }; }