generated from nventive/Template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
375ef8b
commit 7416dd2
Showing
27 changed files
with
418 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Forced Update | ||
|
||
The forced update feature is for when you want to force the user to update the app. | ||
You could use this, for example, when the backend changes and you do not want the users to still use the old API. | ||
|
||
To force an update, we suscribe to the UpdateRequired Event from the UpdateRequiredservice in the coreStartup. | ||
|
||
```cs | ||
private void SuscribeToRequiredUpdate(IServiceProvider services) | ||
{ | ||
var updateRequiredService = services.GetRequiredService<IUpdateRequiredService>(); | ||
|
||
updateRequiredService.UpdateRequired += ForceUpdate; | ||
|
||
void ForceUpdate(object sender, EventArgs e) | ||
{ | ||
var navigationController = services.GetRequiredService<ISectionsNavigator>(); | ||
|
||
_ = Task.Run(async () => | ||
{ | ||
await navigationController.NavigateAndClear(CancellationToken.None, () => new ForcedUpdatePageViewModel()); | ||
}); | ||
|
||
updateRequiredService.UpdateRequired -= ForceUpdate; | ||
updateRequiredService.Dispose(); | ||
} | ||
} | ||
``` | ||
|
||
This will direct the user to a page from which they cannot navigate back. The page will contain a button that leads them to the appropriate page for updating the app, with the links defined in AppSettings. |
19 changes: 19 additions & 0 deletions
19
src/app/ApplicationTemplate.Access/ApiClients/MinimumVersion/IMinimumVersionReposiory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
|
||
namespace ApplicationTemplate.DataAccess; | ||
|
||
/// <summary> | ||
/// Gets the minimum version required to use the application. | ||
/// </summary> | ||
public interface IMinimumVersionReposiory : IDisposable | ||
{ | ||
/// <summary> | ||
/// Checks the minimum required version. | ||
/// </summary> | ||
void CheckMinimumVersion(); | ||
|
||
/// <summary> | ||
/// An observable that emits the minimum version required to use the application. | ||
/// </summary> | ||
IObservable<Version> MinimumVersionObservable { get; } | ||
} |
27 changes: 27 additions & 0 deletions
27
src/app/ApplicationTemplate.Access/ApiClients/MinimumVersion/MinimumVersionRepositoryMock.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Reactive.Subjects; | ||
|
||
namespace ApplicationTemplate.DataAccess; | ||
|
||
/// <summary> | ||
/// A mock implementation of the minimum version repository. Used for testing. | ||
/// </summary> | ||
public sealed class MinimumVersionRepositoryMock : IMinimumVersionReposiory | ||
{ | ||
private readonly Subject<Version> _minimumVersionSubject = new(); | ||
|
||
/// <inheritdoc/> | ||
public IObservable<Version> MinimumVersionObservable => _minimumVersionSubject; | ||
|
||
/// <inheritdoc/> | ||
public void CheckMinimumVersion() | ||
{ | ||
_minimumVersionSubject.OnNext(new Version(1, 0, 0, 0)); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Dispose() | ||
{ | ||
_minimumVersionSubject.Dispose(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/app/ApplicationTemplate.Access/Configuration/ApplicationStoreUrisOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
|
||
namespace ApplicationTemplate; | ||
|
||
/// <summary> | ||
/// Contains the configuration for the application store URLs. | ||
/// </summary> | ||
public sealed class ApplicationStoreUrisOptions | ||
{ | ||
/// <summary> | ||
/// The URL to the application store for Android. | ||
/// </summary> | ||
public Uri Android { get; set; } | ||
|
||
/// <summary> | ||
/// The URL to the application store for iOS. | ||
/// </summary> | ||
public Uri Ios { get; set; } | ||
} |
14 changes: 14 additions & 0 deletions
14
src/app/ApplicationTemplate.Business/ForcedUpdates/IUpdateRequiredService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
|
||
namespace ApplicationTemplate.Business; | ||
|
||
/// <summary> | ||
/// This service checks if the application is running the minimum required version. | ||
/// </summary> | ||
public interface IUpdateRequiredService : IDisposable | ||
{ | ||
/// <summary> | ||
/// Event that is raised when the application needs to be updated. | ||
/// </summary> | ||
event EventHandler UpdateRequired; | ||
} |
33 changes: 33 additions & 0 deletions
33
src/app/ApplicationTemplate.Business/ForcedUpdates/UpdateRequiredServiceMock.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Reactive.Linq; | ||
using ApplicationTemplate.DataAccess; | ||
|
||
namespace ApplicationTemplate.Business; | ||
|
||
/// <summary> | ||
/// Mock implementation of the <see cref="IUpdateRequiredService"/>. | ||
/// </summary> | ||
public sealed class UpdateRequiredServiceMock : IUpdateRequiredService | ||
{ | ||
private readonly IDisposable _subscription; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="UpdateRequiredServiceMock"/> class. | ||
/// </summary> | ||
/// <param name="minimumVersionReposiory"> A repository that contains an observable we can use to update the app. </param> | ||
public UpdateRequiredServiceMock(IMinimumVersionReposiory minimumVersionReposiory) | ||
{ | ||
_subscription = minimumVersionReposiory.MinimumVersionObservable | ||
.Subscribe(_ => UpdateRequired?.Invoke(this, EventArgs.Empty)); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public event EventHandler UpdateRequired; | ||
|
||
/// <inheritdoc /> | ||
public void Dispose() | ||
{ | ||
_subscription.Dispose(); | ||
UpdateRequired = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/app/ApplicationTemplate.Presentation/Framework/Launcher/IAppStoreUriProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
|
||
namespace ApplicationTemplate; | ||
|
||
/// <summary> | ||
/// Provides the Uri to the app store for the current platform. | ||
/// </summary> | ||
public interface IAppStoreUriProvider | ||
{ | ||
/// <summary> | ||
/// Gets the Uri to the app store for the current platform. | ||
/// </summary> | ||
/// <returns>The Uri to the app store for the current platform.</returns> | ||
Uri GetAppStoreUri(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/app/ApplicationTemplate.Presentation/ViewModels/ForcedUpdatePageViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Chinook.DynamicMvvm; | ||
|
||
namespace ApplicationTemplate.Presentation; | ||
|
||
/// <summary> | ||
/// The ViewModel for the forced update page. | ||
/// </summary> | ||
public sealed class ForcedUpdatePageViewModel : ViewModel | ||
{ | ||
/// <summary> | ||
/// Navigates to the App Store. | ||
/// </summary> | ||
public IDynamicCommand NavigateToStore => this.GetCommandFromTask(async ct => | ||
{ | ||
var uriProvider = this.GetService<IAppStoreUriProvider>(); | ||
|
||
var uri = uriProvider.GetAppStoreUri(); | ||
|
||
await this.GetService<ILauncherService>().Launch(uri); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/app/ApplicationTemplate.Shared.Views/Content/ForcedUpdate/ForcedUpdatePage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<Page x:Class="ApplicationTemplate.Views.Content.ForcedUpdatePage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" | ||
mc:Ignorable="d"> | ||
|
||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
<TextBlock x:Uid="ForcedUpdateContent" | ||
Margin="0,0,0,20" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
FontSize="24" | ||
Text="An update is required to continue using the application." /> | ||
<Button HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Command="{Binding NavigateToStore}" | ||
Content="Update" | ||
Grid.Row="1"/> | ||
</Grid> | ||
</Page> |
Oops, something went wrong.