[14677, 14673, 14672, 14671, 14664] Fix bottom sheet dismissal problems (#14791)

This commit is contained in:
Ibrahem Khalil 2023-01-30 12:33:12 -08:00 committed by GitHub
parent 0fd2783774
commit d7d256b139
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 579 additions and 257 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

@ -35,5 +35,4 @@
(get-icons 16)
(get-icons 20)
(get-icons 24)
(get-icons 32)
(get-icons 120)))
(get-icons 32)))

View File

@ -7,12 +7,14 @@
(defn themes
[type]
(case type
:main {:icon-color (theme-colors colors/neutral-50 colors/neutral-10)
:background (theme-colors colors/white colors/neutral-90)
:text-color (theme-colors colors/neutral-100 colors/white)}
:danger {:icon-color (theme-colors colors/danger-50 colors/danger-60)
:background (theme-colors colors/white colors/neutral-90)
:text-color (theme-colors colors/danger-50 colors/danger-60)}))
:main {:icon-color (theme-colors colors/neutral-50 colors/neutral-10)
:background (theme-colors colors/white colors/neutral-90)
:text-color (theme-colors colors/neutral-100 colors/white)}
:danger {:icon-color (theme-colors colors/danger-50 colors/danger-60)
:background (theme-colors colors/white colors/neutral-90)
:text-color (theme-colors colors/danger-50 colors/danger-60)}
:transparent {:icon-color (theme-colors colors/neutral-50 colors/neutral-10)
:text-color (theme-colors colors/neutral-100 colors/white)}))
(defn menu-item
[{:keys [type title accessibility-label icon on-press style-props subtitle subtitle-color]

View File

@ -1,28 +0,0 @@
(ns status-im.bottom-sheet.core
(:require [utils.re-frame :as rf]))
(rf/defn show-bottom-sheet
[{:keys [db]} {:keys [view options]}]
{:show-bottom-sheet nil
:db (assoc db
:bottom-sheet/show? true
:bottom-sheet/view view
:bottom-sheet/options options)})
(rf/defn show-bottom-sheet-event
{:events [:bottom-sheet/show-sheet]}
[cofx view options]
(show-bottom-sheet
cofx
{:view view
:options options}))
(rf/defn hide-bottom-sheet
{:events [:bottom-sheet/hide]}
[{:keys [db]}]
{:db (assoc db :bottom-sheet/show? false)})
(rf/defn hide-bottom-sheet-navigation-overlay
{:events [:bottom-sheet/hide-navigation-overlay]}
[{}]
{:hide-bottom-sheet nil})

View File

@ -3,7 +3,7 @@
["eth-phishing-detect" :as eth-phishing-detect]
[clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im.browser.eip3085 :as eip3085]
[status-im.browser.eip3326 :as eip3326]
[status-im.browser.permissions :as browser.permissions]

View File

@ -6,7 +6,7 @@
[re-frame.core :as re-frame]
[utils.i18n :as i18n]
[status-im.async-storage.core :as async-storage]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im2.constants :as constants]
[status-im.ui.components.emoji-thumbnail.styles :as emoji-thumbnail-styles]
[utils.re-frame :as rf]

View File

@ -2,7 +2,7 @@
(:refer-clojure :exclude [name])
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.eip55 :as eip55]
[status-im.ethereum.ens :as ens]

View File

@ -213,6 +213,11 @@
[{:keys [db]} id]
{:db (update db :group/selected-contacts conj id)})
(rf/defn clear-contacts
{:events [:group-chat/clear-contacts]}
[{:keys [db]}]
{:db (assoc db :group/selected-contacts #{})})
(rf/defn deselect-participant
{:events [:deselect-participant]}
[{:keys [db]} id]

View File

@ -1,7 +1,7 @@
(ns status-im.keycard.common
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im.ethereum.core :as ethereum]
[utils.i18n :as i18n]
[status-im.keycard.nfc :as nfc]

View File

@ -1,5 +1,5 @@
(ns status-im.keycard.login
(:require [status-im.bottom-sheet.core :as bottom-sheet]
(:require [status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im.ethereum.core :as ethereum]
[status-im.keycard.common :as common]
status-im.keycard.fx

View File

@ -1,7 +1,7 @@
(ns status-im.keycard.recovery
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im2.constants :as constants]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.eip55 :as eip55]

View File

@ -1,5 +1,5 @@
(ns status-im.keycard.wallet
(:require [status-im.bottom-sheet.core :as bottom-sheet]
(:require [status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im2.constants :as constants]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.eip55 :as eip55]

View File

@ -1,5 +1,5 @@
(ns status-im.mobile-sync-settings.core
(:require [status-im.bottom-sheet.core :as bottom-sheet]
(:require [status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im.mailserver.core :as mailserver]
[status-im.multiaccounts.model :as multiaccounts.model]
[status-im.multiaccounts.update.core :as multiaccounts.update]

View File

@ -2,7 +2,7 @@
(:require [clojure.string :as string]
[quo.platform :as platform]
[re-frame.core :as re-frame]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im.ethereum.stateofus :as stateofus]
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.native-module.core :as native-module]

View File

@ -1,7 +1,7 @@
(ns status-im.multiaccounts.key-storage.core
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.mnemonic :as mnemonic]
[utils.i18n :as i18n]

View File

@ -1,7 +1,7 @@
(ns status-im.multiaccounts.recover.core
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im2.constants :as constants]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.mnemonic :as mnemonic]

View File

@ -358,8 +358,8 @@
(fn [] (gestureHandlerRootHOC views/sheet-comp))
(fn [] views/sheet-comp)))
(re-frame/reg-fx :show-bottom-sheet (fn [] (show-overlay "bottom-sheet")))
(re-frame/reg-fx :hide-bottom-sheet (fn [] (dissmiss-overlay "bottom-sheet")))
(re-frame/reg-fx :show-bottom-sheet-overlay (fn [] (show-overlay "bottom-sheet")))
(re-frame/reg-fx :dismiss-bottom-sheet-overlay (fn [] (dissmiss-overlay "bottom-sheet")))
;; WALLET CONNECT

View File

@ -52,7 +52,9 @@
:community-cover (js/require "../resources/images/ui/community-cover.png")
:lifestyle (js/require "../resources/images/ui/lifestyle.png")
:music (js/require "../resources/images/ui/music.png")
:podcasts (js/require "../resources/images/ui/podcasts.png")})
:podcasts (js/require "../resources/images/ui/podcasts.png")
:no-contacts (js/require "../resources/images/ui/no-contacts.png")
:no-contacts-dark (js/require "../resources/images/ui/no-contacts-dark.png")})
(def mock-images
{:photo1 (js/require "../resources/images/mock/photo1.png")

View File

@ -1,7 +1,7 @@
(ns status-im.signing.gas
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im.ethereum.core :as ethereum]
[utils.i18n :as i18n]
[status-im.popover.core :as popover]

View File

@ -1,7 +1,7 @@
(ns status-im.ui.screens.home.sheet.views
(:require [quo.core :as quo]
[quo2.foundations.colors :as colors]
[re-frame.core :as rf]
[utils.re-frame :as rf]
[utils.i18n :as i18n]
[status-im.qr-scanner.core :as qr-scanner]
[status-im.ui.components.invite.views :as invite]
@ -11,7 +11,7 @@
[quo2.core :as quo2]
[status-im.ui.screens.home.sheet.styles :as style]))
(defn hide-sheet-and-dispatch
(defn- hide-sheet-and-dispatch
[event]
(rf/dispatch [:bottom-sheet/hide])
(rf/dispatch event))
@ -51,7 +51,7 @@
:accessibility-label :join-public-chat-button
:icon :main-icons/public-chat
:on-press #(hide-sheet-and-dispatch [:open-modal :new-public-chat])}]
(when @(rf/subscribe [:communities/enabled?])
(when (rf/sub [:communities/enabled?])
[quo/list-item
{:theme :accent
:title (i18n/label :t/communities-alpha)
@ -65,28 +65,21 @@
[]
[rn/view
[quo2/menu-item
{:theme :main
{:type :transparent
:title (i18n/label :t/new-chat)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:style-props {:border-bottom-width 1
:border-bottom-color (colors/theme-colors colors/neutral-10
colors/neutral-90)}
:icon-color (colors/theme-colors colors/neutral-50 colors/neutral-40)
:accessibility-label :start-a-new-chat
:icon :i/new-message
:on-press (fn [] ;; Note: currently the bottom button is overlapping with
;; safe-area
;; because it is using old bottom-sheet
(rf/dispatch [:bottom-sheet/hide])
;; A one second delay is needed because there are 2 bottom-sheets here
;; It would better to migrate contact-selection-list component to use
;; a screen
(js/setTimeout #(rf/dispatch [:bottom-sheet/show-sheet
{:content
new-chat-aio/contact-selection-list}])
1000))}]
:on-press #(hide-sheet-and-dispatch [:bottom-sheet/show-sheet
:start-a-new-chat {}])}]
[quo2/menu-item
{:theme :main
{:type :transparent
:title (i18n/label :t/add-a-contact)
:icon-bg-color :transparent
:icon-container-style {:padding-horizontal 0}
@ -102,7 +95,6 @@
:icon :i/add-user
:on-press #(hide-sheet-and-dispatch [:open-modal :new-contact])}]])
(def new-chat-bottom-sheet-comp
{:content new-chat-bottom-sheet})

View File

@ -4,7 +4,7 @@
[quo.design-system.colors :as colors]
[re-frame.core :as re-frame]
[reagent.core :as reagent]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im2.constants :as constants]
[utils.i18n :as i18n]
[status-im.keycard.login :as keycard.login]

View File

@ -3,12 +3,16 @@
[re-frame.core :as re-frame]
[utils.i18n :as i18n]))
(defn- hide-sheet-and-dispatch
[event]
(re-frame/dispatch [:bottom-sheet/hide])
(re-frame/dispatch event))
(defn actions-sheet
[]
[quo/list-item
{:theme :accent
:on-press #(do (re-frame/dispatch [:bottom-sheet/hide])
(re-frame/dispatch [:generate-and-derive-addresses]))
:on-press #(hide-sheet-and-dispatch [:generate-and-derive-addresses])
:icon :main-icons/add
:accessibility-label :generate-a-new-key
:title (i18n/label :t/generate-a-new-key)}])

View File

@ -10,8 +10,8 @@
[status-im.ui.components.react :as react]
[status-im.ui.components.toolbar :as toolbar]
[status-im.ui.screens.chat.photos :as photos]
[status-im.ui.screens.multiaccounts.sheets :as sheets]
[status-im.ui.screens.multiaccounts.styles :as styles]
[status-im.ui.screens.multiaccounts.sheets :as sheets]
[utils.security.core :as security]))
(defn multiaccount-view
@ -43,7 +43,6 @@
[]
(re-frame/dispatch [:bottom-sheet/show-sheet
{:content sheets/actions-sheet}]))
(defview multiaccounts
[]
(letsubs [multiaccounts [:multiaccounts/multiaccounts]]

View File

@ -1,4 +1,5 @@
(ns status-im.ui2.screens.chat.components.new-chat.styles)
(def contact-selection-heading
{:style {:flex-direction :row
:justify-content :space-between
@ -13,4 +14,8 @@
:margin-left 20
:margin-bottom 36
:justify-content :center
:align-items :center})
:align-items :center})
(defn chat-button
[{:keys [bottom]}]
{:bottom (- bottom 50)})

View File

@ -8,12 +8,19 @@
[utils.i18n :as i18n]
[status-im.ui.components.react :as react]
[utils.re-frame :as rf]
[status-im.ui.screens.chat.sheets :refer [hide-sheet-and-dispatch]]
[status-im.ui.components.toolbar :as toolbar]
[status-im2.common.contact-list.view :as contact-list]
[quo2.components.markdown.text :as text]
[status-im.ui.components.invite.events :as invite.events]
[status-im.ui2.screens.chat.components.new-chat.styles :as style]))
[status-im.ui2.screens.chat.components.new-chat.styles :as style]
[quo.react :as quo.react]
[quo.components.safe-area :as safe-area]
[status-im.react-native.resources :as resources]))
(defn- hide-sheet-and-dispatch
[event]
(rf/dispatch [:bottom-sheet/hide])
(rf/dispatch event))
(defn- on-toggle
[allow-new-users? checked? public-key]
@ -31,88 +38,95 @@
{:style {:justify-content :center
:align-items :center
:margin-top 120}}
[quo2/icon :i/no-contacts
{:size 120
:no-color true}]
[react/image
{:source (resources/get-image (if (quo2.colors/dark?) :no-contacts-dark :no-contacts))}]
[text/text
{:weight :semi-bold
:size :paragraph-1
:style {:margin-bottom 2
:margin-top 20}}
"You have no contacts"]
(i18n/label :t/you-have-no-contacts)]
[text/text
{:weight :regular
:size :label
:style {:margin-bottom 20}}
"Invite your friends and family to Status"]
(i18n/label :t/invite-friends-and-family)]
[quo2/button
{:type :primary
:style {:margin-bottom 12}
:on-press #(rf/dispatch [::invite.events/share-link nil])}
"Invite friends"]
(i18n/label :t/invite-friends)]
[quo2/button
{:type :grey
:on-press #(hide-sheet-and-dispatch [:open-modal :new-contact])}
"Add a contact"]])
(i18n/label :t/add-a-contact)]])
(defn contact-selection-list
[]
(let [contacts (rf/sub
[:contacts/grouped-by-first-letter])
selected-contacts-count (rf/sub [:selected-contacts-count])
one-contact-selected? (= selected-contacts-count 1)
contacts-selected? (pos? selected-contacts-count)
{:keys [names public-key]} (-> contacts first :data first)
added? (reagent/atom '())
{:keys [nickname ens-name three-words-name]} names
first-username (or ens-name nickname three-words-name)
no-contacts? (empty? contacts)]
[react/view {:style {:flex 1}}
[quo2/button
{:type :grey
:icon true
:on-press #(rf/dispatch [:bottom-sheet/hide])
:style style/contact-selection-close
:override-background-color (quo2.colors/theme-colors quo2.colors/neutral-10
quo2.colors/neutral-90)}
:i/close]
[react/view style/contact-selection-heading
[quo2/text
{:weight :semi-bold
:size :heading-1
:style {:color (quo2.colors/theme-colors quo2.colors/neutral-100 quo2.colors/white)}}
(i18n/label :t/new-chat)]
(when-not no-contacts?
[quo2/text
{:size :paragraph-2
:weight :regular
:style {:color (quo2.colors/theme-colors quo2.colors/neutral-40 quo2.colors/neutral-50)}}
(i18n/label :t/selected-count-from-max
{:selected (inc selected-contacts-count)
:max constants/max-group-chat-participants})])]
[react/view
{:style {:height 430
:margin-bottom -20}}
(if no-contacts?
[no-contacts-view]
[contact-list/contact-list
{:icon :check
:group nil
:added? added?
:search? false
:start-a-new-chat? true
:on-toggle on-toggle}])]
(when contacts-selected?
[toolbar/toolbar
{:show-border? false
:center [button/button
{:type :primary
:accessibility-label :next-button
:on-press #(do
(if one-contact-selected?
(hide-sheet-and-dispatch [:chat.ui/start-chat
public-key])
(hide-sheet-and-dispatch [:navigate-to :new-group])))}
(if one-contact-selected?
(i18n/label :t/chat-with {:selected-user first-username})
(i18n/label :t/setup-group-chat))]}])]))
[:f>
(fn []
(quo.react/effect! #(rf/dispatch [:group-chat/clear-contacts]) [])
(let [contacts (rf/sub
[:contacts/sorted-and-grouped-by-first-letter])
selected-contacts-count (rf/sub [:selected-contacts-count])
window-height (rf/sub [:dimensions/window-height])
one-contact-selected? (= selected-contacts-count 1)
contacts-selected? (pos? selected-contacts-count)
{:keys [names public-key]} (-> contacts first :data first)
added? (reagent/atom '())
{:keys [nickname ens-name three-words-name]} names
first-username (or ens-name nickname three-words-name)
no-contacts? (empty? contacts)
safe-area (safe-area/use-safe-area)]
[react/view {:style {:height (* window-height 0.9)}}
[quo2/button
{:type :grey
:icon true
:on-press #(rf/dispatch [:bottom-sheet/hide])
:style style/contact-selection-close
:override-background-color (quo2.colors/theme-colors quo2.colors/neutral-10
quo2.colors/neutral-90)}
:i/close]
[react/view style/contact-selection-heading
[quo2/text
{:weight :semi-bold
:size :heading-1
:style {:color (quo2.colors/theme-colors quo2.colors/neutral-100 quo2.colors/white)}}
(i18n/label :t/new-chat)]
(when-not no-contacts?
[quo2/text
{:size :paragraph-2
:weight :regular
:style {:color (quo2.colors/theme-colors quo2.colors/neutral-40 quo2.colors/neutral-50)}}
(i18n/label :t/selected-count-from-max
{:selected (inc selected-contacts-count)
:max constants/max-group-chat-participants})])]
[react/view
{:style {:height 430
:margin-bottom -20}}
(if no-contacts?
[no-contacts-view]
[contact-list/contact-list
{:icon :check
:group nil
:added? added?
:search? false
:start-a-new-chat? true
:on-toggle on-toggle}])]
(when contacts-selected?
[toolbar/toolbar
{:size :default
:show-border? false
:center [button/button
{:type :primary
:accessibility-label :next-button
:style (style/chat-button safe-area)
:on-press (fn []
(if one-contact-selected?
(hide-sheet-and-dispatch [:chat.ui/start-chat
public-key])
(hide-sheet-and-dispatch [:navigate-to
:new-group])))}
(if one-contact-selected?
(i18n/label :t/chat-with {:selected-user first-username})
(i18n/label :t/setup-group-chat))]}])]))])

View File

@ -0,0 +1,62 @@
(ns status-im.ui2.screens.chat.pin-limit-popover.view
(:require [utils.i18n :as i18n]
[quo.react :as react]
[quo2.core :as quo]
[quo2.foundations.colors :as colors]
[react-native.core :as rn]
[react-native.reanimated :as reanimated]
[status-im.ui2.screens.chat.pin-limit-popover.style :as style]
[utils.re-frame :as rf]))
;; TODO (flexsurfer) this should be an in-app notification component in quo2
;; https://github.com/status-im/status-mobile/issues/14527
(defn pin-limit-popover
[chat-id]
[:f>
(fn []
(let [width (rf/sub [:dimensions/window-width])
show-pin-limit-modal? (rf/sub [:chats/pin-modal chat-id])
opacity-animation (reanimated/use-shared-value 0)
z-index-animation (reanimated/use-shared-value -1)]
(react/effect!
#(do
(reanimated/set-shared-value opacity-animation
(reanimated/with-timing (if show-pin-limit-modal? 1 0)))
(reanimated/set-shared-value z-index-animation
(reanimated/with-timing (if show-pin-limit-modal? 10 -1)))))
(when show-pin-limit-modal?
[reanimated/view
{:style (reanimated/apply-animations-to-style
{:opacity opacity-animation
:z-index z-index-animation}
(style/pin-popover width))
:accessibility-label :pin-limit-popover}
[rn/view {:style (style/pin-alert-container)}
[rn/view {:style style/pin-alert-circle}
[rn/text {:style {:color colors/danger-50}} "!"]]]
[rn/view {:style {:margin-left 8}}
[quo/text {:weight :semi-bold :color (colors/theme-colors colors/white colors/neutral-100)}
(i18n/label :t/cannot-pin-title)]
[quo/text {:size :paragraph-2 :color (colors/theme-colors colors/white colors/neutral-100)}
(i18n/label :t/cannot-pin-desc)]
[rn/touchable-opacity
{:accessibility-label :view-pinned-messages
:active-opacity 1
:on-press (fn []
(rf/dispatch [:pin-message/hide-pin-limit-modal chat-id])
(rf/dispatch [:bottom-sheet/show-sheet :pinned-messages-list
chat-id])
(rf/dispatch [:dismiss-keyboard]))
:style style/view-pinned-messages}
[quo/text {:size :paragraph-2 :weight :medium :color colors/white}
(i18n/label :t/view-pinned-messages)]]]
[rn/touchable-opacity
{:accessibility-label :close-pin-limit-popover
:active-opacity 1
:on-press #(rf/dispatch [:pin-message/hide-pin-limit-modal chat-id])
:style {:position :absolute
:top 16
:right 16}}
[quo/icon :i/close
{:color (colors/theme-colors colors/white colors/neutral-100)
:size 12}]]])))])

