Modify e2e test for GoBack Method

This commit is contained in:
niimima
2024-01-21 18:56:58 +09:00
parent 4a22857c4a
commit ba067220cf
2 changed files with 17 additions and 2 deletions
@@ -29,6 +29,7 @@ public abstract class ViewModelBase : BindableBase, IInitialize, INavigatedAware
SelectedDialog = AvailableDialogs.FirstOrDefault();
ShowDialog = new DelegateCommand(OnShowDialogCommand, () => !string.IsNullOrEmpty(SelectedDialog))
.ObservesProperty(() => SelectedDialog);
GoBack = new DelegateCommand<string>(OnGoBack);
}
public IEnumerable<string> AvailableDialogs { get; }
@@ -52,6 +53,8 @@ public abstract class ViewModelBase : BindableBase, IInitialize, INavigatedAware
public DelegateCommand ShowDialog { get; }
public DelegateCommand<string> GoBack { get; }
private void OnNavigateCommandExecuted(string uri)
{
Messages.Add($"OnNavigateCommandExecuted: {uri}");
@@ -74,6 +77,12 @@ public abstract class ViewModelBase : BindableBase, IInitialize, INavigatedAware
private void DialogCallback(IDialogResult result) =>
Messages.Add("Dialog Closed");
private void OnGoBack(string viewName)
{
Messages.Add($"On Go Back {viewName}");
_navigationService.GoBackAsync(viewName);
}
public void Initialize(INavigationParameters parameters)
{
Messages.Add("ViewModel Initialized");
+8 -2
View File
@@ -7,7 +7,7 @@
x:DataType="loc:ViewModelBase"
Title="{Binding Title}"
BackgroundColor="White">
<Grid RowDefinitions="*,Auto,Auto,Auto"
<Grid RowDefinitions="*,Auto,Auto,Auto,Auto"
ColumnDefinitions="*,*">
<CollectionView ItemsSource="{Binding Messages}"
Grid.ColumnSpan="2">
@@ -57,5 +57,11 @@
Margin="10"
Grid.Row="3"
Grid.Column="1"/>
<Button Text="Go Back View B"
Command="{Binding GoBack}"
CommandParameter="ViewB"
Margin="10"
Grid.Row="4"
Grid.Column="0"/>
</Grid>
</ContentPage>
</ContentPage>