This commit is contained in:
Alexander 2024-01-18 16:23:42 +01:00 committed by GitHub
parent fe9a4eac59
commit f8cdb3bd7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 125 additions and 100 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,4 +1,4 @@
(ns quo.components.list-items.user-list (ns quo.components.list-items.user
(:require (:require
[quo.components.avatars.user-avatar.view :as user-avatar] [quo.components.avatars.user-avatar.view :as user-avatar]
[quo.components.icon :as icons] [quo.components.icon :as icons]
@ -18,14 +18,14 @@
:align-items :center}) :align-items :center})
(defn action-icon (defn action-icon
[{:keys [type on-press on-check disabled? checked?]}] [{:keys [type on-press on-check disabled? checked?]} theme]
[rn/touchable-opacity [rn/touchable-opacity
{:on-press (when on-press on-press)} {:on-press (when on-press on-press)}
(case type (case type
:options :options
[icons/icon :i/options [icons/icon :i/options
{:size 20 {:size 20
:color (colors/theme-colors colors/neutral-50 colors/neutral-40)}] :color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}]
:checkbox :checkbox
[selectors/view [selectors/view
{:type :checkbox {:type :checkbox
@ -37,30 +37,33 @@
[text/text "not implemented"] [text/text "not implemented"]
[rn/view])]) [rn/view])])
(defn user-list (defn user
[{:keys [short-chat-key primary-name secondary-name photo-path online? contact? verified? [{:keys [short-chat-key primary-name secondary-name photo-path online? contact? verified?
untrustworthy? on-press on-long-press accessory]}] untrustworthy? on-press on-long-press accessory customization-color theme]}]
[rn/touchable-opacity [rn/touchable-highlight
{:style container-style {:style container-style
:underlay-color (colors/resolve-color customization-color theme 5)
:accessibility-label :user-list :accessibility-label :user-list
:on-press (when on-press on-press) :on-press (when on-press on-press)
:on-long-press (when on-long-press on-long-press)} :on-long-press (when on-long-press on-long-press)}
[user-avatar/user-avatar [:<>
{:full-name primary-name [user-avatar/user-avatar
:profile-picture photo-path {:full-name primary-name
:online? online? :profile-picture photo-path
:size :small}] :online? online?
[rn/view {:style {:margin-horizontal 8 :flex 1}} :size :small}]
[author/view [rn/view {:style {:margin-horizontal 8 :flex 1}}
{:primary-name primary-name [author/view
:secondary-name secondary-name {:primary-name primary-name
:contact? contact? :secondary-name secondary-name
:verified? verified? :contact? contact?
:untrustworthy? untrustworthy?}] :verified? verified?
(when short-chat-key :untrustworthy? untrustworthy?
[text/text :size 15}]
{:size :paragraph-1 (when short-chat-key
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40)}} [text/text
short-chat-key])] {:size :paragraph-2
(when accessory :style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40)}}
[action-icon accessory])]) short-chat-key])]
(when accessory
[action-icon accessory theme])]])

View File