View File

@ -3,7 +3,7 @@
[goog.string :as gstring]
[re-frame.core :as re-frame]
[react-native.mail :as react-native-mail]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im2.common.bottom-sheet.events :as bottom-sheet]
[utils.i18n :as i18n]
[status-im.native-module.core :as status]
[status-im.transport.utils :as transport.utils]

View File

@ -1,6 +1,6 @@
(ns status-im.wallet.choose-recipient.core
(:require [re-frame.core :as re-frame]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im.contact.db :as contact.db]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.eip681 :as eip681]

View File

@ -4,7 +4,7 @@
[clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.async-storage.core :as async-storage]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im2.common.bottom-sheet.events :as bottom-sheet]
[status-im.contact.db :as contact.db]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.eip55 :as eip55]

View File

@ -0,0 +1,30 @@
(ns status-im2.common.bottom-sheet.events
(:require [utils.re-frame :as rf]))
(rf/defn show-bottom-sheet
[{:keys [db]} {:keys [view options]}]
{:dispatch [:dismiss-keyboard]
:show-bottom-sheet-overlay nil
:db (assoc db
:bottom-sheet/show? true
:bottom-sheet/view view
:bottom-sheet/options options)})
(rf/defn show-bottom-sheet-event
{:events [:bottom-sheet/show-sheet]}
[cofx view options]
(show-bottom-sheet
cofx
{:view view
:options options}))
(rf/defn hide-bottom-sheet
{:events [:bottom-sheet/hide]}
[{:keys [db]}]
{:db (assoc db :bottom-sheet/show? false)
:dismiss-bottom-sheet-overlay nil})
(rf/defn hide-bottom-sheet-navigation-overlay
{:events [:bottom-sheet/hide-navigation-overlay]}
[{}]
{:dismiss-bottom-sheet-overlay nil})

