fix font size, back button and add account button

Former-commit-id: a2e6701db7
This commit is contained in:
Adrian Tiberius 2016-07-06 23:10:41 +03:00
parent 34a31dbb45
commit 762aa20613
5 changed files with 41 additions and 42 deletions

View File

@ -25,7 +25,7 @@
(defn save-password [password] (defn save-password [password]
(storage/put kv/kv-store :password password)) (storage/put kv/kv-store :password password))
(defn account-created [result password] (defn account-created [db result password]
(let [data (json->clj result) (let [data (json->clj result)
public-key (:pubkey data) public-key (:pubkey data)
address (:address data) address (:address data)
@ -38,11 +38,11 @@
(do (do
(save-password password) (save-password password)
(dispatch [:add-account account]) (dispatch [:add-account account])
(dispatch [:login-account address password]))))) (when (not (:signed-up db)) (dispatch [:login-account address password]))))))
(register-handler :create-account (register-handler :create-account
(-> (fn [db [_ password]] (-> (fn [db [_ password]]
(.createAccount geth password (fn [result] (account-created result password))) (.createAccount geth password (fn [result] (account-created db result password)))
db))) db)))
(register-handler :login-account (register-handler :login-account
@ -53,7 +53,7 @@
(dispatch [:set :login {}]) (dispatch [:set :login {}])
(dispatch [:set :current-account account]) (dispatch [:set :current-account account])
(dispatch [:initialize-protocol account]) (dispatch [:initialize-protocol account])
(dispatch [:navigate-to-clean default-view])))) (when (:signed-up db) (dispatch [:navigate-to-clean default-view])))))
db))) db)))
(defn load-accounts! [db _] (defn load-accounts! [db _]

View File

@ -44,38 +44,35 @@
(dispatch [:navigate-to :chat "console"])) (dispatch [:navigate-to :chat "console"]))
(defview accounts [] (defview accounts []
[accounts [:get :accounts]] [accounts [:get :accounts]
(let [accounts (vals accounts)] stack [:get :navigation-stack]]
[view st/screen-container (let [accounts (vals accounts)
[linear-gradient {:colors ["rgba(182, 116, 241, 1)" "rgba(107, 147, 231, 1)" "rgba(43, 171, 238, 1)"] show-back? (> (count stack) 1)]
:start [0, 0] [view st/screen-container
:end [0.5, 1] [linear-gradient {:colors ["rgba(182, 116, 241, 1)" "rgba(107, 147, 231, 1)" "rgba(43, 171, 238, 1)"]
:locations [0, 0.8 ,1] :start [0, 0]
:style st/gradient-background}] :end [0.5, 1]
:locations [0, 0.8, 1]
[toolbar {:background-color :transparent :style st/gradient-background}]
:nav-action {:image {:source {:uri :icon_back_white} [toolbar {:background-color :transparent
:style icon-back} :nav-action {:image {:source (if show-back? {:uri :icon_back_white} nil)
:handler #(dispatch [:navigate-back])} :style icon-back}
:custom-content toolbar-title :handler (if show-back? #(dispatch [:navigate-back]) nil)}
:action {:image {:style icon-search} :custom-content toolbar-title
:handler #()}}] :action {:image {:style icon-search}
[view st/accounts-container :handler #()}}]
[view st/account-list-view-container [view st/accounts-container
[list-view {:dataSource (lw/to-datasource accounts) [view st/account-list-view-container
:enableEmptySections true [list-view {:dataSource (lw/to-datasource accounts)
:renderRow render-row :enableEmptySections true
;:renderSeparator render-separator :renderRow render-row
:style st/account-list}]]] ;:renderSeparator render-separator
[view st/add-account-button-container :style st/account-list}]]]
[touchable-highlight {:on-press create-account} [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])
;{:name (label :t/add-account)
;:address "0x0"
;:photo-path :icon_plus}

View File

@ -76,10 +76,12 @@
:flexDirection :column}) :flexDirection :column})
(def name-text (def name-text
{:color color-white}) {:color color-white
:fontSize 16})
(def address-text (def address-text
{:color color-white}) {:color color-white
:fontSize 12})
(def online-container (def online-container
{:flex 0.2 {:flex 0.2

View File

@ -67,7 +67,7 @@
#(dispatch [:set :keyboard-height 0])))) #(dispatch [:set :keyboard-height 0]))))
:render :render
(fn [] (fn []
(let [startup-view (if @account @view-id (if (= @view-id :login) :login :users))] (let [startup-view (if @account @view-id (if (contains? #{:login :chat} @view-id) @view-id :accounts))]
(log/debug startup-view) (log/debug startup-view)
(case (if @signed-up startup-view :chat) (case (if @signed-up startup-view :chat)
:discovery [main-tabs] :discovery [main-tabs]
@ -83,7 +83,7 @@
:qr-scanner [qr-scanner] :qr-scanner [qr-scanner]
:chat [chat] :chat [chat]
:profile [profile] :profile [profile]
:users [accounts] :accounts [accounts]
:login [login] :login [login]
:my-profile [my-profile])))}))) :my-profile [my-profile])))})))

View File

@ -65,7 +65,7 @@
[view st/switch-users-container [view st/switch-users-container
[touchable-opacity {:onPress (fn [] [touchable-opacity {:onPress (fn []
(close-drawer) (close-drawer)
(dispatch [:navigate-to :users]) (dispatch [:navigate-to :accounts])
;; TODO not implemented ;; TODO not implemented
)} )}
[text {:style st/switch-users-text} [text {:style st/switch-users-text}