replacing the need in passing platform-specific with status-im.utils.platform (#227)

This commit is contained in:
alwxndr 2016-09-15 15:33:19 +03:00
parent fd329ee732
commit b67417f268
41 changed files with 416 additions and 474 deletions

View File

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

View File

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

View File

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

View File

@ -5,11 +5,9 @@
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
[status-im.handlers]
[status-im.subs]
[status-im.android.styles :refer [styles]]
[status-im.components.react :refer [app-registry
keyboard
orientation
show-dialog]]
orientation]]
[status-im.components.main-tabs :refer [main-tabs]]
[status-im.contacts.views.contact-list :refer [contact-list]]
[status-im.contacts.views.new-contact :refer [new-contact]]
@ -106,8 +104,7 @@
:recover recover
:confirm confirm
:my-profile my-profile)]
[component {:platform-specific {:styles styles
:list-selection-fn show-dialog}}])))})))
[component])))})))
(defn init [& [env]]
(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.utils :refer [truncate-str]]
[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.toolbar :refer [toolbar]]
[status-im.chat.views.message :refer [chat-message]]
@ -51,27 +52,26 @@
;; TODO stub data ('online' property)
[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-background
[text {:style st/typing-text
:platform-specific platform-specific
:font :default}
[text {:style st/typing-text
:font :default}
(str member " " (label :t/is-typing))]]])
(defn typing-all [platform-specific]
(defn typing-all []
[view st/typing-all
;; TODO stub data
(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]
(let [message (-> row
(add-message-color contact-by-identity)
(assoc :group-chat group-chat)
(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]
(case position
@ -99,30 +99,27 @@
(label :t/active-online)
(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]])
show-actions (subscribe [:show-actions])
contact (subscribe [:get-in [:contacts @chat-id]])]
(fn [platform-specific]
(fn []
[view (st/chat-name-view @show-actions)
[text {:style st/chat-name-text
:platform-specific platform-specific
:number-of-lines 1
:font :medium}
[text {:style st/chat-name-text
:number-of-lines 1
:font :medium}
(if (str/blank? @name)
(label :t/user-anonymous)
(or @name (label :t/chat-name)))]
(if @group-chat
[view {:flexDirection :row}
[icon :group st/group-icon]
[text {:style st/members
:platform-specific platform-specific
:font :medium}
[text {:style st/members
:font :medium}
(let [cnt (inc (count @contacts))]
(label-pluralize cnt :t/members))]]
[text {:style st/last-activity
:platform-specific platform-specific
:font :default}
[text {:style st/last-activity
:font :default}
(online-text @contact @chat-id)])])))
(defn toolbar-action []
@ -138,22 +135,21 @@
[view st/action
[chat-icon]]]))))
(defview chat-toolbar [platform-specific]
(defview chat-toolbar []
[show-actions [:show-actions]]
[view
[status-bar {:platform-specific platform-specific}]
[status-bar]
[toolbar {:hide-nav? show-actions
:custom-content [toolbar-content platform-specific]
:custom-content [toolbar-content]
: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]
contacts [:chat :contacts]
loaded? [:all-messages-loaded?]]
(let [contacts' (contacts-by-identity contacts)]
[list-view {:renderRow (message-row {:contact-by-identity contacts'
:platform-specific platform-specific
:group-chat group-chat
:messages-count (count messages)})
:renderScrollComponent #(invertible-scroll-view (js->clj %))
@ -184,7 +180,7 @@
[animated-view {:style (st/messages-container messages-offset)}
messages])})))
(defn chat [{platform-specific :platform-specific}]
(defn chat []
(let [group-chat (subscribe [:chat :group-chat])
show-actions (subscribe [:show-actions])
command? (subscribe [:command?])
@ -192,18 +188,18 @@
(r/create-class
{:component-did-mount #(dispatch [:check-autorun])
:reagent-render
(fn [{platform-specific :platform-specific}]
(fn []
[view {:style st/chat-view
:onLayout (fn [event]
(let [height (.. event -nativeEvent -layout -height)]
(when (not= height @layout-height)
(dispatch [:set-layout-height height]))))}
[chat-toolbar platform-specific]
[chat-toolbar]
[messages-container
[messages-view platform-specific @group-chat]]
[messages-view @group-chat]]
;; todo uncomment this
#_(when @group-chat [typing-all platform-specific])
#_(when @group-chat [typing-all])
[response-view]
(when-not @command? [suggestion-container])
[chat-message-new platform-specific]
(when @show-actions [actions-view platform-specific])])})))
[chat-message-new]
(when @show-actions [actions-view])])})))

View File

