flatlist render changes

Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
andrey 2020-12-02 13:32:44 +01:00
parent b62ff59f16
commit 609a7120b6
No known key found for this signature in database
GPG Key ID: 89B67245FD2F0272
20 changed files with 211 additions and 197 deletions

View File

@ -11,7 +11,7 @@
[status-im.ui.components.topbar :as topbar]) [status-im.ui.components.topbar :as topbar])
(:require-macros [status-im.utils.views :as views])) (: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 (let [name (case type
:mainnet (i18n/label :t/mainnet-network) :mainnet (i18n/label :t/mainnet-network)
:testnet (i18n/label :t/ropsten-network) :testnet (i18n/label :t/ropsten-network)
@ -47,10 +47,11 @@
:on-change-text #(re-frame/dispatch [::network/input-changed :url (string/lower-case %)])}]] :on-change-text #(re-frame/dispatch [::network/input-changed :url (string/lower-case %)])}]]
[react/view {:padding-vertical 8} [react/view {:padding-vertical 8}
[react/i18n-text {:key :network-chain}] [react/i18n-text {:key :network-chain}]
[list/flat-list {:data [:mainnet :testnet :rinkeby :custom] [list/flat-list {:data [:mainnet :testnet :rinkeby :custom]
:key-fn (fn [_ i] (str i)) :key-fn (fn [_ i] (str i))
:separator list/base-separator :separator list/base-separator
:render-fn #(render-network-type manage-network %)}]] :render-data manage-network
:render-fn render-network-type}]]
(when custom? (when custom?
[react/view {:padding-vertical 8} [react/view {:padding-vertical 8}
[quo/text-input [quo/text-input

View File

@ -28,18 +28,17 @@
(def mainnet? (def mainnet?
#{"mainnet" "mainnet_rpc"}) #{"mainnet" "mainnet_rpc"})
(defn render-network [current-network] (defn render-network [{:keys [id name] :as network} _ _ current-network]
(fn [{:keys [id name] :as network}] (let [connected? (= id current-network)]
(let [connected? (= id current-network)] [list/touchable-item #(re-frame/dispatch [::network/network-entry-pressed network])
[list/touchable-item #(re-frame/dispatch [::network/network-entry-pressed network]) [react/view styles/network-item
[react/view styles/network-item [network-icon connected? 40]
[network-icon connected? 40] [react/view {:padding-horizontal 16}
[react/view {:padding-horizontal 16} [react/text {:style styles/network-item-name-text} name]
[react/text {:style styles/network-item-name-text} name] (when connected?
(when connected? [react/text {:style styles/network-item-connected-text
[react/text {:style styles/network-item-connected-text :accessibility-label :connected-text}
:accessibility-label :connected-text} (i18n/label :t/connected)])]]]))
(i18n/label :t/connected)])]]])))
(views/defview network-settings [] (views/defview network-settings []
(views/letsubs [current-network [:networks/current-network] (views/letsubs [current-network [:networks/current-network]
@ -61,4 +60,5 @@
:data (:custom networks)}] :data (:custom networks)}]
:key-fn :id :key-fn :id
:default-separator? true :default-separator? true
:render-fn (render-network current-network)}]]])) :render-data current-network
:render-fn render-network}]]]))

View File

@ -82,9 +82,9 @@
[react/view {:style (merge style styles/item-checkbox)} [react/view {:style (merge style styles/item-checkbox)}
[radio/radio (:checked? props)]])]) [radio/radio (:checked? props)]])])
(defn- wrap-render-fn [f] (defn- wrap-render-fn [f render-data]
(fn [^js 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] (defn- wrap-key-fn [f]
(fn [data index] (fn [data index]
@ -96,10 +96,10 @@
(def default-separator [react/view styles/separator]) (def default-separator [react/view styles/separator])
(defn- base-list-props (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))] (let [separator (or separator (when (and platform/ios? default-separator?) default-separator))]
(merge (when key-fn {:keyExtractor (wrap-key-fn key-fn)}) (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 separator {:ItemSeparatorComponent (fn [] (reagent/as-element separator))})
(when empty-component {:ListEmptyComponent (fn [] (reagent/as-element empty-component))}) (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 ;; 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] (defn- wrap-per-section-render-fn [props]
(update (update
(if-let [f (:render-fn props)] (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) props)
:data to-array)) :data to-array))

View File

@ -17,7 +17,7 @@
[reagent.core :as reagent]) [reagent.core :as reagent])
(:require-macros [status-im.utils.views :as views])) (: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)] (let [[first-name second-name] (multiaccounts/contact-two-names row false)]
[quo/list-item [quo/list-item
{:title first-name {:title first-name

View File

@ -7,22 +7,22 @@
[status-im.utils.utils :as utils] [status-im.utils.utils :as utils]
[re-frame.core :as re-frame])) [re-frame.core :as re-frame]))
(defn render-account [dapps-account] (defn render-account [account _ _ dapps-account]
(fn [account] [quo/list-item
[quo/list-item (merge {:accessory :radio
(merge {:accessory :radio :active (= (:address dapps-account) (:address account))
:active (= (:address dapps-account) (:address account)) :icon [chat-icon/custom-icon-view-list (:name account) (:color account)]
:icon [chat-icon/custom-icon-view-list (:name account) (:color account)] :title (:name account)
:title (:name account) :subtitle (utils/get-shortened-checksum-address (:address account))}
:subtitle (utils/get-shortened-checksum-address (:address account))} (when (not= (:address dapps-account) (:address account))
(when (not= (:address dapps-account) (:address account)) {:on-press #(re-frame/dispatch [:dapps-account-selected (:address account)])}))])
{:on-press #(re-frame/dispatch [:dapps-account-selected (:address account)])}))]))
(defn accounts-list [accounts dapps-account] (defn accounts-list [accounts dapps-account]
(fn [] (fn []
[react/view {:flex 1} [react/view {:flex 1}
[react/text {:style {:margin 16 :text-align :center}} [react/text {:style {:margin 16 :text-align :center}}
(i18n/label :t/select-account-dapp)] (i18n/label :t/select-account-dapp)]
[list/flat-list {:data accounts [list/flat-list {:data accounts
:key-fn :address :key-fn :address
:render-fn (render-account dapps-account)}]])) :render-data dapps-account
:render-fn render-account}]]))

View File

@ -199,7 +199,7 @@
input-with-mentions)]])) input-with-mentions)]]))
(defn mention-item (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)] (let [ens-name? (not= alias name)]
[list-item/list-item [list-item/list-item
(cond-> {:icon (cond-> {:icon
@ -257,7 +257,8 @@
:header [rn/view {:style {:height 8}}] :header [rn/view {:style {:height 8}}]
:data suggestions :data suggestions
:key-fn first :key-fn first
:render-fn #(mention-item text-input-ref %)}]]])))) :render-data text-input-ref
:render-fn mention-item}]]]))))
(defn chat-input (defn chat-input
[{:keys [set-active-panel active-panel on-send-press reply [{:keys [set-active-panel active-panel on-send-press reply

View File

@ -154,6 +154,20 @@
first-not-visible))))) first-not-visible)))))
(debounce/debounce-and-dispatch [:chat.ui/message-visibility-changed e] 5000)) (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 (defn messages-view
[{:keys [chat bottom-space pan-responder space-keeper]}] [{:keys [chat bottom-space pan-responder space-keeper]}]
(let [{:keys [group-chat chat-id public? invitation-admin]} chat (let [{:keys [group-chat chat-id public? invitation-admin]} chat
@ -174,19 +188,11 @@
[invite.chat/reward-messages])] [invite.chat/reward-messages])]
:data messages :data messages
:inverted true :inverted true
:render-fn (fn [{:keys [outgoing type] :as message} idx] :render-data {:group-chat group-chat
(if (= type :datemark) :public? public?
[message-datemark/chat-datemark (:value message)] :current-public-key current-public-key
(if (= type :gap) :space-keeper space-keeper}
[gap/gap message idx messages-list-ref false] :render-fn render-fn
; 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])))
:on-viewable-items-changed on-viewable-items-changed :on-viewable-items-changed on-viewable-items-changed
:on-end-reached #(re-frame/dispatch [:chat.ui/load-more-messages]) :on-end-reached #(re-frame/dispatch [:chat.ui/load-more-messages])
:on-scroll-to-index-failed #() ;;don't remove this :on-scroll-to-index-failed #() ;;don't remove this

View File

@ -12,17 +12,16 @@
(defonce search-active? (reagent/atom false)) (defonce search-active? (reagent/atom false))
(defn render-currency [current-currency-id] (defn render-currency [{:keys [id code display-name]} _ _ current-currency-id]
(fn [{:keys [id code display-name]}] (let [selected? (= id current-currency-id)]
(let [selected? (= id current-currency-id)] [react/touchable-highlight
[react/touchable-highlight {:on-press #(re-frame/dispatch [:wallet.settings.ui/currency-selected id])
{:on-press #(re-frame/dispatch [:wallet.settings.ui/currency-selected id]) :accessibility-label :currency-item}
:accessibility-label :currency-item} [react/view styles/currency-item
[react/view styles/currency-item [react/text {:style styles/currency-name-text}
[react/text {:style styles/currency-name-text} (str display-name " (" code ")")]
(str display-name " (" code ")")] (when selected?
(when selected? [vector-icons/icon :main-icons/check {:color :active}])]]))
[vector-icons/icon :main-icons/check {:color :active}])]])))
(views/defview currency-settings [] (views/defview currency-settings []
(views/letsubs [currency-id [:wallet.settings/currency] (views/letsubs [currency-id [:wallet.settings/currency]
@ -48,5 +47,6 @@
vals vals
(sort #(compare (:code %1) (:code %2)))) (sort #(compare (:code %1) (:code %2))))
:key-fn :code :key-fn :code
:render-fn (render-currency currency-id) :render-data currency-id
:render-fn render-currency
:keyboardShouldPersistTaps :always}]]])) :keyboardShouldPersistTaps :always}]]]))

