code review, renamed chats-list to home

This commit is contained in:
Andrey Shovkoplyas 2018-01-10 17:20:10 +03:00 committed by Andrey Shovkoplyas
parent d582e6e366
commit a3cffebb23
16 changed files with 44 additions and 55 deletions

View File

@ -48,7 +48,7 @@
(register-handler
:leave-group-chat
;; todo order of operations tbd
(after (fn [_ _] (dispatch [:navigation-replace :chat-list])))
(after (fn [_ _] (dispatch [:navigation-replace :home])))
(u/side-effect!
(fn [{:keys [web3 current-chat-id chats current-public-key]} _]
(let [{:keys [public-key private-key public?]} (chats current-chat-id)]
@ -136,7 +136,7 @@
::save-public-chat chat
::start-watching-group (merge {:group-id topic}
(select-keys db [:web3 :current-public-key]))})
{:dispatch-n [[:navigate-to-clean :chat-list]
{:dispatch-n [[:navigate-to-clean :home]
[:navigate-to-chat topic]]}))))
(reg-fx
@ -207,7 +207,7 @@
::save-chat new-chat
::start-listen-group (merge {:new-chat new-chat}
(select-keys db [:web3 :current-public-key]))
:dispatch-n [[:navigate-to-clean :chat-list]
:dispatch-n [[:navigate-to-clean :home]
[:navigate-to-chat (:chat-id new-chat)]]})))
(register-handler-fx

View File

@ -1,10 +1,10 @@
(ns status-im.ui.components.chat-preview
(:require [status-im.ui.components.react :as components]
[status-im.ui.screens.chats-list.styles :as st]
[status-im.ui.screens.home.styles :as home.styles]
[status-im.utils.utils :as utils]))
(def default-attributes
{:style st/last-message-text
{:style home.styles/last-message-text
:number-of-lines 1})
(defn text [attributes s]

View File

@ -23,14 +23,7 @@
(def use-def (get-class "Use"))
(def defs (get-class "Defs"))
(def icons {;;NOT USED IN MVP
;;:icons/chats (slurp-svg "./resources/icons/bottom/chats_gray.svg")
;;:icons/chats-active (slurp-svg "./resources/icons/bottom/chats_active.svg")
;;:icons/contacts (slurp-svg "./resources/icons/bottom/contacts_gray.svg")
;;:icons/contacts-active (slurp-svg "./resources/icons/bottom/contacts_active.svg")
;;:icons/discover (slurp-svg "./resources/icons/bottom/discover_gray.svg")
;;:icons/discover-active (slurp-svg "./resources/icons/bottom/discover_active.svg")
:icons/home (slurp-svg "./resources/icons/bottom/home_gray.svg")
(def icons {:icons/home (slurp-svg "./resources/icons/bottom/home_gray.svg")
:icons/home-active (slurp-svg "./resources/icons/bottom/home_blue.svg")
:icons/profile (slurp-svg "./resources/icons/bottom/profile_gray.svg")
:icons/profile-active (slurp-svg "./resources/icons/bottom/profile_blue.svg")

View File

@ -131,8 +131,8 @@
(when (or new-account? recover-in-progress?)
[[:chat-received-message/add console-chat/phone-number-request-message]
[:chat-received-message/add console-chat/shake-your-phone-message]])]
[:navigate-to-clean :chat-list]
[:navigate-to-clean :home]
(if new-account?
[:navigate-to-chat console-chat-id]
[:navigate-to :chat-list])]}
[:navigate-to :home])]}
(log/debug "Error changing acount: " error)))))

View File

@ -427,7 +427,7 @@
:open-chat-with-contact
(fn [_ [_ {:keys [whisper-identity dapp?] :as contact}]]
{:dispatch-n (concat
[[:navigate-to-clean :chat-list]
[[:navigate-to-clean :home]
[:start-chat whisper-identity]]
(when-not dapp?
[[::send-contact-request contact]]))}))

View File

