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
private class StartupTaskSequencer : IStartupTaskSequencer | |
{ | |
public StartupTaskSequencer(Queue<IStartupTask> tasks) => _tasks = tasks; | |
public async Task StartAsync(IStartupTask task, IStartupTaskParameters parameters = null) | |
{ | |
parameters ??= StartupTaskParameters.None; | |
foreach (var next in _tasks.SkipWhile(x => x != task)) | |
{ |
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
public abstract class StartupPage : ContentPage, IStartupTask | |
{ | |
... | |
async Task<IStartupTaskParameters> IStartupTask.RunAsync(IStartupTaskParameters parameters) | |
{ | |
_tcs = new TaskCompletionSource<IStartupTaskParameters>(); | |
await OnStartAsync(parameters); | |
await App.Current.MainPage.Navigation.PushModalAsync(this); |
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
public interface IStartupTaskSequencer | |
{ | |
Task StartAsync(); | |
Task StartAsync(IStartupTask task, IStartupTaskParameters parameters = 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
public partial class LoginPage : StartupPage | |
{ | |
public ICommand NextCommand { get; } | |
public LoginPage() : base() | |
{ | |
InitializeComponent(); | |
NextCommand = new Command(async() => | |
{ | |
await CompleteAsync(new StartupTaskParameters() |
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
public partial class HomePage : TabbedPage, IStartupTask | |
{ | |
public HomePage() | |
{ | |
InitializeComponent(); | |
} | |
public Task<bool> CanRunAsync() => Task.FromResult(true); | |
public async Task<IStartupTaskParameters> RunAsync(IStartupTaskParameters parameters) | |
{ |
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
public interface IStartupTask | |
{ | |
Task<bool> CanRunAsync(); | |
Task<IStartupTaskParameters> RunAsync(IStartupTaskParameters parameters); | |
} |
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
public interface IStartupTaskParameters : IDictionary<string, object>{} | |
public class StartupTaskParameters : Dictionary<string, object>, IStartupTaskParameters | |
{ | |
public static IStartupTaskParameters None => _none ??= new StartupTaskParameters(); | |
private static IStartupTaskParameters _none; | |
} |
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
public partial class AdvertisingPage : StartupPage | |
{ | |
public AdvertisingPage() | |
{ | |
InitializeComponent(); | |
} | |
protected override Task<bool> CanRunAsync() => Task.FromResult(App.VersionType == VersionType.Free); | |
} |
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
public partial class App : Application | |
{ | |
public static VersionType VersionType => VersionType.Paid; | |
public App () | |
{ | |
InitializeComponent(); | |
MainPage = new SplashPage(); | |
} |
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
public partial class SplashPage : ContentPage | |
{ | |
IStartupTaskSequencer sequencer; | |
HomePage homePage = new HomePage(); | |
public SplashPage() | |
{ | |
InitializeComponent(); | |
sequencer = new StartupTaskBuilder() |
NewerOlder