From eec8335d58871dfda0ed8954b58d28e5ca5119e3 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Mon, 4 Nov 2024 04:30:41 -0500 Subject: [PATCH 1/2] Refactor ViewModels and Views for naming consistency Renamed parameters in ActionsViewModel.cs methods for clarity. Removed unused usings and updated VisualStateResult in CoroutineViewModel.cs. Renamed private fields and properties in NavigationSourceViewModel.cs. Updated property names in NavigationTargetViewModel.cs. Renamed controls and updated bindings in ActionsView.xaml. Changed VisualState name in CoroutineView.xaml. Renamed controls in NavigationSourceView.xaml and NavigationTargetView.xaml. --- .../ViewModels/ActionsViewModel.cs | 12 +++++----- .../ViewModels/CoroutineViewModel.cs | 6 ++--- .../ViewModels/NavigationSourceViewModel.cs | 22 +++++++++---------- .../ViewModels/NavigationTargetViewModel.cs | 5 ++--- .../Features.NetFive/Views/ActionsView.xaml | 4 ++-- .../Features.NetFive/Views/CoroutineView.xaml | 2 +- .../Features.UWP/Views/ActionsView.xaml | 4 ++-- .../Features.UWP/Views/CoroutineView.xaml | 2 +- .../Views/NavigationSourceView.xaml | 2 +- .../Features.WPF/Views/ActionsView.xaml | 4 ++-- .../Features.WPF/Views/CoroutineView.xaml | 2 +- .../Views/NavigationTargetView.xaml | 2 +- 12 files changed, 32 insertions(+), 35 deletions(-) diff --git a/samples/features/Features.CrossPlatform.Shared/ViewModels/ActionsViewModel.cs b/samples/features/Features.CrossPlatform.Shared/ViewModels/ActionsViewModel.cs index 4e54b8603..63f388b6f 100644 --- a/samples/features/Features.CrossPlatform.Shared/ViewModels/ActionsViewModel.cs +++ b/samples/features/Features.CrossPlatform.Shared/ViewModels/ActionsViewModel.cs @@ -12,18 +12,18 @@ public class ActionsViewModel : Screen public void SimpleSayHello() => Output = "Hello from Caliburn.Micro"; - public void SayHello(string name) => Output = $"Hello {name}"; + public void SayHello(string username) => Output = $"Hello {username}"; - public bool CanSayHello(string name) => !String.IsNullOrEmpty(name); + public bool CanSayHello(string username) => !String.IsNullOrEmpty(username); - public Task SayGoodbyeAsync(string name) + public Task SayGoodbyeAsync(string username) { - Output = $"Goodbye {name}"; + Output = $"Goodbye {username}"; return TaskHelper.FromResult(true); } - - public bool CanSayGoodbye(string name) => !String.IsNullOrEmpty(name); + + public bool CanSayGoodbye(string username) => !String.IsNullOrEmpty(username); public string Output { diff --git a/samples/features/Features.CrossPlatform.Shared/ViewModels/CoroutineViewModel.cs b/samples/features/Features.CrossPlatform.Shared/ViewModels/CoroutineViewModel.cs index 92bc585a0..0666aaaa3 100644 --- a/samples/features/Features.CrossPlatform.Shared/ViewModels/CoroutineViewModel.cs +++ b/samples/features/Features.CrossPlatform.Shared/ViewModels/CoroutineViewModel.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; +using System.Collections.Generic; using Caliburn.Micro; using Features.CrossPlatform.Results; @@ -17,7 +15,7 @@ public IEnumerable Execute() yield return new BusyResult(false); #else - yield return new VisualStateResult("Loading"); + yield return new VisualStateResult("ShowLoading"); yield return TaskHelper.Delay(2000).AsResult(); diff --git a/samples/features/Features.CrossPlatform.Shared/ViewModels/NavigationSourceViewModel.cs b/samples/features/Features.CrossPlatform.Shared/ViewModels/NavigationSourceViewModel.cs index a2aee64cc..c537d4f24 100644 --- a/samples/features/Features.CrossPlatform.Shared/ViewModels/NavigationSourceViewModel.cs +++ b/samples/features/Features.CrossPlatform.Shared/ViewModels/NavigationSourceViewModel.cs @@ -9,32 +9,32 @@ namespace Features.CrossPlatform.ViewModels { public class NavigationSourceViewModel : Screen { - private readonly INavigationService navigationService; - private string text; - private bool isEnabled; + private readonly INavigationService _navigationService; + private string _text; + private bool _isNavigationEnabled; public NavigationSourceViewModel(INavigationService navigationService) { - this.navigationService = navigationService; + this._navigationService = navigationService; } public string Text { - get { return text; } - set { Set(ref text, value); } + get { return _text; } + set { Set(ref _text, value); } } - public bool IsEnabled + public bool IsNavigationEnabled { - get { return isEnabled; } - set { Set(ref isEnabled, value); } + get { return _isNavigationEnabled; } + set { Set(ref _isNavigationEnabled, value); } } public void Navigate() { - navigationService.For() + _navigationService.For() .WithParam(v => v.Text, Text) - .WithParam(v => v.IsEnabled, IsEnabled) + .WithParam(v => v.IsNavigationEnabled, IsNavigationEnabled) .Navigate(); } } diff --git a/samples/features/Features.CrossPlatform.Shared/ViewModels/NavigationTargetViewModel.cs b/samples/features/Features.CrossPlatform.Shared/ViewModels/NavigationTargetViewModel.cs index 79b584a26..43b5f1f44 100644 --- a/samples/features/Features.CrossPlatform.Shared/ViewModels/NavigationTargetViewModel.cs +++ b/samples/features/Features.CrossPlatform.Shared/ViewModels/NavigationTargetViewModel.cs @@ -1,5 +1,4 @@ -using System; -using Caliburn.Micro; +using Caliburn.Micro; namespace Features.CrossPlatform.ViewModels { @@ -14,7 +13,7 @@ public string Text set { Set(ref text, value); } } - public bool IsEnabled + public bool IsNavigationEnabled { get { return isEnabled; } set { Set(ref isEnabled, value); } diff --git a/samples/features/Features.NetFive/Views/ActionsView.xaml b/samples/features/Features.NetFive/Views/ActionsView.xaml index f4d8cab85..09f95e87f 100644 --- a/samples/features/Features.NetFive/Views/ActionsView.xaml +++ b/samples/features/Features.NetFive/Views/ActionsView.xaml @@ -26,7 +26,7 @@ - +