This commit is contained in:
Iuri Matias 2020-05-21 12:16:00 -04:00
parent ff25fc818a
commit ce236fbc82
6 changed files with 3 additions and 166 deletions

View File

@ -7,7 +7,6 @@ import ../../status/libstatus
import ../../models/accounts as Models
import ../../constants/constants
import ../../status/test as status_test
# import "../../status/core" as status
import ../signals/types
import uuids
import eventemitter
@ -22,7 +21,6 @@ proc newController*(events: EventEmitter): OnboardingController =
result = OnboardingController()
# TODO: events should be specific to the model itself
result.model = newAccountModel(events)
# result.view = newOnboardingView(result.model, storeAccountAndLogin, generateRandomAccountAndLogin)
result.view = newOnboardingView(result.model)
result.variant = newQVariant(result.view)
@ -31,19 +29,7 @@ proc delete*(self: OnboardingController) =
delete self.variant
proc init*(self: OnboardingController) =
# let addresses = parseJson(status_accounts.generateAddresses())
let accounts = self.model.generateAddresses()
for account in accounts:
# self.view.addAddressToList("account.username", "account.identicon", "account.key")
self.view.addAddressToList(account.username, account.identicon, account.key)
# echo address
# var username = $libstatus.generateAlias(address["publicKey"].str.toGoString)
# var identicon = $libstatus.identicon(address["publicKey"].str.toGoString)
# var generatedAddress = address["address"].str
# self.view.addAddressToList(username, identicon, generatedAddress)
# method onSignal(self: OnboardingController, data: Signal) =
# echo "new signal received"
# var msg = cast[WalletSignal](data)
# self.view.setLastMessage(msg.content)

View File

@ -25,9 +25,6 @@ QtObject:
type OnboardingView* = ref object of QAbstractListModel
addresses*: seq[Address]
model: AccountModel
# m_generatedAddresses: string
# doStoreAccountAndLogin: proc(model: AccountModel, selectedAccount: int, password: string): string
# doGenerateRandomAccountAndLogin: proc(events: EventEmitter)
proc setup(self: OnboardingView) =
self.QAbstractListModel.setup
@ -38,12 +35,9 @@ QtObject:
address.delete
self.addresses = @[]
# proc newOnboardingView*(model: AccountModel, doStoreAccountAndLogin: proc, doGenerateRandomAccountAndLogin: proc(events: EventEmitter)): OnboardingView =
proc newOnboardingView*(model: AccountModel): OnboardingView =
new(result, delete)
result.model = model
# result.doStoreAccountAndLogin = doStoreAccountAndLogin
# result.doGenerateRandomAccountAndLogin = doGenerateRandomAccountAndLogin
result.addresses = @[]
result.setup
@ -75,41 +69,7 @@ QtObject:
AddressRoles.Identicon.int:"identicon",
AddressRoles.Key.int:"key" }.toTable
# proc getGeneratedAddresses*(self: OnboardingView): string {.slot.} =
# result = self.m_generatedAddresses
# proc generatedAddressesChanged*(self: OnboardingView,
# generatedAddresses: string) {.signal.}
# proc setGeneratedAddresses*(self: OnboardingView, generatedAddresses: string) {.slot.} =
# if self.m_generatedAddresses == generatedAddresses:
# return
# self.m_generatedAddresses = generatedAddresses
# self.generatedAddressesChanged(generatedAddresses)
# QtProperty[string]generatedAddresses:
# read = getGeneratedAddresses
# write = setGeneratedAddresses
# notify = generatedAddressesChanged
# QML functions
# proc generateAddresses*(self: OnboardingView) {.slot.} =
# self.setGeneratedAddresses(status_accounts.generateAddresses())
# proc generateAlias*(self: OnboardingView, publicKey: string): string {.slot.} =
# result = $libstatus.generateAlias(publicKey.toGoString)
# proc identicon*(self: OnboardingView, publicKey: string): string {.slot.} =
# result = $libstatus.identicon(publicKey.toGoString)
# proc storeAccountAndLogin(self: OnboardingView, selectedAccount: string, password: string): string {.slot.} =
proc storeAccountAndLogin(self: OnboardingView, selectedAccountIndex: int, password: string): string {.slot.} =
echo "--------------------"
echo "--------------------"
echo selectedAccountIndex
echo "--------------------"
echo "--------------------"
# var selectedAccountIndex = self.addresses
result = self.model.storeAccountAndLogin(selectedAccountIndex, password)
# TODO: this is temporary and will be removed once accounts import and creation is working

View File

@ -58,12 +58,6 @@ proc generateAddresses*(self: AccountModel): seq[GeneratedAccount] =
generatedAccount.identicon = $libstatus.identicon(account["publicKey"].str.toGoString)
generatedAccount.key = account["address"].str
# var generatedAccount = cast[GeneratedAccount](account.to(GeneratedAccountBase))
# generatedAccount.username = $libstatus.generateAlias(account["publicKey"].str.toGoString)
# generatedAccount.identicon = $libstatus.identicon(account["publicKey"].str.toGoString)
# generatedAccount.key = account["address"].str
self.generatedAddresses.add(generatedAccount)
self.generatedAddresses

View File

@ -81,14 +81,6 @@ proc mainProc() =
engine.setRootContextProperty("onboardingLogic", onboarding.variant)
engine.setRootContextProperty("onboardingModel", onboarding.variant)
# TODO: figure out a way to prevent this from breaking Qt Creator
# var initLibStatusQml = proc(): LibStatusQml =
# let libStatus = newLibStatusQml();
# return libStatus;
# discard qmlRegisterSingletonType[LibStatusQml]("im.status.desktop.Status", 1, 0, "Status", initLibStatusQml)
var profile = profile.newController()
# profile.init(accounts) # TODO: use correct account
engine.setRootContextProperty("profileModel", profile.variant)

View File

@ -12,7 +12,7 @@ SwipeView {
// property string strGeneratedAccounts: onboardingLogic.generatedAddresses
// property var generatedAccounts: {}
// signal storeAccountAndLoginResult(response: var)
signal storeAccountAndLoginResult()
signal loginDone()
onCurrentItemChanged: {
currentItem.txtPassword.focus = true;
@ -39,12 +39,6 @@ SwipeView {
anchors.horizontalCenter: parent.horizontalCenter
}
// Item {
// Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
// transformOrigin: Item.Center
// anchors.top: parent.top
// anchors.topMargin: 50
Row {
Layout.fillHeight: true
Layout.fillWidth: true
@ -134,59 +128,9 @@ SwipeView {
Layout.fillWidth: true
anchors.topMargin: 36
anchors.fill: parent
// model: ListModel {
// ListElement {
// username: "Bill Smith"
// key: "0x123"
// }
// ListElement {
// username: "Slushy Welltodo Woodborer"
// key: "0x234"
// }
// }
}
// Repeater {
// model: generatedAccountsModel
// Rectangle {
// height: 32
// width: 32
// anchors.leftMargin: 20
// anchors.rightMargin: 20
// Row {
// RadioButton {
// checked: index == 0 ? true : false
// ButtonGroup.group: accountGroup
// onClicked: {
// wizardStep2.selectedIndex = index;
// }
// }
// Column {
// Image {
// source: identicon
// }
// }
// Column {
// Text {
// text: alias
// }
// Text {
// text: publicKey
// width: 160
// elide: Text.ElideMiddle
// }
// }
// }
// }
// }
}
// }
Button {
text: "Select"
anchors.horizontalCenter: parent.horizontalCenter
@ -199,8 +143,6 @@ SwipeView {
}
}
}
}
@ -214,7 +156,6 @@ SwipeView {
anchors.top: parent.top
anchors.topMargin: 20
anchors.horizontalCenter: parent.horizontalCenter
}
Rectangle {
@ -288,15 +229,10 @@ SwipeView {
}
}
MessageDialog {
id: storeAccountAndLoginError
title: "Error storing account and logging in"
text: "An error occurred while storing your account and logging in: "
// icon: StandardIcon.Error
standardButtons: StandardButton.Ok
}
@ -317,48 +253,17 @@ SwipeView {
const storeResponse = onboardingModel.storeAccountAndLogin(selectedAccountIndex, txtPassword.text)
// const storeResponse = onboardingModel.storeAccountAndLogin(JSON.stringify(selectedAccount), txtPassword.text)
// const selectedAccount = swipeView.generatedAccounts[wizardStep2.selectedIndex];
// const storeResponse = onboardingModel.storeAccountAndLogin(JSON.stringify(selectedAccount), txtPassword.text)
const response = JSON.parse(storeResponse);
// if (response.error) {
// storeAccountAndLoginError.text += response.error;
// return storeAccountAndLoginError.open();
// }
console.log("=======");
console.log(storeResponse);
console.log("=======")
// swipeView.storeAccountAndLoginResult(response);
swipeView.storeAccountAndLoginResult();
swipeView.loginDone();
}
}
}
// handle the serialised result coming from node and deserialise into JSON
// TODO: maybe we should figure out a clever to avoid this?
// onStrGeneratedAccountsChanged: {
// if (generatedAccounts === null || generatedAccounts === "") {
// return;
// }
// swipeView.generatedAccounts = JSON.parse(strGeneratedAccounts);
// }
// handle deserialised data coming from the node
// onGeneratedAccountsChanged: {
// generatedAccountsModel.clear();
// generatedAccounts.forEach(acc => {
// generatedAccountsModel.append({
// publicKey: acc.publicKey,
// alias: onboardingLogic.generateAlias(acc.publicKey),
// identicon: onboardingLogic.identicon(acc.publicKey)
// });
// });
// }
}
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}

View File

@ -57,7 +57,7 @@ Page {
DSM.SignalTransition {
targetState: appState
signal: genKey.storeAccountAndLoginResult
signal: genKey.loginDone
// guard: !response.error
}
}