[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 16)
(get-icons 20) (get-icons 20)
(get-icons 24) (get-icons 24)
(get-icons 32) (get-icons 32)))
(get-icons 120)))

View File

@ -7,12 +7,14 @@
(defn themes (defn themes
[type] [type]
(case type (case type
:main {:icon-color (theme-colors colors/neutral-50 colors/neutral-10) :main {:icon-color (theme-colors colors/neutral-50 colors/neutral-10)
:background (theme-colors colors/white colors/neutral-90) :background (theme-colors colors/white colors/neutral-90)
:text-color (theme-colors colors/neutral-100 colors/white)} :text-color (theme-colors colors/neutral-100 colors/white)}
:danger {:icon-color (theme-colors colors/danger-50 colors/danger-60) :danger {:icon-color (theme-colors colors/danger-50 colors/danger-60)
:background (theme-colors colors/white colors/neutral-90) :background (theme-colors colors/white colors/neutral-90)
:text-color (theme-colors colors/danger-50 colors/danger-60)})) :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 (defn menu-item
[{:keys [type title accessibility-label icon on-press style-props subtitle subtitle-color] [{: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] ["eth-phishing-detect" :as eth-phishing-detect]
[clojure.string :as string] [clojure.string :as string]
[re-frame.core :as re-frame] [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.eip3085 :as eip3085]
[status-im.browser.eip3326 :as eip3326] [status-im.browser.eip3326 :as eip3326]
[status-im.browser.permissions :as browser.permissions] [status-im.browser.permissions :as browser.permissions]

View File

@ -6,7 +6,7 @@
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[status-im.async-storage.core :as async-storage] [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-im2.constants :as constants]
[status-im.ui.components.emoji-thumbnail.styles :as emoji-thumbnail-styles] [status-im.ui.components.emoji-thumbnail.styles :as emoji-thumbnail-styles]
[utils.re-frame :as rf] [utils.re-frame :as rf]

View File

@ -2,7 +2,7 @@
(:refer-clojure :exclude [name]) (:refer-clojure :exclude [name])
(:require [clojure.string :as string] (:require [clojure.string :as string]
[re-frame.core :as re-frame] [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.core :as ethereum]
[status-im.ethereum.eip55 :as eip55] [status-im.ethereum.eip55 :as eip55]
[status-im.ethereum.ens :as ens] [status-im.ethereum.ens :as ens]

View File

@ -213,6 +213,11 @@
[{:keys [db]} id] [{:keys [db]} id]
{:db (update db :group/selected-contacts conj 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 (rf/defn deselect-participant
{:events [:deselect-participant]} {:events [:deselect-participant]}
[{:keys [db]} id] [{:keys [db]} id]

View File

@ -1,7 +1,7 @@
(ns status-im.keycard.common (ns status-im.keycard.common
(:require [clojure.string :as string] (:require [clojure.string :as string]
[re-frame.core :as re-frame] [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.core :as ethereum]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[status-im.keycard.nfc :as nfc] [status-im.keycard.nfc :as nfc]

View File

@ -1,5 +1,5 @@
(ns status-im.keycard.login (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.ethereum.core :as ethereum]
[status-im.keycard.common :as common] [status-im.keycard.common :as common]
status-im.keycard.fx status-im.keycard.fx

View File

@ -1,7 +1,7 @@
(ns status-im.keycard.recovery (ns status-im.keycard.recovery
(:require [clojure.string :as string] (:require [clojure.string :as string]
[re-frame.core :as re-frame] [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-im2.constants :as constants]
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]
[status-im.ethereum.eip55 :as eip55] [status-im.ethereum.eip55 :as eip55]

View File

@ -1,5 +1,5 @@
(ns status-im.keycard.wallet (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-im2.constants :as constants]
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]
[status-im.ethereum.eip55 :as eip55] [status-im.ethereum.eip55 :as eip55]

View File

@ -1,5 +1,5 @@
(ns status-im.mobile-sync-settings.core (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.mailserver.core :as mailserver]
[status-im.multiaccounts.model :as multiaccounts.model] [status-im.multiaccounts.model :as multiaccounts.model]
[status-im.multiaccounts.update.core :as multiaccounts.update] [status-im.multiaccounts.update.core :as multiaccounts.update]

View File

@ -2,7 +2,7 @@
(:require [clojure.string :as string] (:require [clojure.string :as string]
[quo.platform :as platform] [quo.platform :as platform]
[re-frame.core :as re-frame] [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.ethereum.stateofus :as stateofus]
[status-im.multiaccounts.update.core :as multiaccounts.update] [status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.native-module.core :as native-module] [status-im.native-module.core :as native-module]

View File

@ -1,7 +1,7 @@
(ns status-im.multiaccounts.key-storage.core (ns status-im.multiaccounts.key-storage.core
(:require [clojure.string :as string] (:require [clojure.string :as string]
[re-frame.core :as re-frame] [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.core :as ethereum]
[status-im.ethereum.mnemonic :as mnemonic] [status-im.ethereum.mnemonic :as mnemonic]
[utils.i18n :as i18n] [utils.i18n :as i18n]

View File

@ -1,7 +1,7 @@
(ns status-im.multiaccounts.recover.core (ns status-im.multiaccounts.recover.core
(:require [clojure.string :as string] (:require [clojure.string :as string]
[re-frame.core :as re-frame] [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-im2.constants :as constants]
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]
[status-im.ethereum.mnemonic :as mnemonic] [status-im.ethereum.mnemonic :as mnemonic]

View File

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

View File

@ -52,7 +52,9 @@
:community-cover (js/require "../resources/images/ui/community-cover.png") :community-cover (js/require "../resources/images/ui/community-cover.png")
:lifestyle (js/require "../resources/images/ui/lifestyle.png") :lifestyle (js/require "../resources/images/ui/lifestyle.png")
:music (js/require "../resources/images/ui/music.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 (def mock-images
{:photo1 (js/require "../resources/images/mock/photo1.png") {:photo1 (js/require "../resources/images/mock/photo1.png")

View File

@ -1,7 +1,7 @@
(ns status-im.signing.gas (ns status-im.signing.gas
(:require [clojure.string :as string] (:require [clojure.string :as string]
[re-frame.core :as re-frame] [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.core :as ethereum]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[status-im.popover.core :as popover] [status-im.popover.core :as popover]

View File

@ -1,7 +1,7 @@
(ns status-im.ui.screens.home.sheet.views (ns status-im.ui.screens.home.sheet.views
(:require [quo.core :as quo] (:require [quo.core :as quo]
[quo2.foundations.colors :as colors] [quo2.foundations.colors :as colors]
[re-frame.core :as rf] [utils.re-frame :as rf]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[status-im.qr-scanner.core :as qr-scanner] [status-im.qr-scanner.core :as qr-scanner]
[status-im.ui.components.invite.views :as invite] [status-im.ui.components.invite.views :as invite]
@ -11,7 +11,7 @@
[quo2.core :as quo2] [quo2.core :as quo2]
[status-im.ui.screens.home.sheet.styles :as style])) [status-im.ui.screens.home.sheet.styles :as style]))
(defn hide-sheet-and-dispatch (defn- hide-sheet-and-dispatch
[event] [event]
(rf/dispatch [:bottom-sheet/hide]) (rf/dispatch [:bottom-sheet/hide])
(rf/dispatch event)) (rf/dispatch event))
@ -51,7 +51,7 @@
:accessibility-label :join-public-chat-button :accessibility-label :join-public-chat-button
:icon :main-icons/public-chat :icon :main-icons/public-chat
:on-press #(hide-sheet-and-dispatch [:open-modal :new-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 [quo/list-item
{:theme :accent {:theme :accent
:title (i18n/label :t/communities-alpha) :title (i18n/label :t/communities-alpha)
@ -65,28 +65,21 @@
[] []
[rn/view [rn/view
[quo2/menu-item [quo2/menu-item
{:theme :main {:type :transparent
:title (i18n/label :t/new-chat) :title (i18n/label :t/new-chat)
:icon-bg-color :transparent :icon-bg-color :transparent
:container-padding-vertical 12 :container-padding-vertical 12
:title-column-style {:margin-left 2} :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) :icon-color (colors/theme-colors colors/neutral-50 colors/neutral-40)
:accessibility-label :start-a-new-chat :accessibility-label :start-a-new-chat
:icon :i/new-message :icon :i/new-message
:on-press (fn [] ;; Note: currently the bottom button is overlapping with :on-press #(hide-sheet-and-dispatch [:bottom-sheet/show-sheet
;; safe-area :start-a-new-chat {}])}]
;; 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))}]
[quo2/menu-item [quo2/menu-item
{:theme :main {:type :transparent
:title (i18n/label :t/add-a-contact) :title (i18n/label :t/add-a-contact)
:icon-bg-color :transparent :icon-bg-color :transparent
:icon-container-style {:padding-horizontal 0} :icon-container-style {:padding-horizontal 0}
@ -102,7 +95,6 @@
:icon :i/add-user :icon :i/add-user
:on-press #(hide-sheet-and-dispatch [:open-modal :new-contact])}]]) :on-press #(hide-sheet-and-dispatch [:open-modal :new-contact])}]])
(def new-chat-bottom-sheet-comp (def new-chat-bottom-sheet-comp
{:content new-chat-bottom-sheet}) {:content new-chat-bottom-sheet})

View File

@ -4,7 +4,7 @@
[quo.design-system.colors :as colors] [quo.design-system.colors :as colors]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[reagent.core :as reagent] [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] [status-im2.constants :as constants]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[status-im.keycard.login :as keycard.login] [status-im.keycard.login :as keycard.login]

View File

@ -3,12 +3,16 @@
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[utils.i18n :as i18n])) [utils.i18n :as i18n]))
(defn- hide-sheet-and-dispatch
[event]
(re-frame/dispatch [:bottom-sheet/hide])
(re-frame/dispatch event))
(defn actions-sheet (defn actions-sheet
[] []
[quo/list-item [quo/list-item
{:theme :accent {:theme :accent
:on-press #(do (re-frame/dispatch [:bottom-sheet/hide]) :on-press #(hide-sheet-and-dispatch [:generate-and-derive-addresses])
(re-frame/dispatch [:generate-and-derive-addresses]))
:icon :main-icons/add :icon :main-icons/add
:accessibility-label :generate-a-new-key :accessibility-label :generate-a-new-key
:title (i18n/label :t/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.react :as react]
[status-im.ui.components.toolbar :as toolbar] [status-im.ui.components.toolbar :as toolbar]
[status-im.ui.screens.chat.photos :as photos] [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.styles :as styles]
[status-im.ui.screens.multiaccounts.sheets :as sheets]
[utils.security.core :as security])) [utils.security.core :as security]))
(defn multiaccount-view (defn multiaccount-view
@ -43,7 +43,6 @@
[] []
(re-frame/dispatch [:bottom-sheet/show-sheet (re-frame/dispatch [:bottom-sheet/show-sheet
{:content sheets/actions-sheet}])) {:content sheets/actions-sheet}]))
(defview multiaccounts (defview multiaccounts
[] []
(letsubs [multiaccounts [:multiaccounts/multiaccounts]] (letsubs [multiaccounts [:multiaccounts/multiaccounts]]

View File

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

View File

@ -1,6 +1,6 @@
(ns status-im.wallet.choose-recipient.core (ns status-im.wallet.choose-recipient.core
(:require [re-frame.core :as re-frame] (: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.contact.db :as contact.db]
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]
[status-im.ethereum.eip681 :as eip681] [status-im.ethereum.eip681 :as eip681]

View File

@ -4,7 +4,7 @@
[clojure.string :as string] [clojure.string :as string]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.async-storage.core :as async-storage] [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.contact.db :as contact.db]
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]
[status-im.ethereum.eip55 :as eip55] [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 (ns status-im2.common.bottom-sheet.sheets
(:require [re-frame.core :as re-frame] (:require [utils.re-frame :as rf]
[status-im.ui.screens.about-app.views :as about-app] [status-im.ui.screens.about-app.views :as about-app]
[status-im.ui.screens.home.sheet.views :as home.sheet] [status-im.ui.screens.home.sheet.views :as home.sheet]
[status-im.ui.screens.keycard.views :as keycard] [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.key-storage.views :as key-storage]
[status-im.ui.screens.multiaccounts.recover.views :as recover.views] [status-im.ui.screens.multiaccounts.recover.views :as recover.views]
[status-im2.common.bottom-sheet.view :as bottom-sheet] [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 (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] {:keys [content]
:as opts} :as opts}
(cond-> {:visible? show?} (cond-> {:visible? show?}
@ -47,6 +51,12 @@
(= view :pinned-messages-list) (= view :pinned-messages-list)
(merge {:content pin.list/pinned-messages-list}))] (merge {:content pin.list/pinned-messages-list}))]
[bottom-sheet/bottom-sheet opts [:f>
(when content (fn []
[content (when options options)])])) (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) options)
callback)) 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 (defn get-bottom-sheet-gesture
[pan-y translate-y bg-height bg-height-expanded [pan-y translate-y bg-height bg-height-expanded
window-height keyboard-shown disable-drag? expandable? 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/gesture-pan)
(gesture/on-start (gesture/on-start
(fn [_] (fn [_]
@ -70,8 +56,8 @@
(reset! gesture-running? false) (reset! gesture-running? false)
(when (and (not disable-drag?) show-bottom-sheet?) (when (and (not disable-drag?) show-bottom-sheet?)
(let [end-pan-y (- window-height (.-value translate-y)) (let [end-pan-y (- window-height (.-value translate-y))
expand-threshold (min (* bg-height * 1.1) (+ bg-height 50)) expand-threshold (min (* bg-height 1.1) (+ bg-height 50))
collapse-threshold (max (* bg-height-expanded * 0.9) (- bg-height-expanded 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))] should-close-bottom-sheet? (< end-pan-y (max (* bg-height 0.7) 50))]
(cond (cond
should-close-bottom-sheet? should-close-bottom-sheet?
@ -95,17 +81,30 @@
(defn bottom-sheet (defn bottom-sheet
[props children] [props children]
(let [{on-cancel :on-cancel (let [{on-cancel :on-cancel
disable-drag? :disable-drag? disable-drag? :disable-drag?
show-handle? :show-handle? show-handle? :show-handle?
visible? :visible? visible? :visible?
backdrop-dismiss? :backdrop-dismiss? backdrop-dismiss? :backdrop-dismiss?
expandable? :expandable? expandable? :expandable?
selected-item :selected-item selected-item :selected-item
:or {show-handle? true is-initially-expaned? :expanded?
backdrop-dismiss? true :or {show-handle? true
expandable? false}} backdrop-dismiss? true
expandable? false
is-initially-expaned? false}}
props 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 [] close-bottom-sheet (fn []
(reset! show-bottom-sheet? false) (reset! show-bottom-sheet? false)
(when (fn? on-cancel) (on-cancel)) (when (fn? on-cancel) (on-cancel))
@ -150,7 +149,8 @@
expandable? expandable?
show-bottom-sheet? show-bottom-sheet?
expanded? expanded?
close-bottom-sheet) close-bottom-sheet
gesture-running?)
handle-comp [gesture/gesture-detector {:gesture bottom-sheet-gesture} handle-comp [gesture/gesture-detector {:gesture bottom-sheet-gesture}
[handle-comp window-width]]] [handle-comp window-width]]]

View File

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

View File

@ -269,3 +269,4 @@
(def ^:const theme-type-system 0) (def ^:const theme-type-system 0)
(def ^:const theme-type-light 1) (def ^:const theme-type-light 1)
(def ^:const theme-type-dark 2) (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 (ns status-im2.contexts.activity-center.notification.contact-verification.view
(:require [clojure.string :as string] (:require [clojure.string :as string]
[utils.i18n :as i18n]
[quo2.core :as quo] [quo2.core :as quo]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.activity-center.notification.common.view :as common]
[utils.datetime :as datetime] [utils.datetime :as datetime]
[utils.i18n :as i18n] [status-im2.contexts.activity-center.notification.common.view :as common]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
(defn- hide-bottom-sheet-and-dispatch (defn- hide-bottom-sheet-and-dispatch
[event] [event]
(rf/dispatch [:bottom-sheet/hide]) (rf/dispatch [:bottom-sheet/hide])
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch event)) (rf/dispatch event))
(defn- context-tags (defn- context-tags

View File

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

View File

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

View File

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

View File

@ -27,5 +27,9 @@
:emoji-id emoji-id}])) :emoji-id emoji-id}]))
:accessibility-label (str "emoji-reaction-" emoji-id)}]]) :accessibility-label (str "emoji-reaction-" emoji-id)}]])
[quo/add-reaction [quo/add-reaction
{:on-press #(rf/dispatch [:bottom-sheet/show-sheet {:on-press (fn []
{:content (fn [] [drawers/reactions chat-id message-id])}])}]]))) (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 [rn/touchable-highlight
{:underlay-color (colors/theme-colors colors/neutral-5 colors/neutral-90) {:underlay-color (colors/theme-colors colors/neutral-5 colors/neutral-90)
:style {:border-radius 16} :style {:border-radius 16}
:on-press #(rf/dispatch [:dismiss-keyboard]) :on-press #()
:on-long-press #(message-on-long-press message-data context)} :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} [rn/view {:padding-vertical 8}
(when (and (seq response-to) quoted-message) (when (and (seq response-to) quoted-message)
[old-message/quoted-message {:message-id response-to :chat-id chat-id} 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)}]) :id (if pinned :unpin :pin)}])
(when-not pinned (when-not pinned
[{:type :danger [{:type :danger
:on-press #(rf/dispatch [:chat.ui/delete-message-for-me message-data :on-press (fn []
constants/delete-message-for-me-undo-time-limit-ms]) (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) :label (i18n/label :t/delete-for-me)
:icon :i/delete :icon :i/delete
:id :delete-for-me}]) :id :delete-for-me}])
(when (and (or outgoing can-delete-message-for-everyone?) config/delete-message-enabled?) (when (and (or outgoing can-delete-message-for-everyone?) config/delete-message-enabled?)
[{:type :danger [{:type :danger
:on-press #(rf/dispatch [:chat.ui/delete-message message-data :on-press (fn []
constants/delete-message-undo-time-limit-ms]) (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) :label (i18n/label :t/delete-for-everyone)
:icon :i/delete :icon :i/delete
:id :delete-for-all}]))) :id :delete-for-all}])))
@ -72,7 +78,7 @@
:emoji-reaction-id)) :emoji-reaction-id))
(defn reactions (defn reactions
[chat-id message-id] [{:keys [chat-id message-id]}]
(let [reactions (rf/sub [:chats/message-reactions message-id chat-id]) (let [reactions (rf/sub [:chats/message-reactions message-id chat-id])
own-reactions (reduce (fn [acc {:keys [emoji-id own emoji-reaction-id]}] own-reactions (reduce (fn [acc {:keys [emoji-id own emoji-reaction-id]}]
(if own (if own
@ -119,7 +125,7 @@
admin-actions (filter #(= (:type %) :admin) actions)] admin-actions (filter #(= (:type %) :admin) actions)]
[:<> [:<>
;; REACTIONS ;; REACTIONS
[reactions chat-id message-id] [reactions {:chat-id chat-id :message-id message-id}]
;; MAIN ACTIONS ;; MAIN ACTIONS
[rn/view {:style {:padding-horizontal 8}} [rn/view {:style {:padding-horizontal 8}}
@ -131,9 +137,9 @@
:title (:label action) :title (:label action)
:accessibility-label (:label action) :accessibility-label (:label action)
:icon (:icon action) :icon (:icon action)
:on-press #(do :on-press (fn []
(when on-press (on-press)) (rf/dispatch [:bottom-sheet/hide])
(rf/dispatch [:bottom-sheet/hide]))}])) (when on-press (on-press)))}]))
(when-not (empty? danger-actions) (when-not (empty? danger-actions)
[quo/separator]) [quo/separator])
@ -146,9 +152,9 @@
:title (:label action) :title (:label action)
:accessibility-label (:label action) :accessibility-label (:label action)
:icon (:icon action) :icon (:icon action)
:on-press #(do :on-press (fn []
(when on-press (on-press)) (rf/dispatch [:bottom-sheet/hide])
(rf/dispatch [:bottom-sheet/hide]))}])) (when on-press (on-press)))}]))
(when-not (empty? admin-actions) (when-not (empty? admin-actions)
[quo/separator]) [quo/separator])
@ -161,6 +167,6 @@
:title (:label action) :title (:label action)
:accessibility-label (:label action) :accessibility-label (:label action)
:icon (:icon action) :icon (:icon action)
:on-press #(do :on-press (fn []
(when on-press (on-press)) (rf/dispatch [:bottom-sheet/hide])
(rf/dispatch [:bottom-sheet/hide]))}]))]]))) (when on-press (on-press)))}]))]])))

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -264,8 +264,8 @@
(fn [] (dissmiss-overlay "visibility-status-popover"))) (fn [] (dissmiss-overlay "visibility-status-popover")))
;; BOTTOM SHEETS ;; BOTTOM SHEETS
(re-frame/reg-fx :show-bottom-sheet (fn [] (show-overlay "bottom-sheet"))) (re-frame/reg-fx :show-bottom-sheet-overlay (fn [] (show-overlay "bottom-sheet")))
(re-frame/reg-fx :hide-bottom-sheet (fn [] (dissmiss-overlay "bottom-sheet"))) (re-frame/reg-fx :dismiss-bottom-sheet-overlay (fn [] (dissmiss-overlay "bottom-sheet")))
;; WALLET CONNECT ;; WALLET CONNECT
(re-frame/reg-fx :show-wallet-connect-sheet (fn [] (show-overlay "wallet-connect-sheet"))) (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] [react-native.safe-area :as safe-area]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.keycard.test-menu :as keycard.test-menu] [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.popover.views :as popover]
[status-im.ui.screens.profile.visibility-status.views :as visibility-status-views] [status-im.ui.screens.profile.visibility-status.views :as visibility-status-views]
[status-im.ui.screens.signing.views :as signing] [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.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
[status-im.utils.gfycat.core :as gfycat] [status-im.utils.gfycat.core :as gfycat]
[status-im.utils.image-server :as image-server] [status-im.utils.image-server :as image-server]
[utils.collection])) [utils.collection]
[status-im2.constants :as constants]))
(re-frame/reg-sub (re-frame/reg-sub
::query-current-chat-contacts ::query-current-chat-contacts
@ -111,6 +112,23 @@
(sort-by (sort-by
#(visibility-status-utils/visibility-status-order (:public-key %)))))) #(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 (re-frame/reg-sub
:contacts/active-count :contacts/active-count
:<- [:contacts/active] :<- [: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", "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": "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.", "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",
@ -1952,5 +1952,8 @@
"join-one-user": "Join {{user}}", "join-one-user": "Join {{user}}",
"join-two-users": "Join {{user1}} and {{user2}}", "join-two-users": "Join {{user1}} and {{user2}}",
"join-more-users": "Join {{user1}}, {{user2}} and {{left-count}} more", "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"
} }