flatlist render changes
Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
b62ff59f16
commit
609a7120b6
|
@ -11,7 +11,7 @@
|
|||
[status-im.ui.components.topbar :as topbar])
|
||||
(:require-macros [status-im.utils.views :as views]))
|
||||
|
||||
(defn- render-network-type [manage-network type]
|
||||
(defn- render-network-type [type _ _ manage-network]
|
||||
(let [name (case type
|
||||
:mainnet (i18n/label :t/mainnet-network)
|
||||
:testnet (i18n/label :t/ropsten-network)
|
||||
|
@ -47,10 +47,11 @@
|
|||
:on-change-text #(re-frame/dispatch [::network/input-changed :url (string/lower-case %)])}]]
|
||||
[react/view {:padding-vertical 8}
|
||||
[react/i18n-text {:key :network-chain}]
|
||||
[list/flat-list {:data [:mainnet :testnet :rinkeby :custom]
|
||||
:key-fn (fn [_ i] (str i))
|
||||
:separator list/base-separator
|
||||
:render-fn #(render-network-type manage-network %)}]]
|
||||
[list/flat-list {:data [:mainnet :testnet :rinkeby :custom]
|
||||
:key-fn (fn [_ i] (str i))
|
||||
:separator list/base-separator
|
||||
:render-data manage-network
|
||||
:render-fn render-network-type}]]
|
||||
(when custom?
|
||||
[react/view {:padding-vertical 8}
|
||||
[quo/text-input
|
||||
|
|
|
@ -28,18 +28,17 @@
|
|||
(def mainnet?
|
||||
#{"mainnet" "mainnet_rpc"})
|
||||
|
||||
(defn render-network [current-network]
|
||||
(fn [{:keys [id name] :as network}]
|
||||
(let [connected? (= id current-network)]
|
||||
[list/touchable-item #(re-frame/dispatch [::network/network-entry-pressed network])
|
||||
[react/view styles/network-item
|
||||
[network-icon connected? 40]
|
||||
[react/view {:padding-horizontal 16}
|
||||
[react/text {:style styles/network-item-name-text} name]
|
||||
(when connected?
|
||||
[react/text {:style styles/network-item-connected-text
|
||||
:accessibility-label :connected-text}
|
||||
(i18n/label :t/connected)])]]])))
|
||||
(defn render-network [{:keys [id name] :as network} _ _ current-network]
|
||||
(let [connected? (= id current-network)]
|
||||
[list/touchable-item #(re-frame/dispatch [::network/network-entry-pressed network])
|
||||
[react/view styles/network-item
|
||||
[network-icon connected? 40]
|
||||
[react/view {:padding-horizontal 16}
|
||||
[react/text {:style styles/network-item-name-text} name]
|
||||
(when connected?
|
||||
[react/text {:style styles/network-item-connected-text
|
||||
:accessibility-label :connected-text}
|
||||
(i18n/label :t/connected)])]]]))
|
||||
|
||||
(views/defview network-settings []
|
||||
(views/letsubs [current-network [:networks/current-network]
|
||||
|
@ -61,4 +60,5 @@
|
|||
:data (:custom networks)}]
|
||||
:key-fn :id
|
||||
:default-separator? true
|
||||
:render-fn (render-network current-network)}]]]))
|
||||
:render-data current-network
|
||||
:render-fn render-network}]]]))
|
||||
|
|
|
@ -82,9 +82,9 @@
|
|||
[react/view {:style (merge style styles/item-checkbox)}
|
||||
[radio/radio (:checked? props)]])])
|
||||
|
||||
(defn- wrap-render-fn [f]
|
||||
(defn- wrap-render-fn [f render-data]
|
||||
(fn [^js data]
|
||||
(reagent/as-element [f (.-item data) (.-index data) (.-separators data)])))
|
||||
(reagent/as-element [f (.-item data) (.-index data) (.-separators data) render-data])))
|
||||
|
||||
(defn- wrap-key-fn [f]
|
||||
(fn [data index]
|
||||
|
@ -96,10 +96,10 @@
|
|||
(def default-separator [react/view styles/separator])
|
||||
|
||||
(defn- base-list-props
|
||||
[{:keys [key-fn render-fn empty-component header footer separator default-separator?]}]
|
||||
[{:keys [key-fn render-fn empty-component header footer separator default-separator? render-data]}]
|
||||
(let [separator (or separator (when (and platform/ios? default-separator?) default-separator))]
|
||||
(merge (when key-fn {:keyExtractor (wrap-key-fn key-fn)})
|
||||
(when render-fn {:renderItem (wrap-render-fn render-fn)})
|
||||
(when render-fn {:renderItem (wrap-render-fn render-fn render-data)})
|
||||
(when separator {:ItemSeparatorComponent (fn [] (reagent/as-element separator))})
|
||||
(when empty-component {:ListEmptyComponent (fn [] (reagent/as-element empty-component))})
|
||||
;; header and footer not wrapped in anonymous function to prevent re-creation on every re-render
|
||||
|
@ -146,7 +146,7 @@
|
|||
(defn- wrap-per-section-render-fn [props]
|
||||
(update
|
||||
(if-let [f (:render-fn props)]
|
||||
(assoc (dissoc props :render-fn) :renderItem (wrap-render-fn f))
|
||||
(assoc (dissoc props :render-fn :render-data) :renderItem (wrap-render-fn f (:render-data props)))
|
||||
props)
|
||||
:data to-array))
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
[reagent.core :as reagent])
|
||||
(:require-macros [status-im.utils.views :as views]))
|
||||
|
||||
(defn- render-row [row _ _]
|
||||
(defn- render-row [row]
|
||||
(let [[first-name second-name] (multiaccounts/contact-two-names row false)]
|
||||
[quo/list-item
|
||||
{:title first-name
|
||||
|
|
|
@ -7,22 +7,22 @@
|
|||
[status-im.utils.utils :as utils]
|
||||
[re-frame.core :as re-frame]))
|
||||
|
||||
(defn render-account [dapps-account]
|
||||
(fn [account]
|
||||
[quo/list-item
|
||||
(merge {:accessory :radio
|
||||
:active (= (:address dapps-account) (:address account))
|
||||
:icon [chat-icon/custom-icon-view-list (:name account) (:color account)]
|
||||
:title (:name account)
|
||||
:subtitle (utils/get-shortened-checksum-address (:address account))}
|
||||
(when (not= (:address dapps-account) (:address account))
|
||||
{:on-press #(re-frame/dispatch [:dapps-account-selected (:address account)])}))]))
|
||||
(defn render-account [account _ _ dapps-account]
|
||||
[quo/list-item
|
||||
(merge {:accessory :radio
|
||||
:active (= (:address dapps-account) (:address account))
|
||||
:icon [chat-icon/custom-icon-view-list (:name account) (:color account)]
|
||||
:title (:name account)
|
||||
:subtitle (utils/get-shortened-checksum-address (:address account))}
|
||||
(when (not= (:address dapps-account) (:address account))
|
||||
{:on-press #(re-frame/dispatch [:dapps-account-selected (:address account)])}))])
|
||||
|
||||
(defn accounts-list [accounts dapps-account]
|
||||
(fn []
|
||||
[react/view {:flex 1}
|
||||
[react/text {:style {:margin 16 :text-align :center}}
|
||||
(i18n/label :t/select-account-dapp)]
|
||||
[list/flat-list {:data accounts
|
||||
:key-fn :address
|
||||
:render-fn (render-account dapps-account)}]]))
|
||||
[list/flat-list {:data accounts
|
||||
:key-fn :address
|
||||
:render-data dapps-account
|
||||
:render-fn render-account}]]))
|
||||
|
|
|
@ -199,7 +199,7 @@
|
|||
input-with-mentions)]]))
|
||||
|
||||
(defn mention-item
|
||||
[text-input-ref [_ {:keys [identicon alias name nickname] :as user}]]
|
||||
[[_ {:keys [identicon alias name nickname] :as user}] _ _ text-input-ref]
|
||||
(let [ens-name? (not= alias name)]
|
||||
[list-item/list-item
|
||||
(cond-> {:icon
|
||||
|
@ -257,7 +257,8 @@
|
|||
:header [rn/view {:style {:height 8}}]
|
||||
:data suggestions
|
||||
:key-fn first
|
||||
:render-fn #(mention-item text-input-ref %)}]]]))))
|
||||
:render-data text-input-ref
|
||||
:render-fn mention-item}]]]))))
|
||||
|
||||
(defn chat-input
|
||||
[{:keys [set-active-panel active-panel on-send-press reply
|
||||
|
|
|
@ -154,6 +154,20 @@
|
|||
first-not-visible)))))
|
||||
(debounce/debounce-and-dispatch [:chat.ui/message-visibility-changed e] 5000))
|
||||
|
||||
(defn render-fn [{:keys [outgoing type] :as message} idx _ {:keys [group-chat public? current-public-key space-keeper]}]
|
||||
(if (= type :datemark)
|
||||
[message-datemark/chat-datemark (:value message)]
|
||||
(if (= type :gap)
|
||||
[gap/gap message idx messages-list-ref false]
|
||||
; message content
|
||||
[message/chat-message
|
||||
(assoc message
|
||||
:incoming-group (and group-chat (not outgoing))
|
||||
:group-chat group-chat
|
||||
:public? public?
|
||||
:current-public-key current-public-key)
|
||||
space-keeper])))
|
||||
|
||||
(defn messages-view
|
||||
[{:keys [chat bottom-space pan-responder space-keeper]}]
|
||||
(let [{:keys [group-chat chat-id public? invitation-admin]} chat
|
||||
|
@ -174,19 +188,11 @@
|
|||
[invite.chat/reward-messages])]
|
||||
:data messages
|
||||
:inverted true
|
||||
:render-fn (fn [{:keys [outgoing type] :as message} idx]
|
||||
(if (= type :datemark)
|
||||
[message-datemark/chat-datemark (:value message)]
|
||||
(if (= type :gap)
|
||||
[gap/gap message idx messages-list-ref false]
|
||||
; message content
|
||||
[message/chat-message
|
||||
(assoc message
|
||||
:incoming-group (and group-chat (not outgoing))
|
||||
:group-chat group-chat
|
||||
:public? public?
|
||||
:current-public-key current-public-key)
|
||||
space-keeper])))
|
||||
:render-data {:group-chat group-chat
|
||||
:public? public?
|
||||
:current-public-key current-public-key
|
||||
:space-keeper space-keeper}
|
||||
:render-fn render-fn
|
||||
:on-viewable-items-changed on-viewable-items-changed
|
||||
:on-end-reached #(re-frame/dispatch [:chat.ui/load-more-messages])
|
||||
:on-scroll-to-index-failed #() ;;don't remove this
|
||||
|
|
|
@ -12,17 +12,16 @@
|
|||
|
||||
(defonce search-active? (reagent/atom false))
|
||||
|
||||
(defn render-currency [current-currency-id]
|
||||
(fn [{:keys [id code display-name]}]
|
||||
(let [selected? (= id current-currency-id)]
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [:wallet.settings.ui/currency-selected id])
|
||||
:accessibility-label :currency-item}
|
||||
[react/view styles/currency-item
|
||||
[react/text {:style styles/currency-name-text}
|
||||
(str display-name " (" code ")")]
|
||||
(when selected?
|
||||
[vector-icons/icon :main-icons/check {:color :active}])]])))
|
||||
(defn render-currency [{:keys [id code display-name]} _ _ current-currency-id]
|
||||
(let [selected? (= id current-currency-id)]
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [:wallet.settings.ui/currency-selected id])
|
||||
:accessibility-label :currency-item}
|
||||
[react/view styles/currency-item
|
||||
[react/text {:style styles/currency-name-text}
|
||||
(str display-name " (" code ")")]
|
||||
(when selected?
|
||||
[vector-icons/icon :main-icons/check {:color :active}])]]))
|
||||
|
||||
(views/defview currency-settings []
|
||||
(views/letsubs [currency-id [:wallet.settings/currency]
|
||||
|
@ -48,5 +47,6 @@
|
|||
vals
|
||||
(sort #(compare (:code %1) (:code %2))))
|
||||
:key-fn :code
|
||||
:render-fn (render-currency currency-id)
|
||||
:render-data currency-id
|
||||
:render-fn render-currency
|
||||
:keyboardShouldPersistTaps :always}]]]))
|
||||
|
|
|
@ -17,17 +17,16 @@
|
|||
(defn change-fleet [fleet]
|
||||
(re-frame/dispatch [:fleet.ui/fleet-selected fleet]))
|
||||
|
||||
(defn render-row [current-fleet]
|
||||
(fn [fleet]
|
||||
(let [current? (= fleet current-fleet)]
|
||||
[react/touchable-highlight
|
||||
{:on-press #(change-fleet fleet)
|
||||
:accessibility-label :fleet-item}
|
||||
[react/view styles/fleet-item
|
||||
[fleet-icon current?]
|
||||
[react/view styles/fleet-item-inner
|
||||
[react/text {:style styles/fleet-item-name-text}
|
||||
fleet]]]])))
|
||||
(defn render-row [fleet _ _ current-fleet]
|
||||
(let [current? (= fleet current-fleet)]
|
||||
[react/touchable-highlight
|
||||
{:on-press #(change-fleet fleet)
|
||||
:accessibility-label :fleet-item}
|
||||
[react/view styles/fleet-item
|
||||
[fleet-icon current?]
|
||||
[react/view styles/fleet-item-inner
|
||||
[react/text {:style styles/fleet-item-name-text}
|
||||
fleet]]]]))
|
||||
|
||||
(defn fleets [custom-fleets]
|
||||
(map name (keys (node/fleets {:custom-fleets custom-fleets}))))
|
||||
|
@ -41,4 +40,5 @@
|
|||
[list/flat-list {:data (fleets custom-fleets)
|
||||
:default-separator? false
|
||||
:key-fn identity
|
||||
:render-fn (render-row (name current-fleet))}]]]))
|
||||
:render-data (name current-fleet)
|
||||
:render-fn render-row}]]]))
|
||||
|
|
|
@ -64,18 +64,18 @@
|
|||
:active contact-selected?
|
||||
:accessory :checkbox}])))
|
||||
|
||||
(defn- group-toggle-contact [allow-new-users? contact]
|
||||
(defn- group-toggle-contact [contact _ _ allow-new-users?]
|
||||
[toggle-item allow-new-users? :is-contact-selected? contact on-toggle])
|
||||
|
||||
(defn- group-toggle-participant [allow-new-users? contact]
|
||||
(defn- group-toggle-participant [contact _ _ allow-new-users?]
|
||||
[toggle-item allow-new-users? :is-participant-selected? contact on-toggle-participant])
|
||||
|
||||
(defn toggle-list [{:keys [contacts render-fn]}]
|
||||
[react/scroll-view {:flex 1}
|
||||
[list/flat-list {:data contacts
|
||||
:key-fn :public-key
|
||||
:render-fn render-fn
|
||||
:keyboardShouldPersistTaps :always}]])
|
||||
(defn toggle-list [{:keys [contacts render-fn render-data]}]
|
||||
[list/flat-list {:data contacts
|
||||
:key-fn :public-key
|
||||
:render-data render-data
|
||||
:render-fn render-fn
|
||||
:keyboardShouldPersistTaps :always}])
|
||||
|
||||
(defn no-contacts [{:keys [no-contacts]}]
|
||||
[react/view {:style styles/no-contacts}
|
||||
|
@ -153,8 +153,9 @@
|
|||
[react/view {:style {:flex 1
|
||||
:padding-vertical 8}}
|
||||
(if (seq contacts)
|
||||
[toggle-list {:contacts (filter-contacts @search-value contacts)
|
||||
:render-fn (partial toggle-fn allow-new-users?)}]
|
||||
[toggle-list {:contacts (filter-contacts @search-value contacts)
|
||||
:render-data allow-new-users?
|
||||
:render-fn toggle-fn}]
|
||||
[no-contacts {:no-contacts no-contacts-label}])]])))
|
||||
|
||||
;; Start group chat
|
||||
|
|
|
@ -132,6 +132,9 @@
|
|||
(re-frame/dispatch [:set :public-group-topic nil])
|
||||
(re-frame/dispatch [:search/home-filter-changed nil]))}])])))
|
||||
|
||||
(defn render-fn [home-item]
|
||||
[inner-item/home-list-item home-item])
|
||||
|
||||
(views/defview chats-list []
|
||||
(views/letsubs [loading? [:chats/loading?]
|
||||
{:keys [chats search-filter]} [:home-items]
|
||||
|
@ -148,7 +151,7 @@
|
|||
{:key-fn :chat-id
|
||||
:keyboard-should-persist-taps :always
|
||||
:data chats
|
||||
:render-fn (fn [home-item] [inner-item/home-list-item home-item])
|
||||
:render-fn render-fn
|
||||
:header (when (or (seq chats) @search-active? (seq search-filter))
|
||||
[search-input-wrapper search-filter chats])
|
||||
:empty-component (when (or @search-active? (seq search-filter))
|
||||
|
|
|
@ -16,17 +16,16 @@
|
|||
(defn change-log-level [log-level]
|
||||
(re-frame/dispatch [:log-level.ui/log-level-selected log-level]))
|
||||
|
||||
(defn render-row [current-log-level]
|
||||
(fn [{:keys [name value] :as log-level}]
|
||||
(let [current? (= value current-log-level)]
|
||||
[react/touchable-highlight
|
||||
{:on-press #(change-log-level log-level)
|
||||
:accessibility-label :log-level-item}
|
||||
[react/view styles/log-level-item
|
||||
[log-level-icon current?]
|
||||
[react/view styles/log-level-item-inner
|
||||
[react/text {:style styles/log-level-item-name-text}
|
||||
name]]]])))
|
||||
(defn render-row [{:keys [name value] :as log-level} _ _ current-log-level]
|
||||
(let [current? (= value current-log-level)]
|
||||
[react/touchable-highlight
|
||||
{:on-press #(change-log-level log-level)
|
||||
:accessibility-label :log-level-item}
|
||||
[react/view styles/log-level-item
|
||||
[log-level-icon current?]
|
||||
[react/view styles/log-level-item-inner
|
||||
[react/text {:style styles/log-level-item-name-text}
|
||||
name]]]]))
|
||||
|
||||
(def log-levels
|
||||
[{:name "DISABLED"
|
||||
|
@ -50,4 +49,5 @@
|
|||
[list/flat-list {:data log-levels
|
||||
:default-separator? false
|
||||
:key-fn :name
|
||||
:render-fn (render-row current-log-level)}]]]))
|
||||
:render-data current-log-level
|
||||
:render-fn render-row}]]]))
|
||||
|
|
|
@ -24,26 +24,26 @@
|
|||
[react/text {:style styles/explanation-text}
|
||||
(i18n/label :t/mailserver-automatic-switch-explanation)]]])
|
||||
|
||||
(defn render-row [current-mailserver-id pinned?]
|
||||
(fn [{:keys [name id user-defined]}]
|
||||
(let [connected? (= id current-mailserver-id)
|
||||
visible? (or pinned? ; show everything when auto selection is turned off
|
||||
(and (not pinned?) ; auto selection turned on
|
||||
(= current-mailserver-id id) ; show only the selected server
|
||||
))]
|
||||
(when visible?
|
||||
[react/touchable-highlight
|
||||
{:on-press (when pinned? #(if user-defined
|
||||
(re-frame/dispatch [:mailserver.ui/user-defined-mailserver-selected id])
|
||||
(re-frame/dispatch [:mailserver.ui/default-mailserver-selected id])))
|
||||
:accessibility-label :mailserver-item}
|
||||
[react/view (styles/mailserver-item)
|
||||
[react/text {:style styles/mailserver-item-name-text}
|
||||
name]
|
||||
(defn render-row [{:keys [name id user-defined]} _ _ {:keys [current-mailserver-id preferred-mailserver-id]}]
|
||||
(let [pinned? preferred-mailserver-id
|
||||
connected? (= id current-mailserver-id)
|
||||
visible? (or pinned? ; show everything when auto selection is turned off
|
||||
(and (not pinned?) ; auto selection turned on
|
||||
(= current-mailserver-id id)))] ; show only the selected server
|
||||
|
||||
(if pinned?
|
||||
[radio/radio connected?]
|
||||
[vector-icons/icon :check {:color colors/blue}])]]))))
|
||||
(when visible?
|
||||
[react/touchable-highlight
|
||||
{:on-press (when pinned? #(if user-defined
|
||||
(re-frame/dispatch [:mailserver.ui/user-defined-mailserver-selected id])
|
||||
(re-frame/dispatch [:mailserver.ui/default-mailserver-selected id])))
|
||||
:accessibility-label :mailserver-item}
|
||||
[react/view (styles/mailserver-item)
|
||||
[react/text {:style styles/mailserver-item-name-text}
|
||||
name]
|
||||
|
||||
(if pinned?
|
||||
[radio/radio connected?]
|
||||
[vector-icons/icon :check {:color colors/blue}])]])))
|
||||
|
||||
(views/defview offline-messaging-settings []
|
||||
(views/letsubs [current-mailserver-id [:mailserver/current-id]
|
||||
|
@ -78,5 +78,6 @@
|
|||
[list/flat-list {:data (vals mailservers)
|
||||
:default-separator? false
|
||||
:key-fn :name
|
||||
:render-fn (render-row current-mailserver-id
|
||||
preferred-mailserver-id)}]])]]))
|
||||
:render-data {:current-mailserver-id current-mailserver-id
|
||||
:preferred-mailserver-id preferred-mailserver-id}
|
||||
:render-fn render-row}]])]]))
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
:on-viewable-items-changed chat.views/on-viewable-items-changed
|
||||
:on-end-reached #(re-frame/dispatch [:chat.ui/load-more-messages])
|
||||
:on-scroll-to-index-failed #() ;;don't remove this
|
||||
:render-fn (status.views/render-message false nil)
|
||||
:render-fn status.views/render-message
|
||||
:data messages}])))
|
||||
|
||||
(views/defview profile []
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
:icon :main-icons/remove-contact
|
||||
:on-press #(chat.sheets/hide-sheet-and-dispatch [:group-chats.ui/remove-member-pressed chat-id (:public-key member)])}])]))
|
||||
|
||||
(defn render-member [chat-id {:keys [public-key] :as member} admin? current-user-identity]
|
||||
(defn render-member [{:keys [public-key] :as member} _ _ {:keys [chat-id admin? current-user-identity]}]
|
||||
(let [[first-name second-name] (multiaccounts/contact-two-names member false)]
|
||||
[quo/list-item
|
||||
(merge
|
||||
|
@ -82,9 +82,12 @@
|
|||
(defview chat-group-members-view [chat-id admin? current-user-identity]
|
||||
(letsubs [members [:contacts/current-chat-contacts]]
|
||||
(when (seq members)
|
||||
[list/flat-list {:data members
|
||||
:key-fn :address
|
||||
:render-fn #(render-member chat-id % admin? current-user-identity)}])))
|
||||
[list/flat-list {:data members
|
||||
:key-fn :address
|
||||
:render-data {:chat-id chat-id
|
||||
:admin? admin?
|
||||
:current-user-identity current-user-identity}
|
||||
:render-fn render-member}])))
|
||||
|
||||
(defn members-list [{:keys [chat-id admin? current-pk allow-adding-members?]}]
|
||||
[react/view
|
||||
|
|
|
@ -135,41 +135,39 @@
|
|||
[message/render-parsed-text (assoc message :outgoing false) (:parsed-text content)]])
|
||||
[link-preview/link-preview-wrapper (:links content) outgoing true]]]]))
|
||||
|
||||
(defn render-message [timeline? account]
|
||||
(fn [{:keys [type] :as message} idx]
|
||||
[(fn []
|
||||
(if (= type :datemark)
|
||||
nil
|
||||
(if (= type :gap)
|
||||
(if timeline?
|
||||
nil
|
||||
[gap/gap message idx messages-list-ref true])
|
||||
; message content
|
||||
(let [chat-id (chat/profile-chat-topic (:from message))]
|
||||
[react/view (merge {:accessibility-label :chat-item}
|
||||
(when (:last-in-group? message)
|
||||
{:padding-bottom 8
|
||||
:margin-bottom 8
|
||||
:border-bottom-width 1
|
||||
:border-bottom-color colors/gray-lighter}))
|
||||
[reactions/with-reaction-picker
|
||||
{:message message
|
||||
:timeline true
|
||||
:reactions @(re-frame/subscribe [:chats/message-reactions (:message-id message)])
|
||||
:picker-on-open (fn [])
|
||||
:picker-on-close (fn [])
|
||||
:send-emoji (fn [{:keys [emoji-id]}]
|
||||
(re-frame/dispatch [::models.reactions/send-emoji-reaction
|
||||
{:message-id (:message-id message)
|
||||
:chat-id chat-id
|
||||
:emoji-id emoji-id}]))
|
||||
:retract-emoji (fn [{:keys [emoji-id emoji-reaction-id]}]
|
||||
(re-frame/dispatch [::models.reactions/send-emoji-reaction-retraction
|
||||
{:message-id (:message-id message)
|
||||
:chat-id chat-id
|
||||
:emoji-id emoji-id
|
||||
:emoji-reaction-id emoji-reaction-id}]))
|
||||
:render (message-item account)}]]))))]))
|
||||
(defn render-message [{:keys [type] :as message} idx _ {:keys [timeline account]}]
|
||||
(if (= type :datemark)
|
||||
nil
|
||||
(if (= type :gap)
|
||||
(if timeline
|
||||
nil
|
||||
[gap/gap message idx messages-list-ref true])
|
||||
; message content
|
||||
(let [chat-id (chat/profile-chat-topic (:from message))]
|
||||
[react/view (merge {:accessibility-label :chat-item}
|
||||
(when (:last-in-group? message)
|
||||
{:padding-bottom 8
|
||||
:margin-bottom 8
|
||||
:border-bottom-width 1
|
||||
:border-bottom-color colors/gray-lighter}))
|
||||
[reactions/with-reaction-picker
|
||||
{:message message
|
||||
:timeline true
|
||||
:reactions @(re-frame/subscribe [:chats/message-reactions (:message-id message)])
|
||||
:picker-on-open (fn [])
|
||||
:picker-on-close (fn [])
|
||||
:send-emoji (fn [{:keys [emoji-id]}]
|
||||
(re-frame/dispatch [::models.reactions/send-emoji-reaction
|
||||
{:message-id (:message-id message)
|
||||
:chat-id chat-id
|
||||
:emoji-id emoji-id}]))
|
||||
:retract-emoji (fn [{:keys [emoji-id emoji-reaction-id]}]
|
||||
(re-frame/dispatch [::models.reactions/send-emoji-reaction-retraction
|
||||
{:message-id (:message-id message)
|
||||
:chat-id chat-id
|
||||
:emoji-id emoji-id
|
||||
:emoji-reaction-id emoji-reaction-id}]))
|
||||
:render (message-item account)}]]))))
|
||||
|
||||
(def state (reagent/atom {:tab :timeline}))
|
||||
|
||||
|
@ -207,7 +205,9 @@
|
|||
(i18n/label :t/statuses-my-status-descr))]]]
|
||||
[list/flat-list
|
||||
{:key-fn #(or (:message-id %) (:value %))
|
||||
:render-fn (render-message (= :timeline (:tab @state)) account)
|
||||
:render-data {:timeline (= :timeline (:tab @state))
|
||||
:account account}
|
||||
:render-fn render-message
|
||||
:data messages
|
||||
:on-viewable-items-changed chat.views/on-viewable-items-changed
|
||||
:on-end-reached #(re-frame/dispatch [:chat.ui/load-more-messages])
|
||||
|
|
|
@ -129,7 +129,8 @@
|
|||
[list/flat-list {:data tokens
|
||||
:default-separator? false
|
||||
:key-fn :name
|
||||
:render-fn (accounts/render-asset (:code currency))}]
|
||||
:render-data (:code currency)
|
||||
:render-fn accounts/render-asset}]
|
||||
(= tab :nft)
|
||||
[react/view
|
||||
[collectibles-link]
|
||||
|
|
|
@ -60,25 +60,22 @@
|
|||
[icons/icon :main-icons/add-circle {:color colors/blue}]
|
||||
[react/text {:style styles/add-text} (i18n/label :t/add-account)]]])
|
||||
|
||||
(defn render-asset [currency & [on-press]]
|
||||
(fn [{:keys [icon decimals amount color value] :as token}]
|
||||
[quo/list-item
|
||||
(merge {:title [quo/text {:weight :medium}
|
||||
[quo/text {:weight :inherit}
|
||||
(str (if amount
|
||||
(wallet.utils/format-amount amount decimals)
|
||||
"...")
|
||||
" ")]
|
||||
[quo/text {:color :secondary
|
||||
:weight :inherit}
|
||||
(wallet.utils/display-symbol token)]]
|
||||
:subtitle (str (if value value "...") " " currency)
|
||||
:accessibility-label (str (:symbol token) "-asset-value")
|
||||
:icon (if icon
|
||||
[list/item-image icon]
|
||||
[chat-icon/custom-icon-view-list (:name token) color])}
|
||||
(when on-press
|
||||
{:on-press #(on-press token)}))]))
|
||||
(defn render-asset [{:keys [icon decimals amount color value] :as token} _ _ currency]
|
||||
[quo/list-item
|
||||
{:title [quo/text {:weight :medium}
|
||||
[quo/text {:weight :inherit}
|
||||
(str (if amount
|
||||
(wallet.utils/format-amount amount decimals)
|
||||
"...")
|
||||
" ")]
|
||||
[quo/text {:color :secondary
|
||||
:weight :inherit}
|
||||
(wallet.utils/display-symbol token)]]
|
||||
:subtitle (str (if value value "...") " " currency)
|
||||
:accessibility-label (str (:symbol token) "-asset-value")
|
||||
:icon (if icon
|
||||
[list/item-image icon]
|
||||
[chat-icon/custom-icon-view-list (:name token) color])}])
|
||||
|
||||
(views/defview assets []
|
||||
(views/letsubs [{:keys [tokens]} [:wallet/all-visible-assets-with-values]
|
||||
|
@ -86,7 +83,8 @@
|
|||
[list/flat-list {:data tokens
|
||||
:default-separator? false
|
||||
:key-fn :name
|
||||
:render-fn (render-asset (:code currency))}]))
|
||||
:render-data (:code currency)
|
||||
:render-fn render-asset}]))
|
||||
|
||||
(views/defview send-button []
|
||||
(views/letsubs [account [:multiaccount/default-account]]
|
||||
|
|
|
@ -11,27 +11,26 @@
|
|||
(views/defview assets [address]
|
||||
(views/letsubs [{:keys [tokens]} [:wallet/visible-assets-with-values address]
|
||||
currency [:wallet/currency]]
|
||||
(let [render (wallet.accounts/render-asset
|
||||
(:code currency)
|
||||
#(re-frame/dispatch [:wallet.send/set-symbol (:symbol %)]))]
|
||||
[:<>
|
||||
(for [token tokens]
|
||||
^{:key (str (:symbol token))}
|
||||
[render token])])))
|
||||
[:<>
|
||||
(for [token tokens]
|
||||
^{:key (str (:symbol token))}
|
||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:wallet.send/set-symbol (:symbol token)])}
|
||||
[wallet.accounts/render-asset token nil nil (:code currency)]])]))
|
||||
|
||||
(defn render-account [field event]
|
||||
(fn [account]
|
||||
[quo/list-item
|
||||
{:icon [chat-icon/custom-icon-view-list (:name account) (:color account)]
|
||||
:title (:name account)
|
||||
:on-press #(re-frame/dispatch [event field account])}]))
|
||||
(defn render-account [account _ _ {:keys [field event]}]
|
||||
[quo/list-item
|
||||
{:icon [chat-icon/custom-icon-view-list (:name account) (:color account)]
|
||||
:title (:name account)
|
||||
:on-press #(re-frame/dispatch [event field account])}])
|
||||
|
||||
(views/defview accounts-list [field event]
|
||||
(views/letsubs [accounts [:multiaccount/accounts]
|
||||
accounts-whithout-watch [:accounts-without-watch-only]]
|
||||
[list/flat-list {:data (if (= :to field) accounts accounts-whithout-watch)
|
||||
:key-fn :address
|
||||
:render-fn (render-account field event)}]))
|
||||
:render-data {:field field
|
||||
:event event}
|
||||
:render-fn render-account}]))
|
||||
|
||||
(defn show-accounts-list []
|
||||
(re-frame/dispatch [:bottom-sheet/hide])
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
[list/section-list
|
||||
{:sections transactions-history-sections
|
||||
:key-fn :hash
|
||||
:render-fn #(render-transaction %)
|
||||
:render-fn render-transaction
|
||||
:empty-component
|
||||
[react/i18n-text {:style styles/empty-text
|
||||
:key (if (or fetching-recent-history? fetching-more-history?)
|
||||
|
|
Loading…
Reference in New Issue