private static void StatePropertyChanged(BindableObject bindableobject, Object oldValue, Object newValue) { FloatingLabelEntryStateProperties stateProperties = null; var fl = bindableobject as FloatingLabelEntryBase; if (fl.StatesProperties.TryGetValue((FloatingLabelEntryState)newValue, out stateProperties)) { fl.InfoMessage = stateProperties.InfoMessage; fl.Icon.Source = stateProperties.IconSource; if (stateProperties.IconSource != null) { fl._DisplayView.WidthRequest = fl.Height; fl.Icon.Opacity = 1; } else { fl.Icon.Opacity = 0; fl._DisplayView.WidthRequest = 0; } if (stateProperties.BackgroundColor != fl.BackgroundColor) { fl.BackgroundColor = stateProperties.BackgroundColor; } if (stateProperties.BorderColor != fl.BorderColor) { fl.BorderColor = stateProperties.BorderColor; } if (stateProperties.BorderThickness != fl.BorderThickness) { fl.BorderThickness = stateProperties.BorderThickness; } } }
public PasswordFloatingLabelEntry() { this.InputValidator = InputValidatorDelegate; this.MustValidate = true; this.IsPassword = true; this.LabelText = "Test your password"; var validEntryStateProperties = new FloatingLabelEntryStateProperties { IconSource = ImageSource.FromFile ("ValidationIcons/ValidIcon.png"), BorderColor =Color.Green, BorderThickness=3, InfoMessage="Password safe", }; var errorEntryStateProperties = new FloatingLabelEntryStateProperties { IconSource = ImageSource.FromFile ("ValidationIcons/ErrorIcon.png"), BorderColor=Color.Red, BorderThickness=3, InfoMessage= "Password very weak.", }; var warningEntryStateProperties = new FloatingLabelEntryStateProperties { IconSource = ImageSource.FromFile ("ValidationIcons/WarningIcon.png"), BorderColor=Color.FromHex("FFA500"), BorderThickness=3, InfoMessage= "Password strength average.", }; var normalEntryStateProperties = new FloatingLabelEntryStateProperties { BorderColor=Color.FromHex("4b9be0"), BorderThickness=3, }; this.AddPropertiesForState (validEntryStateProperties, FloatingLabelEntryState.Valid); this.AddPropertiesForState (warningEntryStateProperties, FloatingLabelEntryState.Warning); this.AddPropertiesForState (errorEntryStateProperties, FloatingLabelEntryState.Error); this.AddPropertiesForState (normalEntryStateProperties, FloatingLabelEntryState.Neutral); this.State = FloatingLabelEntryState.Neutral; }
public void AddPropertiesForState(FloatingLabelEntryStateProperties property, FloatingLabelEntryState state) { RemovePropertyForState(state); this.StatesProperties.Add(state, property); }
public void AddPropertiesForState(FloatingLabelEntryStateProperties property, FloatingLabelEntryState state) { RemovePropertyForState (state); this.StatesProperties.Add (state, property); }