@ -1,7 +1,7 @@
(ns status-im.chat.subs
(:require-macros [reagent.ratom :refer [reaction]])
(: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.constants :refer [response-suggesstion-resize-duration]]
[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.chat.styles.screen :as st]
[status-im.i18n :refer [label label-pluralize]]
[status-im.utils.platform :refer [platform-specific]]
[status-im.utils.logging :as log]))
(defview menu-item-icon-profile []
@ -97,13 +98,12 @@
[view nil]]
items])
(defn action-view [{{:keys [icon-style
custom-icon
handler
title
subtitle]
icon-name :icon} :action
platform-specific :platform-specific}]
(defn action-view [{:keys [icon-style
custom-icon
handler
title
subtitle]
icon-name :icon}]
[touchable-highlight {:on-press (fn []
(dispatch [:set-show-actions false])
(when handler
@ -113,33 +113,30 @@
(or custom-icon
[icon icon-name icon-style])]
[view st/action-view
[text {:style st/action-title
:platform-specific platform-specific
:number-of-lines 1
:font :medium} title]
[text {:style st/action-title
:number-of-lines 1
:font :medium} title]
(when-let [subtitle subtitle]
[text {:style st/action-subtitle
:platform-specific platform-specific
:number-of-lines 1
:font :default}
[text {:style st/action-subtitle
:number-of-lines 1
:font :default}
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]])
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
(group-chat-items @members)
(user-chat-items @chat-id (first @members)))]
[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-view
(for [action actions]
(if action
^{:key action} [action-view {:platform-specific platform-specific
:action action}]))]])))
^{:key action} [action-view action]))]])))
(defn actions-view [platform-specific]
(defn actions-view []
[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]]
[status-im.utils.logging :as log]))
(defn message-date [timestamp platform-specific]
(defn message-date [timestamp]
[view {}
[view st/message-date-container
[text {:style st/message-date-text
:platform-specific platform-specific
:font :default}
[text {:style st/message-date-text
:font :default}
(time/to-short-str timestamp)]]])
(defn contact-photo [{:keys [photo-path]}]
@ -43,21 +42,19 @@
[view st/online-dot-left]
[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-image-view
[contact-photo {}]
[contact-online {:online true}]]
[text {:style st/status-from
:platform-specific platform-specific
:font :default}
[text {:style st/status-from
:font :default}
from]
[text {:style st/status-text
:platform-specific platform-specific
:font :default}
[text {:style st/status-text
:font :default}
content]])
(defn message-content-audio [{:keys [platform-specific]}]
(defn message-content-audio [_]
[view st/audio-container
[view st/play-view
[image {:source res/play
@ -65,21 +62,19 @@
[view st/track-container
[view st/track]
[view st/track-mark]
[text {:style st/track-duration-text
:platform-specific platform-specific
:font :default}
[text {:style st/track-duration-text
:font :default}
"03:39"]]])
(defview message-content-command [content preview platform-specific]
(defview message-content-command [content preview]
[commands [:get-commands-and-responses]]
(let [{:keys [command content]} (parse-command-message-content commands content)
{:keys [name icon type]} command]
[view st/content-command-view
[view st/command-container
[view (st/command-view command)
[text {:style st/command-name
:platform-specific platform-specific
:font :default}
[text {:style st/command-name
:font :default}
(str (if (= :command type) "!" "") name)]]]
(when icon
[view st/command-image-view
@ -87,9 +82,8 @@
:style st/command-image}]])
(if preview
preview
[text {:style st/command-text
:platform-specific platform-specific
:font :default}
[text {:style st/command-text
:font :default}
(str content)])]))
(defn set-chat-command [message-id command]
@ -107,41 +101,37 @@
(message :content-type)))
(defmethod message-content content-type-command-request
[wrapper message platform-specific]
[wrapper message [message-content-command-request message platform-specific] platform-specific])
[wrapper message]
[wrapper message [message-content-command-request message]])
(defn text-message
[{:keys [content] :as message} platform-specific]
[{:keys [content] :as message}]
[message-view message
[text {:style (st/text-message message)
:platform-specific platform-specific
:font :default}
[text {:style (st/text-message message)
:font :default}
(str content)]])
(defmethod message-content text-content-type
[wrapper message platform-specific]
[wrapper message [text-message message platform-specific] platform-specific])
[wrapper message]
[wrapper message [text-message message]])
(defmethod message-content content-type-status
[_ message platform-specific]
[message-content-status message platform-specific])
[_ message]
[message-content-status message])
(defmethod message-content content-type-command
[wrapper {:keys [content rendered-preview] :as message} platform-specific]
[wrapper {:keys [content rendered-preview] :as message}]
[wrapper message
[message-view message [message-content-command content rendered-preview platform-specific]]
platform-specific])
[message-view message [message-content-command content rendered-preview]]])
(defmethod message-content :default
[wrapper {:keys [content-type content] :as message} platform-specific]
[wrapper {:keys [content-type content] :as message}]
[wrapper message
[message-view message
[message-content-audio {:content content
:content-type content-type
:platform-specific platform-specific}]]
platform-specific])
[message-content-audio {:content content
:content-type content-type}]]])
(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]]]
[view st/delivery-view
[image {:source (case (or status delivery-status)
@ -150,9 +140,8 @@
:failed res/delivery-failed-icon
nil)
:style st/delivery-image}]
[text {:style st/delivery-text
:platform-specific platform-specific
:font :default}
[text {:style st/delivery-text
:font :default}
(message-status-label (or status delivery-status))]])
(defview member-photo [from]
@ -164,13 +153,12 @@
:style st/photo}]])
(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]
[view st/group-message-wrapper
(when selected
[text {:style st/selected-message
:platform-specific platform-specific
:font :default}
[text {:style st/selected-message
:font :default}
"Mar 7th, 15:22"])
[view (st/incoming-group-message-body-st message)
[view st/message-author
@ -179,14 +167,14 @@
content
;; TODO show for last or selected
(when (and selected delivery-status)
[message-delivery-status {:delivery-status delivery-status} platform-specific])]]]))
[message-delivery-status {:delivery-status delivery-status}])]]]))
(defn message-body
[{:keys [outgoing] :as message} content platform-specific]
[{:keys [outgoing] :as message} content]
[view (st/message-body message)
content
(when outgoing
[message-delivery-status message platform-specific])])
[message-delivery-status message])])
(defn message-container-animation-logic [{:keys [to-value val callback]}]
(fn [_]
@ -223,8 +211,7 @@
(into [view] children)))
(defn chat-message [{:keys [outgoing delivery-status timestamp new-day group-chat message-id chat-id]
:as message}
platform-specific]
:as message}]
(let [status (subscribe [:get-in [:message-status chat-id message-id]])]
(r/create-class
{:component-did-mount
@ -235,12 +222,11 @@
(dispatch [:send-seen! chat-id message-id])))
:reagent-render
(fn [{:keys [outgoing delivery-status timestamp new-day group-chat]
:as message}
platform-specific]
:as message}]
[message-container message
;; TODO there is no new-day info in message
(when new-day
[message-date timestamp platform-specific])
[message-date timestamp])
[view
(let [incoming-group (and group-chat (not outgoing))]
[message-content
@ -248,5 +234,4 @@
incoming-group-message-body
message-body)
(merge message {:delivery-status (keyword delivery-status)
:incoming-group incoming-group})
platform-specific])]])})))
:incoming-group incoming-group})])]])})))