@ -38,7 +38,7 @@
(defn icon-container (defn icon-container
[is-first?] [is-first?]
{:margin-left (if is-first? 4 2) {:margin-left (if is-first? 4 2)
:margin-bottom 2}) :margin-bottom 4})
(defn time-text (defn time-text
[theme] [theme]

View File

@ -51,8 +51,7 @@
[icons/icon :main-icons2/untrustworthy [icons/icon :main-icons2/untrustworthy
{:size 12 {:size 12
:no-color true :no-color true
:container-style (style/icon-container contact?)}]) :container-style (style/icon-container contact?)}])]
]
(when (and (not verified?) short-chat-key) (when (and (not verified?) short-chat-key)
[text/text [text/text
{:weight :monospace {:weight :monospace

View File

@ -86,7 +86,7 @@
quo.components.list-items.saved-contact-address.view quo.components.list-items.saved-contact-address.view
quo.components.list-items.token-network.view quo.components.list-items.token-network.view
quo.components.list-items.token-value.view quo.components.list-items.token-value.view
quo.components.list-items.user-list quo.components.list-items.user
quo.components.loaders.skeleton-list.view quo.components.loaders.skeleton-list.view
quo.components.markdown.list.view quo.components.markdown.list.view
quo.components.markdown.text quo.components.markdown.text
@ -299,7 +299,7 @@
(def account-list-card quo.components.list-items.account-list-card.view/view) (def account-list-card quo.components.list-items.account-list-card.view/view)
(def address quo.components.list-items.address.view/view) (def address quo.components.list-items.address.view/view)
(def channel quo.components.list-items.channel.view/view) (def channel quo.components.list-items.channel.view/view)
(def community-list-item quo.components.list-items.community.view/view) (def community-list quo.components.list-items.community.view/view)
(def dapp quo.components.list-items.dapp.view/view) (def dapp quo.components.list-items.dapp.view/view)
(def menu-item quo.components.list-items.menu-item/menu-item) (def menu-item quo.components.list-items.menu-item/menu-item)
(def preview-list quo.components.list-items.preview-list.view/view) (def preview-list quo.components.list-items.preview-list.view/view)
@ -308,7 +308,7 @@
(def saved-contact-address quo.components.list-items.saved-contact-address.view/view) (def saved-contact-address quo.components.list-items.saved-contact-address.view/view)
(def token-network quo.components.list-items.token-network.view/view) (def token-network quo.components.list-items.token-network.view/view)
(def token-value quo.components.list-items.token-value.view/view) (def token-value quo.components.list-items.token-value.view/view)
(def user-list quo.components.list-items.user-list/user-list) (def user quo.components.list-items.user/user)
;;;; Loaders ;;;; Loaders
(def skeleton-list quo.components.loaders.skeleton-list.view/view) (def skeleton-list quo.components.loaders.skeleton-list.view/view)

View File

@ -17,19 +17,19 @@
(fn [^js data] (fn [^js data]
(let [^js section (.-section data)] (let [^js section (.-section data)]
(reagent/as-element [f (reagent/as-element [f
{:title (.-title section) {:index (.-index section)
:title (.-title section)
:data (.-data section)}])))) :data (.-data section)}]))))
(defn- wrap-per-section-render-fn (defn- wrap-per-section-render-fn
[props] [index props]
(update (-> (if-let [f (:render-fn props)]
(if-let [f (:render-fn props)] (assoc (dissoc props :render-fn :render-data)
(assoc (dissoc props :render-fn :render-data) :renderItem
:renderItem (memo-wrap-render-fn f (:render-data props)))
(memo-wrap-render-fn f (:render-data props))) props)
props) (update :data to-array)
:data (assoc :index index)))
to-array))
(defn section-list (defn section-list
"A wrapper for SectionList. "A wrapper for SectionList.
@ -42,6 +42,8 @@
props props
(when render-section-footer-fn (when render-section-footer-fn
{:renderSectionFooter (wrap-render-section-header-fn render-section-footer-fn)}) {:renderSectionFooter (wrap-render-section-header-fn render-section-footer-fn)})
{:sections (clj->js (map wrap-per-section-render-fn sections)) {:sections (->> sections
(map-indexed wrap-per-section-render-fn)
(clj->js))
:renderSectionHeader (wrap-render-section-header-fn render-section-header-fn) :renderSectionHeader (wrap-render-section-header-fn render-section-header-fn)
:style style})]) :style style})])

View File

@ -0,0 +1,5 @@
(ns status-im.common.contact-list.style)
(defn contacts-section-header
[first-item?]
{:padding-top (if first-item? 0 8)})

View File

@ -1,7 +1,10 @@
(ns status-im.common.contact-list.view (ns status-im.common.contact-list.view
(:require (:require
[quo.core :as quo])) [quo.core :as quo]
[react-native.core :as rn]
[status-im.common.contact-list.style :as style]))
(defn contacts-section-header (defn contacts-section-header
[{:keys [title]}] [{:keys [title index]}]
[quo/divider-label title]) [rn/view (style/contacts-section-header (= index 0))
[quo/divider-label title]])