View File

@ -17,17 +17,16 @@
(defn change-fleet [fleet] (defn change-fleet [fleet]
(re-frame/dispatch [:fleet.ui/fleet-selected fleet])) (re-frame/dispatch [:fleet.ui/fleet-selected fleet]))
(defn render-row [current-fleet] (defn render-row [fleet _ _ current-fleet]
(fn [fleet] (let [current? (= fleet current-fleet)]
(let [current? (= fleet current-fleet)] [react/touchable-highlight
[react/touchable-highlight {:on-press #(change-fleet fleet)
{:on-press #(change-fleet fleet) :accessibility-label :fleet-item}
:accessibility-label :fleet-item} [react/view styles/fleet-item
[react/view styles/fleet-item [fleet-icon current?]
[fleet-icon current?] [react/view styles/fleet-item-inner
[react/view styles/fleet-item-inner [react/text {:style styles/fleet-item-name-text}
[react/text {:style styles/fleet-item-name-text} fleet]]]]))
fleet]]]])))
(defn fleets [custom-fleets] (defn fleets [custom-fleets]
(map name (keys (node/fleets {:custom-fleets custom-fleets})))) (map name (keys (node/fleets {:custom-fleets custom-fleets}))))
@ -41,4 +40,5 @@
[list/flat-list {:data (fleets custom-fleets) [list/flat-list {:data (fleets custom-fleets)
:default-separator? false :default-separator? false
:key-fn identity :key-fn identity
:render-fn (render-row (name current-fleet))}]]])) :render-data (name current-fleet)
:render-fn render-row}]]]))

View File

@ -64,18 +64,18 @@
:active contact-selected? :active contact-selected?
:accessory :checkbox}]))) :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]) [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]) [toggle-item allow-new-users? :is-participant-selected? contact on-toggle-participant])
(defn toggle-list [{:keys [contacts render-fn]}] (defn toggle-list [{:keys [contacts render-fn render-data]}]
[react/scroll-view {:flex 1} [list/flat-list {:data contacts
[list/flat-list {:data contacts :key-fn :public-key
:key-fn :public-key :render-data render-data
:render-fn render-fn :render-fn render-fn
:keyboardShouldPersistTaps :always}]]) :keyboardShouldPersistTaps :always}])
(defn no-contacts [{:keys [no-contacts]}] (defn no-contacts [{:keys [no-contacts]}]
[react/view {:style styles/no-contacts} [react/view {:style styles/no-contacts}
@ -153,8 +153,9 @@
[react/view {:style {:flex 1 [react/view {:style {:flex 1
:padding-vertical 8}} :padding-vertical 8}}
(if (seq contacts) (if (seq contacts)
[toggle-list {:contacts (filter-contacts @search-value contacts) [toggle-list {:contacts (filter-contacts @search-value contacts)
:render-fn (partial toggle-fn allow-new-users?)}] :render-data allow-new-users?
:render-fn toggle-fn}]
[no-contacts {:no-contacts no-contacts-label}])]]))) [no-contacts {:no-contacts no-contacts-label}])]])))
;; Start group chat ;; Start group chat

