private MainView ui;
private LinkedList<Lazy<ProcessStep>> steps;
private LinkedListNode<Lazy<ProcessStep>> current;
- private Lazy<ProcessStep> welcome;
static private string doneFile = Tizen.Applications.CoreUIApplication.Current.DirectoryInfo.Data + "oobe_done";
+ private class NavigationController : IProcessNavigation
+ {
+ private ProcessStep step;
+ private ProcessManager manager;
+
+ public NavigationController(ProcessManager manager, ProcessStep step)
+ {
+ this.step = step;
+ this.manager = manager;
+ }
+
+ public void Next()
+ {
+ if (manager.CurrentStep == step)
+ {
+ manager.Next();
+ }
+ }
+
+ public void Previous()
+ {
+ if (manager.CurrentStep == step)
+ {
+ manager.Previous();
+ }
+ }
+
+ public void Finish()
+ {
+ if (manager.CurrentStep == step)
+ {
+ manager.Finish();
+ }
+ }
+ }
+
public ProcessManager()
{
//TODO consider loading this from xaml, xml or something...
new Lazy<ProcessStep>(() => new RegionStep()),
new Lazy<ProcessStep>(() => new TermsStep()),
new Lazy<ProcessStep>(() => new WifiStep()),
+ new Lazy<ProcessStep>(() => new WelcomeStep()),
}
);
- welcome = new Lazy<ProcessStep>(() => new WelcomeStep());
}
+ public ProcessStep CurrentStep { get => current.Value.Value; }
+
public void Start()
{
ui = new MainView(Window.Instance);
ui.PaginationVisible = true;
- ui.PagesCount = steps.Count;
+ ui.PagesCount = steps.Count - 1;
current = steps.First;
current.Value.Value.Initialize();
- ui.Push(current.Value.Value.CreateView(this));
+ ui.Push(current.Value.Value.CreateView(new NavigationController(this, current.Value.Value)));
current.Next?.Value.Value.Initialize();
}
/// </summary>
public void Next()
{
- // end process if all steps are done
+ // do not show pagination on last page
if (current.Next == null)
{
- ShowWelcomeScreen();
- return;
+ ui.PaginationVisible = false;
}
current = current.Next;
- ui.Push(current.Value.Value.CreateView(this));
+ ui.Push(current.Value.Value.CreateView(new NavigationController(this, current.Value.Value)));
current.Next?.Value.Value.Initialize();
}
- private void ShowWelcomeScreen()
- {
- ui.PaginationVisible = false;
- ui.Push(welcome.Value.CreateView(this));
- }
-
/// <summary>
/// Finishes process and exits application
/// </summary>