Skip to content

Commit

Permalink
Code style cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
martijn00 committed Sep 30, 2019
1 parent d17a345 commit 14dd8e2
Show file tree
Hide file tree
Showing 58 changed files with 204 additions and 269 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Android.App;

Expand Down
7 changes: 1 addition & 6 deletions Samples/MaterialMvvmSample.iOS/Main.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;

using Foundation;
using UIKit;
using UIKit;

namespace MaterialMvvmSample.iOS
{
Expand Down
1 change: 0 additions & 1 deletion Samples/MaterialMvvmSample.iOS/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Foundation;
using MaterialMvvmSample.iOS.Renderers;
using MaterialMvvmSample.iOS.Renderers;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
Expand Down
1 change: 0 additions & 1 deletion Samples/MaterialMvvmSample/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using MaterialMvvmSample.Utilities;
using MaterialMvvmSample.Views;
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

Expand Down
6 changes: 3 additions & 3 deletions Samples/MaterialMvvmSample/Controls/CustomNavigationPage.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using MaterialMvvmSample.Utilities;
using MaterialMvvmSample.ViewModels;
using System;
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using MaterialMvvmSample.Utilities;
using MaterialMvvmSample.ViewModels;
using Xamarin.Forms;
using XF.Material.Forms.UI;

Expand Down
4 changes: 2 additions & 2 deletions Samples/MaterialMvvmSample/Utilities/NavigationService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MaterialMvvmSample.Controls;
using System.Threading.Tasks;
using System.Threading.Tasks;
using MaterialMvvmSample.Controls;
using Xamarin.Forms;

namespace MaterialMvvmSample.Utilities
Expand Down
82 changes: 41 additions & 41 deletions Samples/MaterialMvvmSample/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using MaterialMvvmSample.Utilities.Dialogs;
using MaterialMvvmSample.Views;
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using MaterialMvvmSample.Utilities.Dialogs;
using MaterialMvvmSample.Views;
using Xamarin.Forms;
using Xamarin.Forms.Internals;
using XF.Material.Forms.Models;
Expand Down Expand Up @@ -96,7 +96,7 @@ public bool HasError
"San Miguel Corporation",
"YNGEN Holdings Inc.",
"ERNI Development Center Philippines, Inc., Bern, Switzerland"
};
};

public ICommand JobSelectedCommand => new Command<string>(async (s) => await this.ViewItemSelected(s));

Expand Down Expand Up @@ -146,29 +146,29 @@ private async Task ListMenuSelected(MaterialMenuResult s)
switch (s.Index)
{
case 0:
{
var result = await _dialogService.AddNewJob();

if (this.Models.Any(m => m.Title == result))
{
await _dialogService.AlertExistingJob(result);
}
else if (!string.IsNullOrEmpty(result))
{
this.Models.Where(m => m.IsNew).ForEach(m => m.IsNew = false);
var result = await _dialogService.AddNewJob();

var model = new TestModel
if (this.Models.Any(m => m.Title == result))
{
Title = result,
Id = Guid.NewGuid().ToString("N"),
IsNew = true
};
await _dialogService.AlertExistingJob(result);
}
else if (!string.IsNullOrEmpty(result))
{
this.Models.Where(m => m.IsNew).ForEach(m => m.IsNew = false);

this.Models.Add(model);
}
var model = new TestModel
{
Title = result,
Id = Guid.NewGuid().ToString("N"),
IsNew = true
};

break;
}
this.Models.Add(model);
}