View File

@ -1,5 +1,5 @@
(ns status-im.ui.screens.bottom-sheets.views
(:require [re-frame.core :as re-frame]
(ns status-im2.common.bottom-sheet.sheets
(:require [utils.re-frame :as rf]
[status-im.ui.screens.about-app.views :as about-app]
[status-im.ui.screens.home.sheet.views :as home.sheet]
[status-im.ui.screens.keycard.views :as keycard]
@ -7,11 +7,15 @@
[status-im.ui.screens.multiaccounts.key-storage.views :as key-storage]
[status-im.ui.screens.multiaccounts.recover.views :as recover.views]
[status-im2.common.bottom-sheet.view :as bottom-sheet]
[status-im2.contexts.chat.messages.pin.list.view :as pin.list]))
[status-im2.contexts.chat.messages.pin.list.view :as pin.list]
[react-native.core :as rn]))
(defn bottom-sheet
[]
(let [{:keys [show? view options]} @(re-frame/subscribe [:bottom-sheet])
(let [dismiss-bottom-sheet-callback (fn []
(rf/dispatch [:bottom-sheet/hide])
true)
{:keys [show? view options]} (rf/sub [:bottom-sheet])
{:keys [content]
:as opts}
(cond-> {:visible? show?}
@ -47,6 +51,12 @@
(= view :pinned-messages-list)
(merge {:content pin.list/pinned-messages-list}))]
[bottom-sheet/bottom-sheet opts
(when content
[content (when options options)])]))
[:f>
(fn []
(rn/use-effect (fn []
(rn/hw-back-add-listener dismiss-bottom-sheet-callback)
(fn []
(rn/hw-back-remove-listener dismiss-bottom-sheet-callback))))
[bottom-sheet/bottom-sheet opts
(when content
[content (when options options)])])]))

