Merge pull request #229 from status-im/feature/no-platform-specific-#227

No passing :platform-specific to each component in the code (#227)
This commit is contained in:
Roman Volosovskyi 2016-09-16 11:33:32 +03:00 committed by GitHub
commit f3cf024454
41 changed files with 416 additions and 474 deletions

View File

@ -25,11 +25,10 @@
[status-im.i18n :refer [label]] [status-im.i18n :refer [label]]
[status-im.accounts.login.styles :as st])) [status-im.accounts.login.styles :as st]))
(defn toolbar-title [platform-specific] (defn toolbar-title []
[view toolbar-title-container [view toolbar-title-container
[text {:style (merge toolbar-title-text {:color color-white}) [text {:style (merge toolbar-title-text {:color color-white})
:platform-specific platform-specific :font :medium}
:font :medium}
(label :t/login)]]) (label :t/login)]])
(defview address-input [address] (defview address-input [address]
@ -58,7 +57,7 @@
(dispatch [:set-in [:login :password] %]) (dispatch [:set-in [:login :password] %])
(dispatch [:set-in [:login :error] ""]))}]]) (dispatch [:set-in [:login :error] ""]))}]])
(defview login [{platform-specific :platform-specific}] (defview login []
[{:keys [address password error]} [:get :login] [{:keys [address password error]} [:get :login]
keyboard-height [:get :keyboard-height]] keyboard-height [:get :keyboard-height]]
[view st/screen-container [view st/screen-container
@ -67,13 +66,12 @@
:end [0.5, 1] :end [0.5, 1]
:locations [0, 0.8, 1] :locations [0, 0.8, 1]
:style st/gradient-background}] :style st/gradient-background}]
[status-bar {:platform-specific platform-specific [status-bar {:type :transparent}]
:type :transparent}]
[toolbar {:background-color :transparent [toolbar {:background-color :transparent
:nav-action {:image {:source {:uri :icon_back_white} :nav-action {:image {:source {:uri :icon_back_white}
:style icon-back} :style icon-back}
:handler #(dispatch [:navigate-back])} :handler #(dispatch [:navigate-back])}
:custom-content [toolbar-title platform-specific] :custom-content [toolbar-title]
:action {:image {:style icon-search} :action {:image {:style icon-search}
:handler #()}}] :handler #()}}]
[view st/form-container [view st/form-container
@ -85,6 +83,5 @@
[touchable-highlight [touchable-highlight
{:on-press #(dispatch [:login-account address password])} {:on-press #(dispatch [:login-account address password])}
[view st/connect-button [view st/connect-button
[text {:style st/connect-button-text [text {:style st/connect-button-text}
:platform-specific platform-specific}
(label :t/connect)]]]]]]) (label :t/connect)]]]]]])

View File

@ -26,12 +26,10 @@
[clojure.string :as str] [clojure.string :as str]
[status-im.utils.logging :as log])) [status-im.utils.logging :as log]))
(defn toolbar-title (defn toolbar-title []
[platform-specific]
[view toolbar-title-container [view toolbar-title-container
[text {:style toolbar-title-text [text {:style toolbar-title-text
:platform-specific platform-specific :font :medium}
:font :medium}
(label :t/recover-from-passphrase)]]) (label :t/recover-from-passphrase)]])
(defview passphrase-input [passphrase] (defview passphrase-input [passphrase]
@ -69,7 +67,7 @@
:inputStyle st/input-style :inputStyle st/input-style
:onChangeText #(dispatch [:set-in [:recover :password] %])}]])) :onChangeText #(dispatch [:set-in [:recover :password] %])}]]))
(defview recover [{platform-specific :platform-specific}] (defview recover []
[{:keys [passphrase password passphrase-error password-error]} [:get :recover]] [{:keys [passphrase password passphrase-error password-error]} [:get :recover]]
(let [valid-form? (and (let [valid-form? (and
(s/valid? ::v/passphrase passphrase) (s/valid? ::v/passphrase passphrase)
@ -79,22 +77,20 @@
"rgba(24, 52, 76, 0)"] "rgba(24, 52, 76, 0)"]
_ (log/debug passphrase " - " password)] _ (log/debug passphrase " - " password)]
[view st/screen-container [view st/screen-container
[status-bar {:platform-specific platform-specific [status-bar {:type :transparent}]
:type :transparent}]
[toolbar {:background-color :transparent [toolbar {:background-color :transparent
:nav-action {:image {:source {:uri :icon_back} :nav-action {:image {:source {:uri :icon_back}
:style icon-back} :style icon-back}
:handler #(dispatch [:navigate-back])} :handler #(dispatch [:navigate-back])}
:custom-content [toolbar-title platform-specific] :custom-content [toolbar-title]
:action {:image {:style icon-search} :action {:image {:style icon-search}
:handler #()}}] :handler #()}}]
[linear-gradient {:locations [0 0.6 1] [linear-gradient {:locations [0 0.6 1]
:colors gradient-colors :colors gradient-colors
:style toolbar-gradient}] :style toolbar-gradient}]
[view st/recover-explain-container [view st/recover-explain-container
[text {:style st/recover-explain-text [text {:style st/recover-explain-text
:platform-specific platform-specific :font :medium}
:font :medium}
(label :t/recover-explain)]] (label :t/recover-explain)]]
[view st/form-container [view st/form-container
[view st/form-container-inner [view st/form-container-inner
@ -106,6 +102,5 @@
{:on-press #(when valid-form? {:on-press #(when valid-form?
(dispatch [:recover-account passphrase password]))} (dispatch [:recover-account passphrase password]))}
[view (st/recover-button valid-form?) [view (st/recover-button valid-form?)
[text {:style st/recover-button-text [text {:style st/recover-button-text}
:platform-specific platform-specific}
(label :t/recover)]]]]]])) (label :t/recover)]]]]]]))

View File

@ -30,12 +30,11 @@
[status-im.accounts.styles :as st] [status-im.accounts.styles :as st]
[status-im.utils.logging :as log])) [status-im.utils.logging :as log]))
(defn toolbar-title [platform-specific] (defn toolbar-title []
(let [style (merge toolbar-title-text {:color color-white})] (let [style (merge toolbar-title-text {:color color-white})]
[view toolbar-title-container [view toolbar-title-container
[text {:style style [text {:style style
:platform-specific platform-specific :font :medium}
:font :medium}
(label :t/switch-users)]])) (label :t/switch-users)]]))
(defn render-row [row _ _] (defn render-row [row _ _]
@ -51,7 +50,7 @@
(dispatch [:navigate-to-clean :accounts]) (dispatch [:navigate-to-clean :accounts])
(dispatch [:navigate-to :chat "console"])) (dispatch [:navigate-to :chat "console"]))
(defview accounts [{platform-specific :platform-specific}] (defview accounts []
[accounts [:get :accounts] [accounts [:get :accounts]
stack [:get :navigation-stack]] stack [:get :navigation-stack]]
(let [accounts (vals accounts) (let [accounts (vals accounts)
@ -64,16 +63,14 @@
:end [0.5, 1] :end [0.5, 1]
:locations [0, 0.8, 1] :locations [0, 0.8, 1]
:style st/gradient-background} :style st/gradient-background}
[status-bar {:platform-specific platform-specific [status-bar {:type :transparent}]
:type :transparent}] [toolbar {:background-color :transparent
[toolbar {:background-color :transparent :nav-action {:image {:source (if show-back? {:uri :icon_back_white} nil)
:nav-action {:image {:source (if show-back? {:uri :icon_back_white} nil) :style icon-back}
:style icon-back} :handler (if show-back? #(dispatch [:navigate-back]) nil)}
:handler (if show-back? #(dispatch [:navigate-back]) nil)} :custom-content [toolbar-title]
:custom-content [toolbar-title platform-specific] :action {:image {:style icon-search}
:action {:image {:style icon-search} :handler #()}}]
:handler #()}
:platform-specific platform-specific}]
[list-view {:dataSource (lw/to-datasource accounts) [list-view {:dataSource (lw/to-datasource accounts)
:enableEmptySections true :enableEmptySections true
:renderRow render-row :renderRow render-row
@ -84,8 +81,7 @@
[touchable-highlight [touchable-highlight
{:on-press #(dispatch [:navigate-to :recover])} {:on-press #(dispatch [:navigate-to :recover])}
[view st/recover-button [view st/recover-button
[text {:style st/recover-button-text [text {:style st/recover-button-text}
:platform-specific platform-specific}
(label :t/recover-access)]]]] (label :t/recover-access)]]]]
[view st/add-account-button-container [view st/add-account-button-container
[touchable-highlight {:on-press create-account [touchable-highlight {:on-press create-account
@ -93,8 +89,7 @@
[view st/add-account-button [view st/add-account-button
[image {:source {:uri :icon_add} [image {:source {:uri :icon_add}
:style st/icon-plus}] :style st/icon-plus}]
[text {:style st/add-account-text [text {:style st/add-account-text
:platform-specific platform-specific :font :default}
:font :default}
(label :t/add-account)]]]] (label :t/add-account)]]]]
]]])) ]]]))

View File

@ -5,11 +5,9 @@
[re-frame.core :refer [subscribe dispatch dispatch-sync]] [re-frame.core :refer [subscribe dispatch dispatch-sync]]
[status-im.handlers] [status-im.handlers]
[status-im.subs] [status-im.subs]
[status-im.android.styles :refer [styles]]
[status-im.components.react :refer [app-registry [status-im.components.react :refer [app-registry
keyboard keyboard
orientation orientation]]
show-dialog]]
[status-im.components.main-tabs :refer [main-tabs]] [status-im.components.main-tabs :refer [main-tabs]]
[status-im.contacts.views.contact-list :refer [contact-list]] [status-im.contacts.views.contact-list :refer [contact-list]]
[status-im.contacts.views.new-contact :refer [new-contact]] [status-im.contacts.views.new-contact :refer [new-contact]]
@ -106,8 +104,7 @@
:recover recover :recover recover
:confirm confirm :confirm confirm
:my-profile my-profile)] :my-profile my-profile)]
[component {:platform-specific {:styles styles [component])))})))
:list-selection-fn show-dialog}}])))})))
(defn init [& [env]] (defn init [& [env]]
(dispatch-sync [:reset-app]) (dispatch-sync [:reset-app])

View File

@ -0,0 +1,36 @@
(ns status-im.android.platform
(:require [status-im.components.styles :as styles]
[status-im.utils.utils :as u]))
(def component-styles
{:status-bar {:default {:height 0
:bar-style "default"
:color styles/color-gray}
:transparent {:height 20
:bar-style "default"
:translucent? true
:color styles/color-transparent}}})
(def fonts
{:default {:font-family "sans-serif"}
:medium {:font-family "sans-serif-medium"}})
;; Dialogs
(def react-native-dialogs (u/require "react-native-dialogs"))
(defn show-dialog [{:keys [title options callback]}]
(let [dialog (new react-native-dialogs)]
(.set dialog (clj->js {:title title
:items options
:itemsCallback callback}))
(.show dialog)))
;; Structure to be exported
(def platform-specific
{:component-styles component-styles
:fonts fonts
:list-selection-fn show-dialog})

View File

@ -1,19 +0,0 @@
(ns status-im.android.styles
(:require [status-im.components.styles :as styles]))
(def components
{:status-bar {:default {:height 0
:bar-style "default"
:color styles/color-gray}
:transparent {:height 20
:bar-style "default"
:translucent? true
:color styles/color-transparent}}})
(def fonts
{:default {:font-family "sans-serif"}
:medium {:font-family "sans-serif-medium"}})
(def styles
{:components components
:fonts fonts})

View File

@ -16,6 +16,7 @@
[status-im.utils.listview :refer [to-datasource-inverted]] [status-im.utils.listview :refer [to-datasource-inverted]]
[status-im.utils.utils :refer [truncate-str]] [status-im.utils.utils :refer [truncate-str]]
[status-im.utils.datetime :as time] [status-im.utils.datetime :as time]
[status-im.utils.platform :refer [platform-specific]]
[status-im.components.invertible-scroll-view :refer [invertible-scroll-view]] [status-im.components.invertible-scroll-view :refer [invertible-scroll-view]]
[status-im.components.toolbar :refer [toolbar]] [status-im.components.toolbar :refer [toolbar]]
[status-im.chat.views.message :refer [chat-message]] [status-im.chat.views.message :refer [chat-message]]
@ -51,27 +52,26 @@
;; TODO stub data ('online' property) ;; TODO stub data ('online' property)
[chat-icon-view-action chat-id group-chat name color true]) [chat-icon-view-action chat-id group-chat name color true])
(defn typing [member platform-specific] (defn typing [member]
[view st/typing-view [view st/typing-view
[view st/typing-background [view st/typing-background
[text {:style st/typing-text [text {:style st/typing-text
:platform-specific platform-specific :font :default}
:font :default}
(str member " " (label :t/is-typing))]]]) (str member " " (label :t/is-typing))]]])
(defn typing-all [platform-specific] (defn typing-all []
[view st/typing-all [view st/typing-all
;; TODO stub data ;; TODO stub data
(for [member ["Geoff" "Justas"]] (for [member ["Geoff" "Justas"]]
^{:key member} [typing member platform-specific])]) ^{:key member} [typing member])])
(defn message-row [{:keys [contact-by-identity platform-specific group-chat messages-count]}] (defn message-row [{:keys [contact-by-identity group-chat messages-count]}]
(fn [row _ idx] (fn [row _ idx]
(let [message (-> row (let [message (-> row
(add-message-color contact-by-identity) (add-message-color contact-by-identity)
(assoc :group-chat group-chat) (assoc :group-chat group-chat)
(assoc :last-message (= (js/parseInt idx) (dec messages-count))))] (assoc :last-message (= (js/parseInt idx) (dec messages-count))))]
(list-item [chat-message message platform-specific])))) (list-item [chat-message message]))))
(defn on-action-selected [position] (defn on-action-selected [position]
(case position (case position
@ -99,30 +99,27 @@
(label :t/active-online) (label :t/active-online)
(label :t/active-unknown)))) (label :t/active-unknown))))
(defn toolbar-content [platform-specific] (defn toolbar-content []
(let [{:keys [group-chat name contacts chat-id]} (subscribe [:chat-properties [:group-chat :name :contacts :chat-id]]) (let [{:keys [group-chat name contacts chat-id]} (subscribe [:chat-properties [:group-chat :name :contacts :chat-id]])
show-actions (subscribe [:show-actions]) show-actions (subscribe [:show-actions])
contact (subscribe [:get-in [:contacts @chat-id]])] contact (subscribe [:get-in [:contacts @chat-id]])]
(fn [platform-specific] (fn []
[view (st/chat-name-view @show-actions) [view (st/chat-name-view @show-actions)
[text {:style st/chat-name-text [text {:style st/chat-name-text
:platform-specific platform-specific :number-of-lines 1
:number-of-lines 1 :font :medium}
:font :medium}
(if (str/blank? @name) (if (str/blank? @name)
(label :t/user-anonymous) (label :t/user-anonymous)
(or @name (label :t/chat-name)))] (or @name (label :t/chat-name)))]
(if @group-chat (if @group-chat
[view {:flexDirection :row} [view {:flexDirection :row}
[icon :group st/group-icon] [icon :group st/group-icon]
[text {:style st/members [text {:style st/members
:platform-specific platform-specific :font :medium}
:font :medium}
(let [cnt (inc (count @contacts))] (let [cnt (inc (count @contacts))]
(label-pluralize cnt :t/members))]] (label-pluralize cnt :t/members))]]
[text {:style st/last-activity [text {:style st/last-activity
:platform-specific platform-specific :font :default}
:font :default}
(online-text @contact @chat-id)])]))) (online-text @contact @chat-id)])])))
(defn toolbar-action [] (defn toolbar-action []
@ -138,22 +135,21 @@
[view st/action [view st/action
[chat-icon]]])))) [chat-icon]]]))))
(defview chat-toolbar [platform-specific] (defview chat-toolbar []
[show-actions [:show-actions]] [show-actions [:show-actions]]
[view [view
[status-bar {:platform-specific platform-specific}] [status-bar]
[toolbar {:hide-nav? show-actions [toolbar {:hide-nav? show-actions
:custom-content [toolbar-content platform-specific] :custom-content [toolbar-content]
:custom-action [toolbar-action] :custom-action [toolbar-action]
:style (get-in platform-specific [:styles :components :toolbar])}]]) :style (get-in platform-specific [:component-styles :toolbar])}]])
(defview messages-view [platform-specific group-chat] (defview messages-view [group-chat]
[messages [:chat :messages] [messages [:chat :messages]
contacts [:chat :contacts] contacts [:chat :contacts]
loaded? [:all-messages-loaded?]] loaded? [:all-messages-loaded?]]
(let [contacts' (contacts-by-identity contacts)] (let [contacts' (contacts-by-identity contacts)]
[list-view {:renderRow (message-row {:contact-by-identity contacts' [list-view {:renderRow (message-row {:contact-by-identity contacts'
:platform-specific platform-specific
:group-chat group-chat :group-chat group-chat
:messages-count (count messages)}) :messages-count (count messages)})
:renderScrollComponent #(invertible-scroll-view (js->clj %)) :renderScrollComponent #(invertible-scroll-view (js->clj %))
@ -184,7 +180,7 @@
[animated-view {:style (st/messages-container messages-offset)} [animated-view {:style (st/messages-container messages-offset)}
messages])}))) messages])})))
(defn chat [{platform-specific :platform-specific}] (defn chat []
(let [group-chat (subscribe [:chat :group-chat]) (let [group-chat (subscribe [:chat :group-chat])
show-actions (subscribe [:show-actions]) show-actions (subscribe [:show-actions])
command? (subscribe [:command?]) command? (subscribe [:command?])
@ -192,18 +188,18 @@
(r/create-class (r/create-class
{:component-did-mount #(dispatch [:check-autorun]) {:component-did-mount #(dispatch [:check-autorun])
:reagent-render :reagent-render
(fn [{platform-specific :platform-specific}] (fn []
[view {:style st/chat-view [view {:style st/chat-view
:onLayout (fn [event] :onLayout (fn [event]
(let [height (.. event -nativeEvent -layout -height)] (let [height (.. event -nativeEvent -layout -height)]
(when (not= height @layout-height) (when (not= height @layout-height)
(dispatch [:set-layout-height height]))))} (dispatch [:set-layout-height height]))))}
[chat-toolbar platform-specific] [chat-toolbar]
[messages-container [messages-container
[messages-view platform-specific @group-chat]] [messages-view @group-chat]]
;; todo uncomment this ;; todo uncomment this
#_(when @group-chat [typing-all platform-specific]) #_(when @group-chat [typing-all])
[response-view] [response-view]
(when-not @command? [suggestion-container]) (when-not @command? [suggestion-container])
[chat-message-new platform-specific] [chat-message-new]
(when @show-actions [actions-view platform-specific])])}))) (when @show-actions [actions-view])])})))

View File

@ -1,7 +1,7 @@
(ns status-im.chat.subs (ns status-im.chat.subs
(:require-macros [reagent.ratom :refer [reaction]]) (:require-macros [reagent.ratom :refer [reaction]])
(:require [re-frame.core :refer [register-sub dispatch subscribe path]] (:require [re-frame.core :refer [register-sub dispatch subscribe path]]
[status-im.components.react :refer [ios?]] [status-im.utils.platform :refer [ios?]]
[status-im.models.commands :as commands] [status-im.models.commands :as commands]
[status-im.constants :refer [response-suggesstion-resize-duration]] [status-im.constants :refer [response-suggesstion-resize-duration]]
[status-im.chat.constants :as c] [status-im.chat.constants :as c]

View File

@ -12,6 +12,7 @@
[status-im.components.chat-icon.screen :refer [chat-icon-view-menu-item]] [status-im.components.chat-icon.screen :refer [chat-icon-view-menu-item]]
[status-im.chat.styles.screen :as st] [status-im.chat.styles.screen :as st]
[status-im.i18n :refer [label label-pluralize]] [status-im.i18n :refer [label label-pluralize]]
[status-im.utils.platform :refer [platform-specific]]
[status-im.utils.logging :as log])) [status-im.utils.logging :as log]))
(defview menu-item-icon-profile [] (defview menu-item-icon-profile []
@ -97,13 +98,12 @@
[view nil]] [view nil]]
items]) items])
(defn action-view [{{:keys [icon-style (defn action-view [{:keys [icon-style
custom-icon custom-icon
handler handler
title title
subtitle] subtitle]
icon-name :icon} :action icon-name :icon}]
platform-specific :platform-specific}]
[touchable-highlight {:on-press (fn [] [touchable-highlight {:on-press (fn []
(dispatch [:set-show-actions false]) (dispatch [:set-show-actions false])
(when handler (when handler
@ -113,33 +113,30 @@
(or custom-icon (or custom-icon
[icon icon-name icon-style])] [icon icon-name icon-style])]
[view st/action-view [view st/action-view
[text {:style st/action-title [text {:style st/action-title
:platform-specific platform-specific :number-of-lines 1
:number-of-lines 1 :font :medium} title]
:font :medium} title]
(when-let [subtitle subtitle] (when-let [subtitle subtitle]
[text {:style st/action-subtitle [text {:style st/action-subtitle
:platform-specific platform-specific :number-of-lines 1
:number-of-lines 1 :font :default}
:font :default}
subtitle])]]]) subtitle])]]])
(defn actions-list-view [{styles :styles :as platform-specific}] (defn actions-list-view []
(let [{:keys [group-chat chat-id]} (subscribe [:chat-properties [:group-chat :chat-id]]) (let [{:keys [group-chat chat-id]} (subscribe [:chat-properties [:group-chat :chat-id]])
members (subscribe [:current-chat-contacts]) members (subscribe [:current-chat-contacts])
status-bar-height (get-in styles [:components :status-bar :default :height])] status-bar-height (get-in platform-specific [:component-styles :status-bar :default :height])]
(when-let [actions (if @group-chat (when-let [actions (if @group-chat
(group-chat-items @members) (group-chat-items @members)
(user-chat-items @chat-id (first @members)))] (user-chat-items @chat-id (first @members)))]
[view (-> (st/actions-wrapper status-bar-height) [view (-> (st/actions-wrapper status-bar-height)
(merge (get-in styles [:components :actions-list-view]))) (merge (get-in platform-specific [:component-styles :actions-list-view])))
[view st/actions-separator] [view st/actions-separator]
[view st/actions-view [view st/actions-view
(for [action actions] (for [action actions]
(if action (if action
^{:key action} [action-view {:platform-specific platform-specific ^{:key action} [action-view action]))]])))
:action action}]))]])))
(defn actions-view [platform-specific] (defn actions-view []
[overlay {:on-click-outside #(dispatch [:set-show-actions false])} [overlay {:on-click-outside #(dispatch [:set-show-actions false])}
[actions-list-view platform-specific]]) [actions-list-view]])

View File

@ -22,12 +22,11 @@
content-type-command-request]] content-type-command-request]]
[status-im.utils.logging :as log])) [status-im.utils.logging :as log]))
(defn message-date [timestamp platform-specific] (defn message-date [timestamp]
[view {} [view {}
[view st/message-date-container [view st/message-date-container
[text {:style st/message-date-text [text {:style st/message-date-text
:platform-specific platform-specific :font :default}
:font :default}
(time/to-short-str timestamp)]]]) (time/to-short-str timestamp)]]])
(defn contact-photo [{:keys [photo-path]}] (defn contact-photo [{:keys [photo-path]}]
@ -43,21 +42,19 @@
[view st/online-dot-left] [view st/online-dot-left]
[view st/online-dot-right]])) [view st/online-dot-right]]))
(defn message-content-status [{:keys [from content]} platform-specific] (defn message-content-status [{:keys [from content]}]
[view st/status-container [view st/status-container
[view st/status-image-view [view st/status-image-view
[contact-photo {}] [contact-photo {}]
[contact-online {:online true}]] [contact-online {:online true}]]
[text {:style st/status-from [text {:style st/status-from
:platform-specific platform-specific :font :default}
:font :default}
from] from]
[text {:style st/status-text [text {:style st/status-text
:platform-specific platform-specific :font :default}
:font :default}
content]]) content]])
(defn message-content-audio [{:keys [platform-specific]}] (defn message-content-audio [_]
[view st/audio-container [view st/audio-container
[view st/play-view [view st/play-view
[image {:source res/play [image {:source res/play
@ -65,21 +62,19 @@
[view st/track-container [view st/track-container
[view st/track] [view st/track]
[view st/track-mark] [view st/track-mark]
[text {:style st/track-duration-text [text {:style st/track-duration-text
:platform-specific platform-specific :font :default}
:font :default}
"03:39"]]]) "03:39"]]])
(defview message-content-command [content preview platform-specific] (defview message-content-command [content preview]
[commands [:get-commands-and-responses]] [commands [:get-commands-and-responses]]
(let [{:keys [command content]} (parse-command-message-content commands content) (let [{:keys [command content]} (parse-command-message-content commands content)
{:keys [name icon type]} command] {:keys [name icon type]} command]
[view st/content-command-view [view st/content-command-view
[view st/command-container [view st/command-container
[view (st/command-view command) [view (st/command-view command)
[text {:style st/command-name [text {:style st/command-name
:platform-specific platform-specific :font :default}
:font :default}
(str (if (= :command type) "!" "") name)]]] (str (if (= :command type) "!" "") name)]]]
(when icon (when icon
[view st/command-image-view [view st/command-image-view
@ -87,9 +82,8 @@
:style st/command-image}]]) :style st/command-image}]])
(if preview (if preview
preview preview
[text {:style st/command-text [text {:style st/command-text
:platform-specific platform-specific :font :default}
:font :default}
(str content)])])) (str content)])]))
(defn set-chat-command [message-id command] (defn set-chat-command [message-id command]
@ -107,41 +101,37 @@
(message :content-type))) (message :content-type)))
(defmethod message-content content-type-command-request (defmethod message-content content-type-command-request
[wrapper message platform-specific] [wrapper message]
[wrapper message [message-content-command-request message platform-specific] platform-specific]) [wrapper message [message-content-command-request message]])
(defn text-message (defn text-message
[{:keys [content] :as message} platform-specific] [{:keys [content] :as message}]
[message-view message [message-view message
[text {:style (st/text-message message) [text {:style (st/text-message message)
:platform-specific platform-specific :font :default}
:font :default}
(str content)]]) (str content)]])
(defmethod message-content text-content-type (defmethod message-content text-content-type
[wrapper message platform-specific] [wrapper message]
[wrapper message [text-message message platform-specific] platform-specific]) [wrapper message [text-message message]])
(defmethod message-content content-type-status (defmethod message-content content-type-status
[_ message platform-specific] [_ message]
[message-content-status message platform-specific]) [message-content-status message])
(defmethod message-content content-type-command (defmethod message-content content-type-command
[wrapper {:keys [content rendered-preview] :as message} platform-specific] [wrapper {:keys [content rendered-preview] :as message}]
[wrapper message [wrapper message
[message-view message [message-content-command content rendered-preview platform-specific]] [message-view message [message-content-command content rendered-preview]]])
platform-specific])
(defmethod message-content :default (defmethod message-content :default
[wrapper {:keys [content-type content] :as message} platform-specific] [wrapper {:keys [content-type content] :as message}]
[wrapper message [wrapper message
[message-view message [message-view message
[message-content-audio {:content content [message-content-audio {:content content
:content-type content-type :content-type content-type}]]])
:platform-specific platform-specific}]]
platform-specific])
(defview message-delivery-status [{:keys [delivery-status chat-id message-id] :as message} platform-specific] (defview message-delivery-status [{:keys [delivery-status chat-id message-id] :as message}]
[status [:get-in [:message-status chat-id message-id]]] [status [:get-in [:message-status chat-id message-id]]]
[view st/delivery-view [view st/delivery-view
[image {:source (case (or status delivery-status) [image {:source (case (or status delivery-status)
@ -150,9 +140,8 @@
:failed res/delivery-failed-icon :failed res/delivery-failed-icon
nil) nil)
:style st/delivery-image}] :style st/delivery-image}]
[text {:style st/delivery-text [text {:style st/delivery-text
:platform-specific platform-specific :font :default}
:font :default}
(message-status-label (or status delivery-status))]]) (message-status-label (or status delivery-status))]])
(defview member-photo [from] (defview member-photo [from]
@ -164,13 +153,12 @@
:style st/photo}]]) :style st/photo}]])
(defn incoming-group-message-body (defn incoming-group-message-body
[{:keys [selected same-author from] :as message} content platform-specific] [{:keys [selected same-author from] :as message} content]
(let [delivery-status :seen-by-everyone] (let [delivery-status :seen-by-everyone]
[view st/group-message-wrapper [view st/group-message-wrapper
(when selected (when selected
[text {:style st/selected-message [text {:style st/selected-message
:platform-specific platform-specific :font :default}
:font :default}
"Mar 7th, 15:22"]) "Mar 7th, 15:22"])
[view (st/incoming-group-message-body-st message) [view (st/incoming-group-message-body-st message)
[view st/message-author [view st/message-author
@ -179,14 +167,14 @@
content content
;; TODO show for last or selected ;; TODO show for last or selected
(when (and selected delivery-status) (when (and selected delivery-status)
[message-delivery-status {:delivery-status delivery-status} platform-specific])]]])) [message-delivery-status {:delivery-status delivery-status}])]]]))
(defn message-body (defn message-body
[{:keys [outgoing] :as message} content platform-specific] [{:keys [outgoing] :as message} content]
[view (st/message-body message) [view (st/message-body message)
content content
(when outgoing (when outgoing
[message-delivery-status message platform-specific])]) [message-delivery-status message])])
(defn message-container-animation-logic [{:keys [to-value val callback]}] (defn message-container-animation-logic [{:keys [to-value val callback]}]
(fn [_] (fn [_]
@ -223,8 +211,7 @@
(into [view] children))) (into [view] children)))
(defn chat-message [{:keys [outgoing delivery-status timestamp new-day group-chat message-id chat-id] (defn chat-message [{:keys [outgoing delivery-status timestamp new-day group-chat message-id chat-id]
:as message} :as message}]
platform-specific]
(let [status (subscribe [:get-in [:message-status chat-id message-id]])] (let [status (subscribe [:get-in [:message-status chat-id message-id]])]
(r/create-class (r/create-class
{:component-did-mount {:component-did-mount
@ -235,12 +222,11 @@
(dispatch [:send-seen! chat-id message-id]))) (dispatch [:send-seen! chat-id message-id])))
:reagent-render :reagent-render
(fn [{:keys [outgoing delivery-status timestamp new-day group-chat] (fn [{:keys [outgoing delivery-status timestamp new-day group-chat]
:as message} :as message}]
platform-specific]
[message-container message [message-container message
;; TODO there is no new-day info in message ;; TODO there is no new-day info in message
(when new-day (when new-day
[message-date timestamp platform-specific]) [message-date timestamp])
[view [view
(let [incoming-group (and group-chat (not outgoing))] (let [incoming-group (and group-chat (not outgoing))]
[message-content [message-content
@ -248,5 +234,4 @@
incoming-group-message-body incoming-group-message-body
message-body) message-body)
(merge message {:delivery-status (keyword delivery-status) (merge message {:delivery-status (keyword delivery-status)
:incoming-group incoming-group}) :incoming-group incoming-group})])]])})))
platform-specific])]])})))

