Skip to content

Commit b924a71

Browse files
committed
Surface errors in vault wizard summary pages
1 parent 2bc33e4 commit b924a71

4 files changed

Lines changed: 71 additions & 17 deletions

File tree

src/Platforms/SecureFolderFS.Maui/Views/Modals/Wizard/SummaryWizardPage.xaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@
3333
<RoundRectangle CornerRadius="24" />
3434
</Border.StrokeShape>
3535
<Grid>
36+
<!-- Success indicator -->
3637
<mi:MauiIcon
3738
HorizontalOptions="Center"
3839
Icon="{mi_material:Material Icon=Check,
3940
IconSize=48}"
4041
IconColor="{AppThemeBinding Light={StaticResource PrimaryLightColor},
4142
Dark={StaticResource PrimaryDarkColor}}"
43+
IsVisible="{Binding ViewModel.IsError, Mode=OneWay, Converter={StaticResource BoolInvertConverter}}"
4244
OnPlatforms="Android"
4345
VerticalOptions="Center" />
4446
<mi:MauiIcon
@@ -47,6 +49,27 @@
4749
IconSize=48}"
4850
IconColor="{AppThemeBinding Light={StaticResource PrimaryLightColor},
4951
Dark={StaticResource PrimaryDarkColor}}"
52+
IsVisible="{Binding ViewModel.IsError, Mode=OneWay, Converter={StaticResource BoolInvertConverter}}"
53+
OnPlatforms="iOS"
54+
VerticalOptions="Center" />
55+
56+
<!-- Error indicator -->
57+
<mi:MauiIcon
58+
HorizontalOptions="Center"
59+
Icon="{mi_material:Material Icon=ErrorOutline,
60+
IconSize=48}"
61+
IconColor="{AppThemeBinding Light={StaticResource PrimaryLightColor},
62+
Dark={StaticResource PrimaryDarkColor}}"
63+
IsVisible="{Binding ViewModel.IsError, Mode=OneWay}"
64+
OnPlatforms="Android"
65+
VerticalOptions="Center" />
66+
<mi:MauiIcon
67+
HorizontalOptions="Center"
68+
Icon="{mi_cupertino:Cupertino Icon=ExclamationmarkCircle,
69+
IconSize=48}"
70+
IconColor="{AppThemeBinding Light={StaticResource PrimaryLightColor},
71+
Dark={StaticResource PrimaryDarkColor}}"
72+
IsVisible="{Binding ViewModel.IsError, Mode=OneWay}"
5073
OnPlatforms="iOS"
5174
VerticalOptions="Center" />
5275
</Grid>

src/Platforms/SecureFolderFS.Uno/Views/VaultWizard/SummaryWizardPage.xaml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,34 @@
2222
Orientation="Vertical"
2323
Spacing="8">
2424
<Grid Width="32" Height="32">
25-
<Ellipse Margin="0,-4,0,2" Fill="LimeGreen" />
26-
<not_win:FontIcon FontSize="18" Glyph="&#xE73E;" />
27-
<win:AnimatedVisualPlayer
28-
x:Name="VisualPlayer"
29-
AutoPlay="False"
30-
Loaded="VisualPlayer_Loaded">
31-
<AnimatedVisualPlayer.Source>
32-
<animvis:AnimatedAcceptVisualSource x:Name="CheckVisualSource" />
33-
</AnimatedVisualPlayer.Source>
34-
</win:AnimatedVisualPlayer>
25+
<!-- Success indicator -->
26+
<Grid Visibility="{x:Bind ViewModel.IsError, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=invert}">
27+
<Ellipse Margin="0,-4,0,2" Fill="LimeGreen" />
28+
<not_win:FontIcon FontSize="18" Glyph="&#xE73E;" />
29+
<win:AnimatedVisualPlayer
30+
x:Name="VisualPlayer"
31+
AutoPlay="False"
32+
Loaded="VisualPlayer_Loaded">
33+
<AnimatedVisualPlayer.Source>
34+
<animvis:AnimatedAcceptVisualSource x:Name="CheckVisualSource" />
35+
</AnimatedVisualPlayer.Source>
36+
</win:AnimatedVisualPlayer>
37+
</Grid>
38+
39+
<!-- Error indicator -->
40+
<FontIcon
41+
FontSize="24"
42+
Foreground="{ThemeResource SystemFillColorCriticalBrush}"
43+
Glyph="&#xE7BA;"
44+
Visibility="{x:Bind ViewModel.IsError, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
3545
</Grid>
36-
<TextBlock FontSize="20" Text="{x:Bind ViewModel.Message, Mode=OneWay}" />
46+
<TextBlock
47+
MaxWidth="400"
48+
HorizontalAlignment="Center"
49+
FontSize="20"
50+
HorizontalTextAlignment="Center"
51+
Text="{x:Bind ViewModel.Message, Mode=OneWay}"
52+
TextWrapping="Wrap" />
3753
</StackPanel>
3854

3955
<TextBlock

src/Sdk/SecureFolderFS.Sdk/ViewModels/Views/Wizard/SummaryWizardViewModel.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public sealed partial class SummaryWizardViewModel : OverlayViewModel, IStagingV
1919

2020
[ObservableProperty] private string? _Message;
2121
[ObservableProperty] private string? _VaultName;
22+
[ObservableProperty] private bool _IsError;
2223

2324
public SummaryWizardViewModel(IVaultModel vaultModel, IVaultCollectionModel vaultCollectionModel)
2425
{
@@ -50,12 +51,13 @@ public override async void OnAppearing()
5051
// Add the newly created vault
5152
_vaultCollectionModel.Add(_vaultModel);
5253

53-
// Try to save the new vault
54-
var result = await _vaultCollectionModel.TrySaveAsync();
55-
_ = result; // TODO: Maybe use the result to indicate whether the save was successful or not
56-
57-
// Display result as message
58-
Message = "VaultAdded".ToLocalized();
54+
// Try to save the new vault and reflect the outcome to the user. A silent failure here would
55+
// leave the vault absent after the next app restart, so it must be surfaced
56+
var saved = await _vaultCollectionModel.TrySaveAsync();
57+
IsError = !saved;
58+
Message = saved
59+
? "VaultAdded".ToLocalized()
60+
: "VaultAddedSaveFailed".ToLocalized();
5961
}
6062
}
6163
}

src/Shared/SecureFolderFS.Shared/Models/Result.Message.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ public MessageResult(bool isSuccess, string? message = null)
2020
{
2121
Message = message;
2222
}
23+
24+
/// <summary>
25+
/// Creates an instance of <see cref="IResultWithMessage"/> by combining the given base result and an additional message.
26+
/// </summary>
27+
/// <param name="baseResult">The base result, which contains the success state or an exception.</param>
28+
/// <param name="message">The additional message to include in the result.</param>
29+
/// <returns>A new instance of <see cref="IResultWithMessage"/> containing the provided base result and message.</returns>
30+
public static IResultWithMessage WithMessage(IResult baseResult, string message)
31+
{
32+
return baseResult.Exception is not null
33+
? new MessageResult(baseResult.Exception, message)
34+
: new MessageResult(baseResult.Successful, message);
35+
}
2336
}
2437

2538
/// <inheritdoc cref="IResultWithMessage{T}"/>

0 commit comments

Comments
 (0)