renamed users to accounts and fixed current account setting

This commit is contained in:
Adrian Tiberius 2016-07-05 19:14:41 +03:00
parent 6e42338fdc
commit 6841e8e430
7 changed files with 27 additions and 26 deletions

View File

@ -33,9 +33,9 @@
(when (not (str/blank? public-key)) (when (not (str/blank? public-key))
(do (do
(save-password password) (save-password password)
(dispatch [:add-account account])
(dispatch [:login-account address password]) (dispatch [:login-account address password])
(dispatch [:initialize-protocol account]) (dispatch [:initialize-protocol account])))))
(dispatch [:add-account account])))))
(register-handler :create-account (register-handler :create-account
(-> (fn [db [_ password]] (-> (fn [db [_ password]]
@ -44,5 +44,8 @@
(register-handler :login-account (register-handler :login-account
(-> (fn [db [_ address password]] (-> (fn [db [_ address password]]
(.login geth address password (fn [result] (log/debug "Logged in account: " address result))) (.login geth address password (fn [result]
(log/debug "Logged in account: " address result)
(dispatch [:set :current-account (get-in db [:accounts address])])))
db))) 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-macros [status-im.utils.views :refer [defview]])
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]] (:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
[status-im.components.react :refer [view [status-im.components.react :refer [view
@ -21,9 +21,9 @@
button-input button-input
white-form-text-input]] white-form-text-input]]
[status-im.utils.listview :as lw] [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.i18n :refer [label]]
[status-im.users.styles :as st])) [status-im.accounts.styles :as st]))
(def toolbar-title (def toolbar-title
[view toolbar-title-container [view toolbar-title-container
@ -31,13 +31,13 @@
(label :t/switch-users)]]) (label :t/switch-users)]])
(defn render-row [row _ _] (defn render-row [row _ _]
(list-item [user-view row])) (list-item [account-view row]))
(defn render-separator [_ row-id _] (defn render-separator [_ row-id _]
(list-item [view {:style st/row-separator (list-item [view {:style st/row-separator
:key row-id}])) :key row-id}]))
(defview users [] (defview accounts []
[accounts [:get :accounts]] [accounts [:get :accounts]]
(let [accounts (conj (vals accounts) {:name (label :t/add-account) (let [accounts (conj (vals accounts) {:name (label :t/add-account)
:address "0x0" :address "0x0"
@ -57,12 +57,12 @@
:action {:image {:style icon-search} :action {:image {:style icon-search}
:handler #()}}] :handler #()}}]
[view st/user-list-container [view st/account-list-container
[list-view {:dataSource (lw/to-datasource accounts) [list-view {:dataSource (lw/to-datasource accounts)
:enableEmptySections true :enableEmptySections true
:renderRow render-row :renderRow render-row
:renderSeparator render-separator :renderSeparator render-separator
:style st/user-list}]]])) :style st/account-list}]]]))
;(re-frame.core/dispatch [:set :view-id :users]) ;(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 (:require [status-im.components.styles :refer [font
title-font title-font
text1-color text1-color
@ -18,7 +18,7 @@
:bottom 0 :bottom 0
:left 0}) :left 0})
(def user-list-container1 (def account-list-container1
{:position :absolute {:position :absolute
:top 56 :top 56
:right 0 :right 0
@ -26,19 +26,19 @@
:left 0 :left 0
:justifyContent :center}) :justifyContent :center})
(def user-list-container (def account-list-container
{:flex 1 {:flex 1
:flexDirection :column :flexDirection :column
:justifyContent :center}) :justifyContent :center})
(def user-list (def account-list
{}) {})
(def row-separator (def row-separator
{:borderBottomWidth 1 {:borderBottomWidth 1
:borderBottomColor "#bababa"}) :borderBottomColor "#bababa"})
(def user-container (def account-container
{:flex 1 {:flex 1
:flexDirection :row :flexDirection :row
:height 69 :height 69
@ -52,7 +52,7 @@
:alignItems :center :alignItems :center
:justifyContent :center}) :justifyContent :center})
(def user-photo-container (def account-photo-container
{:flex 1 {:flex 1
:backgroundColor "rgba(255, 255, 255, 0.2)" :backgroundColor "rgba(255, 255, 255, 0.2)"
:borderRadius 50 :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-macros [status-im.utils.views :refer [defview]])
(:require [clojure.string :as s] (:require [clojure.string :as s]
[status-im.resources :as res] [status-im.resources :as res]
@ -9,19 +9,19 @@
[re-frame.core :refer [dispatch subscribe]] [re-frame.core :refer [dispatch subscribe]]
[status-im.components.styles :refer [icon-ok [status-im.components.styles :refer [icon-ok
icon-plus]] icon-plus]]
[status-im.users.styles :as st])) [status-im.accounts.styles :as st]))
(defn on-press [address] (defn on-press [address]
(dispatch [:navigate-to :login address]) (dispatch [:navigate-to :login address])
(dispatch [:set-in [:login :address] 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]] [current-account [:get :current-account]]
[touchable-highlight [touchable-highlight
{:onPress #(on-press address)} {:onPress #(on-press address)}
[view st/user-container [view st/account-container
[view st/photo-container [view st/photo-container
[view st/user-photo-container [view st/account-photo-container
(if (not= address "0x0") (if (not= address "0x0")
[image {:source {:uri (if (s/blank? photo-path) :avatar photo-path)} [image {:source {:uri (if (s/blank? photo-path) :avatar photo-path)}
:style st/photo-image}] :style st/photo-image}]

View File

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

View File

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

View File

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