added add account button functionality

This commit is contained in:
Adrian Tiberius 2016-07-05 22:24:09 +03:00
parent d1446634b4
commit 1555002bcd
2 changed files with 29 additions and 6 deletions

View File

@ -8,6 +8,9 @@
[status-im.protocol.state.storage :as storage] [status-im.protocol.state.storage :as storage]
[status-im.utils.identicon :refer [identicon]] [status-im.utils.identicon :refer [identicon]]
[status-im.db :refer [default-view]] [status-im.db :refer [default-view]]
[status-im.utils.random :as random]
[status-im.i18n :refer [label]]
[status-im.constants :refer [content-type-command-request]]
[clojure.string :as str])) [clojure.string :as str]))
@ -60,4 +63,18 @@
(into {}))] (into {}))]
(assoc db :accounts accounts))) (assoc db :accounts accounts)))
(register-handler :load-accounts load-accounts!) (register-handler :load-accounts load-accounts!)
(defn console-create-account [db _]
(let [msg-id (random/id)]
(dispatch [:received-msg
{:msg-id msg-id
:content {:command (name :keypair)
:content (label :t/keypair-generated)}
:content-type content-type-command-request
:outgoing false
:from "console"
:to "me"}])
db))
(register-handler :console-create-account console-create-account)

View File

@ -24,7 +24,8 @@
[status-im.utils.listview :as lw] [status-im.utils.listview :as lw]
[status-im.accounts.views.account :refer [account-view]] [status-im.accounts.views.account :refer [account-view]]
[status-im.i18n :refer [label]] [status-im.i18n :refer [label]]
[status-im.accounts.styles :as st])) [status-im.accounts.styles :as st]
[status-im.utils.logging :as log]))
(def toolbar-title (def toolbar-title
[view toolbar-title-container [view toolbar-title-container
@ -38,6 +39,10 @@
(list-item [view {:style st/row-separator (list-item [view {:style st/row-separator
:key row-id}])) :key row-id}]))
(defn create-account [event]
(dispatch [:console-create-account])
(dispatch [:navigate-to :chat "console"]))
(defview accounts [] (defview accounts []
[accounts [:get :accounts]] [accounts [:get :accounts]]
(let [accounts (vals accounts)] (let [accounts (vals accounts)]
@ -63,10 +68,11 @@
:renderSeparator render-separator :renderSeparator render-separator
:style st/account-list}]] :style st/account-list}]]
[view st/add-account-button-container [view st/add-account-button-container
[view st/add-account-button [touchable-highlight {:on-press create-account}
[image {:source {:uri :icon_add} [view st/add-account-button
:style st/icon-plus}] [image {:source {:uri :icon_add}
[text {:style st/add-account-text} (label :t/add-account)]]]])) :style st/icon-plus}]
[text {:style st/add-account-text} (label :t/add-account)]]]]]))
;(re-frame.core/dispatch [:set :view-id :users]) ;(re-frame.core/dispatch [:set :view-id :users])