rename onboarding view

This commit is contained in:
Iuri Matias 2020-05-20 13:47:06 -04:00
parent 6ef7c9008e
commit e08c4b75a4
2 changed files with 14 additions and 16 deletions

View File

@ -5,14 +5,12 @@ import eventemitter
import onboarding import onboarding
type OnboardingController* = ref object of SignalSubscriber type OnboardingController* = ref object of SignalSubscriber
# view*: OnboardingView view*: OnboardingView
view*: Onboarding
variant*: QVariant variant*: QVariant
proc newController*(events: EventEmitter): OnboardingController = proc newController*(events: EventEmitter): OnboardingController =
result = OnboardingController() result = OnboardingController()
# result.view = newOnboardingView() result.view = newOnboardingView(events)
result.view = newOnboarding(events)
result.variant = newQVariant(result.view) result.variant = newQVariant(result.view)
proc delete*(self: OnboardingController) = proc delete*(self: OnboardingController) =

View File

@ -12,20 +12,20 @@ import ../../status/test as status_test
# Probably all QT classes will look like this: # Probably all QT classes will look like this:
QtObject: QtObject:
type Onboarding* = ref object of QObject type OnboardingView* = ref object of QObject
m_generatedAddresses: string m_generatedAddresses: string
events: EventEmitter events: EventEmitter
# ¯\_(ツ)_/¯ dunno what is this # ¯\_(ツ)_/¯ dunno what is this
proc setup(self: Onboarding) = proc setup(self: OnboardingView) =
self.QObject.setup self.QObject.setup
# ¯\_(ツ)_/¯ seems to be a method for garbage collection # ¯\_(ツ)_/¯ seems to be a method for garbage collection
proc delete*(self: Onboarding) = proc delete*(self: OnboardingView) =
self.QObject.delete self.QObject.delete
# Constructor # Constructor
proc newOnboarding*(events: EventEmitter): Onboarding = proc newOnboardingView*(events: EventEmitter): OnboardingView =
new(result, delete) new(result, delete)
result.events = events result.events = events
result.setup() result.setup()
@ -33,13 +33,13 @@ QtObject:
# Read more about slots and signals here: https://doc.qt.io/qt-5/signalsandslots.html # Read more about slots and signals here: https://doc.qt.io/qt-5/signalsandslots.html
# Accesors # Accesors
proc getGeneratedAddresses*(self: Onboarding): string {.slot.} = proc getGeneratedAddresses*(self: OnboardingView): string {.slot.} =
result = self.m_generatedAddresses result = self.m_generatedAddresses
proc generatedAddressesChanged*(self: Onboarding, proc generatedAddressesChanged*(self: OnboardingView,
generatedAddresses: string) {.signal.} generatedAddresses: string) {.signal.}
proc setGeneratedAddresses*(self: Onboarding, generatedAddresses: string) {.slot.} = proc setGeneratedAddresses*(self: OnboardingView, generatedAddresses: string) {.slot.} =
if self.m_generatedAddresses == generatedAddresses: if self.m_generatedAddresses == generatedAddresses:
return return
self.m_generatedAddresses = generatedAddresses self.m_generatedAddresses = generatedAddresses
@ -51,16 +51,16 @@ QtObject:
notify = generatedAddressesChanged notify = generatedAddressesChanged
# QML functions # QML functions
proc generateAddresses*(self: Onboarding) {.slot.} = proc generateAddresses*(self: OnboardingView) {.slot.} =
self.setGeneratedAddresses(generateAddresses()) self.setGeneratedAddresses(generateAddresses())
proc generateAlias*(self: Onboarding, publicKey: string): string {.slot.} = proc generateAlias*(self: OnboardingView, publicKey: string): string {.slot.} =
result = $libstatus.generateAlias(publicKey.toGoString) result = $libstatus.generateAlias(publicKey.toGoString)
proc identicon*(self: Onboarding, publicKey: string): string {.slot.} = proc identicon*(self: OnboardingView, publicKey: string): string {.slot.} =
result = $libstatus.identicon(publicKey.toGoString) result = $libstatus.identicon(publicKey.toGoString)
proc storeAccountAndLogin(self: Onboarding, selectedAccount: string, password: string): string {.slot.} = proc storeAccountAndLogin(self: OnboardingView, selectedAccount: string, password: string): string {.slot.} =
let account = to(json.parseJson(selectedAccount), Models.GeneratedAccount) let account = to(json.parseJson(selectedAccount), Models.GeneratedAccount)
let password = "0x" & $keccak_256.digest(password) let password = "0x" & $keccak_256.digest(password)
let multiAccount = %* { let multiAccount = %* {
@ -136,7 +136,7 @@ QtObject:
self.events.emit("node:ready", Args()) self.events.emit("node:ready", Args())
echo "Account saved succesfully" echo "Account saved succesfully"
proc generateRandomAccountAndLogin*(self: Onboarding) {.slot.} = proc generateRandomAccountAndLogin*(self: OnboardingView) {.slot.} =
discard status_test.setupNewAccount() discard status_test.setupNewAccount()
self.events.emit("node:ready", Args()) self.events.emit("node:ready", Args())