View File

@ -26,24 +26,10 @@
options)
callback))
(def content-height (reagent/atom nil))
(def show-bottom-sheet? (reagent/atom nil))
(def keyboard-was-shown? (reagent/atom false))
(def expanded? (reagent/atom false))
(def gesture-running? (reagent/atom false))
(defn reset-atoms
[]
(reset! show-bottom-sheet? nil)
(reset! content-height nil)
(reset! expanded? false)
(reset! keyboard-was-shown? false)
(reset! gesture-running? false))
(defn get-bottom-sheet-gesture
[pan-y translate-y bg-height bg-height-expanded
window-height keyboard-shown disable-drag? expandable?
show-bottom-sheet? expanded? close-bottom-sheet]
show-bottom-sheet? expanded? close-bottom-sheet gesture-running?]
(-> (gesture/gesture-pan)
(gesture/on-start
(fn [_]
@ -70,8 +56,8 @@
(reset! gesture-running? false)
(when (and (not disable-drag?) show-bottom-sheet?)
(let [end-pan-y (- window-height (.-value translate-y))
expand-threshold (min (* bg-height * 1.1) (+ bg-height 50))
collapse-threshold (max (* bg-height-expanded * 0.9) (- bg-height-expanded 50))
expand-threshold (min (* bg-height 1.1) (+ bg-height 50))
collapse-threshold (max (* bg-height-expanded 0.9) (- bg-height-expanded 50))
should-close-bottom-sheet? (< end-pan-y (max (* bg-height 0.7) 50))]
(cond
should-close-bottom-sheet?
@ -95,17 +81,30 @@
(defn bottom-sheet
[props children]
(let [{on-cancel :on-cancel
disable-drag? :disable-drag?
show-handle? :show-handle?
visible? :visible?
backdrop-dismiss? :backdrop-dismiss?
expandable? :expandable?
selected-item :selected-item
:or {show-handle? true
backdrop-dismiss? true
expandable? false}}
(let [{on-cancel :on-cancel
disable-drag? :disable-drag?
show-handle? :show-handle?
visible? :visible?
backdrop-dismiss? :backdrop-dismiss?
expandable? :expandable?
selected-item :selected-item
is-initially-expaned? :expanded?
:or {show-handle? true
backdrop-dismiss? true
expandable? false
is-initially-expaned? false}}
props
content-height (reagent/atom nil)
show-bottom-sheet? (reagent/atom nil)
keyboard-was-shown? (reagent/atom false)
expanded? (reagent/atom is-initially-expaned?)
gesture-running? (reagent/atom false)
reset-atoms (fn []
(reset! show-bottom-sheet? nil)
(reset! content-height nil)
(reset! expanded? false)
(reset! keyboard-was-shown? false)
(reset! gesture-running? false))
close-bottom-sheet (fn []
(reset! show-bottom-sheet? false)
(when (fn? on-cancel) (on-cancel))
@ -150,7 +149,8 @@
expandable?
show-bottom-sheet?
expanded?
close-bottom-sheet)
close-bottom-sheet
gesture-running?)
handle-comp [gesture/gesture-detector {:gesture bottom-sheet-gesture}
[handle-comp window-width]]]

View File

@ -19,13 +19,14 @@
(rf/dispatch [:deselect-member public-key true]))))
(defn open-chat
[public-key member? selected?]
[public-key member? selected? current-pk]
(let [view-id (rf/sub [:view-id])]
(case view-id
:shell-stack (do (rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:chat.ui/show-profile public-key])
(rf/dispatch [:search/home-filter-changed nil]))
:group-chat-profile (group-chat-member-toggle member? selected? public-key))))
(when (not= current-pk public-key)
(case view-id
:shell-stack (do (rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:chat.ui/show-profile public-key])
(rf/dispatch [:search/home-filter-changed nil]))
:group-chat-profile (group-chat-member-toggle member? selected? public-key)))))
(defn action-icon
[{:keys [public-key]
@ -55,14 +56,8 @@
:on-change on-check}])])]))
(defn contact-list-item
[item _ _ {:keys [start-a-new-chat? on-toggle] :as extra-data}]
(let [{:keys [public-key
compressed-key
ens-verified
added?
images
group]}
item
[item _ _ {:keys [start-a-new-chat? on-toggle group] :as extra-data}]
(let [{:keys [public-key compressed-key ens-verified added? images]} item
display-name (first
(rf/sub
[:contacts/contact-two-names-by-identity
@ -86,7 +81,7 @@
:active-opacity 1
:on-press #(if start-a-new-chat?
(on-toggle true user-selected? public-key)
(open-chat public-key member? (swap! checked? not)))
(open-chat public-key member? (swap! checked? not) current-pk))
:on-long-press #(rf/dispatch [:bottom-sheet/show-sheet
{:content (fn [] [actions/actions item extra-data])}])})
[quo/user-avatar
@ -100,11 +95,17 @@
[rn/view {:style {:flex-direction :row}}
[quo/text {:weight :semi-bold} display-name]
(if ens-verified
[rn/view {:style {:margin-left 5 :margin-top 4}}
[rn/view
{:style {:margin-left 5
:margin-top 4}}
[quo/icon :i/verified
{:no-color true :size 12 :color (colors/theme-colors colors/success-50 colors/success-60)}]]
{:no-color true
:size 12
:color (colors/theme-colors colors/success-50 colors/success-60)}]]
(when added?
[rn/view {:style {:margin-left 5 :margin-top 4}}
[rn/view
{:style {:margin-left 5
:margin-top 4}}
[quo/icon :i/contact
{:no-color true
:size 12

View File

@ -269,3 +269,4 @@
(def ^:const theme-type-system 0)
(def ^:const theme-type-light 1)
(def ^:const theme-type-dark 2)
(def ^:const bottom-sheet-animation-delay 450)

View File

@ -1,16 +1,15 @@
(ns status-im2.contexts.activity-center.notification.contact-verification.view
(:require [clojure.string :as string]
[utils.i18n :as i18n]
[quo2.core :as quo]
[status-im2.constants :as constants]
[status-im2.contexts.activity-center.notification.common.view :as common]
[utils.datetime :as datetime]
[utils.i18n :as i18n]
[status-im2.contexts.activity-center.notification.common.view :as common]
[utils.re-frame :as rf]))
(defn- hide-bottom-sheet-and-dispatch
[event]
(rf/dispatch [:bottom-sheet/hide])
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch event))
(defn- context-tags

View File

@ -1,6 +1,5 @@
(ns status-im2.contexts.chat.group-details.style
(:require [quo2.foundations.colors :as colors]
[react-native.platform :as platform]))
(:require [quo2.foundations.colors :as colors]))
(defn actions-view
[]
@ -40,7 +39,6 @@
:padding-vertical 12
:padding-bottom (+ 33 (:bottom safe-area))
:width "100%"
:background-color colors/white
:flex-direction :row
:margin-bottom (if platform/ios? 0 70)})
:background-color (colors/theme-colors colors/white colors/neutral-95-opa-70)
:flex-direction :row})

View File

@ -93,10 +93,12 @@
{:style {:flex 1}
:accessibility-label :save
:on-press (fn []
(rf/dispatch [:group-chats.ui/add-members-pressed])
(js/setTimeout #(rf/dispatch [:group-chats.ui/remove-members-pressed])
(rf/dispatch [:bottom-sheet/hide])
(js/setTimeout (fn []
(rf/dispatch
[:group-chats.ui/remove-members-pressed]))
500)
(rf/dispatch [:bottom-sheet/hide]))
(rf/dispatch [:group-chats.ui/add-members-pressed]))
:disabled (and (zero? (count selected-participants))
(zero? (count deselected-members)))}
(i18n/label :t/save)]]]))])
@ -135,6 +137,7 @@
{:style (style/action-container color)
:accessibility-label :pinned-messages
:on-press (fn []
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:bottom-sheet/show-sheet :pinned-messages-list chat-id]))}
[rn/view
{:style {:flex-direction :row

View File

@ -28,9 +28,9 @@
(let [response-to (:response-to (:content message))
default-size 36]
[rn/touchable-opacity
{:on-press #(do
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:bottom-sheet/show-sheet :pinned-messages-list chat-id]))
{:on-press (fn []
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:bottom-sheet/show-sheet :pinned-messages-list chat-id]))
:active-opacity 1
:style (merge {:flex-direction :row :margin-vertical 8}
(old-style/message-wrapper message))}

View File

@ -27,5 +27,9 @@
:emoji-id emoji-id}]))
:accessibility-label (str "emoji-reaction-" emoji-id)}]])
[quo/add-reaction
{:on-press #(rf/dispatch [:bottom-sheet/show-sheet
{:content (fn [] [drawers/reactions chat-id message-id])}])}]])))
{:on-press (fn []
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch
[:bottom-sheet/show-sheet
{:content (fn [] [drawers/reactions
{:chat-id chat-id :message-id message-id}])}]))}]])))

