renamed users to accounts and fixed current account setting

Former-commit-id: 6841e8e430
This commit is contained in:
Adrian Tiberius 2016-07-05 19:14:41 +03:00
parent 4f74c035ac
commit 70026a7694
7 changed files with 27 additions and 26 deletions

View File

@ -33,9 +33,9 @@
(when (not (str/blank? public-key))
(do
(save-password password)
(dispatch [:add-account account])
(dispatch [:login-account address password])
(dispatch [:initialize-protocol account])
(dispatch [:add-account account])))))
(dispatch [:initialize-protocol account])))))
(register-handler :create-account
(-> (fn [db [_ password]]
@ -44,5 +44,8 @@
(register-handler :login-account
(-> (fn [db [_ address password]]
(.login geth address password (fn [result] (log/debug "Logged in account: " address result)))
db)))
(.login geth address password (fn [result]
(log/debug "Logged in account: " address result)
(dispatch [:set :current-account (get-in db [:accounts address])])))
db)))

View File

@ -1,4 +1,4 @@
(ns status-im.users.screen
(ns status-im.accounts.screen
(:require-macros [status-im.utils.views :refer [defview]])
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
[status-im.components.react :refer [view
@ -21,9 +21,9 @@
button-input
white-form-text-input]]
[status-im.utils.listview :as lw]
[status-im.users.views.user :refer [user-view]]
[status-im.accounts.views.account :refer [account-view]]
[status-im.i18n :refer [label]]
[status-im.users.styles :as st]))
[status-im.accounts.styles :as st]))
(def toolbar-title
[view toolbar-title-container
@ -31,13 +31,13 @@
(label :t/switch-users)]])
(defn render-row [row _ _]
(list-item [user-view row]))
(list-item [account-view row]))
(defn render-separator [_ row-id _]
(list-item [view {:style st/row-separator
:key row-id}]))
(defview users []
(defview accounts []
[accounts [:get :accounts]]
(let [accounts (conj (vals accounts) {:name (label :t/add-account)
:address "0x0"
@ -57,12 +57,12 @@
:action {:image {:style icon-search}
:handler #()}}]
[view st/user-list-container
[view st/account-list-container
[list-view {:dataSource (lw/to-datasource accounts)
:enableEmptySections true
:renderRow render-row
:renderSeparator render-separator
:style st/user-list}]]]))
:style st/account-list}]]]))
;(re-frame.core/dispatch [:set :view-id :users])

View File

@ -1,4 +1,4 @@
(ns status-im.users.styles
(ns status-im.accounts.styles
(:require [status-im.components.styles :refer [font
title-font
text1-color
@ -18,7 +18,7 @@
:bottom 0
:left 0})
(def user-list-container1
(def account-list-container1
{:position :absolute
:top 56
:right 0
@ -26,19 +26,19 @@
:left 0
:justifyContent :center})
(def user-list-container
(def account-list-container
{:flex 1
:flexDirection :column
:justifyContent :center})
(def user-list
(def account-list
{})
(def row-separator
{:borderBottomWidth 1
:borderBottomColor "#bababa"})
(def user-container
(def account-container
{:flex 1
:flexDirection :row
:height 69
@ -52,7 +52,7 @@
:alignItems :center
:justifyContent :center})
(def user-photo-container
(def account-photo-container
{:flex 1
:backgroundColor "rgba(255, 255, 255, 0.2)"
:borderRadius 50

View File

@ -1,4 +1,4 @@
(ns status-im.users.views.user
(ns status-im.accounts.views.account
(:require-macros [status-im.utils.views :refer [defview]])
(:require [clojure.string :as s]
[status-im.resources :as res]
@ -9,19 +9,19 @@
[re-frame.core :refer [dispatch subscribe]]
[status-im.components.styles :refer [icon-ok
icon-plus]]
[status-im.users.styles :as st]))
[status-im.accounts.styles :as st]))
(defn on-press [address]
(dispatch [:navigate-to :login address])
(dispatch [:set-in [:login :address] address]))
(defview user-view [{:keys [address photo-path name] :as account}]
(defview account-view [{:keys [address photo-path name] :as account}]
[current-account [:get :current-account]]
[touchable-highlight
{:onPress #(on-press address)}
[view st/user-container
[view st/account-container
[view st/photo-container
[view st/user-photo-container
[view st/account-photo-container
(if (not= address "0x0")
[image {:source {:uri (if (s/blank? photo-path) :avatar photo-path)}
:style st/photo-image}]

View File

@ -15,7 +15,7 @@
[status-im.discovery.tag :refer [discovery-tag]]
[status-im.chat.screen :refer [chat]]
[status-im.login.screen :refer [login]]
[status-im.users.screen :refer [users]]
[status-im.accounts.screen :refer [accounts]]
[status-im.chats-list.screen :refer [chats-list]]
[status-im.new-group.screen :refer [new-group]]
[status-im.participants.views.add :refer [new-participants]]
@ -78,7 +78,7 @@
:qr-scanner [qr-scanner]
:chat [chat]
:profile [profile]
:users [users]
:users [accounts]
:login [login]
:my-profile [my-profile]))})))

View File

@ -1 +0,0 @@
(ns status-im.users.handlers)

View File

@ -1 +0,0 @@
(ns status-im.users.subs)