From 2a019f330acfdb05faedc711f02b925d573f4e90 Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Fri, 30 Sep 2022 21:15:12 +0200 Subject: [PATCH] chore(@desktop/keycard): `quaternary` and `quinary` actions introduced --- src/app/modules/startup/internal/state.nim | 16 ++++++++++++ .../startup/internal/state_wrapper.nim | 10 ++++++- src/app/modules/startup/io_interface.nim | 6 +++++ src/app/modules/startup/module.nim | 26 +++++++++++++++++++ src/app/modules/startup/view.nim | 8 ++++++ .../Onboarding/stores/StartupStore.qml | 8 ++++++ 6 files changed, 73 insertions(+), 1 deletion(-) diff --git a/src/app/modules/startup/internal/state.nim b/src/app/modules/startup/internal/state.nim index 76e7fb101c..22347a45b8 100644 --- a/src/app/modules/startup/internal/state.nim +++ b/src/app/modules/startup/internal/state.nim @@ -120,6 +120,14 @@ method getNextSecondaryState*(self: State, controller: Controller): State {.inli method getNextTertiaryState*(self: State, controller: Controller): State {.inline base.} = return nil +## Returns next state instance in case the "quaternary" action is triggered +method getNextQuaternaryState*(self: State, controller: Controller): State {.inline base.} = + return nil + +## Returns next state instance in case the "quinary" action is triggered +method getNextQuinaryState*(self: State, controller: Controller): State {.inline base.} = + return nil + ## This method is executed in case "back" button is clicked method executeBackCommand*(self: State, controller: Controller) {.inline base.} = discard @@ -136,6 +144,14 @@ method executeSecondaryCommand*(self: State, controller: Controller) {.inline ba method executeTertiaryCommand*(self: State, controller: Controller) {.inline base.} = discard +## This method is executed in case "quaternary" action is triggered +method executeQuaternaryCommand*(self: State, controller: Controller) {.inline base.} = + discard + +## This method is executed in case "quinary" action is triggered +method executeQuinaryCommand*(self: State, controller: Controller) {.inline base.} = + discard + ## This method is used for handling aync responses for keycard related states method resolveKeycardNextState*(self: State, keycardFlowType: string, keycardEvent: KeycardEvent, controller: Controller): State {.inline base.} = diff --git a/src/app/modules/startup/internal/state_wrapper.nim b/src/app/modules/startup/internal/state_wrapper.nim index 84e21005ea..84c7faf15d 100644 --- a/src/app/modules/startup/internal/state_wrapper.nim +++ b/src/app/modules/startup/internal/state_wrapper.nim @@ -59,4 +59,12 @@ QtObject: proc tertiaryActionClicked*(self: StateWrapper) {.signal.} proc doTertiaryAction*(self: StateWrapper) {.slot.} = - self.tertiaryActionClicked() \ No newline at end of file + self.tertiaryActionClicked() + + proc quaternaryActionClicked*(self: StateWrapper) {.signal.} + proc doQuaternaryAction*(self: StateWrapper) {.slot.} = + self.quaternaryActionClicked() + + proc quinaryActionClicked*(self: StateWrapper) {.signal.} + proc doQuinaryAction*(self: StateWrapper) {.slot.} = + self.quinaryActionClicked() \ No newline at end of file diff --git a/src/app/modules/startup/io_interface.nim b/src/app/modules/startup/io_interface.nim index efabae52d0..47a2fef67e 100644 --- a/src/app/modules/startup/io_interface.nim +++ b/src/app/modules/startup/io_interface.nim @@ -40,6 +40,12 @@ method onSecondaryActionClicked*(self: AccessInterface) {.base.} = method onTertiaryActionClicked*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") +method onQuaternaryActionClicked*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method onQuinaryActionClicked*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + method startUpUIRaised*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/startup/module.nim b/src/app/modules/startup/module.nim index f1bd95ef26..b5969b2c30 100644 --- a/src/app/modules/startup/module.nim +++ b/src/app/modules/startup/module.nim @@ -176,6 +176,32 @@ method onTertiaryActionClicked*[T](self: Module[T]) = self.view.setCurrentStartupState(nextState) debug "tertiary_action - set state", setCurrFlow=nextState.flowType(), setCurrState=nextState.stateType() +method onQuaternaryActionClicked*[T](self: Module[T]) = + let currStateObj = self.view.currentStartupStateObj() + if currStateObj.isNil: + error "cannot resolve current state" + return + debug "quaternary_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType() + currStateObj.executeQuaternaryCommand(self.controller) + let nextState = currStateObj.getNextQuaternaryState(self.controller) + if nextState.isNil: + return + self.view.setCurrentStartupState(nextState) + debug "quaternary_action - set state", setCurrFlow=nextState.flowType(), setCurrState=nextState.stateType() + +method onQuinaryActionClicked*[T](self: Module[T]) = + let currStateObj = self.view.currentStartupStateObj() + if currStateObj.isNil: + error "cannot resolve current state" + return + debug "quinary_action", currFlow=currStateObj.flowType(), currState=currStateObj.stateType() + currStateObj.executeQuinaryCommand(self.controller) + let nextState = currStateObj.getNextQuinaryState(self.controller) + if nextState.isNil: + return + self.view.setCurrentStartupState(nextState) + debug "quinary_action - set state", setCurrFlow=nextState.flowType(), setCurrState=nextState.stateType() + method getImportedAccount*[T](self: Module[T]): GeneratedAccountDto = return self.controller.getImportedAccount() diff --git a/src/app/modules/startup/view.nim b/src/app/modules/startup/view.nim index ba57062594..f12377f879 100644 --- a/src/app/modules/startup/view.nim +++ b/src/app/modules/startup/view.nim @@ -59,6 +59,8 @@ QtObject: signalConnect(result.currentStartupState, "primaryActionClicked()", result, "onPrimaryActionClicked()", 2) signalConnect(result.currentStartupState, "secondaryActionClicked()", result, "onSecondaryActionClicked()", 2) signalConnect(result.currentStartupState, "tertiaryActionClicked()", result, "onTertiaryActionClicked()", 2) + signalConnect(result.currentStartupState, "quaternaryActionClicked()", result, "onQuaternaryActionClicked()", 2) + signalConnect(result.currentStartupState, "quinaryActionClicked()", result, "onQuinaryActionClicked()", 2) proc currentStartupStateObj*(self: View): State = return self.currentStartupState.getStateObj() @@ -87,6 +89,12 @@ QtObject: proc onTertiaryActionClicked*(self: View) {.slot.} = self.delegate.onTertiaryActionClicked() + proc onQuaternaryActionClicked*(self: View) {.slot.} = + self.delegate.onQuaternaryActionClicked() + + proc onQuinaryActionClicked*(self: View) {.slot.} = + self.delegate.onQuinaryActionClicked() + proc startUpUIRaised*(self: View) {.signal.} proc showBeforeGetStartedPopup*(self: View): bool {.slot.} = diff --git a/ui/app/AppLayouts/Onboarding/stores/StartupStore.qml b/ui/app/AppLayouts/Onboarding/stores/StartupStore.qml index 2b8300e07a..f8b3799e07 100644 --- a/ui/app/AppLayouts/Onboarding/stores/StartupStore.qml +++ b/ui/app/AppLayouts/Onboarding/stores/StartupStore.qml @@ -23,6 +23,14 @@ QtObject { root.currentStartupState.doTertiaryAction() } + function doQuaternaryAction() { + root.currentStartupState.doQuaternaryAction() + } + + function doQuinaryAction() { + root.currentStartupState.doQuinaryAction() + } + function showBeforeGetStartedPopup() { return root.startupModuleInst.showBeforeGetStartedPopup() }