View File

@ -87,8 +87,12 @@
[rn/touchable-highlight
{:underlay-color (colors/theme-colors colors/neutral-5 colors/neutral-90)
:style {:border-radius 16}
:on-press #(rf/dispatch [:dismiss-keyboard])
:on-long-press #(message-on-long-press message-data context)}
:on-press #()
:on-long-press (fn []
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:bottom-sheet/show-sheet
{:content (drawers/reactions-and-actions message-data
context)}]))}
[rn/view {:padding-vertical 8}
(when (and (seq response-to) quoted-message)
[old-message/quoted-message {:message-id response-to :chat-id chat-id} quoted-message])

View File

@ -51,15 +51,21 @@
:id (if pinned :unpin :pin)}])
(when-not pinned
[{:type :danger
:on-press #(rf/dispatch [:chat.ui/delete-message-for-me message-data
constants/delete-message-for-me-undo-time-limit-ms])
:on-press (fn []
(rf/dispatch
[:bottom-sheet/hide])
(rf/dispatch [:chat.ui/delete-message-for-me message-data
constants/delete-message-for-me-undo-time-limit-ms]))
:label (i18n/label :t/delete-for-me)
:icon :i/delete
:id :delete-for-me}])
(when (and (or outgoing can-delete-message-for-everyone?) config/delete-message-enabled?)
[{:type :danger
:on-press #(rf/dispatch [:chat.ui/delete-message message-data
constants/delete-message-undo-time-limit-ms])
:on-press (fn []
(rf/dispatch [:bottom-sheet/hide])
(rf/dispatch [:chat.ui/delete-message message-data
constants/delete-message-undo-time-limit-ms]))
:label (i18n/label :t/delete-for-everyone)
:icon :i/delete
:id :delete-for-all}])))
@ -72,7 +78,7 @@
:emoji-reaction-id))
(defn reactions
[chat-id message-id]
[{:keys [chat-id message-id]}]
(let [reactions (rf/sub [:chats/message-reactions message-id chat-id])
own-reactions (reduce (fn [acc {:keys [emoji-id own emoji-reaction-id]}]
(if own
@ -119,7 +125,7 @@
admin-actions (filter #(= (:type %) :admin) actions)]
[:<>
;; REACTIONS
[reactions chat-id message-id]
[reactions {:chat-id chat-id :message-id message-id}]
;; MAIN ACTIONS
[rn/view {:style {:padding-horizontal 8}}
@ -131,9 +137,9 @@
:title (:label action)
:accessibility-label (:label action)
:icon (:icon action)
:on-press #(do
(when on-press (on-press))
(rf/dispatch [:bottom-sheet/hide]))}]))
:on-press (fn []
(rf/dispatch [:bottom-sheet/hide])
(when on-press (on-press)))}]))
(when-not (empty? danger-actions)
[quo/separator])
@ -146,9 +152,9 @@
:title (:label action)
:accessibility-label (:label action)
:icon (:icon action)
:on-press #(do
(when on-press (on-press))
(rf/dispatch [:bottom-sheet/hide]))}]))
:on-press (fn []
(rf/dispatch [:bottom-sheet/hide])
(when on-press (on-press)))}]))
(when-not (empty? admin-actions)
[quo/separator])
@ -161,6 +167,6 @@
:title (:label action)
:accessibility-label (:label action)
:icon (:icon action)
:on-press #(do
(when on-press (on-press))
(rf/dispatch [:bottom-sheet/hide]))}]))]])))
:on-press (fn []
(rf/dispatch [:bottom-sheet/hide])
(when on-press (on-press)))}]))]])))

