From 589fcf485576d2717e6090789aeb17ed75e2a140 Mon Sep 17 00:00:00 2001 From: Martijn van Dijk Date: Mon, 5 Oct 2020 13:18:48 +0200 Subject: [PATCH] Cleanup --- .../ViewModels/PropertyChangeAware.cs | 4 +- XF.Material/Material.cs | 20 ++-- .../MaterialNavigationPageRenderer.cs | 2 +- XF.Material/Platforms/Ios/MaterialHelper.cs | 2 +- .../Ios/Renderers/MaterialButtonRenderer.cs | 2 +- .../Renderers/MaterialDatePickerRenderer.cs | 6 +- .../Ios/Renderers/MaterialIconRenderer.cs | 4 +- .../MaterialNavigationPageRenderer.cs | 3 +- .../MaterialConfirmationDialog.xaml.cs | 1 - XF.Material/UI/Dialogs/MaterialDialog.cs | 2 +- XF.Material/UI/MaterialDateField.xaml.cs | 112 +++++++++--------- XF.Material/UI/MaterialLabel.cs | 3 +- XF.Material/UI/MaterialTextField.xaml.cs | 12 +- XF.Material/Utilities/PropertyChangeAware.cs | 4 +- 14 files changed, 87 insertions(+), 90 deletions(-) diff --git a/Samples/MaterialMvvmSample/ViewModels/PropertyChangeAware.cs b/Samples/MaterialMvvmSample/ViewModels/PropertyChangeAware.cs index 993a9c9d..79127bae 100644 --- a/Samples/MaterialMvvmSample/ViewModels/PropertyChangeAware.cs +++ b/Samples/MaterialMvvmSample/ViewModels/PropertyChangeAware.cs @@ -23,7 +23,7 @@ public abstract class PropertyChangeAware : INotifyPropertyChanged /// The field containing the current property's value. /// The new value to be assigned. /// The name of the property. - protected void Set(ref T field, T newValue = default(T), [CallerMemberName]string propertyName = null) + protected void Set(ref T field, T newValue = default(T), [CallerMemberName] string propertyName = null) { if (!EqualityComparer.Default.Equals(field, default(T))) { @@ -46,7 +46,7 @@ public abstract class PropertyChangeAware : INotifyPropertyChanged /// Method called to raise the event if there was a change in any property. /// /// The name of the property who's value has changed. - protected virtual void OnPropertyChanged([CallerMemberName]string propertyName = null) + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } diff --git a/XF.Material/Material.cs b/XF.Material/Material.cs index 63974c91..e91dcd2a 100644 --- a/XF.Material/Material.cs +++ b/XF.Material/Material.cs @@ -36,7 +36,7 @@ public static void Use(string key) //Replace instance //new Material(Application.Current, GetResource(key)); var config = GetResource(key); - if(config != null) + if (config != null) Instance.MergeMaterialDictionaries(config, false); } @@ -54,7 +54,7 @@ public static void Use(string key) /// public static T GetResource(string key) { - if(Instance._res == null) + if (Instance._res == null) throw new Exception("You must call one of the Init() methods in App.xaml.cs before InitializeComponent()"); if (Instance._res.TryGetValue(key ?? throw new ArgumentNullException(nameof(key)), out var value) @@ -103,17 +103,17 @@ public static void Init(Application app) Lazy defaultColors = new Lazy(() => new MaterialColors(new MaterialColorConfiguration())); Lazy defaultTypos = new Lazy(() => new MaterialTypography(new MaterialFontConfiguration())); Lazy defaultSizes = new Lazy(() => new MaterialSizes()); - + private void MergeMaterialDictionaries(MaterialConfiguration config, bool addDefaults) { - if(config != null) + if (config != null) { if (config.ColorConfiguration != null) { _res.MergedDictionaries.Remove(defaultColors.Value); _res.MergedDictionaries.Add(new MaterialColors(config.ColorConfiguration)); } - else if(addDefaults &&!_res.MergedDictionaries.Contains((defaultColors.Value))) + else if (addDefaults && !_res.MergedDictionaries.Contains((defaultColors.Value))) _res.MergedDictionaries.Add(defaultColors.Value); if (config.FontConfiguration != null) @@ -121,7 +121,7 @@ private void MergeMaterialDictionaries(MaterialConfiguration config, bool addDef _res.MergedDictionaries.Remove(defaultTypos.Value); _res.MergedDictionaries.Add(new MaterialTypography(config.FontConfiguration)); } - else if(addDefaults &&!_res.MergedDictionaries.Contains((defaultTypos.Value))) + else if (addDefaults && !_res.MergedDictionaries.Contains((defaultTypos.Value))) _res.MergedDictionaries.Add(defaultTypos.Value); } @@ -129,13 +129,13 @@ private void MergeMaterialDictionaries(MaterialConfiguration config, bool addDef { if (config == null) { - if(!_res.MergedDictionaries.Contains((defaultColors.Value))) + if (!_res.MergedDictionaries.Contains((defaultColors.Value))) _res.MergedDictionaries.Add(defaultColors.Value); - if(!_res.MergedDictionaries.Contains((defaultTypos.Value))) + if (!_res.MergedDictionaries.Contains((defaultTypos.Value))) _res.MergedDictionaries.Add(defaultTypos.Value); } - if(!_res.MergedDictionaries.Contains((defaultSizes.Value))) + if (!_res.MergedDictionaries.Contains((defaultSizes.Value))) _res.MergedDictionaries.Add(defaultSizes.Value); } } @@ -219,7 +219,7 @@ private static Xamarin.Forms.Color GetSecondaryColor() /// /// Static class that contains the current Material font family values. /// - public static class FontFamily + public static class FontFamily { /// /// Body 1 font family, used for long-form writing and small text sizes. diff --git a/XF.Material/Platforms/Android/Renderers/MaterialNavigationPageRenderer.cs b/XF.Material/Platforms/Android/Renderers/MaterialNavigationPageRenderer.cs index bef58fc5..463caab8 100644 --- a/XF.Material/Platforms/Android/Renderers/MaterialNavigationPageRenderer.cs +++ b/XF.Material/Platforms/Android/Renderers/MaterialNavigationPageRenderer.cs @@ -127,7 +127,7 @@ private void ChildPage_PropertyChanged(object sender, PropertyChangedEventArgs e { var page = sender as Page; - if(page == null) + if (page == null) { return; } diff --git a/XF.Material/Platforms/Ios/MaterialHelper.cs b/XF.Material/Platforms/Ios/MaterialHelper.cs index 8d25757f..27f6516f 100644 --- a/XF.Material/Platforms/Ios/MaterialHelper.cs +++ b/XF.Material/Platforms/Ios/MaterialHelper.cs @@ -27,7 +27,7 @@ internal static UIColor DarkenColor(this UIColor color) internal static void Elevate(this UIView view, double elevation) { - if(elevation > 0) + if (elevation > 0) { view.Layer.MasksToBounds = false; view.Layer.ShadowColor = UIColor.Black.CGColor; diff --git a/XF.Material/Platforms/Ios/Renderers/MaterialButtonRenderer.cs b/XF.Material/Platforms/Ios/Renderers/MaterialButtonRenderer.cs index 3c601610..d7665663 100644 --- a/XF.Material/Platforms/Ios/Renderers/MaterialButtonRenderer.cs +++ b/XF.Material/Platforms/Ios/Renderers/MaterialButtonRenderer.cs @@ -310,7 +310,7 @@ private async void SetupIcon() { image = UIImage.FromFile(_materialButton.Image.File) ?? UIImage.FromBundle(_materialButton.Image.File); } - else if(!(_materialButton.ImageSource?.IsEmpty ?? true)) + else if (!(_materialButton.ImageSource?.IsEmpty ?? true)) { IImageSourceHandler imageSourceHandler = _materialButton.ImageSource.GetImageSourceHandler(); image = await imageSourceHandler.LoadImageAsync(_materialButton.ImageSource); diff --git a/XF.Material/Platforms/Ios/Renderers/MaterialDatePickerRenderer.cs b/XF.Material/Platforms/Ios/Renderers/MaterialDatePickerRenderer.cs index 730a3d8b..5f1b9e10 100644 --- a/XF.Material/Platforms/Ios/Renderers/MaterialDatePickerRenderer.cs +++ b/XF.Material/Platforms/Ios/Renderers/MaterialDatePickerRenderer.cs @@ -1,10 +1,10 @@ -using XF.Material.iOS.Renderers; -using UIKit; +using UIKit; using Xamarin.Forms; using Xamarin.Forms.Platform.iOS; using XF.Material.Forms.UI.Internals; +using XF.Material.iOS.Renderers; -[assembly:ExportRenderer(typeof(MaterialDatePicker), typeof(MaterialDatePickerRenderer))] +[assembly: ExportRenderer(typeof(MaterialDatePicker), typeof(MaterialDatePickerRenderer))] namespace XF.Material.iOS.Renderers { diff --git a/XF.Material/Platforms/Ios/Renderers/MaterialIconRenderer.cs b/XF.Material/Platforms/Ios/Renderers/MaterialIconRenderer.cs index 1fc9c64c..c6a32658 100644 --- a/XF.Material/Platforms/Ios/Renderers/MaterialIconRenderer.cs +++ b/XF.Material/Platforms/Ios/Renderers/MaterialIconRenderer.cs @@ -38,13 +38,13 @@ private void ChangeTintColor() { var control = Control; var element = _materialIcon; - if(control == null || element == null) + if (control == null || element == null) return; if (element.TintColor.IsDefault) control.TintColor = null; else - control.TintColor = element.TintColor.ToUIColor(); + control.TintColor = element.TintColor.ToUIColor(); } } } diff --git a/XF.Material/Platforms/Ios/Renderers/MaterialNavigationPageRenderer.cs b/XF.Material/Platforms/Ios/Renderers/MaterialNavigationPageRenderer.cs index 7c12f618..2b56e458 100644 --- a/XF.Material/Platforms/Ios/Renderers/MaterialNavigationPageRenderer.cs +++ b/XF.Material/Platforms/Ios/Renderers/MaterialNavigationPageRenderer.cs @@ -2,7 +2,6 @@ using System.ComponentModel; using System.Linq; using System.Threading.Tasks; -using CoreGraphics; using ObjCRuntime; using UIKit; using Xamarin.Forms; @@ -81,7 +80,7 @@ private void ChildPage_PropertyChanged(object sender, PropertyChangedEventArgs e { var page = sender as Page; - if(page == null) + if (page == null) { return; } diff --git a/XF.Material/UI/Dialogs/MaterialConfirmationDialog.xaml.cs b/XF.Material/UI/Dialogs/MaterialConfirmationDialog.xaml.cs index 02e6daee..ec5e594f 100644 --- a/XF.Material/UI/Dialogs/MaterialConfirmationDialog.xaml.cs +++ b/XF.Material/UI/Dialogs/MaterialConfirmationDialog.xaml.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.CompilerServices; using System.Threading.Tasks; using Xamarin.Essentials; using Xamarin.Forms; diff --git a/XF.Material/UI/Dialogs/MaterialDialog.cs b/XF.Material/UI/Dialogs/MaterialDialog.cs index 13966d08..891654bf 100644 --- a/XF.Material/UI/Dialogs/MaterialDialog.cs +++ b/XF.Material/UI/Dialogs/MaterialDialog.cs @@ -107,7 +107,7 @@ public async Task SelectChoiceAsync( MaterialConfirmationDialogConfiguration configuration = null, bool closeOnSelection = false) { - return (int) await MaterialConfirmationDialog.ShowSelectChoiceAsync(title, choices, confirmingText, dismissiveText, configuration, closeOnSelection); + return (int)await MaterialConfirmationDialog.ShowSelectChoiceAsync(title, choices, confirmingText, dismissiveText, configuration, closeOnSelection); } public async Task SelectChoiceAsync( diff --git a/XF.Material/UI/MaterialDateField.xaml.cs b/XF.Material/UI/MaterialDateField.xaml.cs index a8e28f98..bbdc9314 100644 --- a/XF.Material/UI/MaterialDateField.xaml.cs +++ b/XF.Material/UI/MaterialDateField.xaml.cs @@ -15,7 +15,7 @@ namespace XF.Material.Forms.UI { internal class NullImageSourceToBoolConverter : IValueConverter { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => value != null && value is ImageSource imageSource && !imageSource.IsEmpty; public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) @@ -53,9 +53,9 @@ public partial class MaterialDateField : ContentView, IMaterialElementConfigurat public static readonly BindableProperty TextFontSizeProperty = BindableProperty.Create(nameof(TextFontSize), typeof(double), typeof(MaterialDateField), 16d); public static readonly BindableProperty DateProperty = BindableProperty.Create(nameof(Date), typeof(DateTime?), typeof(MaterialDateField), null, BindingMode.TwoWay); public static readonly BindableProperty TintColorProperty = BindableProperty.Create(nameof(TintColor), typeof(Color), typeof(MaterialDateField), Material.Color.Secondary); - public static readonly BindableProperty ClearIconProperty = BindableProperty.Create(nameof(ClearIcon), typeof(ImageSource), typeof(MaterialDateField), new FileImageSource { File = "xf_clear"}); - public static readonly BindableProperty ErrorIconProperty = BindableProperty.Create(nameof(ErrorIcon), typeof(ImageSource), typeof(MaterialDateField), new FileImageSource { File = "xf_error"}); - public static readonly BindableProperty DropDrownArrowIconProperty = BindableProperty.Create(nameof(DropDrownArrowIcon), typeof(ImageSource), typeof(MaterialDateField), new FileImageSource { File = "xf_arrow_dropdown"}); + public static readonly BindableProperty ClearIconProperty = BindableProperty.Create(nameof(ClearIcon), typeof(ImageSource), typeof(MaterialDateField), new FileImageSource { File = "xf_clear" }); + public static readonly BindableProperty ErrorIconProperty = BindableProperty.Create(nameof(ErrorIcon), typeof(ImageSource), typeof(MaterialDateField), new FileImageSource { File = "xf_error" }); + public static readonly BindableProperty DropDrownArrowIconProperty = BindableProperty.Create(nameof(DropDrownArrowIcon), typeof(ImageSource), typeof(MaterialDateField), new FileImageSource { File = "xf_arrow_dropdown" }); public static readonly BindableProperty UnderlineColorProperty = BindableProperty.Create(nameof(UnderlineColor), typeof(Color), typeof(MaterialDateField), Color.FromHex("#99000000")); public new static readonly BindableProperty BackgroundColorProperty = BindableProperty.Create(nameof(BackgroundColor), typeof(Color), typeof(MaterialDateField), Color.FromHex("#DCDCDC")); @@ -63,7 +63,7 @@ public partial class MaterialDateField : ContentView, IMaterialElementConfigurat private readonly Dictionary _propertyChangeActions; private DisplayInfo _lastDeviceDisplay; const uint AnimDurationMs = 350; //250/2; - const double AnimDurationS = AnimDurationMs/1000.0; + const double AnimDurationS = AnimDurationMs / 1000.0; private bool? IsFloating = null; /// @@ -410,14 +410,14 @@ void IMaterialElementConfiguration.ElementChanged(bool created) protected override void OnBindingContextChanged() { base.OnBindingContextChanged(); - if(BindingContext != null) + if (BindingContext != null) Device.BeginInvokeOnMainThread(() => UpdateState(false)); } protected override void OnParentSet() { base.OnParentSet(); - if(Parent != null) + if (Parent != null) Device.BeginInvokeOnMainThread(() => UpdateState(false)); } @@ -453,7 +453,7 @@ private void UpdateState(bool animated = true) if (isFloating != IsFloating) { IsFloating = isFloating; - + if (FloatingPlaceholderEnabled) { var normalPlaceholderFontSize = datePicker.FontSize; @@ -481,7 +481,7 @@ private void UpdateState(bool animated = true) UnderlineSetState(anim); - if(animated) + if (animated) anim.Commit(this, Guid.NewGuid().ToString(), rate: 2, length: AnimDurationMs, easing: _animationCurve); else anim.Commit(this, Guid.NewGuid().ToString(), 1, 1); @@ -535,7 +535,7 @@ await Task.WhenAll( OnPropertyChanged(nameof(SmallText)); helper.TranslationY = -4; await Task.WhenAll( - helper.FadeTo(1, AnimDurationMs, _animationCurve), + helper.FadeTo(1, AnimDurationMs, _animationCurve), helper.TranslateTo(0, 0, AnimDurationMs, _animationCurve)); } } @@ -545,7 +545,7 @@ private void UnderlineSetState(Animation anim = null) { var isFocused = datePicker.IsFocused; var hasValue = Date.HasValue; - + var hasLine = hasValue || isFocused; var hasThickLine = isFocused; @@ -557,7 +557,7 @@ private void UnderlineSetState(Animation anim = null) { underline.WidthRequest = -1; underline.HorizontalOptions = LayoutOptions.FillAndExpand; - if(hasThickLine) + if (hasThickLine) underline.HeightRequest = 2; } else @@ -578,7 +578,7 @@ private void UnderlineSetState(Animation anim = null) })); anim.Add(0, AnimDurationS, new Animation(v => underline.HeightRequest = v, underline.HeightRequest, hasThickLine ? 2 : 1, _animationCurve)); } - else if(isLineVisible) + else if (isLineVisible) { anim.Add(0, AnimDurationS, new Animation(v => underline.WidthRequest = v, Width, 0, _animationCurve, () => { @@ -595,11 +595,11 @@ private void UnderlineSetColorState() var isFocused = datePicker.IsFocused; var hasValue = Date.HasValue; - if(HasError) + if (HasError) underline.Color = ErrorColor; - else if(isFocused || hasValue) + else if (isFocused || hasValue) underline.Color = TintColor; - else if(AlwaysShowUnderline) + else if (AlwaysShowUnderline) underline.Color = UnderlineColor; else underline.Color = Color.Transparent; @@ -630,40 +630,40 @@ private void DatePicker_Unfocused(object sender, FocusEventArgs e) //private void Entry_SizeChanged(object sender, EventArgs e) //{ - //var baseHeight = FloatingPlaceholderEnabled ? 56 : 40; - //var diff = datePicker.Height - 20; - //var rawRowHeight = baseHeight + diff; - //_autoSizingRow.Height = new GridLength(rawRowHeight); - - //var iconVerticalMargin = (_autoSizingRow.Height.Value - 24) / 2; - - //if (leadingIcon.IsVisible) - //{ - // leadingIcon.Margin = new Thickness(HorizontalPadding.Left, iconVerticalMargin, 0, iconVerticalMargin); - // datePicker.Margin = new Thickness(12, datePicker.Margin.Top, HorizontalPadding.Right, datePicker.Margin.Bottom); - //} - //else - //{ - // datePicker.Margin = new Thickness(HorizontalPadding.Left, datePicker.Margin.Top, HorizontalPadding.Right, datePicker.Margin.Bottom); - //} - - //if (trailingIcon.IsVisible) - //{ - // var entryPaddingLeft = leadingIcon.IsVisible ? 12 : HorizontalPadding; - // trailingIcon.Margin = new Thickness(12, iconVerticalMargin, HorizontalPadding.Right, iconVerticalMargin); - // datePicker.Margin = new Thickness(entryPaddingLeft.Left, datePicker.Margin.Top, 0, datePicker.Margin.Bottom); - //} - - //helper.Margin = new Thickness(HorizontalPadding.Left, helper.Margin.Top, 12, 0); - //counter.Margin = new Thickness(0, counter.Margin.Top, HorizontalPadding.Right, 0); - - //var placeholderLeftMargin = FloatingPlaceholderEnabled ? HorizontalPadding.Left : datePicker.Margin.Left; - //placeholder.Margin = new Thickness(placeholderLeftMargin, 0, 0, 0); - - //if (HasError) - //{ - // underline.Color = ErrorColor; - //} + //var baseHeight = FloatingPlaceholderEnabled ? 56 : 40; + //var diff = datePicker.Height - 20; + //var rawRowHeight = baseHeight + diff; + //_autoSizingRow.Height = new GridLength(rawRowHeight); + + //var iconVerticalMargin = (_autoSizingRow.Height.Value - 24) / 2; + + //if (leadingIcon.IsVisible) + //{ + // leadingIcon.Margin = new Thickness(HorizontalPadding.Left, iconVerticalMargin, 0, iconVerticalMargin); + // datePicker.Margin = new Thickness(12, datePicker.Margin.Top, HorizontalPadding.Right, datePicker.Margin.Bottom); + //} + //else + //{ + // datePicker.Margin = new Thickness(HorizontalPadding.Left, datePicker.Margin.Top, HorizontalPadding.Right, datePicker.Margin.Bottom); + //} + + //if (trailingIcon.IsVisible) + //{ + // var entryPaddingLeft = leadingIcon.IsVisible ? 12 : HorizontalPadding; + // trailingIcon.Margin = new Thickness(12, iconVerticalMargin, HorizontalPadding.Right, iconVerticalMargin); + // datePicker.Margin = new Thickness(entryPaddingLeft.Left, datePicker.Margin.Top, 0, datePicker.Margin.Bottom); + //} + + //helper.Margin = new Thickness(HorizontalPadding.Left, helper.Margin.Top, 12, 0); + //counter.Margin = new Thickness(0, counter.Margin.Top, HorizontalPadding.Right, 0); + + //var placeholderLeftMargin = FloatingPlaceholderEnabled ? HorizontalPadding.Left : datePicker.Margin.Left; + //placeholder.Margin = new Thickness(placeholderLeftMargin, 0, 0, 0); + + //if (HasError) + //{ + // underline.Color = ErrorColor; + //} //} private void DatePicker_DateChanged(object sender, NullableDateChangedEventArgs e) @@ -689,14 +689,14 @@ private void OnFloatingPlaceholderEnabledChanged() _autoSizingRow.Height = FloatingPlaceholderEnabled ? new GridLength(54) : GridLength.Auto; UpdateState(false); - // double marginTopVariation = Device.RuntimePlatform == Device.iOS ? 18 : 20; - // datePicker.Margin = isEnabled ? new Thickness(datePicker.Margin.Left, 24, datePicker.Margin.Right, 0) : new Thickness(datePicker.Margin.Left, marginTopVariation - 9, datePicker.Margin.Right, 0); + // double marginTopVariation = Device.RuntimePlatform == Device.iOS ? 18 : 20; + // datePicker.Margin = isEnabled ? new Thickness(datePicker.Margin.Left, 24, datePicker.Margin.Right, 0) : new Thickness(datePicker.Margin.Left, marginTopVariation - 9, datePicker.Margin.Right, 0); - // var iconMargin = leadingIcon.Margin; - // leadingIcon.Margin = isEnabled ? new Thickness(iconMargin.Left, 16, iconMargin.Right, 16) : new Thickness(iconMargin.Left, 8, iconMargin.Right, 8); + // var iconMargin = leadingIcon.Margin; + // leadingIcon.Margin = isEnabled ? new Thickness(iconMargin.Left, 16, iconMargin.Right, 16) : new Thickness(iconMargin.Left, 8, iconMargin.Right, 8); - // var trailingIconMargin = trailingIcon.Margin; - // trailingIcon.Margin = isEnabled ? new Thickness(trailingIconMargin.Left, 16, trailingIconMargin.Right, 16) : new Thickness(trailingIconMargin.Left, 8, trailingIconMargin.Right, 8); + // var trailingIconMargin = trailingIcon.Margin; + // trailingIcon.Margin = isEnabled ? new Thickness(trailingIconMargin.Left, 16, trailingIconMargin.Right, 16) : new Thickness(trailingIconMargin.Left, 8, trailingIconMargin.Right, 8); } private void OnHelperTextChanged() diff --git a/XF.Material/UI/MaterialLabel.cs b/XF.Material/UI/MaterialLabel.cs index 637ba4f3..72cbcf87 100644 --- a/XF.Material/UI/MaterialLabel.cs +++ b/XF.Material/UI/MaterialLabel.cs @@ -1,5 +1,4 @@ -using System; -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; using Xamarin.Forms; using XF.Material.Forms.Resources.Typography; diff --git a/XF.Material/UI/MaterialTextField.xaml.cs b/XF.Material/UI/MaterialTextField.xaml.cs index e52ee303..4b91fa08 100644 --- a/XF.Material/UI/MaterialTextField.xaml.cs +++ b/XF.Material/UI/MaterialTextField.xaml.cs @@ -35,7 +35,7 @@ public partial class MaterialTextField : ContentView, IMaterialElementConfigurat private static void SelectedChoicePropertyChange(BindableObject bindable, object oldValue, object newValue) { - if(bindable is MaterialTextField control) + if (bindable is MaterialTextField control) control.SetSelectedChoice(newValue); } @@ -52,7 +52,7 @@ private void SetSelectedChoice(object selectedChoice) if (_selectedIndex != index) { _selectedIndex = index; - Text = index>=0 ? _choicesResults[index] : null; + Text = index >= 0 ? _choicesResults[index] : null; AnimateToInactiveOrFocusedStateOnStart(this, false); UpdateCounter(); @@ -929,7 +929,7 @@ private void Entry_Focused(object sender, FocusEventArgs e) if (InputType == MaterialTextFieldInputType.Choice || InputType == MaterialTextFieldInputType.SingleImmediateChoice || InputType == MaterialTextFieldInputType.CommandChoice) { - ((View) sender).Unfocus(); + ((View)sender).Unfocus(); } else { @@ -1022,9 +1022,9 @@ private IList GetChoices(out IList choicesResults) var propInfo = listType.GetProperty(ChoicesBindingName); if (propInfo != null) - { + { var propValue = propInfo.GetValue(item); - choice =propValue?.ToString(); + choice = propValue?.ToString(); } } @@ -1068,7 +1068,7 @@ private void OnBackgroundColorChanged() { if (base.BackgroundColor != Color.Transparent) { - if(base.BackgroundColor != Color.Default) + if (base.BackgroundColor != Color.Default) CardBackgroundColor = base.BackgroundColor; base.BackgroundColor = Color.Transparent; } diff --git a/XF.Material/Utilities/PropertyChangeAware.cs b/XF.Material/Utilities/PropertyChangeAware.cs index 8cd0f72a..ee9f994f 100644 --- a/XF.Material/Utilities/PropertyChangeAware.cs +++ b/XF.Material/Utilities/PropertyChangeAware.cs @@ -22,7 +22,7 @@ internal abstract class PropertyChangeAware : INotifyPropertyChanged /// The field containing the current property's value. /// The new value to be assigned. /// The name of the property. - protected void Set(ref T field, T newValue = default(T), [CallerMemberName]string propertyName = null) + protected void Set(ref T field, T newValue = default(T), [CallerMemberName] string propertyName = null) { if (!EqualityComparer.Default.Equals(field, default(T))) { @@ -45,7 +45,7 @@ internal abstract class PropertyChangeAware : INotifyPropertyChanged /// Method called to raise the event if there was a change in any property. /// /// The name of the property who's value has changed. - protected virtual void OnPropertyChanged([CallerMemberName]string propertyName = null) + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }