Merge branch 'develop-1.8' of https://github.com/kepler155c/opus-apps into develop-1.8
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
local UI = require('opus.ui')
|
local UI = require('opus.ui')
|
||||||
local Krist = require('swshop.krist')--??
|
local Krist = require('swshop.krist')
|
||||||
|
|
||||||
local colors = _G.colors
|
local colors = _G.colors
|
||||||
local device = _G.device
|
local device = _G.device
|
||||||
@@ -34,6 +34,7 @@ local wizardPage = UI.WizardPage {
|
|||||||
},
|
},
|
||||||
[4] = UI.Chooser {
|
[4] = UI.Chooser {
|
||||||
width = 9,
|
width = 9,
|
||||||
|
formIndex = 5,
|
||||||
formLabel = 'Font Size', formKey = 'textScale',
|
formLabel = 'Font Size', formKey = 'textScale',
|
||||||
nochoice = 'Small',
|
nochoice = 'Small',
|
||||||
choices = {
|
choices = {
|
||||||
@@ -42,49 +43,10 @@ local wizardPage = UI.WizardPage {
|
|||||||
},
|
},
|
||||||
help = 'Adjust text scaling',
|
help = 'Adjust text scaling',
|
||||||
},
|
},
|
||||||
[5] = UI.TextEntry {
|
|
||||||
formLabel = 'Password', formKey = 'password',
|
|
||||||
shadowText = 'password or private key',
|
|
||||||
limit = 256,
|
|
||||||
required = true,
|
|
||||||
pass = true,
|
|
||||||
help = 'Krist wallet password',
|
|
||||||
},
|
|
||||||
[6] = UI.Checkbox {
|
|
||||||
formLabel = 'Is private key', formKey = 'isPrivateKey',
|
|
||||||
help = 'Password is in private key format',
|
|
||||||
limit = 64,
|
|
||||||
ispkey = true,
|
|
||||||
},
|
|
||||||
[7] = UI.TextEntry {
|
|
||||||
inactive = true,
|
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
textColor = colors.yellow,
|
|
||||||
formLabel = 'Using address',
|
|
||||||
formKey = 'address',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local function makeAddress(text, isPrivateKey)
|
|
||||||
local privKey = text
|
|
||||||
if not isPrivateKey then
|
|
||||||
privKey = Krist.toKristWalletFormat(privKey)
|
|
||||||
end
|
|
||||||
return Krist.makev2address(privKey)
|
|
||||||
end
|
|
||||||
|
|
||||||
function wizardPage.form:eventHandler(event)
|
|
||||||
if (event.type == 'text_change' and event.element.pass) or
|
|
||||||
(event.type == 'checkbox_change' and event.element.ispkey) then
|
|
||||||
self[7].value = makeAddress(self[5].value, self[6].value)
|
|
||||||
self[7]:draw()
|
|
||||||
end
|
|
||||||
return UI.Form.eventHandler(self, event)
|
|
||||||
end
|
|
||||||
|
|
||||||
function wizardPage:setNode(node)
|
function wizardPage:setNode(node)
|
||||||
node.address = node.password and makeAddress(node.password, node.isPrivateKey) or ''
|
|
||||||
self.form:setValues(node)
|
self.form:setValues(node)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -110,4 +72,68 @@ function wizardPage:isValidFor(node)
|
|||||||
return node.mtype == 'shop'
|
return node.mtype == 'shop'
|
||||||
end
|
end
|
||||||
|
|
||||||
UI:getPage('nodeWizard').wizard:add({ storeFront = wizardPage })
|
-- [[Password View]] --
|
||||||
|
local passwordPage = UI.WizardPage {
|
||||||
|
title = 'Krist Settings',
|
||||||
|
index = 3,
|
||||||
|
backgroundColor = colors.cyan,
|
||||||
|
form = UI.Form {
|
||||||
|
x = 2, ex = -2, y = 1, ey = -2,
|
||||||
|
manualControls = true,
|
||||||
|
passEntry = UI.TextEntry {
|
||||||
|
formIndex = 1,
|
||||||
|
formLabel = 'Password', formKey = 'password',
|
||||||
|
shadowText = 'Password',
|
||||||
|
help = 'Krist wallet password',
|
||||||
|
limit = 256,
|
||||||
|
required = true,
|
||||||
|
pass = true,
|
||||||
|
},
|
||||||
|
pkeyCheck = UI.Checkbox {
|
||||||
|
formIndex = 2,
|
||||||
|
formLabel = 'Is private key', formKey = 'isPrivateKey',
|
||||||
|
help = 'Password is in private key format',
|
||||||
|
ispkey = true,
|
||||||
|
},
|
||||||
|
preview = UI.TextEntry {
|
||||||
|
formIndex = 4,
|
||||||
|
formLabel = 'Using address', formKey = 'address',
|
||||||
|
backgroundColor = colors.cyan,
|
||||||
|
textColor = colors.yellow,
|
||||||
|
inactive = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local function makeAddress(text, isPrivateKey)
|
||||||
|
local privKey = text
|
||||||
|
if not isPrivateKey then
|
||||||
|
privKey = Krist.toKristWalletFormat(privKey)
|
||||||
|
end
|
||||||
|
return Krist.makev2address(privKey)
|
||||||
|
end
|
||||||
|
|
||||||
|
function passwordPage.form:eventHandler(event)
|
||||||
|
if (event.type == 'text_change' and event.element.pass) or
|
||||||
|
(event.type == 'checkbox_change' and event.element.ispkey) then
|
||||||
|
self.passEntry.shadowText = self.pkeyCheck.value and 'Private key' or 'Password'
|
||||||
|
self.preview.value = makeAddress(self.passEntry.value, self.pkeyCheck.value)
|
||||||
|
self:draw()
|
||||||
|
end
|
||||||
|
return UI.Form.eventHandler(self, event)
|
||||||
|
end
|
||||||
|
|
||||||
|
function passwordPage:setNode(node)
|
||||||
|
node.address = node.password and makeAddress(node.password, node.isPrivateKey) or ''
|
||||||
|
self.form:setValues(node)
|
||||||
|
end
|
||||||
|
|
||||||
|
function passwordPage:validate()
|
||||||
|
return self.form:save()
|
||||||
|
end
|
||||||
|
|
||||||
|
function passwordPage:isValidFor(node)
|
||||||
|
return node.mtype == 'shop'
|
||||||
|
end
|
||||||
|
|
||||||
|
UI:getPage('nodeWizard').wizard:add({ storeFronta = wizardPage, storeFrontb = passwordPage })
|
||||||
|
|||||||
Reference in New Issue
Block a user