break;
}
case 1:
this.Models = new ObservableCollection<TestModel>(this.Models.OrderBy(m => m.Title));
break;
Expand All @@ -192,35 +192,35 @@ private async Task MenuSelected(MaterialMenuResult i)
switch (i.Index)
{
case 0:
{
if (model != null)
{
var result = await _dialogService.EditJob(model.Title);

if (!string.IsNullOrEmpty(result))
if (model != null)
{
model.Title = result;
var result = await _dialogService.EditJob(model.Title);

if (!string.IsNullOrEmpty(result))
{
model.Title = result;
}
}
}

break;
}
break;
}
case 1:
{
if (model != null)
{
var confirmed = await _dialogService.DeleteJob(model.Title);

if (confirmed == true)
if (model != null)
{
this.Models.Remove(model);
var confirmed = await _dialogService.DeleteJob(model.Title);

await _dialogService.JobDeleted();
if (confirmed == true)
{
this.Models.Remove(model);

await _dialogService.JobDeleted();
}
}
}

break;
}
break;
}
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions Samples/MaterialMvvmSample/ViewModels/SecondViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace MaterialMvvmSample.ViewModels
namespace MaterialMvvmSample.ViewModels
{
public class SecondViewModel : BaseViewModel
{
Expand Down
9 changes: 0 additions & 9 deletions Samples/MaterialMvvmSample/Views/MainView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
using MaterialMvvmSample.ViewModels;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using Xamarin.Forms;
using XF.Material.Forms;
using Xamarin.Forms.Xaml;
using XF.Material.Forms.UI;
using XF.Material.Forms.UI.Dialogs;
using Xamarin.Forms.Internals;

namespace MaterialMvvmSample.Views
{
Expand Down
12 changes: 6 additions & 6 deletions Samples/MaterialMvvmSample/Views/SecondView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
namespace MaterialMvvmSample.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SecondView : BaseSecondView
public partial class SecondView : BaseSecondView
{
public SecondView ()
{
this.InitializeComponent ();
}
}
public SecondView()
{
this.InitializeComponent();
}
}

public abstract class BaseSecondView : BaseView<SecondViewModel> { }
}
2 changes: 1 addition & 1 deletion XF.Material/FormsResources/MaterialColorConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public Color Secondary
{
var color = (Color)this.GetValue(SecondaryProperty);

if(color.IsDefault && this.Primary.IsDefault)
if (color.IsDefault && this.Primary.IsDefault)
{
return Color.Accent;
}
Expand Down
4 changes: 2 additions & 2 deletions XF.Material/FormsResources/MaterialConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class MaterialConfiguration : BindableObject
/// </summary>
public MaterialFontConfiguration FontConfiguration
{
get => (MaterialFontConfiguration) this.GetValue(FontConfigurationProperty);
get => (MaterialFontConfiguration)this.GetValue(FontConfigurationProperty);
set => this.SetValue(FontConfigurationProperty, value);
}

Expand All @@ -33,7 +33,7 @@ public MaterialFontConfiguration FontConfiguration
/// </summary>
public MaterialColorConfiguration ColorConfiguration
{
get => (MaterialColorConfiguration) this.GetValue(ColorConfigurationProperty);
get => (MaterialColorConfiguration)this.GetValue(ColorConfigurationProperty);
set => this.SetValue(ColorConfigurationProperty, value);
}
}
Expand Down
14 changes: 7 additions & 7 deletions XF.Material/FormsResources/MaterialSizes.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
namespace XF.Material.Forms.Resources
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MaterialSizes : ResourceDictionary
{
public MaterialSizes ()
{
this.InitializeComponent ();
}
}
public partial class MaterialSizes : ResourceDictionary
{
public MaterialSizes()
{
this.InitializeComponent();
}
}
}
6 changes: 3 additions & 3 deletions XF.Material/Platforms/Android/Material.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Android.App;
using System;
using System.Linq;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Support.V7.App;
using Rg.Plugins.Popup;
using Rg.Plugins.Popup.Services;
using System;
using System.Linq;
using XF.Material.Forms.UI.Dialogs;

namespace XF.Material.Droid
Expand Down
6 changes: 1 addition & 5 deletions XF.Material/Platforms/Android/MaterialHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Android.App;
using Android.Content;
using System;
using Android.Content.Res;
using Android.Graphics;
using Android.Graphics.Drawables;
Expand All @@ -8,9 +7,6 @@
using Android.Support.V4.Graphics.Drawable;
using Android.Support.V4.View;
using Android.Util;
using Android.Views.InputMethods;
using Android.Widget;
using System;
using Xamarin.Forms.Platform.Android;

namespace XF.Material.Droid
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
using Android.App;
using System.ComponentModel;
using Android.Content;
using Android.Graphics.Drawables;
using Android.Runtime;
using Android.Support.V4.Content;
using Android.Views;
using Android.Views.InputMethods;
using Android.Widget;
using System.ComponentModel;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using XF.Material.Droid.Renderers.Internals;
using XF.Material.Forms.UI.Internals;
using static Android.Text.TextUtils;
using static Android.Widget.TextView;

[assembly: ExportRenderer(typeof(MaterialDatePicker), typeof(MaterialDatePickerRenderer))]
namespace XF.Material.Droid.Renderers.Internals
Expand All @@ -36,12 +28,12 @@ protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.D

protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
base.OnElementPropertyChanged(sender, e);
}

private void SetControl()
{
if(this.Control == null)
if (this.Control == null)
{
return;
}
Expand All @@ -53,7 +45,7 @@ private void SetControl()

var layoutParams = new MarginLayoutParams(this.Control.LayoutParameters);
layoutParams.SetMargins(0, 0, 0, 0);
this.Control.LayoutParameters = layoutParams;
}
this.Control.LayoutParameters = layoutParams;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ namespace XF.Material.Droid.Renderers.Internals
{
internal class MaterialElementRenderer : ViewRenderer<View, Android.Views.View>
{
public MaterialElementRenderer(Context context): base(context) { }
public MaterialElementRenderer(Context context) : base(context) { }

protected override void OnElementChanged(ElementChangedEventArgs<View> e)
{
base.OnElementChanged(e);

if(e?.OldElement != null)
if (e?.OldElement != null)
{
(this.Element as IMaterialElementConfiguration)?.ElementChanged(false);
}

if(e?.NewElement != null)
if (e?.NewElement != null)
{
(this.Element as IMaterialElementConfiguration)?.ElementChanged(true);
}
Expand Down
Loading

0 comments on commit 14dd8e2

Please sign in to comment.