Skip to content

Refactor ViewModels and Views for naming consistency #919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -17,7 +15,7 @@ public IEnumerable<IResult> Execute()

yield return new BusyResult(false);
#else
yield return new VisualStateResult("Loading");
yield return new VisualStateResult("ShowLoading");

yield return TaskHelper.Delay(2000).AsResult();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<NavigationTargetViewModel>()
_navigationService.For<NavigationTargetViewModel>()
.WithParam(v => v.Text, Text)
.WithParam(v => v.IsEnabled, IsEnabled)
.WithParam(v => v.IsNavigationEnabled, IsNavigationEnabled)
.Navigate();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Caliburn.Micro;
using Caliburn.Micro;

namespace Features.CrossPlatform.ViewModels
{
Expand All @@ -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); }
Expand Down
4 changes: 2 additions & 2 deletions samples/features/Features.NetFive/Views/ActionsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</TextBlock>

<TextBlock Text="Name"/>
<TextBox x:Name="Name" Margin="0,10,0,0" HorizontalAlignment="Stretch"/>
<TextBox x:Name="UserName" Margin="0,10,0,0" HorizontalAlignment="Stretch"/>

<Button x:Name="Clear" Content="Clear" Style="{StaticResource ActionButtonStyle}"/>
<Button x:Name="SimpleSayHello" Content="Simple Say Hello" Style="{StaticResource ActionButtonStyle}"/>
Expand All @@ -40,7 +40,7 @@
</i:Interaction.Triggers>
</Button>
<Button x:Name="SayHello" Content="Say Hello (with parameter)" Style="{StaticResource ActionButtonStyle}"/>
<Button cm:Message.Attach="SayHello(Name)" Content="Say Hello (with parameter and Message.Attach)" Style="{StaticResource ActionButtonStyle}"/>
<Button cm:Message.Attach="SayHello(UserName)" Content="Say Hello (with parameter and Message.Attach)" Style="{StaticResource ActionButtonStyle}"/>
<Button x:Name="SayGoodbye" Content="Say Goodbye (async method)" Style="{StaticResource ActionButtonStyle}"/>
</StackPanel>
</ScrollViewer>
Expand Down
2 changes: 1 addition & 1 deletion samples/features/Features.NetFive/Views/CoroutineView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LoadingStateGroup">
<VisualState x:Name="Loading">
<VisualState x:Name="ShowLoading">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LoadingBar" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Grid>
<StackPanel Margin="20">
<TextBox x:Name="Text" />
<CheckBox x:Name="IsEnabled" Content="Is Enabled" Margin="0,10" />
<CheckBox x:Name="IsNavigationEnabled" Content="Is Enabled" Margin="0,10" />
<Button x:Name="Navigate" Content="Navigate" />
</StackPanel>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Grid>
<StackPanel Margin="20">
<TextBlock x:Name="Text" />
<TextBlock x:Name="IsEnabled" />
<TextBlock x:Name="IsNavigationEnabled" />
</StackPanel>
</Grid>
</Page>
Expand Down
4 changes: 2 additions & 2 deletions samples/features/Features.UWP/Views/ActionsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<Run Text="{Binding Output}"/>
</TextBlock>

<TextBox Header="Name" x:Name="Name" Margin="0,10,0,0" Width="600" HorizontalAlignment="Left"/>
<TextBox Header="Name" x:Name="UserName" Margin="0,10,0,0" Width="600" HorizontalAlignment="Left"/>

<Button x:Name="Clear" Content="Clear" Style="{StaticResource ActionButtonStyle}"/>
<Button x:Name="SimpleSayHello" Content="Simple Say Hello" Style="{StaticResource ActionButtonStyle}"/>
Expand All @@ -39,7 +39,7 @@
</i:Interaction.Behaviors>
</Button>
<Button x:Name="SayHello" Content="Say Hello (with parameter)" Style="{StaticResource ActionButtonStyle}"/>
<Button cm:Message.Attach="SayHello(Name)" Content="Say Hello (with parameter and Message.Attach)" Style="{StaticResource ActionButtonStyle}"/>
<Button cm:Message.Attach="SayHello(UserName)" Content="Say Hello (with parameter and Message.Attach)" Style="{StaticResource ActionButtonStyle}"/>
<Button x:Name="SayGoodbye" Content="Say Goodbye (async method)" Style="{StaticResource ActionButtonStyle}"/>
</StackPanel>
</StackPanel>
Expand Down
2 changes: 1 addition & 1 deletion samples/features/Features.UWP/Views/CoroutineView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LoadingStateGroup">
<VisualState x:Name="Loading">
<VisualState x:Name="ShowLoading">
<VisualState.Setters>
<Setter Target="LoadingRing.IsActive" Value="True"/>
</VisualState.Setters>
Expand Down
25 changes: 13 additions & 12 deletions samples/features/Features.UWP/Views/MenuView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:cm="using:Caliburn.Micro"
mc:Ignorable="d">

