replacing the need in passing platform-specific with status-im.utils.platform (#227)
This commit is contained in:
parent
fd329ee732
commit
b67417f268
|
@ -25,10 +25,9 @@
|
|||
[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}
|
||||
(label :t/login)]])
|
||||
|
||||
|
@ -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)]]]]]])
|
||||
|
|
|
@ -26,11 +26,9 @@
|
|||
[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}
|
||||
(label :t/recover-from-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,13 +77,12 @@
|
|||
"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]
|
||||
|
@ -93,7 +90,6 @@
|
|||
:style toolbar-gradient}]
|
||||
[view st/recover-explain-container
|
||||
[text {:style st/recover-explain-text
|
||||
:platform-specific platform-specific
|
||||
:font :medium}
|
||||
(label :t/recover-explain)]]
|
||||
[view st/form-container
|
||||
|
@ -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)]]]]]]))
|
||||
|
|
|
@ -30,11 +30,10 @@
|
|||
[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}
|
||||
(label :t/switch-users)]]))
|
||||
|
||||
|
@ -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}]
|
||||
[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 platform-specific]
|
||||
:custom-content [toolbar-title]
|
||||
:action {:image {:style icon-search}
|
||||
:handler #()}
|
||||
:platform-specific platform-specific}]
|
||||
: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
|
||||
|
@ -94,7 +90,6 @@
|
|||
[image {:source {:uri :icon_add}
|
||||
:style st/icon-plus}]
|
||||
[text {:style st/add-account-text
|
||||
:platform-specific platform-specific
|
||||
:font :default}
|
||||
(label :t/add-account)]]]]
|
||||
]]]))
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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})
|
|
@ -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})
|
|
@ -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}
|
||||
(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,14 +99,13 @@
|
|||
(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}
|
||||
(if (str/blank? @name)
|
||||
|
@ -116,12 +115,10 @@
|
|||
[view {:flexDirection :row}
|
||||
[icon :group st/group-icon]
|
||||
[text {:style st/members
|
||||
:platform-specific platform-specific
|
||||
:font :medium}
|
||||
(let [cnt (inc (count @contacts))]
|
||||
(label-pluralize cnt :t/members))]]
|
||||
[text {:style st/last-activity
|
||||
:platform-specific platform-specific
|
||||
:font :default}
|
||||
(online-text @contact @chat-id)])])))
|
||||
|
||||
|
@ -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])])})))
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
(defn action-view [{:keys [icon-style
|
||||
custom-icon
|
||||
handler
|
||||
title
|
||||
subtitle]
|
||||
icon-name :icon} :action
|
||||
platform-specific :platform-specific}]
|
||||
icon-name :icon}]
|
||||
[touchable-highlight {:on-press (fn []
|
||||
(dispatch [:set-show-actions false])
|
||||
(when handler
|
||||
|
@ -114,32 +114,29 @@
|
|||
[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]
|
||||
(when-let [subtitle subtitle]
|
||||
[text {:style st/action-subtitle
|
||||
:platform-specific platform-specific
|
||||
: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]])
|
|
@ -22,11 +22,10 @@
|
|||
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}
|
||||
(time/to-short-str timestamp)]]])
|
||||
|
||||
|
@ -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}
|
||||
from]
|
||||
[text {:style st/status-text
|
||||
:platform-specific platform-specific
|
||||
: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
|
||||
|
@ -66,11 +63,10 @@
|
|||
[view st/track]
|
||||
[view st/track-mark]
|
||||
[text {:style st/track-duration-text
|
||||
:platform-specific platform-specific
|
||||
: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]
|
||||
|
@ -78,7 +74,6 @@
|
|||
[view st/command-container
|
||||
[view (st/command-view command)
|
||||
[text {:style st/command-name
|
||||
:platform-specific platform-specific
|
||||
:font :default}
|
||||
(str (if (= :command type) "!" "") name)]]]
|
||||
(when icon
|
||||
|
@ -88,7 +83,6 @@
|
|||
(if preview
|
||||
preview
|
||||
[text {:style st/command-text
|
||||
:platform-specific platform-specific
|
||||
:font :default}
|
||||
(str content)])]))
|
||||
|
||||
|
@ -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}
|
||||
(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])
|
||||
: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)
|
||||
|
@ -151,7 +141,6 @@
|
|||
nil)
|
||||
:style st/delivery-image}]
|
||||
[text {:style st/delivery-text
|
||||
:platform-specific platform-specific
|
||||
:font :default}
|
||||
(message-status-label (or status delivery-status))]])
|
||||
|
||||
|
@ -164,12 +153,11 @@
|
|||
: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}
|
||||
"Mar 7th, 15:22"])
|
||||
[view (st/incoming-group-message-body-st message)
|
||||
|
@ -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})])]])})))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
@ -77,17 +77,14 @@
|
|||
[view st/command-request-message-view
|
||||
(when incoming-group
|
||||
[text {:style st/command-request-from-text
|
||||
:platform-specific platform-specific
|
||||
:font :default}
|
||||
from])
|
||||
[text {:style st/style-message-text
|
||||
:platform-specific platform-specific
|
||||
: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}
|
||||
(:request-text command)]])]))))
|
||||
|
|
|
@ -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]))
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
(ns status-im.components.carousel.carousel
|
||||
(:require [status-im.components.react :refer [android?
|
||||
view
|
||||
(:require [status-im.components.react :refer [view
|
||||
scroll-view
|
||||
touchable-without-feedback
|
||||
text]]
|
||||
|
|
|
@ -27,24 +27,22 @@
|
|||
{: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}
|
||||
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}
|
||||
(if (= name address)
|
||||
|
@ -52,27 +50,21 @@
|
|||
name)]]
|
||||
[view st/menu-items-container
|
||||
[menu-item {:name (label :t/profile)
|
||||
:handler #(dispatch [:navigate-to :my-profile])
|
||||
:platform-specific platform-specific}]
|
||||
:handler #(dispatch [:navigate-to :my-profile])}]
|
||||
[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}]
|
||||
:handler #(dispatch [:navigate-to :discovery])}]
|
||||
[menu-item {:name (label :t/contacts)
|
||||
:handler #(dispatch [:navigate-to :contact-list])
|
||||
:platform-specific platform-specific}]
|
||||
:handler #(dispatch [:navigate-to :contact-list])}]
|
||||
[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}]]
|
||||
:handler (fn [])}]]
|
||||
[view st/switch-users-container
|
||||
[touchable-opacity {:onPress (fn []
|
||||
(close-drawer)
|
||||
|
@ -80,14 +72,13 @@
|
|||
;; TODO not implemented
|
||||
)}
|
||||
[text {:style st/switch-users-text
|
||||
:platform-specific platform-specific
|
||||
: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])
|
||||
|
|
|
@ -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}]]]]])
|
||||
|
|
|
@ -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
|
||||
(let [font (get-in platform-specific [:fonts font])]
|
||||
[text-class
|
||||
(cond
|
||||
(and platform-specific font)
|
||||
(-> 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))
|
||||
|
||||
|
|
|
@ -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
|
||||
(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?
|
||||
|
|
|
@ -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})
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
custom-action :custom-action
|
||||
background-color :background-color
|
||||
custom-content :custom-content
|
||||
style :style
|
||||
platform-specific :platform-specific}]
|
||||
style :style}]
|
||||
(let [style (merge {:flexDirection :row
|
||||
:backgroundColor (or background-color toolbar-background1)
|
||||
:height toolbar-height
|
||||
|
@ -49,7 +48,6 @@
|
|||
(or custom-content
|
||||
[view {:style toolbar-title-container}
|
||||
[text {:style toolbar-title-text
|
||||
:platform-specific platform-specific
|
||||
:font :medium}
|
||||
title]])
|
||||
custom-action
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,13 +39,13 @@
|
|||
: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}
|
||||
[drawer-view
|
||||
[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
|
||||
;; about this?
|
||||
(when contacts
|
||||
|
|
|
@ -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}
|
||||
|
@ -99,6 +99,5 @@
|
|||
[contact-whisper-id-input new-contact-identity error]]
|
||||
[view st/address-explication-container
|
||||
[text {:style st/address-explication
|
||||
:platform-specific platform-specific
|
||||
:font :default}
|
||||
(label :t/address-explication)]]])
|
||||
|
|
|
@ -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
|
||||
|
@ -33,47 +33,42 @@
|
|||
(dispatch [:navigate-to :discovery-search-results])))}]
|
||||
[view
|
||||
[text {:style st/discovery-title
|
||||
:platform-specific platform-specific
|
||||
: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}
|
||||
(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}
|
||||
(label :t/recent)]]
|
||||
[discovery-recent {:contacts contacts
|
||||
:platform-specific platform-specific}]]
|
||||
[discovery-recent {:contacts contacts}]]
|
||||
|
||||
[bottom-gradient]])
|
||||
|
|
|
@ -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}
|
||||
(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}]]))
|
||||
|
|
|
@ -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}]]))
|
||||
|
|
|
@ -7,13 +7,12 @@
|
|||
[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}
|
||||
(cond
|
||||
|
@ -21,7 +20,6 @@
|
|||
(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}
|
||||
status]]
|
||||
|
|
|
@ -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}])]
|
||||
:contacts contacts}])]
|
||||
[text (label :t/none)]))
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
(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
|
||||
|
@ -23,14 +23,12 @@
|
|||
[touchable-highlight {:onPress #(dispatch [:show-discovery-tag tag])}
|
||||
[view
|
||||
[text {:style st/tag-name
|
||||
:platform-specific platform-specific
|
||||
:font :medium}
|
||||
(str " #" (name tag))]]]]
|
||||
[view st/tag-count-container
|
||||
[text {:style st/tag-count
|
||||
:platform-specific platform-specific
|
||||
: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])])
|
||||
|
|
|
@ -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])])
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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})
|
||||
|
|
@ -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]
|
||||
|
|
|
@ -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}]])
|
||||
|
|
|
@ -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}]])
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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}
|
||||
|
@ -71,7 +71,6 @@
|
|||
:name username}
|
||||
:edit? edit?}])]
|
||||
[text {:style st/username
|
||||
:platform-specific platform-specific
|
||||
:font :default}
|
||||
(if (= username address)
|
||||
(label :t/user-anonymous)
|
||||
|
@ -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,8 +120,7 @@
|
|||
[view st/actions-btn-container
|
||||
[icon :dots st/edit-btn-icon]]]]
|
||||
|
||||
[status-image-view {:platform-specific platform-specific
|
||||
:account contact
|
||||
[status-image-view {:account contact
|
||||
:photo-path photo-path
|
||||
:edit? false}]
|
||||
|
||||
|
@ -143,25 +139,22 @@
|
|||
[profile-property-view {:name (label :t/username)
|
||||
:value (if (not= username address)
|
||||
username)
|
||||
:empty-value (label :t/not-specified)
|
||||
:platform-specific platform-specific}]
|
||||
: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)
|
||||
:platform-specific platform-specific}]
|
||||
: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)
|
||||
:platform-specific platform-specific}]
|
||||
: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,13 +168,12 @@
|
|||
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
|
||||
[status-image-view {:account account
|
||||
:photo-path (or new-photo-path photo-path)
|
||||
:status (or new-status status)
|
||||
:edit? edit?}]
|
||||
|
@ -192,21 +184,18 @@
|
|||
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-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
|
||||
:platform-specific platform-specific}]
|
||||
: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
|
||||
:platform-specific platform-specific}]
|
||||
: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)
|
||||
|
|
|
@ -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:" ""))]
|
||||
|
|
|
@ -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 {}))
|
|
@ -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")))
|
||||
|
|
Loading…
Reference in New Issue