View File

@ -6,6 +6,7 @@
[status-im.chat.views.message-input :refer [plain-message-input-view]]
[status-im.chat.views.staged-command :refer [simple-command-staged-view]]
[status-im.utils.phone-number :refer [valid-mobile-number?]]
[status-im.utils.platform :refer [platform-specific]]
[status-im.chat.styles.message :as st]))
(defn staged-command-view [stage-command]
@ -36,10 +37,10 @@
[plain-message-input-view
(when command? (get-options parameter type))])
(defview chat-message-new [platform-specific]
(defview chat-message-new []
[staged-commands [:get-chat-staged-commands]
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)
style)
(when (seq staged-commands)

View File

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

View File

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

View File

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

View File

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

View File

@ -95,20 +95,20 @@
[animated-view {:style (st/tab-view-container anim-value)}
content])})))
(defn tab-view [platform-specific {:keys [view-id screen]}]
(defn tab-view [{:keys [view-id screen]}]
^{:key 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]
tab-animation? [:get :prev-tab-view-id]]
[view common-st/flex
[status-bar {:platform-specific platform-specific}]
[status-bar]
[view common-st/flex
[drawer-view {:platform-specific platform-specific}
[drawer-view
[view {:style common-st/flex
: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
:tab-list tab-list}]]]]])

View File