View File

@ -6,6 +6,7 @@
[status-im.chat.views.message-input :refer [plain-message-input-view]] [status-im.chat.views.message-input :refer [plain-message-input-view]]
[status-im.chat.views.staged-command :refer [simple-command-staged-view]] [status-im.chat.views.staged-command :refer [simple-command-staged-view]]
[status-im.utils.phone-number :refer [valid-mobile-number?]] [status-im.utils.phone-number :refer [valid-mobile-number?]]
[status-im.utils.platform :refer [platform-specific]]
[status-im.chat.styles.message :as st])) [status-im.chat.styles.message :as st]))
(defn staged-command-view [stage-command] (defn staged-command-view [stage-command]
@ -36,10 +37,10 @@
[plain-message-input-view [plain-message-input-view
(when command? (get-options parameter type))]) (when command? (get-options parameter type))])
(defview chat-message-new [platform-specific] (defview chat-message-new []
[staged-commands [:get-chat-staged-commands] [staged-commands [:get-chat-staged-commands]
margin [:input-margin]] margin [:input-margin]]
(let [style (get-in platform-specific [:styles :components :chat :new-message])] (let [style (get-in platform-specific [:component-styles :chat :new-message])]
[view (merge (st/new-message-container margin) [view (merge (st/new-message-container margin)
style) style)
(when (seq staged-commands) (when (seq staged-commands)

View File

@ -68,7 +68,7 @@
:style st/command-request-image}]]]))}))) :style st/command-request-image}]]]))})))
(defn message-content-command-request (defn message-content-command-request
[{:keys [message-id content from incoming-group]} platform-specific] [{:keys [message-id content from incoming-group]}]
(let [commands-atom (subscribe [:get-responses])] (let [commands-atom (subscribe [:get-responses])]
(fn [{:keys [message-id content from incoming-group]}] (fn [{:keys [message-id content from incoming-group]}]
(let [commands @commands-atom (let [commands @commands-atom
@ -76,18 +76,15 @@
[view st/comand-request-view [view st/comand-request-view
[view st/command-request-message-view [view st/command-request-message-view
(when incoming-group (when incoming-group
[text {:style st/command-request-from-text [text {:style st/command-request-from-text
:platform-specific platform-specific :font :default}
:font :default}
from]) from])
[text {:style st/style-message-text [text {:style st/style-message-text
:platform-specific platform-specific :font :default}
:font :default}
content]] content]]
[request-button message-id command] [request-button message-id command]
(when (:request-text command) (when (:request-text command)
[view st/command-request-text-view [view st/command-request-text-view
[text {:style st/style-sub-text [text {:style st/style-sub-text
:platform-specific platform-specific :font :default}
:font :default}
(:request-text command)]])])))) (:request-text command)]])]))))

View File

@ -26,10 +26,10 @@
[status-im.components.tabs.bottom-gradient :refer [bottom-gradient]] [status-im.components.tabs.bottom-gradient :refer [bottom-gradient]]
[status-im.components.tabs.styles :refer [tabs-height]])) [status-im.components.tabs.styles :refer [tabs-height]]))
(defview chats-list-toolbar [platform-specific] (defview chats-list-toolbar []
[chats-scrolled? [:get :chats-scrolled?]] [chats-scrolled? [:get :chats-scrolled?]]
[view [view
[status-bar {:platform-specific platform-specific}] [status-bar]
[toolbar {:nav-action {:image {:source {:uri :icon_hamburger} [toolbar {:nav-action {:image {:source {:uri :icon_hamburger}
:style st/hamburger-icon} :style st/hamburger-icon}
:handler open-drawer} :handler open-drawer}
@ -42,12 +42,12 @@
:style st/search-icon} :style st/search-icon}
:handler (fn [])}}]]) :handler (fn [])}}]])
(defview chats-list [{platform-specific :platform-specific}] (defview chats-list []
[chats [:get :chats]] [chats [:get :chats]]
;; todo what is this?! ;; todo what is this?!
#_(dispatch [:set :chats-scrolled? false]) #_(dispatch [:set :chats-scrolled? false])
[view st/chats-container [view st/chats-container
[chats-list-toolbar platform-specific] [chats-list-toolbar]
[list-view {:dataSource (to-datasource chats) [list-view {:dataSource (to-datasource chats)
:renderRow (fn [row _ _] :renderRow (fn [row _ _]
(list-item [chat-list-item row])) (list-item [chat-list-item row]))

View File

@ -1,9 +1,8 @@
(ns status-im.components.carousel.carousel (ns status-im.components.carousel.carousel
(:require [status-im.components.react :refer [android? (:require [status-im.components.react :refer [view
view scroll-view
scroll-view touchable-without-feedback
touchable-without-feedback text]]
text]]
[status-im.components.carousel.styles :as st] [status-im.components.carousel.styles :as st]
[status-im.utils.logging :as log] [status-im.utils.logging :as log]
[status-im.components.react :as r])) [status-im.components.react :as r]))

View File

@ -27,67 +27,58 @@
{:uri photo-path}) {:uri photo-path})
:style st/user-photo}]) :style st/user-photo}])
(defn menu-item [{:keys [name handler platform-specific]}] (defn menu-item [{:keys [name handler]}]
[touchable-opacity {:style st/menu-item-touchable [touchable-opacity {:style st/menu-item-touchable
:onPress (fn [] :onPress (fn []
(close-drawer) (close-drawer)
(handler))} (handler))}
[text {:style st/menu-item-text [text {:style st/menu-item-text
:platform-specific platform-specific :font :default}
:font :default}
name]]) name]])
(defview drawer-menu [{platform-specific :platform-specific}] (defview drawer-menu []
[{:keys [name address photo-path]} [:get-current-account]] [{:keys [name address photo-path]} [:get-current-account]]
[view st/drawer-menu [view st/drawer-menu
[view st/user-photo-container [view st/user-photo-container
[user-photo {:photo-path photo-path}]] [user-photo {:photo-path photo-path}]]
[view st/name-container [view st/name-container
[text {:style st/name-text [text {:style st/name-text
:platform-specific platform-specific :number-of-lines 1
:number-of-lines 1 :font :default}
:font :default}
(if (= name address) (if (= name address)
(label :t/user-anonymous) (label :t/user-anonymous)
name)]] name)]]
[view st/menu-items-container [view st/menu-items-container
[menu-item {:name (label :t/profile) [menu-item {:name (label :t/profile)
:handler #(dispatch [:navigate-to :my-profile]) :handler #(dispatch [:navigate-to :my-profile])}]
:platform-specific platform-specific}] [menu-item {:name (label :t/settings)
[menu-item {:name (label :t/settings) :handler (fn []
:handler (fn [] ;; TODO not implemented
;; TODO not implemented )}]
) [menu-item {:name (label :t/discovery)
:platform-specific platform-specific}] :handler #(dispatch [:navigate-to :discovery])}]
[menu-item {:name (label :t/discovery) [menu-item {:name (label :t/contacts)
:handler #(dispatch [:navigate-to :discovery]) :handler #(dispatch [:navigate-to :contact-list])}]
:platform-specific platform-specific}] [menu-item {:name (label :t/invite-friends)
[menu-item {:name (label :t/contacts) :handler (fn []
:handler #(dispatch [:navigate-to :contact-list]) ;; TODO not implemented
:platform-specific platform-specific}] )}]
[menu-item {:name (label :t/invite-friends) [menu-item {:name (label :t/faq)
:handler (fn [] :handler (fn [])}]]
;; TODO not implemented
)
:platform-specific platform-specific}]
[menu-item {:name (label :t/faq)
:handler (fn [])
:platform-specific platform-specific}]]
[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 :accounts]) (dispatch [:navigate-to :accounts])
;; TODO not implemented ;; TODO not implemented
)} )}
[text {:style st/switch-users-text [text {:style st/switch-users-text
:platform-specific platform-specific :font :default}
:font :default}
(label :t/switch-users)]]]]) (label :t/switch-users)]]]])
(defn drawer-view [opts items] (defn drawer-view [items]
[drawer-layout-android {:drawerWidth 260 [drawer-layout-android {:drawerWidth 260
:drawerPosition js/ReactNative.DrawerLayoutAndroid.positions.Left :drawerPosition js/ReactNative.DrawerLayoutAndroid.positions.Left
:render-navigation-view #(r/as-element [drawer-menu opts]) :render-navigation-view #(r/as-element [drawer-menu])
:ref (fn [drawer] :ref (fn [drawer]
(reset! drawer-atom drawer))} (reset! drawer-atom drawer))}
items]) items])