View File

@ -6,17 +6,21 @@
(defn contact-list-item (defn contact-list-item
[{:keys [on-press on-long-press accessory]} [{:keys [on-press on-long-press accessory]}
{:keys [primary-name secondary-name public-key compressed-key ens-verified added?]}] {:keys [primary-name secondary-name public-key compressed-key ens-verified added?]}
(let [photo-path (rf/sub [:chats/photo-path public-key]) theme]
online? (rf/sub [:visibility-status-updates/online? public-key])] (let [photo-path (rf/sub [:chats/photo-path public-key])
[quo/user-list online? (rf/sub [:visibility-status-updates/online? public-key])
{:short-chat-key (address/get-shortened-compressed-key (or compressed-key public-key)) customization-color (rf/sub [:profile/customization-color])]
:primary-name primary-name [quo/user
:secondary-name secondary-name {:customization-color customization-color
:photo-path photo-path :theme theme
:online? online? :short-chat-key (address/get-shortened-compressed-key (or compressed-key public-key))
:verified? ens-verified :primary-name primary-name
:contact? added? :secondary-name secondary-name
:on-press on-press :photo-path photo-path
:on-long-press on-long-press :online? online?
:accessory accessory}])) :verified? ens-verified
:contact? added?
:on-press on-press
:on-long-press on-long-press
:accessory accessory}]))

View File

@ -38,6 +38,9 @@
:no-contacts :no-contacts
{:light (js/require "../resources/images/ui2/no-contacts-light.png") {:light (js/require "../resources/images/ui2/no-contacts-light.png")
:dark (js/require "../resources/images/ui2/no-contacts-dark.png")} :dark (js/require "../resources/images/ui2/no-contacts-dark.png")}
:no-contacts-to-chat
{:light (js/require "../resources/images/ui2/no-contacts-to-chat-light.png")
:dark (js/require "../resources/images/ui2/no-contacts-to-chat-dark.png")}
:keycard-chip :keycard-chip
{:light (js/require "../resources/images/ui2/keycard-chip-light.png") {:light (js/require "../resources/images/ui2/keycard-chip-light.png")
:dark (js/require "../resources/images/ui2/keycard-chip-dark.png")} :dark (js/require "../resources/images/ui2/keycard-chip-dark.png")}

View File

@ -29,7 +29,7 @@
{:icon :i/add-user {:icon :i/add-user
:accessibility-label :add-a-contact :accessibility-label :add-a-contact
:label (i18n/label :t/add-a-contact) :label (i18n/label :t/add-a-contact)
:sub-label (i18n/label :t/enter-a-chat-key) :sub-label (i18n/label :t/enter-chat-key)
:add-divider? true :add-divider? true
:on-press #(debounce/dispatch-and-chill :on-press #(debounce/dispatch-and-chill
[:open-modal :new-contact] [:open-modal :new-contact]

View File

@ -21,7 +21,7 @@
[] []
{:size :heading-1 {:size :heading-1
:weight :semi-bold :weight :semi-bold
:style {:margin-top 32 :style {:margin-top 28
:margin-bottom 6 :margin-bottom 6
:color (colors/theme-colors colors/neutral-100 colors/white)}}) :color (colors/theme-colors colors/neutral-100 colors/white)}})

View File