@ -1,13 +1,13 @@
(ns status-im.components.react
(:require [reagent.core :as r]
[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 native-modules (.-NativeModules react-native))
(def device-event-emitter (.-DeviceEventEmitter react-native))
(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 dismiss-keyboard! (u/require "dismissKeyboard"))
@ -64,18 +64,15 @@
(defn text
([t]
(r/as-element [text-class t]))
([{:keys [style platform-specific font] :as opts
([{:keys [style font] :as opts
:or {font :default}} t]
(r/as-element
[text-class
(cond
(and platform-specific font)
(let [font (get-in platform-specific [:fonts font])]
[text-class
(-> opts
(dissoc :platform-specific :font)
(assoc :style (st/with-font style platform-specific font)))
style opts
:else {:style opts})
t])))
(dissoc :font)
(assoc :style (merge style font)))
t]))))
(defn text-input [props text]
[text-input-class (merge
@ -110,22 +107,8 @@
[props & children]
(vec (concat [linear-gradient-class (merge {:inverted true} props)] children)))
;; List 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)))
(defn show-action-sheet [{:keys [options callback cancel-text]}]
(.showActionSheetWithOptions (get-class "ActionSheetIOS")
(clj->js {:options (conj options cancel-text)
:cancelButtonIndex (count options)})
callback))
(defn list-item [component]
(r/as-element component))
;; Image picker
@ -138,15 +121,3 @@
(.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
(: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
type :type
:or {type :default}}]
(defn status-bar [{type :type
:or {type :default}}]
(let [{:keys [height
bar-style
translucent?
color]} (get-in styles [:components :status-bar type])]
color]} (get-in platform-specific [:component-styles :status-bar type])]
[ui/view
[ui/status-bar {:background-color color
:translucent translucent?

View File

@ -35,10 +35,6 @@
(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
{:flex 1})

View File

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

View File

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

View File

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

View File

@ -83,12 +83,12 @@
[scan-button {:showLabel (zero? (count whisper-identity))
: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]
error [:get :new-contact-address-error]]
[view st/contact-form-container
[view
[status-bar {:platform-specific platform-specific}]
[status-bar]
[toolbar {:background-color :white
:nav-action {:image {:source {:uri :icon_back}
:style icon-back}
@ -98,7 +98,6 @@
[view st/form-container
[contact-whisper-id-input new-contact-identity error]]
[view st/address-explication-container
[text {:style st/address-explication
:platform-specific platform-specific
:font :default}
[text {:style st/address-explication
:font :default}
(label :t/address-explication)]]])

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,9 @@
(ns status-im.ios.styles
(:require [status-im.components.styles :as styles]))
(ns status-im.ios.platform
(: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
:bar-style "default"
:color styles/color-white}
@ -19,6 +21,22 @@
{:default {:font-family "SFUIDisplay-Regular"}
:medium {:font-family "SFUIDisplay-Medium"}})
(def styles
{:components components
:fonts fonts})
;; Dialogs
(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]))
(defview new-group-toolbar [platform-specific]
(defview new-group-toolbar []
[group-name [:get :new-chat-name]
creation-disabled? [:get :disable-group-creation]
valid? [:new-chat-name-valid?]]
(let [create-btn-enabled? (and valid? (not creation-disabled?))]
[view
[status-bar {:platform-specific platform-specific}]
[status-bar]
[toolbar
{:title (label :t/new-group-chat)
:action {:image {:source res/v ;; {:uri "icon_search"}
@ -48,10 +48,10 @@
(when (pos? (count 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]]
[view st/new-group-container
[new-group-toolbar platform-specific]
[new-group-toolbar]
[view st/chat-name-container
[text {:style st/chat-name-text} (label :t/chat-name)]
[group-name-input]

View File

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

View File

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

View File

@ -27,10 +27,10 @@
(.log js/console type 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)]
[view st/container
[status-bar {:platform-specific platform-specific}]
[status-bar]
[toolbar {:title (label :t/image-source-title)
:nav-action {:image {:source {:uri :icon_back}
:style icon-back}

View File

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

View File

@ -13,19 +13,19 @@
[status-im.components.styles :as cst]
[clojure.string :as str]))
(defn qr-scanner-toolbar [title platform-specific]
(defn qr-scanner-toolbar [title]
[view
[status-bar {:platform-specific platform-specific}]
[status-bar]
[toolbar {:title title
:background-color toolbar-background1
:action {:image {:source {:uri :icon_lock_white}
:style icon-search}
:handler #()}}]])
(defview qr-scanner [{platform-specific :platform-specific}]
(defview qr-scanner []
[identifier [:get :current-qr-context]]
[view st/barcode-scanner-container
[qr-scanner-toolbar (:toolbar-title identifier) platform-specific]
[qr-scanner-toolbar (:toolbar-title identifier)]
[camera {:onBarCodeRead (fn [code]
(let [data (-> (.-data code)
(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
(:require [status-im.components.react :refer [android?]]
(:require [status-im.utils.platform :refer [android?]]
[status-im.utils.utils :as u]))
(def sms-listener (.-default (u/require "react-native-android-sms-listener")))