View File

@ -95,20 +95,20 @@
[animated-view {:style (st/tab-view-container anim-value)} [animated-view {:style (st/tab-view-container anim-value)}
content])}))) content])})))
(defn tab-view [platform-specific {:keys [view-id screen]}] (defn tab-view [{:keys [view-id screen]}]
^{:key view-id} ^{:key view-id}
[tab-view-container view-id [tab-view-container view-id
[screen {:platform-specific platform-specific}]]) [screen]])
(defview main-tabs [{platform-specific :platform-specific}] (defview main-tabs []
[view-id [:get :view-id] [view-id [:get :view-id]
tab-animation? [:get :prev-tab-view-id]] tab-animation? [:get :prev-tab-view-id]]
[view common-st/flex [view common-st/flex
[status-bar {:platform-specific platform-specific}] [status-bar]
[view common-st/flex [view common-st/flex
[drawer-view {:platform-specific platform-specific} [drawer-view
[view {:style common-st/flex [view {:style common-st/flex
:pointerEvents (if tab-animation? :none :auto)} :pointerEvents (if tab-animation? :none :auto)}
(doall (map #(tab-view platform-specific %) tab-list)) (doall (map #(tab-view %) tab-list))
[tabs {:selected-view-id view-id [tabs {:selected-view-id view-id
:tab-list tab-list}]]]]]) :tab-list tab-list}]]]]])

View File

@ -1,13 +1,13 @@
(ns status-im.components.react (ns status-im.components.react
(:require [reagent.core :as r] (:require [reagent.core :as r]
[status-im.components.styles :as st] [status-im.components.styles :as st]
[status-im.utils.utils :as u])) [status-im.utils.utils :as u]
[status-im.utils.platform :refer [platform-specific]]))
(def react-native (u/require "react-native")) (def react-native (u/require "react-native"))
(def native-modules (.-NativeModules react-native)) (def native-modules (.-NativeModules react-native))
(def device-event-emitter (.-DeviceEventEmitter react-native)) (def device-event-emitter (.-DeviceEventEmitter react-native))
(def geth (.-Geth native-modules)) (def geth (.-Geth native-modules))
(def react-native-dialogs (u/require "react-native-dialogs"))
(def linear-gradient-module (u/require "react-native-linear-gradient")) (def linear-gradient-module (u/require "react-native-linear-gradient"))
(def dismiss-keyboard! (u/require "dismissKeyboard")) (def dismiss-keyboard! (u/require "dismissKeyboard"))
@ -64,18 +64,15 @@
(defn text (defn text
([t] ([t]
(r/as-element [text-class t])) (r/as-element [text-class t]))
([{:keys [style platform-specific font] :as opts ([{:keys [style font] :as opts
:or {font :default}} t] :or {font :default}} t]
(r/as-element (r/as-element
[text-class (let [font (get-in platform-specific [:fonts font])]
(cond [text-class
(and platform-specific font)
(-> opts (-> opts
(dissoc :platform-specific :font) (dissoc :font)
(assoc :style (st/with-font style platform-specific font))) (assoc :style (merge style font)))
style opts t]))))
:else {:style opts})
t])))
(defn text-input [props text] (defn text-input [props text]
[text-input-class (merge [text-input-class (merge
@ -110,22 +107,8 @@
[props & children] [props & children]
(vec (concat [linear-gradient-class (merge {:inverted true} props)] children))) (vec (concat [linear-gradient-class (merge {:inverted true} props)] children)))
(defn list-item [component]
;; List dialogs (r/as-element component))
(defn show-dialog [{:keys [title options callback]}]
(let [dialog (new react-native-dialogs)]
(.set dialog (clj->js {:title title
:items options
:itemsCallback callback}))
(.show dialog)))
(defn show-action-sheet [{:keys [options callback cancel-text]}]
(.showActionSheetWithOptions (get-class "ActionSheetIOS")
(clj->js {:options (conj options cancel-text)
:cancelButtonIndex (count options)})
callback))
;; Image picker ;; Image picker
@ -138,15 +121,3 @@
(.then images-fn)))) (.then images-fn))))
;; Platform
(def platform
(when-let [pl (.-Platform react-native)] (.-OS pl)))
(def android? (= platform "android"))
(def ios? (= platform "ios"))
(defn list-item [component]
(r/as-element component))