View File

@ -15,8 +15,8 @@
[quo/banner
{:latest-pin-text latest-pin-text
:pins-count pins-count
:on-press #(do
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:bottom-sheet/show-sheet :pinned-messages-list chat-id]))}]))
:on-press (fn []
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:bottom-sheet/show-sheet :pinned-messages-list chat-id]))}]))

View File

@ -7,7 +7,7 @@
{:width "100%"
:height (+ (:bottom safe-area) 65)
:position :absolute
:bottom (if platform/ios? 0 33)})
:bottom (if platform/ios? 0 (:bottom safe-area))})
(defn buttons-container
[safe-area]

View File

@ -9,7 +9,6 @@
[reagent.core :as reagent]
[status-im2.contexts.chat.photo-selector.style :as style]
[status-im.utils.core :as utils]
[quo.react]
[utils.re-frame :as rf]))
(def selected (reagent/atom []))
@ -36,7 +35,9 @@
[quo/button
{:style {:align-self :stretch
:margin-horizontal 20}
:on-press #(on-press-confirm-selection chat-id)
:on-press (fn []
(rf/dispatch [:bottom-sheet/hide])
(on-press-confirm-selection chat-id))
:accessibility-label :confirm-selection}
(i18n/label :t/confirm-selection)]])))])
@ -114,4 +115,3 @@
:on-end-reached #(rf/dispatch [:camera-roll/on-end-reached end-cursor loading?
has-next-page?])}]
[bottom-gradient chat-id selected-images]]))]))