@ -14,7 +14,7 @@
[status-im.utils.utils :as u]
[status-im.i18n :refer [label]]
[status-im.ui.screens.contacts.styles :as st]
[status-im.ui.screens.chats-list.styles :as chats-list.styles]
[status-im.ui.screens.home.styles :as home.styles]
[status-im.ui.components.styles :refer [color-blue]]))
(def ^:const contacts-limit 5)
@ -112,7 +112,7 @@
:buttonColor :#9b59b6
:onPress #(dispatch [:navigate-to :new-contact])}
[ion-icon {:name :md-create
:style chats-list.styles/create-icon}]]])
:style home.styles/create-icon}]]])
(defview contact-groups-list [_]
(letsubs [contacts [:get-added-contacts-with-limit contacts-limit]

View File

@ -1,4 +1,4 @@
(ns status-im.ui.screens.chats-list.styles
(ns status-im.ui.screens.home.styles
(:require-macros [status-im.utils.styles :refer [defstyle defnstyle]])
(:require [status-im.ui.components.styles :as component.styles]))

View File

@ -1,4 +1,4 @@
(ns status-im.ui.screens.chats-list.subs
(ns status-im.ui.screens.home.subs
(:require [re-frame.core :refer [reg-sub subscribe]]
[clojure.string :as str]))
@ -13,7 +13,7 @@
:<- [:get-in [:toolbar-search :text]]
:<- [:get-in [:toolbar-search :show]]
(fn [[chats search-text show-search]]
(let [unordered-chats (if (and (= show-search :chat-list) search-text)
(let [unordered-chats (if (and (= show-search :home) search-text)
(filter #(search-filter search-text (second %))
chats)
chats)]

View File

@ -1,4 +1,4 @@
(ns status-im.ui.screens.chats-list.views
(ns status-im.ui.screens.home.views
(:require-macros [status-im.utils.views :as views])
(:require [re-frame.core :as re-frame]
[status-im.ui.components.common.common :as components.common]
@ -9,8 +9,8 @@
[status-im.ui.components.toolbar.view :as toolbar]
[status-im.ui.components.toolbar.actions :as toolbar.actions]
[status-im.ui.components.sync-state.offline :refer [offline-view]]
[status-im.ui.screens.chats-list.views.inner-item :as inner-item]
[status-im.ui.screens.chats-list.styles :as styles]
[status-im.ui.screens.home.views.inner-item :as inner-item]
[status-im.ui.screens.home.styles :as styles]
[status-im.i18n :as i18n]
[status-im.utils.platform :as platform]))
@ -22,7 +22,7 @@
(when platform/ios?
[(toolbar.actions/add #(re-frame/dispatch [:navigate-to :new-chat]))])]])
(defn chats-action-button []
(defn home-action-button []
[native-action-button {:button-color components.styles/color-blue
:offset-x 16
:offset-y 40
@ -36,7 +36,7 @@
[react/view
[inner-item/chat-list-item-inner-view (assoc chat :chat-id chat-id) edit?]]])
(views/defview chats-list []
(views/defview home []
(views/letsubs [chats [:filtered-chats]
edit? [:get-in [:chat-list-ui-props :edit?]]
show-search [:get-in [:toolbar-search :show]]
@ -53,5 +53,5 @@
[components.common/bottom-shadow]])}]
(when platform/android?
[chats-action-button])
[home-action-button])
[offline-view]]))

View File

@ -1,4 +1,4 @@
(ns status-im.ui.screens.chats-list.views.inner-item
(ns status-im.ui.screens.home.views.inner-item
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [re-frame.core :as re-frame]
[reagent.core :as reagent]
@ -7,7 +7,7 @@
[status-im.ui.components.icons.vector-icons :as vi]
[status-im.ui.components.chat-icon.screen :as chat-icon-screen]
[status-im.ui.components.context-menu :as context-menu]
[status-im.ui.screens.chats-list.styles :as st]
[status-im.ui.screens.home.styles :as st]
[status-im.utils.utils :as utils]
[status-im.commands.utils :as commands-utils]
[status-im.i18n :as i18n]

View File

@ -5,31 +5,25 @@
[status-im.ui.components.status-bar.view :as status-bar.view]
[status-im.ui.components.styles :as common.styles]
[status-im.i18n :as i18n]
[status-im.ui.screens.chats-list.views :as chats-list.views]
[status-im.ui.screens.home.views :as home.views]
[status-im.ui.screens.profile.views :as profile.views]
[status-im.ui.screens.wallet.main.views :as wallet.views]
[status-im.ui.screens.main-tabs.styles :as styles]
[re-frame.core :as re-frame]))
(def tabs-list-data
{:chat-list
{:view-id :chat-list
[{:view-id :home
:content {:title (i18n/label :t/home)
:icon-inactive :icons/home
:icon-active :icons/home-active}
:screen chats-list.views/chats-list}
:wallet
:icon-active :icons/home-active}}
{:view-id :wallet
:content {:title (i18n/label :t/wallet)
:icon-inactive :icons/wallet
:icon-active :icons/wallet-active}
:screen wallet.views/wallet}
:my-profile
:icon-active :icons/wallet-active}}
{:view-id :my-profile
:content {:title (i18n/label :t/profile)
:icon-inactive :icons/profile
:icon-active :icons/profile-active}
:screen profile.views/my-profile}})
:icon-active :icons/profile-active}}])
(defn- tab-content [{:keys [title icon-active icon-inactive]}]
(fn [active?]
@ -41,7 +35,7 @@
[react/text {:style (styles/tab-title active?)}
title]]]))
(def tabs-list (map #(update % :content tab-content) (vals tabs-list-data)))
(def tabs-list (map #(update % :content tab-content) tabs-list-data))
(defn tab [view-id content active?]
[react/touchable-highlight {:style common.styles/flex
@ -57,9 +51,11 @@
(views/defview main-tabs []
(views/letsubs [view-id [:get :view-id]]
(let [screen (get-in tabs-list-data [view-id :screen])]
[react/view common.styles/flex
[status-bar.view/status-bar {:type (if (= view-id :wallet) :wallet :main)}]
[react/view common.styles/main-container
[screen]
[tabs view-id]]])))
[react/view common.styles/flex
[status-bar.view/status-bar {:type (if (= view-id :wallet) :wallet :main)}]
[react/view common.styles/main-container
[(case view-id
:home home.views/home
:wallet wallet.views/wallet
:my-profile profile.views/my-profile)]
[tabs view-id]]]))

View File

@ -12,7 +12,7 @@
(defn- replace-top-element [stack view-id]
(let [stack' (if (> 2 (count stack))
(list :chat-list)
(list :home)
(pop stack))]
(conj stack' view-id)))

View File

@ -3,7 +3,7 @@
status-im.chat.subs
status-im.commands.subs
status-im.ui.screens.accounts.subs
status-im.ui.screens.chats-list.subs
status-im.ui.screens.home.subs
status-im.ui.screens.group.chat-settings.subs
status-im.ui.screens.discover.subs
status-im.ui.screens.contacts.subs
@ -39,7 +39,7 @@
:<- [:get :view-id]
(fn [[search-mode? chats-edit-mode? contacts-edit-mode? view-id]]
(or search-mode?
(and (= view-id :chat-list) chats-edit-mode?)
(and (= view-id :home) chats-edit-mode?)
(and (= view-id :contact-list) contacts-edit-mode?))))
(reg-sub :network

View File

@ -73,7 +73,7 @@
(when view-id
(let [current-view (validate-current-view view-id signed-up?)]
(let [component (case current-view
(:wallet :chat-list :my-profile) main-tabs
(:home :wallet :my-profile) main-tabs
:wallet-list wallet-list-screen
:wallet-send-transaction send-transaction
:wallet-transaction-sent transaction-sent

View File

@ -20,7 +20,7 @@
[re-frame/trim-v]
(fn [{{:keys [wallet]} :db} [{:keys [whisper-identity]}]]
{:dispatch-n [[:navigate-back]
[:navigate-to-clean :chat-list]
[:navigate-to-clean :home]
[:add-chat-loaded-event whisper-identity
[::wallet-send-chat-request (some-> wallet :request-transaction :amount money/wei->ether str)]]
[:start-chat whisper-identity]]}))

View File

@ -211,9 +211,9 @@
[status-bar/status-bar]
[toolbar-view current-tab unsigned-transactions-count filter-data]
[tabs current-tab]
(case current-tab
:transactions-history [history-list]
:unsigned-transactions [unsigned-list])]))
[(case current-tab
:transactions-history history-list
:unsigned-transactions unsigned-list)]]))
(defn- pretty-print-asset [symbol amount]
(case symbol