View File

@ -1,14 +1,14 @@
(ns status-im.components.status-bar (ns status-im.components.status-bar
(:require [status-im.components.react :as ui] (:require [status-im.components.react :as ui]
[status-im.components.styles :as cst])) [status-im.components.styles :as cst]
[status-im.utils.platform :refer [platform-specific]]))
(defn status-bar [{{styles :styles} :platform-specific (defn status-bar [{type :type
type :type :or {type :default}}]
:or {type :default}}]
(let [{:keys [height (let [{:keys [height
bar-style bar-style
translucent? translucent?
color]} (get-in styles [:components :status-bar type])] color]} (get-in platform-specific [:component-styles :status-bar type])]
[ui/view [ui/view
[ui/status-bar {:background-color color [ui/status-bar {:background-color color
:translucent translucent? :translucent translucent?

View File

@ -35,10 +35,6 @@
(def toolbar-height 56) (def toolbar-height 56)
(defn with-font [style platform-specific font]
(let [font (get-in platform-specific [:styles :fonts font])]
(merge style font)))
(def flex (def flex
{:flex 1}) {:flex 1})

View File

@ -16,15 +16,14 @@
icon-back icon-back
toolbar-height]])) toolbar-height]]))
(defn toolbar [{title :title (defn toolbar [{title :title
nav-action :nav-action nav-action :nav-action
hide-nav? :hide-nav? hide-nav? :hide-nav?
action :action action :action
custom-action :custom-action custom-action :custom-action
background-color :background-color background-color :background-color
custom-content :custom-content custom-content :custom-content
style :style style :style}]
platform-specific :platform-specific}]
(let [style (merge {:flexDirection :row (let [style (merge {:flexDirection :row
:backgroundColor (or background-color toolbar-background1) :backgroundColor (or background-color toolbar-background1)
:height toolbar-height :height toolbar-height
@ -48,9 +47,8 @@
:style icon-back}]]])) :style icon-back}]]]))
(or custom-content (or custom-content
[view {:style toolbar-title-container} [view {:style toolbar-title-container}
[text {:style toolbar-title-text [text {:style toolbar-title-text
:platform-specific platform-specific :font :medium}
:font :medium}
title]]) title]])
custom-action custom-action
(when action (when action

View File

@ -27,9 +27,9 @@
[status-im.i18n :refer [label]] [status-im.i18n :refer [label]]
[status-im.components.styles :as cst])) [status-im.components.styles :as cst]))
(defn contact-list-toolbar [platform-specific] (defn contact-list-toolbar []
[view [view
[status-bar {:platform-specific platform-specific}] [status-bar]
[toolbar {:nav-action {:image {:source {:uri :icon_hamburger} [toolbar {:nav-action {:image {:source {:uri :icon_hamburger}
:style hamburger-icon} :style hamburger-icon}
:handler open-drawer} :handler open-drawer}
@ -70,14 +70,14 @@
[view [view
[text {:style st/show-all-text} (label :t/show-all)]]]])]) [text {:style st/show-all-text} (label :t/show-all)]]]])])
(defn contact-list [{platform-specific :platform-specific}] (defn contact-list []
(let [contacts (subscribe [:get-added-contacts-with-limit contacts-limit]) (let [contacts (subscribe [:get-added-contacts-with-limit contacts-limit])
contacts-count (subscribe [:added-contacts-count]) contacts-count (subscribe [:added-contacts-count])
click-handler (subscribe [:get :contacts-click-handler]) click-handler (subscribe [:get :contacts-click-handler])
show-toolbar-shadow? (r/atom false)] show-toolbar-shadow? (r/atom false)]
(fn [] (fn []
[view st/contacts-list-container [view st/contacts-list-container
[contact-list-toolbar platform-specific] [contact-list-toolbar]
[view {:style st/toolbar-shadow} [view {:style st/toolbar-shadow}
(when @show-toolbar-shadow? (when @show-toolbar-shadow?
[linear-gradient {:style st/contact-group-header-gradient-bottom [linear-gradient {:style st/contact-group-header-gradient-bottom

View File

@ -27,10 +27,10 @@
(let [whisper-identity (:whisper-identity row)] (let [whisper-identity (:whisper-identity row)]
(on-press whisper-identity)))]))) (on-press whisper-identity)))])))
(defview contact-list-toolbar [platform-specific] (defview contact-list-toolbar []
[group [:get :contacts-group]] [group [:get :contacts-group]]
[view [view
[status-bar {:platform-specific platform-specific}] [status-bar]
[toolbar {:title (label (if (= group :dapps) [toolbar {:title (label (if (= group :dapps)
:t/contacs-group-dapps :t/contacs-group-dapps
:t/contacs-group-people)) :t/contacs-group-people))
@ -39,17 +39,17 @@
:style icon-search} :style icon-search}
:handler (fn [])}}]]) :handler (fn [])}}]])
(defview contact-list [{platform-specific :platform-specific}] (defview contact-list []
[contacts [:contacts-with-letters] [contacts [:contacts-with-letters]
click-handler [:get :contacts-click-handler]] click-handler [:get :contacts-click-handler]]
(let [click-handler click-handler] (let [click-handler click-handler]
[drawer-view {:platform-specific platform-specific} [drawer-view
[view st/contacts-list-container [view st/contacts-list-container
[contact-list-toolbar platform-specific] [contact-list-toolbar]
;; todo what if there is no contacts, should we show some information ;; todo what if there is no contacts, should we show some information
;; about this? ;; about this?
(when contacts (when contacts
[list-view {:dataSource (lw/to-datasource contacts) [list-view {:dataSource (lw/to-datasource contacts)
:enableEmptySections true :enableEmptySections true
:renderRow (render-row click-handler) :renderRow (render-row click-handler)
:style st/contacts-list}])]])) :style st/contacts-list}])]]))

View File

@ -83,12 +83,12 @@
[scan-button {:showLabel (zero? (count whisper-identity)) [scan-button {:showLabel (zero? (count whisper-identity))
:handler #(dispatch [:scan-qr-code {:toolbar-title (label :t/new-contact)} :set-contact-identity-from-qr])}]])) :handler #(dispatch [:scan-qr-code {:toolbar-title (label :t/new-contact)} :set-contact-identity-from-qr])}]]))
(defview new-contact [{platform-specific :platform-specific}] (defview new-contact []
[new-contact-identity [:get :new-contact-identity] [new-contact-identity [:get :new-contact-identity]
error [:get :new-contact-address-error]] error [:get :new-contact-address-error]]
[view st/contact-form-container [view st/contact-form-container
[view [view
[status-bar {:platform-specific platform-specific}] [status-bar]
[toolbar {:background-color :white [toolbar {:background-color :white
:nav-action {:image {:source {:uri :icon_back} :nav-action {:image {:source {:uri :icon_back}
:style icon-back} :style icon-back}
@ -98,7 +98,6 @@
[view st/form-container [view st/form-container
[contact-whisper-id-input new-contact-identity error]] [contact-whisper-id-input new-contact-identity error]]
[view st/address-explication-container [view st/address-explication-container
[text {:style st/address-explication [text {:style st/address-explication
:platform-specific platform-specific :font :default}
:font :default}
(label :t/address-explication)]]]) (label :t/address-explication)]]])

View File

@ -20,7 +20,7 @@
(let [hashtags (map #(str/lower-case (str/replace % #"#" "")) (re-seq #"[^ !?,;:.]+" status))] (let [hashtags (map #(str/lower-case (str/replace % #"#" "")) (re-seq #"[^ !?,;:.]+" status))]
(or hashtags []))) (or hashtags [])))
(defn title-content [platform-specific show-search?] (defn title-content [show-search?]
[view st/discovery-toolbar-content [view st/discovery-toolbar-content
(if show-search? (if show-search?
[text-input {:style st/discovery-search-input [text-input {:style st/discovery-search-input
@ -32,48 +32,43 @@
(dispatch [:set :discovery-search-tags hashtags]) (dispatch [:set :discovery-search-tags hashtags])
(dispatch [:navigate-to :discovery-search-results])))}] (dispatch [:navigate-to :discovery-search-results])))}]
[view [view
[text {:style st/discovery-title [text {:style st/discovery-title
:platform-specific platform-specific :font :default}
:font :default}
(label :t/discovery)]])]) (label :t/discovery)]])])
(defn toogle-search [current-value] (defn toogle-search [current-value]
(dispatch [:set ::show-search? (not current-value)])) (dispatch [:set ::show-search? (not current-value)]))
(defn discovery-toolbar [show-search? platform-specific] (defn discovery-toolbar [show-search?]
[view [view
[status-bar {:platform-specific platform-specific}] [status-bar]
[toolbar [toolbar
{:style st/discovery-toolbar {:style st/discovery-toolbar
:nav-action {:image {:source {:uri :icon_hamburger} :nav-action {:image {:source {:uri :icon_hamburger}
:style st/hamburger-icon} :style st/hamburger-icon}
:handler open-drawer} :handler open-drawer}
:custom-content [title-content platform-specific show-search?] :custom-content [title-content show-search?]
:action {:image {:source {:uri :icon_search} :action {:image {:source {:uri :icon_search}
:style st/search-icon} :style st/search-icon}
:handler #(toogle-search show-search?)}}]]) :handler #(toogle-search show-search?)}}]])
(defview discovery [{platform-specific :platform-specific}] (defview discovery []
[show-search? [:get ::show-search?] [show-search? [:get ::show-search?]
contacts [:get :contacts]] contacts [:get :contacts]]
[view st/discovery-container [view st/discovery-container
[discovery-toolbar show-search? platform-specific] [discovery-toolbar show-search?]
[scroll-view st/scroll-view-container [scroll-view st/scroll-view-container
[view st/section-spacing [view st/section-spacing
[text {:style st/discovery-subtitle [text {:style st/discovery-subtitle
:platform-specific platform-specific :font :medium}
:font :medium}
(label :t/popular-tags)]] (label :t/popular-tags)]]
[discovery-popular {:contacts contacts [discovery-popular {:contacts contacts}]
:platform-specific platform-specific}]
[view st/section-spacing [view st/section-spacing
[text {:style st/discovery-subtitle [text {:style st/discovery-subtitle
:platform-specific platform-specific :font :medium}
:font :medium}
(label :t/recent)]] (label :t/recent)]]
[discovery-recent {:contacts contacts [discovery-recent {:contacts contacts}]]
:platform-specific platform-specific}]]
[bottom-gradient]]) [bottom-gradient]])

View File

@ -11,17 +11,16 @@
(list-item [view {:style st/row-separator (list-item [view {:style st/row-separator
:key row-id}])) :key row-id}]))
(defn title-content [tags platform-specific] (defn title-content [tags]
[view st/tag-title-container [view st/tag-title-container
(for [tag (take 3 tags)] (for [tag (take 3 tags)]
^{:key (str "tag-" tag)} ^{:key (str "tag-" tag)}
[view {:style st/tag-container} [view {:style st/tag-container}
[text {:style st/tag-title [text {:style st/tag-title
:platform-specific platform-specific :font :default}
:font :default}
(str " #" tag)]])]) (str " #" tag)]])])
(defview discovery-search-results [{platform-specific :platform-specific}] (defview discovery-search-results []
[discoveries [:get-discovery-search-results] [discoveries [:get-discovery-search-results]
tags [:get :discovery-search-tags]] tags [:get :discovery-search-tags]]
(let [datasource (to-datasource discoveries)] (let [datasource (to-datasource discoveries)]
@ -29,13 +28,13 @@
[toolbar {:nav-action {:image {:source {:uri :icon_back} [toolbar {:nav-action {:image {:source {:uri :icon_back}
:style st/icon-back} :style st/icon-back}
:handler #(dispatch [:navigate-back])} :handler #(dispatch [:navigate-back])}
:custom-content (title-content tags platform-specific) :custom-content (title-content tags)
:action {:image {:source {:uri :icon_search} :action {:image {:source {:uri :icon_search}
:style st/icon-search} :style st/icon-search}
:handler (fn [])}}] :handler (fn [])}}]
[list-view {:dataSource datasource [list-view {:dataSource datasource
:renderRow (fn [row _ _] :renderRow (fn [row _ _]
(list-item [discovery-list-item row platform-specific])) (list-item [discovery-list-item row]))
:renderSeparator render-separator :renderSeparator render-separator
:style st/recent-list}]])) :style st/recent-list}]]))

View File

@ -16,7 +16,7 @@
[view {:style st/tag-container} [view {:style st/tag-container}
[text {:style st/tag-title} (str " #" tag)]]]) [text {:style st/tag-title} (str " #" tag)]]])
(defview discovery-tag [{platform-specific :platform-specific}] (defview discovery-tag []
[tag [:get :current-tag] [tag [:get :current-tag]
discoveries [:get-discoveries-by-tags]] discoveries [:get-discoveries-by-tags]]
(let [datasource (to-datasource discoveries)] (let [datasource (to-datasource discoveries)]
@ -31,6 +31,6 @@
[list-view {:dataSource datasource [list-view {:dataSource datasource
:renderRow (fn [row _ _] :renderRow (fn [row _ _]
(list-item [discovery-list-item row platform-specific])) (list-item [discovery-list-item row]))
:renderSeparator render-separator :renderSeparator render-separator
:style st/recent-list}]])) :style st/recent-list}]]))

View File

@ -7,23 +7,21 @@
[status-im.utils.identicon :refer [identicon]] [status-im.utils.identicon :refer [identicon]]
[status-im.i18n :refer [label]])) [status-im.i18n :refer [label]]))
(defview discovery-list-item [{:keys [name photo-path status whisper-id]} platform-specific] (defview discovery-list-item [{:keys [name photo-path status whisper-id]}]
[{contact-name :name [{contact-name :name
contact-photo-path :photo-path} [:get-in [:contacts whisper-id]]] contact-photo-path :photo-path} [:get-in [:contacts whisper-id]]]
[view st/popular-list-item [view st/popular-list-item
[view st/popular-list-item-name-container [view st/popular-list-item-name-container
[text {:style st/popular-list-item-name [text {:style st/popular-list-item-name
:platform-specific platform-specific :font :medium
:font :medium :number-of-lines 1}
:number-of-lines 1}
(cond (cond
(not (str/blank? contact-name)) contact-name (not (str/blank? contact-name)) contact-name
(not (str/blank? name)) name (not (str/blank? name)) name
:else (label :t/user-anonymous))] :else (label :t/user-anonymous))]
[text {:style st/popular-list-item-status [text {:style st/popular-list-item-status
:platform-specific platform-specific :font :default
:font :default :number-of-lines 2}
:number-of-lines 2}
status]] status]]
[view st/popular-list-item-avatar-container [view st/popular-list-item-avatar-container
[image {:style st/popular-list-item-avatar [image {:style st/popular-list-item-avatar

View File

@ -2,8 +2,7 @@
(:require-macros [status-im.utils.views :refer [defview]]) (:require-macros [status-im.utils.views :refer [defview]])
(:require (:require
[re-frame.core :refer [subscribe]] [re-frame.core :refer [subscribe]]
[status-im.components.react :refer [android? [status-im.components.react :refer [text]]
text]]
[status-im.components.carousel.carousel :refer [carousel]] [status-im.components.carousel.carousel :refer [carousel]]
[status-im.discovery.styles :as st] [status-im.discovery.styles :as st]
[status-im.discovery.views.popular-list :refer [discovery-popular-list]] [status-im.discovery.views.popular-list :refer [discovery-popular-list]]
@ -13,13 +12,12 @@
(defn page-width [] (defn page-width []
(.-width (.get (.. r/react-native -Dimensions) "window"))) (.-width (.get (.. r/react-native -Dimensions) "window")))
(defview discovery-popular [{:keys [contacts platform-specific]}] (defview discovery-popular [{:keys [contacts]}]
[popular-tags [:get-popular-tags 10]] [popular-tags [:get-popular-tags 10]]
(if (pos? (count popular-tags)) (if (pos? (count popular-tags))
[carousel {:pageStyle st/carousel-page-style} [carousel {:pageStyle st/carousel-page-style}
(for [{:keys [name count]} popular-tags] (for [{:keys [name count]} popular-tags]
[discovery-popular-list {:tag name [discovery-popular-list {:tag name
:count count :count count
:contacts contacts :contacts contacts}])]
:platform-specific platform-specific}])]
[text (label :t/none)])) [text (label :t/none)]))

View File

@ -15,22 +15,20 @@
(list-item [view {:style st/row-separator (list-item [view {:style st/row-separator
:key row-id}])) :key row-id}]))
(defview discovery-popular-list [{:keys [tag count contacts platform-specific]}] (defview discovery-popular-list [{:keys [tag count contacts]}]
[discoveries [:get-discoveries-by-tags [tag] 3]] [discoveries [:get-discoveries-by-tags [tag] 3]]
[view st/popular-list-container [view st/popular-list-container
[view st/row [view st/row
[view st/tag-name-container [view st/tag-name-container
[touchable-highlight {:onPress #(dispatch [:show-discovery-tag tag])} [touchable-highlight {:onPress #(dispatch [:show-discovery-tag tag])}
[view [view
[text {:style st/tag-name [text {:style st/tag-name
:platform-specific platform-specific :font :medium}
:font :medium}
(str " #" (name tag))]]]] (str " #" (name tag))]]]]
[view st/tag-count-container [view st/tag-count-container
[text {:style st/tag-count [text {:style st/tag-count
:platform-specific platform-specific :font :default}
:font :default}
count]]] count]]]
(for [{:keys [message-id] :as discovery} discoveries] (for [{:keys [message-id] :as discovery} discoveries]
^{:key (str "message-" message-id)} ^{:key (str "message-" message-id)}
[discovery-list-item discovery platform-specific])]) [discovery-list-item discovery])])

View File

@ -11,9 +11,9 @@
(list-item [view {:style st/row-separator (list-item [view {:style st/row-separator
:key row-id}])) :key row-id}]))
(defview discovery-recent [{platform-specific :platform-specific}] (defview discovery-recent [{:keys [contacts]}]
[discoveries [:get :discoveries]] [discoveries [:get :discoveries]]
[view st/recent-list [view st/recent-list
(for [{:keys [message-id] :as discovery} discoveries] (for [{:keys [message-id] :as discovery} discoveries]
^{:key (str "message-" message-id)} ^{:key (str "message-" message-id)}
[discovery-list-item discovery platform-specific])]) [discovery-list-item discovery])])

View File

@ -105,9 +105,9 @@
[view st/action [view st/action
[chat-icon-view-action chat-id group-chat name color false]]) [chat-icon-view-action chat-id group-chat name color false]])
(defn new-group-toolbar [platform-specific] (defn new-group-toolbar []
[view [view
[status-bar {:platform-specific platform-specific}] [status-bar]
[toolbar {:title (label :t/chat-settings) [toolbar {:title (label :t/chat-settings)
:custom-action [chat-icon]}]]) :custom-action [chat-icon]}]])
@ -145,9 +145,9 @@
(when (pos? (count validation-messages)) (when (pos? (count validation-messages))
[text {:style st/chat-name-validation-message} (first validation-messages)])]) [text {:style st/chat-name-validation-message} (first validation-messages)])])
(defn group-settings [{platform-specific :platform-specific}] (defn group-settings []
[view st/group-settings [view st/group-settings
[new-group-toolbar platform-specific] [new-group-toolbar]
[scroll-view st/body [scroll-view st/body
[chat-name] [chat-name]
[text {:style st/members-text} (label :t/members-title)] [text {:style st/members-text} (label :t/members-title)]

View File

@ -3,11 +3,9 @@
[re-frame.core :refer [subscribe dispatch dispatch-sync]] [re-frame.core :refer [subscribe dispatch dispatch-sync]]
[status-im.handlers] [status-im.handlers]
[status-im.subs] [status-im.subs]
[status-im.ios.styles :refer [styles]]
[status-im.components.react :refer [app-registry [status-im.components.react :refer [app-registry
keyboard keyboard
orientation orientation]]
show-action-sheet]]
[status-im.components.main-tabs :refer [main-tabs]] [status-im.components.main-tabs :refer [main-tabs]]
[status-im.contacts.views.contact-list :refer [contact-list]] [status-im.contacts.views.contact-list :refer [contact-list]]
[status-im.contacts.views.new-contact :refer [new-contact]] [status-im.contacts.views.new-contact :refer [new-contact]]
@ -87,8 +85,7 @@
:accounts accounts :accounts accounts
:login login :login login
:my-profile my-profile)] :my-profile my-profile)]
[component {:platform-specific {:styles styles [component])))})))
:list-selection-fn show-action-sheet}}])))})))
(defn init [] (defn init []
(dispatch-sync [:reset-app]) (dispatch-sync [:reset-app])

View File

@ -1,7 +1,9 @@
(ns status-im.ios.styles (ns status-im.ios.platform
(:require [status-im.components.styles :as styles])) (:require [status-im.components.styles :as styles]
[status-im.utils.utils :as u]
[reagent.core :as r]))
(def components (def component-styles
{:status-bar {:default {:height 20 {:status-bar {:default {:height 20
:bar-style "default" :bar-style "default"
:color styles/color-white} :color styles/color-white}
@ -19,6 +21,22 @@
{:default {:font-family "SFUIDisplay-Regular"} {:default {:font-family "SFUIDisplay-Regular"}
:medium {:font-family "SFUIDisplay-Medium"}}) :medium {:font-family "SFUIDisplay-Medium"}})
(def styles
{:components components ;; Dialogs
:fonts fonts})
(def react-native (u/require "react-native"))
(defn show-action-sheet [{:keys [options callback cancel-text]}]
(.showActionSheetWithOptions (r/adapt-react-class (.-ActionSheetIOS react-native))
(clj->js {:options (conj options cancel-text)
:cancelButtonIndex (count options)})
callback))
;; Structure to be exported
(def platform-specific
{:component-styles component-styles
:fonts fonts
:list-selection-fn show-action-sheet})

View File

@ -20,13 +20,13 @@
[status-im.components.styles :as cst])) [status-im.components.styles :as cst]))
(defview new-group-toolbar [platform-specific] (defview new-group-toolbar []
[group-name [:get :new-chat-name] [group-name [:get :new-chat-name]
creation-disabled? [:get :disable-group-creation] creation-disabled? [:get :disable-group-creation]
valid? [:new-chat-name-valid?]] valid? [:new-chat-name-valid?]]
(let [create-btn-enabled? (and valid? (not creation-disabled?))] (let [create-btn-enabled? (and valid? (not creation-disabled?))]
[view [view
[status-bar {:platform-specific platform-specific}] [status-bar]
[toolbar [toolbar
{:title (label :t/new-group-chat) {:title (label :t/new-group-chat)
:action {:image {:source res/v ;; {:uri "icon_search"} :action {:image {:source res/v ;; {:uri "icon_search"}
@ -48,10 +48,10 @@
(when (pos? (count validation-messages)) (when (pos? (count validation-messages))
[text {:style st/group-name-validation-message} (first validation-messages)])]) [text {:style st/group-name-validation-message} (first validation-messages)])])
(defview new-group [{platform-specific :platform-specific}] (defview new-group []
[contacts [:all-added-contacts]] [contacts [:all-added-contacts]]
[view st/new-group-container [view st/new-group-container
[new-group-toolbar platform-specific] [new-group-toolbar]
[view st/chat-name-container [view st/chat-name-container
[text {:style st/chat-name-text} (label :t/chat-name)] [text {:style st/chat-name-text} (label :t/chat-name)]
[group-name-input] [group-name-input]

View File

@ -12,9 +12,9 @@
[status-im.i18n :refer [label]] [status-im.i18n :refer [label]]
[status-im.components.styles :as cst])) [status-im.components.styles :as cst]))
(defn new-participants-toolbar [platform-specific] (defn new-participants-toolbar []
[view [view
[status-bar {:platform-specific platform-specific}] [status-bar]
[toolbar [toolbar
{:title (label :t/add-participants) {:title (label :t/add-participants)
:action {:image {:source res/v ;; {:uri "icon_search"} :action {:image {:source res/v ;; {:uri "icon_search"}
@ -26,10 +26,10 @@
[row _ _] [row _ _]
(list-item [participant-contact row])) (list-item [participant-contact row]))
(defview new-participants [{platform-specific :platform-specific}] (defview new-participants []
[contacts [:all-new-contacts]] [contacts [:all-new-contacts]]
[view st/participants-container [view st/participants-container
[new-participants-toolbar platform-specific] [new-participants-toolbar]
[list-view {:dataSource (to-datasource contacts) [list-view {:dataSource (to-datasource contacts)
:renderRow new-participants-row :renderRow new-participants-row
:style st/participants-list}]]) :style st/participants-list}]])

View File

@ -19,9 +19,9 @@
[status-im.i18n :refer [label]] [status-im.i18n :refer [label]]
[status-im.components.styles :as cst])) [status-im.components.styles :as cst]))
(defn remove-participants-toolbar [platform-specific] (defn remove-participants-toolbar []
[view [view
[status-bar {:platform-specific platform-specific}] [status-bar]
[toolbar [toolbar
{:title (label :t/remove-participants) {:title (label :t/remove-participants)
:action {:handler #(do (dispatch [:remove-participants]) :action {:handler #(do (dispatch [:remove-participants])
@ -33,10 +33,10 @@
[row _ _] [row _ _]
(r/as-element [participant-contact row])) (r/as-element [participant-contact row]))
(defview remove-participants [{platform-specific :platform-specific}] (defview remove-participants []
[contacts [:current-chat-contacts]] [contacts [:current-chat-contacts]]
[view st/participants-container [view st/participants-container
[remove-participants-toolbar platform-specific] [remove-participants-toolbar]
[list-view {:dataSource (to-datasource contacts) [list-view {:dataSource (to-datasource contacts)
:renderRow remove-participants-row :renderRow remove-participants-row
:style st/participants-list}]]) :style st/participants-list}]])

View File

@ -27,10 +27,10 @@
(.log js/console type error))] (.log js/console type error))]
(img->base64 path on-success on-error))) (img->base64 path on-success on-error)))
(defn profile-photo-capture [{platform-specific :platform-specific}] (defn profile-photo-capture []
(let [camera-ref (r/atom nil)] (let [camera-ref (r/atom nil)]
[view st/container [view st/container
[status-bar {:platform-specific platform-specific}] [status-bar]
[toolbar {:title (label :t/image-source-title) [toolbar {:title (label :t/image-source-title)
:nav-action {:image {:source {:uri :icon_back} :nav-action {:image {:source {:uri :icon_back}
:style icon-back} :style icon-back}

View File

@ -25,6 +25,7 @@
[status-im.utils.fs :refer [read-file]] [status-im.utils.fs :refer [read-file]]
[status-im.utils.types :refer [clj->json]] [status-im.utils.types :refer [clj->json]]
[status-im.utils.image-processing :refer [img->base64]] [status-im.utils.image-processing :refer [img->base64]]
[status-im.utils.platform :refer [platform-specific]]
[status-im.i18n :refer [label]] [status-im.i18n :refer [label]]
[clojure.string :as str])) [clojure.string :as str]))
@ -51,9 +52,7 @@
:style st/ok-btn-icon}] :style st/ok-btn-icon}]
[icon :dots st/edit-btn-icon])]]]) [icon :dots st/edit-btn-icon])]]])
(defview status-image-view [{{:keys [list-selection-fn] (defview status-image-view [{{address :address
:as platform-specific} :platform-specific
{address :address
username :name} :account username :name} :account
photo-path :photo-path photo-path :photo-path
status :status status :status
@ -62,7 +61,8 @@
[view st/user-photo-container [view st/user-photo-container
(if edit? (if edit?
[touchable-highlight {:on-press (fn [] [touchable-highlight {:on-press (fn []
(dispatch [:open-image-source-selector list-selection-fn]))} (let [list-selection-fn (get platform-specific :list-selection-fn)]
(dispatch [:open-image-source-selector list-selection-fn])))}
[view [view
[my-profile-icon {:account {:photo-path photo-path [my-profile-icon {:account {:photo-path photo-path
:name username} :name username}
@ -70,9 +70,8 @@
[my-profile-icon {:account {:photo-path photo-path [my-profile-icon {:account {:photo-path photo-path
:name username} :name username}
:edit? edit?}])] :edit? edit?}])]
[text {:style st/username [text {:style st/username
:platform-specific platform-specific :font :default}
:font :default}
(if (= username address) (if (= username address)
(label :t/user-anonymous) (label :t/user-anonymous)
username)] username)]
@ -87,12 +86,10 @@
value :value value :value
empty-value :empty-value empty-value :empty-value
on-change-text :on-change-text on-change-text :on-change-text
{edit-mode? :edit?} :profile-data {edit-mode? :edit?} :profile-data}]
platform-specific :platform-specific}]
[view st/profile-property-view-container [view st/profile-property-view-container
[view st/profile-property-view-sub-container [view st/profile-property-view-sub-container
[text {:style st/profile-property-view-label [text {:style st/profile-property-view-label
:platform-specific platform-specific
:font :medium} :font :medium}
name] name]
[text-input {:style st/profile-property-view-value [text-input {:style st/profile-property-view-value
@ -100,7 +97,7 @@
:on-change-text on-change-text} :on-change-text on-change-text}
(or value (when-not edit-mode? empty-value))]]]) (or value (when-not edit-mode? empty-value))]]])
(defview profile [{platform-specific :platform-specific}] (defview profile []
[{whisper-identity :whisper-identity [{whisper-identity :whisper-identity
address :address address :address
username :name username :name
@ -110,7 +107,7 @@
status :status status :status
:as contact} [:contact]] :as contact} [:contact]]
[scroll-view {:style st/profile} [scroll-view {:style st/profile}
[status-bar {:platform-specific platform-specific}] [status-bar]
[view [view
[touchable-highlight {:style st/back-btn-touchable [touchable-highlight {:style st/back-btn-touchable
:on-press (fn [] :on-press (fn []
@ -123,10 +120,9 @@
[view st/actions-btn-container [view st/actions-btn-container
[icon :dots st/edit-btn-icon]]]] [icon :dots st/edit-btn-icon]]]]
[status-image-view {:platform-specific platform-specific [status-image-view {:account contact
:account contact :photo-path photo-path
:photo-path photo-path :edit? false}]
:edit? false}]
[view st/status-block [view st/status-block
[view st/btns-container [view st/btns-container
@ -140,28 +136,25 @@
[icon :more_vertical_blue st/more-btn-image]]]]] [icon :more_vertical_blue st/more-btn-image]]]]]
[scroll-view st/profile-properties-container [scroll-view st/profile-properties-container
[profile-property-view {:name (label :t/username) [profile-property-view {:name (label :t/username)
:value (if (not= username address) :value (if (not= username address)
username) username)
:empty-value (label :t/not-specified) :empty-value (label :t/not-specified)}]
:platform-specific platform-specific}] [profile-property-view {:name (label :t/phone-number)
[profile-property-view {:name (label :t/phone-number) :value (if-not (or (not phone) (str/blank? phone))
:value (if-not (or (not phone) (str/blank? phone)) (format-phone-number phone))
(format-phone-number phone)) :empty-value (label :t/not-specified)}]
:empty-value (label :t/not-specified) [profile-property-view {:name (label :t/email)
:platform-specific platform-specific}] :value (if-not (or (not email) (str/blank? email))
[profile-property-view {:name (label :t/email) email)
:value (if-not (or (not email) (str/blank? email)) :empty-value (label :t/not-specified)}]
email)
:empty-value (label :t/not-specified)
:platform-specific platform-specific}]
[view st/report-user-container [view st/report-user-container
[touchable-highlight {:on-press (fn [] [touchable-highlight {:on-press (fn []
;; TODO not implemented ;; TODO not implemented
)} )}
[view [text {:style st/report-user-text} (label :t/report-user)]]]]]]) [view [text {:style st/report-user-text} (label :t/report-user)]]]]]])
(defview my-profile [{platform-specific :platform-specific}] (defview my-profile []
[{public-key :public-key [{public-key :public-key
address :address address :address
username :name username :name
@ -175,38 +168,34 @@
new-photo-path :photo-path new-photo-path :photo-path
:as profile-edit-data} [:get :profile-edit]] :as profile-edit-data} [:get :profile-edit]]
[scroll-view {:style st/profile} [scroll-view {:style st/profile}
[status-bar {:platform-specific platform-specific}] [status-bar]
[toolbar {:account account [toolbar {:account account
:profile-edit-data profile-edit-data :profile-edit-data profile-edit-data
:edit? edit?}] :edit? edit?}]
[status-image-view {:platform-specific platform-specific [status-image-view {:account account
:account account :photo-path (or new-photo-path photo-path)
:photo-path (or new-photo-path photo-path) :status (or new-status status)
:status (or new-status status) :edit? edit?}]
:edit? edit?}]
[scroll-view st/profile-properties-container [scroll-view st/profile-properties-container
[profile-property-view {:name (label :t/username) [profile-property-view {:name (label :t/username)
:value (if (not= username address) :value (if (not= username address)
username) username)
:empty-value (label :t/not-specified) :empty-value (label :t/not-specified)
:on-change-text #(dispatch [:set-in [:profile-edit :name] %]) :on-change-text #(dispatch [:set-in [:profile-edit :name] %])
:profile-data profile-edit-data :profile-data profile-edit-data}]
:platform-specific platform-specific}] [profile-property-view {:name (label :t/phone-number)
[profile-property-view {:name (label :t/phone-number) :value (if-not (or (not phone) (str/blank? phone))
:value (if-not (or (not phone) (str/blank? phone)) (format-phone-number phone))
(format-phone-number phone)) :empty-value (label :t/not-specified)
:empty-value (label :t/not-specified) :profile-data profile-edit-data}]
:profile-data profile-edit-data [profile-property-view {:name (label :t/email)
:platform-specific platform-specific}] :value (if-not (or (not email) (str/blank? email))
[profile-property-view {:name (label :t/email) email)
:value (if-not (or (not email) (str/blank? email)) :empty-value (label :t/not-specified)
email) :on-change-text #(dispatch [:set-in [:profile-edit :email] %])
:empty-value (label :t/not-specified) :profile-data profile-edit-data}]
:on-change-text #(dispatch [:set-in [:profile-edit :email] %])
:profile-data profile-edit-data
:platform-specific platform-specific}]
[view st/qr-code-container [view st/qr-code-container
;; TODO: this public key should be replaced by address ;; TODO: this public key should be replaced by address
[qr-code {:value (str "ethereum:" public-key) [qr-code {:value (str "ethereum:" public-key)

View File

@ -13,19 +13,19 @@
[status-im.components.styles :as cst] [status-im.components.styles :as cst]
[clojure.string :as str])) [clojure.string :as str]))
(defn qr-scanner-toolbar [title platform-specific] (defn qr-scanner-toolbar [title]
[view [view
[status-bar {:platform-specific platform-specific}] [status-bar]
[toolbar {:title title [toolbar {:title title
:background-color toolbar-background1 :background-color toolbar-background1
:action {:image {:source {:uri :icon_lock_white} :action {:image {:source {:uri :icon_lock_white}
:style icon-search} :style icon-search}
:handler #()}}]]) :handler #()}}]])
(defview qr-scanner [{platform-specific :platform-specific}] (defview qr-scanner []
[identifier [:get :current-qr-context]] [identifier [:get :current-qr-context]]
[view st/barcode-scanner-container [view st/barcode-scanner-container
[qr-scanner-toolbar (:toolbar-title identifier) platform-specific] [qr-scanner-toolbar (:toolbar-title identifier)]
[camera {:onBarCodeRead (fn [code] [camera {:onBarCodeRead (fn [code]
(let [data (-> (.-data code) (let [data (-> (.-data code)
(str/replace #"ethereum:" ""))] (str/replace #"ethereum:" ""))]

View File

@ -0,0 +1,19 @@
(ns status-im.utils.platform
(:require [status-im.utils.utils :as u]
[status-im.android.platform :as android]
[status-im.ios.platform :as ios]))
(def react-native (u/require "react-native"))
(def platform
(when-let [pl (.-Platform react-native)]
(.-OS pl)))
(def android? (= platform "android"))
(def ios? (= platform "ios"))
(def platform-specific
(cond
android? android/platform-specific
ios? ios/platform-specific
:else {}))

View File

@ -1,5 +1,5 @@
(ns status-im.utils.sms-listener (ns status-im.utils.sms-listener
(:require [status-im.components.react :refer [android?]] (:require [status-im.utils.platform :refer [android?]]
[status-im.utils.utils :as u])) [status-im.utils.utils :as u]))
(def sms-listener (.-default (u/require "react-native-android-sms-listener"))) (def sms-listener (.-default (u/require "react-native-android-sms-listener")))