<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock Text="features" Style="{StaticResource SubheaderTextBlockStyle}" Margin="40,10,40,0"/>
<ListView x:Name="Features" Padding="40,20" SelectionMode="None" IsItemClickEnabled="True"
<ScrollViewer>
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock Text="features" Style="{StaticResource SubheaderTextBlockStyle}" Margin="40,10,40,0"/>
<ListView x:Name="Features" Padding="40,20" SelectionMode="None" IsItemClickEnabled="True"
cm:Message.Attach="[Event ItemClick] = [ShowFeature($clickedItem)]" >
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Margin" Value="0,0,0,10"/>
<Setter Property="Padding" Value="10"/>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</StackPanel>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Margin" Value="0,0,0,10"/>
<Setter Property="Padding" Value="10"/>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</StackPanel>
</ScrollViewer>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<TextBlock Text="navigation" Style="{StaticResource SubheaderTextBlockStyle}" Margin="40,10,40,0"/>
<StackPanel Margin="40,20">
<TextBox Header="Text" x:Name="Text" />
<CheckBox x:Name="IsEnabled" Content="Is Enabled" />
<CheckBox x:Name="IsNavigationEnabled" Content="Is Enabled" />
<Button x:Name="Navigate" Content="Navigate" />
</StackPanel>
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<TextBlock Text="navigation" Style="{StaticResource SubheaderTextBlockStyle}" Margin="40,10,40,0"/>
<StackPanel Margin="40,20">
<TextBlock x:Name="Text" Style="{StaticResource BodyTextBlockStyle}" />
<TextBlock x:Name="IsEnabled" Style="{StaticResource BodyTextBlockStyle}" />
<TextBlock x:Name="IsNavigationEnabled" Style="{StaticResource BodyTextBlockStyle}" />
</StackPanel>
</StackPanel>
</Page>
4 changes: 2 additions & 2 deletions samples/features/Features.WPF/Views/ActionsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</TextBlock>

<TextBlock Text="Name"/>
<TextBox x:Name="Name" Margin="0,10,0,0" HorizontalAlignment="Stretch"/>
<TextBox x:Name="UserName" Margin="0,10,0,0" HorizontalAlignment="Stretch"/>

<Button x:Name="Clear" Content="Clear" Style="{StaticResource ActionButtonStyle}"/>
<Button x:Name="SimpleSayHello" Content="Simple Say Hello" Style="{StaticResource ActionButtonStyle}"/>
Expand All @@ -40,7 +40,7 @@
</i:Interaction.Triggers>
</Button>
<Button x:Name="SayHello" Content="Say Hello (with parameter)" Style="{StaticResource ActionButtonStyle}"/>
<Button cm:Message.Attach="SayHello(Name)" Content="Say Hello (with parameter and Message.Attach)" Style="{StaticResource ActionButtonStyle}"/>
<Button cm:Message.Attach="SayHello(UserName)" Content="Say Hello (with parameter and Message.Attach)" Style="{StaticResource ActionButtonStyle}"/>
<Button x:Name="SayGoodbye" Content="Say Goodbye (async method)" Style="{StaticResource ActionButtonStyle}"/>
</StackPanel>
</ScrollViewer>
Expand Down
2 changes: 1 addition & 1 deletion samples/features/Features.WPF/Views/CoroutineView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LoadingStateGroup">
<VisualState x:Name="Loading">
<VisualState x:Name="ShowLoading">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LoadingBar" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Grid>
<StackPanel Margin="20">
<TextBox x:Name="Text" />
<CheckBox x:Name="IsEnabled" Content="Is Enabled" Margin="0,10" />
<CheckBox x:Name="IsNavigationEnabled" Content="Is Enabled" Margin="0,10" />
<Button x:Name="Navigate" Content="Navigate" />
</StackPanel>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Grid>
<StackPanel Margin="20">
<TextBlock x:Name="Text" />
<TextBlock x:Name="IsEnabled" />
<TextBlock x:Name="IsNavigationEnabled" />
</StackPanel>
</Grid>
</Page>
Expand Down
Loading