View File

@ -121,8 +121,8 @@
{:accessibility-label :join-community-button
:on-press (fn []
(if can-join?
(do (rf/dispatch [::communities/join id])
(rf/dispatch [:bottom-sheet/hide]))
(do (rf/dispatch [:bottom-sheet/hide])
(rf/dispatch [::communities/join id]))
(do
(and can-request-access?
(not (pos? requested-to-join-at))

View File

@ -1,9 +1,9 @@
(ns status-im2.contexts.syncing.sheets.sync-device-notice.view
(:require [utils.i18n :as i18n]
[quo2.core :as quo]
(:require [quo2.core :as quo]
[react-native.core :as rn]
[status-im2.contexts.syncing.sheets.enter-password.view :as enter-password]
[status-im2.contexts.syncing.sheets.sync-device-notice.styles :as styles]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn sheet
@ -54,8 +54,11 @@
:size 40
:style styles/setup-syncing-button
:before :i/face-id20
:on-press #(rf/dispatch [:bottom-sheet/show-sheet
{:show-handle? false
:content (fn []
[enter-password/sheet])}])}
:on-press (fn []
(rf/dispatch [:bottom-sheet/hide])
(rf/dispatch [:bottom-sheet/show-sheet
{:show-handle? true
:expanded? true
:content (fn []
[enter-password/sheet])}]))}
(i18n/label :t/setup-syncing)]]])

View File

@ -45,8 +45,10 @@
{:label :primary
:size 40
:before :i/placeholder
:on-press #(rf/dispatch [:bottom-sheet/show-sheet
{:show-handle? false
:content (fn []
[sync-device-notice/sheet])}])}
:on-press (fn []
(rf/dispatch [:bottom-sheet/hide])
(rf/dispatch [:bottom-sheet/show-sheet
{:show-handle? false
:content (fn []
[sync-device-notice/sheet])}]))}
(i18n/label :t/sync-new-device)]]]])

View File

@ -10,6 +10,7 @@
[status-im2.common.theme.core :as theme]
[status-im2.common.toasts.events]
[status-im2.contexts.add-new-contact.events]
[status-im2.common.bottom-sheet.events]
[status-im2.navigation.events :as navigation]
[status-im2.db :as db]
[utils.re-frame :as rf]

View File

@ -264,8 +264,8 @@
(fn [] (dissmiss-overlay "visibility-status-popover")))
;; BOTTOM SHEETS
(re-frame/reg-fx :show-bottom-sheet (fn [] (show-overlay "bottom-sheet")))
(re-frame/reg-fx :hide-bottom-sheet (fn [] (dissmiss-overlay "bottom-sheet")))
(re-frame/reg-fx :show-bottom-sheet-overlay (fn [] (show-overlay "bottom-sheet")))
(re-frame/reg-fx :dismiss-bottom-sheet-overlay (fn [] (dissmiss-overlay "bottom-sheet")))
;; WALLET CONNECT
(re-frame/reg-fx :show-wallet-connect-sheet (fn [] (show-overlay "wallet-connect-sheet")))

View File

@ -5,7 +5,7 @@
[react-native.safe-area :as safe-area]
[reagent.core :as reagent]
[status-im.keycard.test-menu :as keycard.test-menu]
[status-im.ui.screens.bottom-sheets.views :as bottom-sheets]
[status-im2.common.bottom-sheet.sheets :as bottom-sheets]
[status-im.ui.screens.popover.views :as popover]
[status-im.ui.screens.profile.visibility-status.views :as visibility-status-views]
[status-im.ui.screens.signing.views :as signing]

View File