@ -16,33 +16,38 @@
(defn- no-contacts-view (defn- no-contacts-view
[{:keys [theme]}] [{:keys [theme]}]
[rn/view (let [customization-color (rf/sub [:profile/customization-color])]
{:style (style/no-contacts)} [rn/view
[rn/image {:source (resources/get-themed-image :no-contacts theme)}] {:style (style/no-contacts)}
[quo/text [rn/image {:source (resources/get-themed-image :no-contacts-to-chat theme)}]
{:weight :semi-bold [quo/text
:size :paragraph-1 {:weight :semi-bold
:style {:margin-bottom 2 :size :paragraph-1
:margin-top 12}} :style {:margin-bottom 2
(i18n/label :t/you-have-no-contacts)] :margin-top 12}}
[quo/text (i18n/label :t/you-have-no-contacts)]
{:weight :regular [quo/text
:size :label} {:weight :regular
(i18n/label :t/dont-yell-at-me)] :size :paragraph-2}
[quo/button (i18n/label :t/dont-yell-at-me)]
{:type :primary [quo/button
:size 32 {:customization-color customization-color
:container-style {:margin-top 20 :theme theme
:margin-bottom 12} :type :primary
:on-press #(rf/dispatch [:invite.events/share-link])} :size 32
(i18n/label :t/invite-friends)] :container-style {:margin-top 20
[quo/button :margin-bottom 12}
{:type :grey :on-press #(rf/dispatch [:invite.events/share-link])}
:size 32 (i18n/label :t/invite-friends)]
:on-press #(do [quo/button
(rf/dispatch [:navigate-back]) {:customization-color customization-color
(rf/dispatch [:open-modal :new-contact]))} :theme theme
(i18n/label :t/add-a-contact)]]) :type :grey
:size 32
:on-press #(do
(rf/dispatch [:navigate-back])
(rf/dispatch [:open-modal :new-contact]))}
(i18n/label :t/add-a-contact)]]))
(defn contact-item-render (defn contact-item-render
[_] [_]

View File

@ -73,7 +73,7 @@
:shared-value scroll-shared-value})}]))) :shared-value scroll-shared-value})}])))
(defn contact-item-render (defn contact-item-render
[{:keys [public-key] :as item}] [{:keys [public-key] :as item} theme]
(let [current-pk (rf/sub [:multiaccount/public-key]) (let [current-pk (rf/sub [:multiaccount/public-key])
show-profile-actions #(rf/dispatch [:show-bottom-sheet show-profile-actions #(rf/dispatch [:show-bottom-sheet
{:content (fn [] [actions/contact-actions item])}])] {:content (fn [] [actions/contact-actions item])}])]
@ -83,7 +83,8 @@
:on-long-press show-profile-actions :on-long-press show-profile-actions
:accessory {:type :options :accessory {:type :options
:on-press show-profile-actions}}) :on-press show-profile-actions}})
item])) item
theme]))
(defn contacts (defn contacts
[{:keys [theme pending-contact-requests set-scroll-ref scroll-shared-value]}] [{:keys [theme pending-contact-requests set-scroll-ref scroll-shared-value]}]
@ -105,7 +106,8 @@
:sections items :sections items
:sticky-section-headers-enabled false :sticky-section-headers-enabled false
:render-section-header-fn contact-list/contacts-section-header :render-section-header-fn contact-list/contacts-section-header
:render-fn contact-item-render :render-fn (fn [data]
(contact-item-render data theme))
:scroll-event-throttle 8 :scroll-event-throttle 8
:on-scroll #(common.banner/set-scroll-shared-value :on-scroll #(common.banner/set-scroll-shared-value
{:scroll-input (oops/oget % "nativeEvent.contentOffset.y") {:scroll-input (oops/oget % "nativeEvent.contentOffset.y")

View File

@ -21,7 +21,7 @@
{:community (assoc item :cover cover) {:community (assoc item :cover cover)
:width width :width width
:on-press #(rf/dispatch [:communities/navigate-to-community-overview (:id item)])}] :on-press #(rf/dispatch [:communities/navigate-to-community-overview (:id item)])}]
[quo/community-list-item [quo/community-list
{:on-press (fn [] {:on-press (fn []
(rf/dispatch [:dismiss-keyboard]) (rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:communities/navigate-to-community-overview (:id item)])) (rf/dispatch [:communities/navigate-to-community-overview (:id item)]))
@ -144,7 +144,7 @@
{:community (assoc community :cover cover) {:community (assoc community :cover cover)
:on-press #(rf/dispatch [:communities/navigate-to-community-overview (:id community)])}] :on-press #(rf/dispatch [:communities/navigate-to-community-overview (:id community)])}]
[quo/community-list-item [quo/community-list
{:on-press (fn [] {:on-press (fn []
(rf/dispatch [:dismiss-keyboard]) (rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:communities/navigate-to-community-overview (rf/dispatch [:communities/navigate-to-community-overview

View File

@ -1,4 +1,4 @@
(ns status-im.contexts.preview.quo.list-items.community-list (ns status-im.contexts.preview.quo.community.list-item
(:require (:require
[quo.core :as quo] [quo.core :as quo]
[quo.theme :as quo.theme] [quo.theme :as quo.theme]
@ -95,7 +95,7 @@
:unread-count 5})] :unread-count 5})]
(fn [] (fn []
[preview/preview-container {:state state :descriptor (descriptors @state)} [preview/preview-container {:state state :descriptor (descriptors @state)}
[quo/community-list-item [quo/community-list
(merge @state (merge @state
{:container-style {:width 335} {:container-style {:width 335}
:logo (resources/get-mock-image :status-logo) :logo (resources/get-mock-image :status-logo)

View File

@ -41,4 +41,4 @@
:descriptor descriptor :descriptor descriptor
:component-container-style {:padding-vertical 30 :component-container-style {:padding-vertical 30
:padding-horizontal 15}} :padding-horizontal 15}}
[quo/user-list @state]]))) [quo/user @state]])))

View File

@ -41,6 +41,7 @@
:as community-membership-list-view] :as community-membership-list-view]
[status-im.contexts.preview.quo.community.community-stat :as community-stat] [status-im.contexts.preview.quo.community.community-stat :as community-stat]
[status-im.contexts.preview.quo.community.discover-card :as discover-card] [status-im.contexts.preview.quo.community.discover-card :as discover-card]
[status-im.contexts.preview.quo.community.list-item :as community-list-item]
[status-im.contexts.preview.quo.community.token-gating :as token-gating] [status-im.contexts.preview.quo.community.token-gating :as token-gating]
[status-im.contexts.preview.quo.counter.counter :as counter] [status-im.contexts.preview.quo.counter.counter :as counter]
[status-im.contexts.preview.quo.counter.step :as step] [status-im.contexts.preview.quo.counter.step :as step]
@ -92,8 +93,6 @@
account-list-card] account-list-card]
[status-im.contexts.preview.quo.list-items.address :as address] [status-im.contexts.preview.quo.list-items.address :as address]
[status-im.contexts.preview.quo.list-items.channel :as channel] [status-im.contexts.preview.quo.list-items.channel :as channel]
[status-im.contexts.preview.quo.list-items.community-list :as
community-list]
[status-im.contexts.preview.quo.list-items.dapp :as dapp] [status-im.contexts.preview.quo.list-items.dapp :as dapp]
[status-im.contexts.preview.quo.list-items.preview-lists :as preview-lists] [status-im.contexts.preview.quo.list-items.preview-lists :as preview-lists]
[status-im.contexts.preview.quo.list-items.quiz-item :as quiz-item] [status-im.contexts.preview.quo.list-items.quiz-item :as quiz-item]
@ -349,7 +348,7 @@
:component channel/view} :component channel/view}
{:name :community-list {:name :community-list
:options {:insets {:top? true}} :options {:insets {:top? true}}
:component community-list/view} :component community-list-item/view}
{:name :dapp {:name :dapp
:component dapp/preview} :component dapp/preview}
{:name :preview-lists {:name :preview-lists

View File

@ -1622,7 +1622,7 @@
"not-enough-snt": "Not enough SNT", "not-enough-snt": "Not enough SNT",
"add-new-contact": "Add new contact", "add-new-contact": "Add new contact",
"add-a-contact": "Add a contact", "add-a-contact": "Add a contact",
"enter-a-chat-key": "Add a chatkey or scan a QR", "enter-chat-key": "Enter chat key or scan a QR",
"you-dont-have-contacts": "You dont have any contacts yet.", "you-dont-have-contacts": "You dont have any contacts yet.",
"set-max": "Set max", "set-max": "Set max",
"continue-anyway": "Continue anyway", "continue-anyway": "Continue anyway",