View File

@ -132,6 +132,9 @@
(re-frame/dispatch [:set :public-group-topic nil]) (re-frame/dispatch [:set :public-group-topic nil])
(re-frame/dispatch [:search/home-filter-changed 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/defview chats-list []
(views/letsubs [loading? [:chats/loading?] (views/letsubs [loading? [:chats/loading?]
{:keys [chats search-filter]} [:home-items] {:keys [chats search-filter]} [:home-items]
@ -148,7 +151,7 @@
{:key-fn :chat-id {:key-fn :chat-id
:keyboard-should-persist-taps :always :keyboard-should-persist-taps :always
:data chats :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)) :header (when (or (seq chats) @search-active? (seq search-filter))
[search-input-wrapper search-filter chats]) [search-input-wrapper search-filter chats])
:empty-component (when (or @search-active? (seq search-filter)) :empty-component (when (or @search-active? (seq search-filter))

View File

@ -16,17 +16,16 @@
(defn change-log-level [log-level] (defn change-log-level [log-level]
(re-frame/dispatch [:log-level.ui/log-level-selected log-level])) (re-frame/dispatch [:log-level.ui/log-level-selected log-level]))
(defn render-row [current-log-level] (defn render-row [{:keys [name value] :as log-level} _ _ current-log-level]
(fn [{:keys [name value] :as log-level}] (let [current? (= value current-log-level)]
(let [current? (= value current-log-level)] [react/touchable-highlight
[react/touchable-highlight {:on-press #(change-log-level log-level)
{:on-press #(change-log-level log-level) :accessibility-label :log-level-item}
:accessibility-label :log-level-item} [react/view styles/log-level-item
[react/view styles/log-level-item [log-level-icon current?]
[log-level-icon current?] [react/view styles/log-level-item-inner
[react/view styles/log-level-item-inner [react/text {:style styles/log-level-item-name-text}
[react/text {:style styles/log-level-item-name-text} name]]]]))
name]]]])))
(def log-levels (def log-levels
[{:name "DISABLED" [{:name "DISABLED"
@ -50,4 +49,5 @@
[list/flat-list {:data log-levels [list/flat-list {:data log-levels
:default-separator? false :default-separator? false
:key-fn :name :key-fn :name
:render-fn (render-row current-log-level)}]]])) :render-data current-log-level
:render-fn render-row}]]]))

View File

@ -24,26 +24,26 @@
[react/text {:style styles/explanation-text} [react/text {:style styles/explanation-text}
(i18n/label :t/mailserver-automatic-switch-explanation)]]]) (i18n/label :t/mailserver-automatic-switch-explanation)]]])
(defn render-row [current-mailserver-id pinned?] (defn render-row [{:keys [name id user-defined]} _ _ {:keys [current-mailserver-id preferred-mailserver-id]}]
(fn [{:keys [name id user-defined]}] (let [pinned? preferred-mailserver-id
(let [connected? (= id current-mailserver-id) connected? (= id current-mailserver-id)
visible? (or pinned? ; show everything when auto selection is turned off visible? (or pinned? ; show everything when auto selection is turned off
(and (not pinned?) ; auto selection turned on (and (not pinned?) ; auto selection turned on
(= current-mailserver-id id) ; show only the selected server (= 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]
(if pinned? (when visible?
[radio/radio connected?] [react/touchable-highlight
[vector-icons/icon :check {:color colors/blue}])]])))) {: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/defview offline-messaging-settings []
(views/letsubs [current-mailserver-id [:mailserver/current-id] (views/letsubs [current-mailserver-id [:mailserver/current-id]
@ -78,5 +78,6 @@
[list/flat-list {:data (vals mailservers) [list/flat-list {:data (vals mailservers)
:default-separator? false :default-separator? false
:key-fn :name :key-fn :name
:render-fn (render-row current-mailserver-id :render-data {:current-mailserver-id current-mailserver-id
preferred-mailserver-id)}]])]])) :preferred-mailserver-id preferred-mailserver-id}
:render-fn render-row}]])]]))