@ -8,7 +8,8 @@
[status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.image-server :as image-server]
[utils.collection]))
[utils.collection]
[status-im2.constants :as constants]))
(re-frame/reg-sub
::query-current-chat-contacts
@ -111,6 +112,23 @@
(sort-by
#(visibility-status-utils/visibility-status-order (:public-key %))))))
(re-frame/reg-sub
:contacts/sorted-and-grouped-by-first-letter
:<- [:contacts/active]
:<- [:selected-contacts-count]
(fn [[contacts selected-contacts-count]]
(->> contacts
(filter :mutual?)
(map #(assoc %
:allow-new-users?
(< selected-contacts-count
(dec constants/max-group-chat-participants))))
(group-by (comp (fnil string/upper-case "") first :alias))
(sort-by first)
(map (fn [[title data]]
{:title title
:data data})))))
(re-frame/reg-sub
:contacts/active-count
:<- [:contacts/active]

View File

@ -0,0 +1,183 @@
(ns status-im2.subs.contact-test
(:require [cljs.test :refer [is testing]]
[re-frame.db :as rf-db]
[test-helpers.unit :as h]
status-im2.subs.contact
[utils.re-frame :as rf]))
(def contacts-sample-data
{:selected-contacts-count 1
:contacts/contacts {"0xtest" {:last-updated 1672582629695
:mutual? true
:contactRequestClock 0
:images {}
:added true
:name "slim.shady"
:Removed false
:trustStatus 0
:alias "Real Slim Shady"
:bio ""
:IsSyncing false
:display-name ""
:ens-verified true
:socialLinks nil
:blocked false
:verificationStatus 0
:lastUpdatedLocally 1672582563204
:public-key "0xtest"
:has-added-us true
:contact-request-state 1}
"0xtest2" {:last-updated 1672582629695
:mutual? true
:contactRequestClock 0
:images {}
:added true
:name "slim.shady"
:Removed false
:trustStatus 0
:alias "Fake Slim Shady"
:bio ""
:IsSyncing false
:display-name ""
:ens-verified true
:socialLinks nil
:blocked false
:verificationStatus 0
:lastUpdatedLocally 1672582563204
:public-key "0xtest"
:has-added-us true
:contact-request-state 1}
"0xtest3" {:last-updated 1672582629695
:mutual? true
:contactRequestClock 0
:images {}
:added true
:name "slim.shady"
:Removed false
:trustStatus 0
:alias "Instant noodles"
:bio ""
:IsSyncing false
:display-name ""
:ens-verified true
:socialLinks nil
:blocked false
:verificationStatus 0
:lastUpdatedLocally 1672582563204
:public-key "0xtest"
:has-added-us true
:contact-request-state 1}}})
(def expected-sorted-contacts
[{:title "F"
:data [{:active? true
:last-updated 1672582629695
:mutual? true
:blocked? false
:contactRequestClock 0
:images {}
:added true
:name "slim.shady"
:added? true
:Removed false
:trustStatus 0
:alias "Fake Slim Shady"
:bio ""
:IsSyncing false
:display-name ""
:ens-verified true
:socialLinks nil
:blocked false
:allow-new-users? true
:verificationStatus 0
:lastUpdatedLocally 1672582563204
:public-key "0xtest"
:names {:nickname nil
:display-name ""
:three-words-name "Fake Slim Shady"
:ens-name "@slim.shady"}
:has-added-us true
:contact-request-state 1}]}
{:title "I"
:data [{:active? true
:last-updated 1672582629695
:mutual? true
:blocked? false
:contactRequestClock 0
:images {}
:added true
:name "slim.shady"
:added? true
:Removed false
:trustStatus 0
:alias "Instant noodles"
:bio ""
:IsSyncing false
:display-name ""
:ens-verified true
:socialLinks nil
:blocked false
:allow-new-users? true
:verificationStatus 0
:lastUpdatedLocally 1672582563204
:public-key "0xtest"
:names {:nickname nil
:display-name ""
:three-words-name "Instant noodles"
:ens-name "@slim.shady"}
:has-added-us true
:contact-request-state 1}]}
{:title "R"
:data [{:active? true
:last-updated 1672582629695
:mutual? true
:blocked? false
:contactRequestClock 0
:images {}
:added true
:name "slim.shady"
:added? true
:Removed false
:trustStatus 0
:alias "Real Slim Shady"
:bio ""
:IsSyncing false
:display-name ""
:ens-verified true
:socialLinks nil
:blocked false
:allow-new-users? true
:verificationStatus 0
:lastUpdatedLocally 1672582563204
:public-key "0xtest"
:names {:nickname nil
:display-name ""
:three-words-name "Real Slim Shady"
:ens-name "@slim.shady"}
:has-added-us true
:contact-request-state 1}]}])
(h/deftest-sub :contacts/sorted-and-grouped-by-first-letter
[sub-name]
(testing "Returning empty sequence when no contacts"
(swap! rf-db/app-db merge (assoc contacts-sample-data :contacts/contacts {}))
(is (empty? (rf/sub [sub-name]))))
(testing "Returning empty sequence when no mutual contacts"
(let [remove-contact-as-mutual #(-> %
(assoc-in ["0xtest" :mutual?] false)
(assoc-in ["0xtest2" :mutual?] false)
(assoc-in ["0xtest3" :mutual?] false))]
(swap! rf-db/app-db merge
(update contacts-sample-data :contacts/contacts remove-contact-as-mutual))
(is (empty? (rf/sub [sub-name])))))
(testing "Returning sorted contacts"
(swap! rf-db/app-db merge contacts-sample-data)
(let [contact-list-without-identicons (mapv (fn [contact-group]
(update contact-group
:data
#(mapv (fn [contact]
(dissoc contact :identicon))
%)))
(rf/sub [sub-name]))]
(is (= expected-sorted-contacts contact-list-without-identicons)))))

View File

@ -1499,7 +1499,7 @@
"not-enough-snt": "Not enough SNT",
"add-new-contact": "Add new contact",
"add-a-contact": "Add a contact",
"enter-a-chat-key": "Enter a chat key or scan a QR",
"enter-a-chat-key": "Add a chatkey or scan a QR",
"you-dont-have-contacts": "You dont have any contacts yet.",
"set-max": "Set max",
"continue-anyway": "Continue anyway",
@ -1952,5 +1952,8 @@
"join-one-user": "Join {{user}}",
"join-two-users": "Join {{user1}} and {{user2}}",
"join-more-users": "Join {{user1}}, {{user2}} and {{left-count}} more",
"wants-to-join": "wants to join"
"wants-to-join": "wants to join",
"connect-with-users": "Connect with users",
"invite-friends-and-family": "Invite your friends and family to Status",
"you-have-no-contacts": "You have no contacts"
}