From 460d29c053e136b6bf8fdb2beced8fd54ad4bd48 Mon Sep 17 00:00:00 2001 From: Adrian Tiberius Date: Tue, 5 Jul 2016 22:24:09 +0300 Subject: [PATCH] added add account button functionality Former-commit-id: 1555002bcdee0d37296193e00428f0868147f747 --- src/status_im/accounts/handlers.cljs | 19 ++++++++++++++++++- src/status_im/accounts/screen.cljs | 16 +++++++++++----- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/status_im/accounts/handlers.cljs b/src/status_im/accounts/handlers.cljs index 88aeabb432..6f8d0ab569 100644 --- a/src/status_im/accounts/handlers.cljs +++ b/src/status_im/accounts/handlers.cljs @@ -8,6 +8,9 @@ [status-im.protocol.state.storage :as storage] [status-im.utils.identicon :refer [identicon]] [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])) @@ -60,4 +63,18 @@ (into {}))] (assoc db :accounts accounts))) -(register-handler :load-accounts load-accounts!) \ No newline at end of file +(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) \ No newline at end of file diff --git a/src/status_im/accounts/screen.cljs b/src/status_im/accounts/screen.cljs index b1ec3e433d..8c3f22101b 100644 --- a/src/status_im/accounts/screen.cljs +++ b/src/status_im/accounts/screen.cljs @@ -24,7 +24,8 @@ [status-im.utils.listview :as lw] [status-im.accounts.views.account :refer [account-view]] [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 [view toolbar-title-container @@ -38,6 +39,10 @@ (list-item [view {:style st/row-separator :key row-id}])) +(defn create-account [event] + (dispatch [:console-create-account]) + (dispatch [:navigate-to :chat "console"])) + (defview accounts [] [accounts [:get :accounts]] (let [accounts (vals accounts)] @@ -63,10 +68,11 @@ :renderSeparator render-separator :style st/account-list}]] [view st/add-account-button-container - [view st/add-account-button - [image {:source {:uri :icon_add} - :style st/icon-plus}] - [text {:style st/add-account-text} (label :t/add-account)]]]])) + [touchable-highlight {:on-press create-account} + [view st/add-account-button + [image {:source {:uri :icon_add} + :style st/icon-plus}] + [text {:style st/add-account-text} (label :t/add-account)]]]]])) ;(re-frame.core/dispatch [:set :view-id :users])