View File

@ -172,7 +172,7 @@
:on-viewable-items-changed chat.views/on-viewable-items-changed :on-viewable-items-changed chat.views/on-viewable-items-changed
:on-end-reached #(re-frame/dispatch [:chat.ui/load-more-messages]) :on-end-reached #(re-frame/dispatch [:chat.ui/load-more-messages])
:on-scroll-to-index-failed #() ;;don't remove this :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}]))) :data messages}])))
(views/defview profile [] (views/defview profile []

View File

@ -54,7 +54,7 @@
:icon :main-icons/remove-contact :icon :main-icons/remove-contact
:on-press #(chat.sheets/hide-sheet-and-dispatch [:group-chats.ui/remove-member-pressed chat-id (:public-key member)])}])])) :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)] (let [[first-name second-name] (multiaccounts/contact-two-names member false)]
[quo/list-item [quo/list-item
(merge (merge
@ -82,9 +82,12 @@
(defview chat-group-members-view [chat-id admin? current-user-identity] (defview chat-group-members-view [chat-id admin? current-user-identity]
(letsubs [members [:contacts/current-chat-contacts]] (letsubs [members [:contacts/current-chat-contacts]]
(when (seq members) (when (seq members)
[list/flat-list {:data members [list/flat-list {:data members
:key-fn :address :key-fn :address
:render-fn #(render-member chat-id % admin? current-user-identity)}]))) :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?]}] (defn members-list [{:keys [chat-id admin? current-pk allow-adding-members?]}]
[react/view [react/view

View File

@ -135,41 +135,39 @@
[message/render-parsed-text (assoc message :outgoing false) (:parsed-text content)]]) [message/render-parsed-text (assoc message :outgoing false) (:parsed-text content)]])
[link-preview/link-preview-wrapper (:links content) outgoing true]]]])) [link-preview/link-preview-wrapper (:links content) outgoing true]]]]))
(defn render-message [timeline? account] (defn render-message [{:keys [type] :as message} idx _ {:keys [timeline account]}]
(fn [{:keys [type] :as message} idx] (if (= type :datemark)
[(fn [] nil
(if (= type :datemark) (if (= type :gap)
nil (if timeline
(if (= type :gap) nil
(if timeline? [gap/gap message idx messages-list-ref true])
nil ; message content
[gap/gap message idx messages-list-ref true]) (let [chat-id (chat/profile-chat-topic (:from message))]
; message content [react/view (merge {:accessibility-label :chat-item}
(let [chat-id (chat/profile-chat-topic (:from message))] (when (:last-in-group? message)
[react/view (merge {:accessibility-label :chat-item} {:padding-bottom 8
(when (:last-in-group? message) :margin-bottom 8
{:padding-bottom 8 :border-bottom-width 1
:margin-bottom 8 :border-bottom-color colors/gray-lighter}))
:border-bottom-width 1 [reactions/with-reaction-picker
:border-bottom-color colors/gray-lighter})) {:message message
[reactions/with-reaction-picker :timeline true
{:message message :reactions @(re-frame/subscribe [:chats/message-reactions (:message-id message)])
:timeline true :picker-on-open (fn [])
:reactions @(re-frame/subscribe [:chats/message-reactions (:message-id message)]) :picker-on-close (fn [])
:picker-on-open (fn []) :send-emoji (fn [{:keys [emoji-id]}]
:picker-on-close (fn []) (re-frame/dispatch [::models.reactions/send-emoji-reaction
:send-emoji (fn [{:keys [emoji-id]}] {:message-id (:message-id message)
(re-frame/dispatch [::models.reactions/send-emoji-reaction :chat-id chat-id
{:message-id (:message-id message) :emoji-id emoji-id}]))
:chat-id chat-id :retract-emoji (fn [{:keys [emoji-id emoji-reaction-id]}]
:emoji-id emoji-id}])) (re-frame/dispatch [::models.reactions/send-emoji-reaction-retraction
:retract-emoji (fn [{:keys [emoji-id emoji-reaction-id]}] {:message-id (:message-id message)
(re-frame/dispatch [::models.reactions/send-emoji-reaction-retraction :chat-id chat-id
{:message-id (:message-id message) :emoji-id emoji-id
:chat-id chat-id :emoji-reaction-id emoji-reaction-id}]))
:emoji-id emoji-id :render (message-item account)}]]))))
:emoji-reaction-id emoji-reaction-id}]))
:render (message-item account)}]]))))]))
(def state (reagent/atom {:tab :timeline})) (def state (reagent/atom {:tab :timeline}))
@ -207,7 +205,9 @@
(i18n/label :t/statuses-my-status-descr))]]] (i18n/label :t/statuses-my-status-descr))]]]
[list/flat-list [list/flat-list
{:key-fn #(or (:message-id %) (:value %)) {: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 :data messages
:on-viewable-items-changed chat.views/on-viewable-items-changed :on-viewable-items-changed chat.views/on-viewable-items-changed
:on-end-reached #(re-frame/dispatch [:chat.ui/load-more-messages]) :on-end-reached #(re-frame/dispatch [:chat.ui/load-more-messages])

View File

@ -129,7 +129,8 @@
[list/flat-list {:data tokens [list/flat-list {:data tokens
:default-separator? false :default-separator? false
:key-fn :name :key-fn :name
:render-fn (accounts/render-asset (:code currency))}] :render-data (:code currency)
:render-fn accounts/render-asset}]
(= tab :nft) (= tab :nft)
[react/view [react/view
[collectibles-link] [collectibles-link]

View File

@ -60,25 +60,22 @@
[icons/icon :main-icons/add-circle {:color colors/blue}] [icons/icon :main-icons/add-circle {:color colors/blue}]
[react/text {:style styles/add-text} (i18n/label :t/add-account)]]]) [react/text {:style styles/add-text} (i18n/label :t/add-account)]]])
(defn render-asset [currency & [on-press]] (defn render-asset [{:keys [icon decimals amount color value] :as token} _ _ currency]
(fn [{:keys [icon decimals amount color value] :as token}] [quo/list-item
[quo/list-item {:title [quo/text {:weight :medium}
(merge {:title [quo/text {:weight :medium} [quo/text {:weight :inherit}
[quo/text {:weight :inherit} (str (if amount
(str (if amount (wallet.utils/format-amount amount decimals)
(wallet.utils/format-amount amount decimals) "...")
"...") " ")]
" ")] [quo/text {:color :secondary
[quo/text {:color :secondary :weight :inherit}
:weight :inherit} (wallet.utils/display-symbol token)]]
(wallet.utils/display-symbol token)]] :subtitle (str (if value value "...") " " currency)
:subtitle (str (if value value "...") " " currency) :accessibility-label (str (:symbol token) "-asset-value")
:accessibility-label (str (:symbol token) "-asset-value") :icon (if icon
:icon (if icon [list/item-image icon]
[list/item-image icon] [chat-icon/custom-icon-view-list (:name token) color])}])
[chat-icon/custom-icon-view-list (:name token) color])}
(when on-press
{:on-press #(on-press token)}))]))
(views/defview assets [] (views/defview assets []
(views/letsubs [{:keys [tokens]} [:wallet/all-visible-assets-with-values] (views/letsubs [{:keys [tokens]} [:wallet/all-visible-assets-with-values]
@ -86,7 +83,8 @@
[list/flat-list {:data tokens [list/flat-list {:data tokens
:default-separator? false :default-separator? false
:key-fn :name :key-fn :name
:render-fn (render-asset (:code currency))}])) :render-data (:code currency)
:render-fn render-asset}]))
(views/defview send-button [] (views/defview send-button []
(views/letsubs [account [:multiaccount/default-account]] (views/letsubs [account [:multiaccount/default-account]]

View File

@ -11,27 +11,26 @@
(views/defview assets [address] (views/defview assets [address]
(views/letsubs [{:keys [tokens]} [:wallet/visible-assets-with-values address] (views/letsubs [{:keys [tokens]} [:wallet/visible-assets-with-values address]
currency [:wallet/currency]] currency [:wallet/currency]]
(let [render (wallet.accounts/render-asset [:<>
(:code currency) (for [token tokens]
#(re-frame/dispatch [:wallet.send/set-symbol (:symbol %)]))] ^{:key (str (:symbol token))}
[:<> [react/touchable-highlight {:on-press #(re-frame/dispatch [:wallet.send/set-symbol (:symbol token)])}
(for [token tokens] [wallet.accounts/render-asset token nil nil (:code currency)]])]))
^{:key (str (:symbol token))}
[render token])])))
(defn render-account [field event] (defn render-account [account _ _ {:keys [field event]}]
(fn [account] [quo/list-item
[quo/list-item {:icon [chat-icon/custom-icon-view-list (:name account) (:color account)]
{:icon [chat-icon/custom-icon-view-list (:name account) (:color account)] :title (:name account)
:title (:name account) :on-press #(re-frame/dispatch [event field account])}])
:on-press #(re-frame/dispatch [event field account])}]))
(views/defview accounts-list [field event] (views/defview accounts-list [field event]
(views/letsubs [accounts [:multiaccount/accounts] (views/letsubs [accounts [:multiaccount/accounts]
accounts-whithout-watch [:accounts-without-watch-only]] accounts-whithout-watch [:accounts-without-watch-only]]
[list/flat-list {:data (if (= :to field) accounts accounts-whithout-watch) [list/flat-list {:data (if (= :to field) accounts accounts-whithout-watch)
:key-fn :address :key-fn :address
:render-fn (render-account field event)}])) :render-data {:field field
:event event}
:render-fn render-account}]))
(defn show-accounts-list [] (defn show-accounts-list []
(re-frame/dispatch [:bottom-sheet/hide]) (re-frame/dispatch [:bottom-sheet/hide])

View File

@ -121,7 +121,7 @@
[list/section-list [list/section-list
{:sections transactions-history-sections {:sections transactions-history-sections
:key-fn :hash :key-fn :hash
:render-fn #(render-transaction %) :render-fn render-transaction
:empty-component :empty-component
[react/i18n-text {:style styles/empty-text [react/i18n-text {:style styles/empty-text
:key (if (or fetching-recent-history? fetching-more-history?) :key (if (or fetching-recent-history? fetching-more-history?)