-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(onboarding): add scaffolding for the new onboarding (#16980)
Part of #16832 Adds the basic files needed for the new onboarding, aka onboarding V2. It does not do anything yet, but it's ready to be implemented. It is locked behind a feature flag. To enable it, run the app with `export FLAG_ONBOARDING_V2_ENABLED=1`
- Loading branch information
1 parent
8aebb81
commit 3dd5fa9
Showing
6 changed files
with
136 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import chronicles | ||
import io_interface | ||
|
||
import app/core/eventemitter | ||
|
||
logScope: | ||
topics = "onboarding-controller" | ||
|
||
type | ||
Controller* = ref object of RootObj | ||
delegate: io_interface.AccessInterface | ||
events: EventEmitter | ||
|
||
proc newController*(delegate: io_interface.AccessInterface, events: EventEmitter): | ||
Controller = | ||
result = Controller() | ||
result.delegate = delegate | ||
result.events = events | ||
|
||
proc delete*(self: Controller) = | ||
discard | ||
|
||
proc init*(self: Controller) = | ||
discard |
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,16 @@ | ||
type | ||
AccessInterface* {.pure inheritable.} = ref object of RootObj | ||
|
||
method delete*(self: AccessInterface) {.base.} = | ||
raise newException(ValueError, "No implementation available") | ||
|
||
method onAppLoaded*(self: AccessInterface) {.base.} = | ||
raise newException(ValueError, "No implementation available") | ||
|
||
method load*(self: AccessInterface) {.base.} = | ||
raise newException(ValueError, "No implementation available") | ||
|
||
# This way (using concepts) is used only for the modules managed by AppController | ||
type | ||
DelegateInterface* = concept c | ||
c.onboardingDidLoad() |
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,49 @@ | ||
import NimQml, chronicles, json | ||
|
||
import io_interface | ||
import view, controller | ||
|
||
import app/global/global_singleton | ||
import app/core/eventemitter | ||
|
||
export io_interface | ||
|
||
logScope: | ||
topics = "onboarding-module" | ||
|
||
type | ||
Module*[T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface | ||
delegate: T | ||
view: View | ||
viewVariant: QVariant | ||
controller: Controller | ||
|
||
proc newModule*[T](delegate: T, events: EventEmitter): Module[T] = | ||
result = Module[T]() | ||
result.delegate = delegate | ||
result.view = view.newView(result) | ||
result.viewVariant = newQVariant(result.view) | ||
result.controller = controller.newController(result, events) | ||
|
||
{.push warning[Deprecated]: off.} | ||
|
||
method delete*[T](self: Module[T]) = | ||
self.view.delete | ||
self.viewVariant.delete | ||
self.controller.delete | ||
|
||
method onAppLoaded*[T](self: Module[T]) = | ||
singletonInstance.engine.setRootContextProperty("onboardingModule", newQVariant()) | ||
self.view.delete | ||
self.view = nil | ||
self.viewVariant.delete | ||
self.viewVariant = nil | ||
self.controller.delete | ||
self.controller = nil | ||
|
||
method load*[T](self: Module[T]) = | ||
singletonInstance.engine.setRootContextProperty("onboardingModule", self.viewVariant) | ||
self.controller.init() | ||
self.delegate.onboardingDidLoad() | ||
|
||
{.pop.} |
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 @@ | ||
import NimQml, json | ||
import io_interface | ||
|
||
QtObject: | ||
type | ||
View* = ref object of QObject | ||
delegate: io_interface.AccessInterface | ||
|
||
proc delete*(self: View) = | ||
self.QObject.delete | ||
|
||
proc newView*(delegate: io_interface.AccessInterface): View = | ||
new(result, delete) | ||
result.QObject.setup | ||
result.delegate = delegate |