Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
martijn00 committed Oct 5, 2020
1 parent 2269472 commit 589fcf4
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 90 deletions.
4 changes: 2 additions & 2 deletions Samples/MaterialMvvmSample/ViewModels/PropertyChangeAware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class PropertyChangeAware : INotifyPropertyChanged
/// <param name="field">The field containing the current property's value.</param>
/// <param name="newValue">The new value to be assigned.</param>
/// <param name="propertyName">The name of the property.</param>
protected void Set<T>(ref T field, T newValue = default(T), [CallerMemberName]string propertyName = null)
protected void Set<T>(ref T field, T newValue = default(T), [CallerMemberName] string propertyName = null)
{
if (!EqualityComparer<T>.Default.Equals(field, default(T)))
{
Expand All @@ -46,7 +46,7 @@ public abstract class PropertyChangeAware : INotifyPropertyChanged
/// Method called to raise the <see cref="INotifyPropertyChanged.PropertyChanged" /> event if there was a change in any property.
/// </summary>
/// <param name="propertyName">The name of the property who's value has changed.</param>
protected virtual void OnPropertyChanged([CallerMemberName]string propertyName = null)
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
Expand Down
20 changes: 10 additions & 10 deletions XF.Material/Material.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void Use(string key)
//Replace instance
//new Material(Application.Current, GetResource<MaterialConfiguration>(key));
var config = GetResource<MaterialConfiguration>(key);
if(config != null)
if (config != null)
Instance.MergeMaterialDictionaries(config, false);
}

Expand All @@ -54,7 +54,7 @@ public static void Use(string key)
/// <exception cref="ArgumentNullException" />
public static T GetResource<T>(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)
Expand Down Expand Up @@ -103,39 +103,39 @@ public static void Init(Application app)
Lazy<MaterialColors> defaultColors = new Lazy<MaterialColors>(() => new MaterialColors(new MaterialColorConfiguration()));
Lazy<MaterialTypography> defaultTypos = new Lazy<MaterialTypography>(() => new MaterialTypography(new MaterialFontConfiguration()));
Lazy<MaterialSizes> defaultSizes = new Lazy<MaterialSizes>(() => 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)
{
_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);
}

if (addDefaults)
{
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);
}
}
Expand Down Expand Up @@ -219,7 +219,7 @@ private static Xamarin.Forms.Color GetSecondaryColor()
/// <summary>
/// Static class that contains the current Material font family values.
/// </summary>
public static class FontFamily
public static class FontFamily
{
/// <summary>
/// Body 1 font family, used for long-form writing and small text sizes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void ChildPage_PropertyChanged(object sender, PropertyChangedEventArgs e
{
var page = sender as Page;

if(page == null)
if (page == null)
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion XF.Material/Platforms/Ios/MaterialHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions XF.Material/Platforms/Ios/Renderers/MaterialIconRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using CoreGraphics;
using ObjCRuntime;
using UIKit;
using Xamarin.Forms;
Expand Down Expand Up @@ -81,7 +80,7 @@ private void ChildPage_PropertyChanged(object sender, PropertyChangedEventArgs e
{
var page = sender as Page;

if(page == null)
if (page == null)
{
return;
}
Expand Down
1 change: 0 additions & 1 deletion XF.Material/UI/Dialogs/MaterialConfirmationDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion XF.Material/UI/Dialogs/MaterialDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public async Task<int> 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<int> SelectChoiceAsync(
Expand Down
Loading

0 comments on commit 589fcf4

Please sign in to comment.