fix: theming toast component (#17918)

This commit is contained in:
codemaster 2023-12-22 09:29:50 -06:00 committed by GitHub
parent 1bd6898e1c
commit 7915ba85ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 123 additions and 166 deletions

View File

@ -38,8 +38,13 @@
{:color (colors/theme-colors colors/white colors/neutral-100 theme)}) {:color (colors/theme-colors colors/white colors/neutral-100 theme)})
(defn icon (defn icon
[theme] [toast-type theme]
{:color (colors/theme-colors colors/white colors/neutral-100 theme) {:color (case toast-type
:negative (colors/resolve-color :danger theme)
:positive (colors/resolve-color :success theme)
:neutral (colors/theme-colors colors/white-opa-40
colors/neutral-80-opa-40
theme))
:container-style {:width 20 :height 20}}) :container-style {:width 20 :height 20}})
(def left-side-container {:padding 2}) (def left-side-container {:padding 2})

View File

@ -69,17 +69,24 @@
(def ^:private toast-container (quo.theme/with-theme toast-container-internal)) (def ^:private toast-container (quo.theme/with-theme toast-container-internal))
(defn toast (defn toast
[{:keys [icon icon-color title text action undo-duration undo-on-press container-style theme user]}] "Options:
(let [context-theme (or theme (quo.theme/get-theme))]
:type => :neutral/:negative/:positive
"
[{:keys [type icon title text action undo-duration undo-on-press container-style theme user]
:or {type :neutral icon :i/placeholder}}]
(let [context-theme (or theme (quo.theme/get-theme))
icon-name (case type
:positive :i/correct
:negative :i/incorrect
:neutral icon)]
[quo.theme/provider {:theme context-theme} [quo.theme/provider {:theme context-theme}
[toast-container [toast-container
{:left (cond icon {:left (cond user
[icon/icon icon [user-avatar/user-avatar user]
(cond-> (style/icon context-theme) icon-name
icon-color [icon/icon icon-name (style/icon type context-theme)]
(assoc :color icon-color))] )
user
[user-avatar/user-avatar user])
:title title :title title
:text text :text text
:right (if undo-duration :right (if undo-duration

View File

@ -1,5 +1,10 @@
(ns quo.core-spec (ns quo.core-spec
(:require (:require ;; [quo.components.list-items.account.component-spec]
;; [quo.components.list-items.address.component-spec]
;; [quo.components.list-items.saved-address.component-spec]
;; [quo.components.list-items.saved-contact-address.component-spec]
;; [quo.components.list-items.saved-contact-address.component-spec]
;; [quo.components.list-items.token-network.component-spec]
[quo.components.avatars.account-avatar.component-spec] [quo.components.avatars.account-avatar.component-spec]
[quo.components.avatars.user-avatar.component-spec] [quo.components.avatars.user-avatar.component-spec]
[quo.components.banners.banner.component-spec] [quo.components.banners.banner.component-spec]

View File

@ -1,6 +1,5 @@
(ns status-im.common.device-permissions (ns status-im.common.device-permissions
(:require (:require
[quo.foundations.colors :as colors]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -12,7 +11,6 @@
:on-allowed on-allowed :on-allowed on-allowed
:on-denied #(rf/dispatch :on-denied #(rf/dispatch
[:toasts/upsert [:toasts/upsert
{:icon :i/info {:type :negative
:icon-color colors/danger-50
:theme :dark :theme :dark
:text (i18n/label :t/camera-permission-denied)}])}])) :text (i18n/label :t/camera-permission-denied)}])}]))

View File

@ -2,7 +2,6 @@
(:require (:require
[clojure.string :as string] [clojure.string :as string]
[quo.core :as quo] [quo.core :as quo]
[quo.foundations.colors :as colors]
[status-im.common.confirmation-drawer.view :as confirmation-drawer] [status-im.common.confirmation-drawer.view :as confirmation-drawer]
[status-im.common.mute-drawer.view :as mute-drawer] [status-im.common.mute-drawer.view :as mute-drawer]
[status-im.common.muting.helpers :refer [format-mute-till]] [status-im.common.muting.helpers :refer [format-mute-till]]
@ -222,9 +221,7 @@
(rf/dispatch [:hide-bottom-sheet]) (rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:toasts/upsert (rf/dispatch [:toasts/upsert
{:id :remove-nickname {:id :remove-nickname
:icon :i/correct :type :positive
:icon-color (colors/theme-colors colors/success-60
colors/success-50)
:text (i18n/label :text (i18n/label
:t/remove-nickname-toast :t/remove-nickname-toast
{:secondary-name secondary-name})}]) {:secondary-name secondary-name})}])

View File

@ -1,6 +1,5 @@
(ns status-im.common.pairing.events (ns status-im.common.pairing.events
(:require (:require
[quo.foundations.colors :as colors]
[status-im.constants :as constants] [status-im.constants :as constants]
[status-im.contexts.communities.discover.events] [status-im.contexts.communities.discover.events]
[taoensso.timbre :as log] [taoensso.timbre :as log]
@ -63,6 +62,5 @@
(and error-on-pairing? (some? error)) (and error-on-pairing? (some? error))
{:dispatch [:toasts/upsert {:dispatch [:toasts/upsert
{:icon :i/alert {:type :negative
:icon-color colors/danger-50
:text error}]})))) :text error}]}))))

View File

@ -141,8 +141,7 @@
(on-failed-scan) (on-failed-scan)
(debounce/debounce-and-dispatch (debounce/debounce-and-dispatch
[:toasts/upsert [:toasts/upsert
{:icon :i/info {:type :negative
:icon-color colors/danger-50
:theme :dark :theme :dark
:text error-message}] :text error-message}]
300))))) 300)))))

View File

@ -1,7 +1,6 @@
(ns status-im.contexts.chat.composer.actions.view (ns status-im.contexts.chat.composer.actions.view
(:require (:require
[quo.core :as quo] [quo.core :as quo]
[quo.foundations.colors :as colors]
[react-native.core :as rn] [react-native.core :as rn]
[react-native.permissions :as permissions] [react-native.permissions :as permissions]
[react-native.platform :as platform] [react-native.platform :as platform]
@ -161,8 +160,7 @@
[] []
(rf/dispatch [:toasts/upsert (rf/dispatch [:toasts/upsert
{:id :random-id {:id :random-id
:icon :info :type :negative
:icon-color colors/danger-50-opa-40
:container-style {:top (when platform/ios? 20)} :container-style {:top (when platform/ios? 20)}
:text (i18n/label :t/only-6-images)}])) :text (i18n/label :t/only-6-images)}]))

View File

@ -3,7 +3,6 @@
[clojure.set :as set] [clojure.set :as set]
[legacy.status-im.chat.models.loading :as loading] [legacy.status-im.chat.models.loading :as loading]
[legacy.status-im.data-store.chats :as chats-store] [legacy.status-im.data-store.chats :as chats-store]
[quo.foundations.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.common.muting.helpers :refer [format-mute-till]] [status-im.common.muting.helpers :refer [format-mute-till]]
@ -350,9 +349,7 @@
:t/channel-unmuted-successfully))))] :t/channel-unmuted-successfully))))]
{:db (assoc-in db [:chats chat-id :muted-till] muted-till) {:db (assoc-in db [:chats chat-id :muted-till] muted-till)
:dispatch [:toasts/upsert :dispatch [:toasts/upsert
{:icon :i/correct {:type :positive
:icon-color (colors/theme-colors colors/success-60
colors/success-50)
:text (mute-duration-text (when (some? muted-till) :text (mute-duration-text (when (some? muted-till)
(str (format-mute-till muted-till))))}]})) (str (format-mute-till muted-till))))}]}))

View File

@ -56,8 +56,7 @@
uri uri
#(rf/dispatch [:toasts/upsert #(rf/dispatch [:toasts/upsert
{:id :random-id {:id :random-id
:icon :i/correct :type :positive
:icon-color colors/success-50
:container-style {:bottom (when platform/android? 20)} :container-style {:bottom (when platform/android? 20)}
:text (i18n/label :t/photo-saved)}])]))}]]])) :text (i18n/label :t/photo-saved)}])]))}]]]))

View File

@ -1,6 +1,5 @@
(ns status-im.contexts.chat.messages.delete-message.events (ns status-im.contexts.chat.messages.delete-message.events
(:require (:require
[quo.foundations.colors :as colors]
[status-im.contexts.chat.messages.list.events :as message-list] [status-im.contexts.chat.messages.list.events :as message-list]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[utils.datetime :as datetime] [utils.datetime :as datetime]
@ -73,9 +72,8 @@
{:events [:chat.ui/delete-message]} {:events [:chat.ui/delete-message]}
[{:keys [db]} {:keys [chat-id message-id]} undo-time-limit-ms] [{:keys [db]} {:keys [chat-id message-id]} undo-time-limit-ms]
(when-let [message (get-in db [:messages chat-id message-id])] (when-let [message (get-in db [:messages chat-id message-id])]
;; all delete message toast are the same toast with id :delete-message-for-everyone ;; all delete message toast are the same toast with id :delete-message-for-everyone new delete
;; new delete operation will reset prev pending deletes' undo timelimit ;; operation will reset prev pending deletes' undo timelimit undo will undo all pending deletes
;; undo will undo all pending deletes
;; all pending deletes are stored in toast ;; all pending deletes are stored in toast
(let [unpin? (should-and-able-to-unpin-to-be-deleted-message (let [unpin? (should-and-able-to-unpin-to-be-deleted-message
db db
@ -107,8 +105,7 @@
[[:toasts/close :delete-message-for-everyone] [[:toasts/close :delete-message-for-everyone]
[:toasts/upsert [:toasts/upsert
{:id :delete-message-for-everyone {:id :delete-message-for-everyone
:icon :i/info :type :negative
:icon-color colors/danger-50-opa-40
:message-deleted-for-everyone-count toast-count :message-deleted-for-everyone-count toast-count
:message-deleted-for-everyone-undos existing-undos :message-deleted-for-everyone-undos existing-undos
:text (i18n/label-pluralize :text (i18n/label-pluralize
@ -164,9 +161,8 @@
(when-let [message (get-in db [:messages chat-id message-id])] (when-let [message (get-in db [:messages chat-id message-id])]
(when (or force? (check-before-delete-and-send db chat-id message-id)) (when (or force? (check-before-delete-and-send db chat-id message-id))
(let [unpin-locally? (let [unpin-locally?
;; this only check against local client data ;; this only check against local client data generally msg is already unpinned at delete
;; generally msg is already unpinned at delete locally phase when user ;; locally phase when user has unpin permission
;; has unpin permission
;; ;;
;; will be true only if ;; will be true only if
;; 1. admin delete an unpinned msg ;; 1. admin delete an unpinned msg

View File

@ -1,6 +1,5 @@
(ns status-im.contexts.chat.messages.delete-message-for-me.events (ns status-im.contexts.chat.messages.delete-message-for-me.events
(:require (:require
[quo.foundations.colors :as colors]
[status-im.contexts.chat.messages.list.events :as message-list] [status-im.contexts.chat.messages.list.events :as message-list]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[utils.datetime :as datetime] [utils.datetime :as datetime]
@ -62,8 +61,7 @@
:dispatch-n [[:toasts/close :delete-message-for-me] :dispatch-n [[:toasts/close :delete-message-for-me]
[:toasts/upsert [:toasts/upsert
{:id :delete-message-for-me {:id :delete-message-for-me
:icon :i/info :type :negative
:icon-color colors/danger-50-opa-40
:message-deleted-for-me-count toast-count :message-deleted-for-me-count toast-count
:message-deleted-for-me-undos existing-undos :message-deleted-for-me-undos existing-undos
:text (i18n/label-pluralize toast-count :text (i18n/label-pluralize toast-count

View File

@ -2,7 +2,6 @@
(:require (:require
[legacy.status-im.data-store.messages :as data-store.messages] [legacy.status-im.data-store.messages :as data-store.messages]
[legacy.status-im.data-store.pin-messages :as data-store.pin-messages] [legacy.status-im.data-store.pin-messages :as data-store.pin-messages]
[quo.foundations.colors :as colors]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.common.toasts.events :as toasts] [status-im.common.toasts.events :as toasts]
[status-im.constants :as constants] [status-im.constants :as constants]
@ -123,8 +122,7 @@
{:events [:pin-message/show-pin-limit-modal]} {:events [:pin-message/show-pin-limit-modal]}
[cofx] [cofx]
(toasts/upsert cofx (toasts/upsert cofx
{:icon :alert {:type :negative
:icon-color colors/danger-50
:text (i18n/label :t/pin-limit-reached)})) :text (i18n/label :t/pin-limit-reached)}))
(rf/defn show-pins-bottom-sheet (rf/defn show-pins-bottom-sheet

View File

@ -1,7 +1,6 @@
(ns status-im.contexts.chat.photo-selector.view (ns status-im.contexts.chat.photo-selector.view
(:require (:require
[quo.core :as quo] [quo.core :as quo]
[quo.foundations.colors :as colors]
[react-native.core :as rn] [react-native.core :as rn]
[react-native.gesture :as gesture] [react-native.gesture :as gesture]
[react-native.linear-gradient :as linear-gradient] [react-native.linear-gradient :as linear-gradient]
@ -22,8 +21,7 @@
[] []
(rf/dispatch [:toasts/upsert (rf/dispatch [:toasts/upsert
{:id :random-id {:id :random-id
:icon :i/info :type :negative
:icon-color colors/danger-50-opa-40
:container-style {:top (when platform/ios? 20)} :container-style {:top (when platform/ios? 20)}
:text (i18n/label :t/only-6-images)}])) :text (i18n/label :t/only-6-images)}]))

View File

@ -1,6 +1,5 @@
(ns status-im.contexts.communities.actions.community-options.events (ns status-im.contexts.communities.actions.community-options.events
(:require [quo.foundations.colors :as quo.colors] (:require [status-im.common.muting.helpers :as muting.helpers]
[status-im.common.muting.helpers :as muting.helpers]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -26,8 +25,7 @@
{:db (assoc-in db [:communities community-id :muted-till] muted-till) {:db (assoc-in db [:communities community-id :muted-till] muted-till)
:dispatch-n [[:community/update-community-chats-mute-status community-id muted? muted-till] :dispatch-n [[:community/update-community-chats-mute-status community-id muted? muted-till]
[:toasts/upsert [:toasts/upsert
{:icon :correct {:type :positive
:icon-color (quo.colors/theme-colors quo.colors/success-60 quo.colors/success-50)
:text (if muted? :text (if muted?
(when (some? muted-till) (when (some? muted-till)
(time-string :t/muted-until (time-string :t/muted-until

View File

@ -1,6 +1,5 @@
(ns status-im.contexts.communities.actions.leave.events (ns status-im.contexts.communities.actions.leave.events
(:require [legacy.status-im.ui.components.colors :as colors] (:require [taoensso.timbre :as log]
[taoensso.timbre :as log]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -9,8 +8,7 @@
{:fx [[:dispatch [:sanitize-messages-and-process-response response-js]] {:fx [[:dispatch [:sanitize-messages-and-process-response response-js]]
[:dispatch [:dispatch
[:toasts/upsert [:toasts/upsert
{:icon :correct {:type :positive
:icon-color (:positive-01 @colors/theme)
:text (i18n/label :t/you-canceled-the-request)}]]]})) :text (i18n/label :t/you-canceled-the-request)}]]]}))
(rf/reg-event-fx :communities/cancel-request-to-join (rf/reg-event-fx :communities/cancel-request-to-join
@ -28,8 +26,7 @@
{:fx [[:dispatch [:sanitize-messages-and-process-response response-js]] {:fx [[:dispatch [:sanitize-messages-and-process-response response-js]]
[:dispatch [:dispatch
[:toasts/upsert [:toasts/upsert
{:icon :correct {:type :positive
:icon-color (:positive-01 @colors/theme)
:text (i18n/label :t/left-community {:community community-name})}]] :text (i18n/label :t/left-community {:community community-name})}]]
[:dispatch [:activity-center.notifications/fetch-unread-count]] [:dispatch [:activity-center.notifications/fetch-unread-count]]
[:dispatch [:navigate-back]]]}))) [:dispatch [:navigate-back]]]})))

View File

@ -1,7 +1,6 @@
(ns status-im.contexts.communities.events (ns status-im.contexts.communities.events
(:require [clojure.set :as set] (:require [clojure.set :as set]
[clojure.walk :as walk] [clojure.walk :as walk]
[legacy.status-im.ui.components.colors :as colors]
[status-im.constants :as constants] [status-im.constants :as constants]
status-im.contexts.communities.actions.community-options.events status-im.contexts.communities.actions.community-options.events
status-im.contexts.communities.actions.leave.events status-im.contexts.communities.actions.leave.events
@ -93,9 +92,8 @@
(assoc-in db [:communities/my-pending-requests-to-join community-id] request) (assoc-in db [:communities/my-pending-requests-to-join community-id] request)
(and (= constants/community-request-to-join-state-accepted state) (not deleted)) (and (= constants/community-request-to-join-state-accepted state) (not deleted))
(do (rf/dispatch [:toasts/upsert (do (rf/dispatch [:toasts/upsert
{:icon :i/correct {:id :joined-community
:id :joined-community :type :positive
:icon-color (:positive-01 @colors/theme)
:text (i18n/label :t/joined-community {:community name})}]) :text (i18n/label :t/joined-community {:community name})}])
(update-in db [:communities/my-pending-requests-to-join] dissoc community-id)) (update-in db [:communities/my-pending-requests-to-join] dissoc community-id))
:else (update-in db [:communities/my-pending-requests-to-join] dissoc community-id)))) :else (update-in db [:communities/my-pending-requests-to-join] dissoc community-id))))

View File

@ -1,7 +1,6 @@
(ns status-im.contexts.communities.overview.events (ns status-im.contexts.communities.overview.events
(:require (:require
[legacy.status-im.data-store.communities :as data-store] [legacy.status-im.data-store.communities :as data-store]
[legacy.status-im.ui.components.colors :as colors]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -104,8 +103,7 @@
[:dispatch [:hide-bottom-sheet]] [:dispatch [:hide-bottom-sheet]]
[:dispatch [:dispatch
[:toasts/upsert [:toasts/upsert
{:icon :correct {:type :positive
:icon-color (:positive-01 @colors/theme)
:text (i18n/label :text (i18n/label
:t/requested-to-join-community :t/requested-to-join-community
{:community community-name})}]]]}))) {:community community-name})}]]]})))

View File

@ -17,8 +17,7 @@
(rf/dispatch [:hide-bottom-sheet]) (rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:toasts/upsert (rf/dispatch [:toasts/upsert
{:id :add-nickname {:id :add-nickname
:icon :i/correct :type :positive
:icon-color (colors/theme-colors colors/success-60 colors/success-50)
:text (i18n/label :text (i18n/label
:t/set-nickname-toast :t/set-nickname-toast
{:primary-name primary-name {:primary-name primary-name

View File

@ -1,7 +1,6 @@
(ns status-im.contexts.quo-preview.notifications.toast (ns status-im.contexts.quo-preview.notifications.toast
(:require (:require
[quo.core :as quo] [quo.core :as quo]
[quo.foundations.colors :as colors]
[react-native.core :as rn] [react-native.core :as rn]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.common.resources :as resources] [status-im.common.resources :as resources]
@ -25,21 +24,19 @@
[] []
[toast-button [toast-button
"Toast: basic" "Toast: basic"
{:icon :placeholder :icon-color "white" :text "This is an example toast"}]) {:text "This is an example toast"}])
(defn toast-button-with-undo-action (defn toast-button-with-undo-action
[] []
[toast-button [toast-button
"Toast: with undo action" "Toast: with undo action"
{:icon :info {:type :negative
:icon-color colors/danger-50-opa-40
:text "This is an example toast" :text "This is an example toast"
:duration 4000 :duration 4000
:undo-duration 4 :undo-duration 4
:undo-on-press #(do :undo-on-press #(do
(rf/dispatch [:toasts/upsert (rf/dispatch [:toasts/upsert
{:icon :i/correct {:type :positive
:icon-color colors/success-50-opa-40
:text "Undo pressed"}]) :text "Undo pressed"}])
(rf/dispatch [:toasts/close (rf/dispatch [:toasts/close
"Toast: with undo action"]))}]) "Toast: with undo action"]))}])
@ -48,8 +45,7 @@
[] []
[toast-button [toast-button
"Toast: multiline" "Toast: multiline"
{:icon :correct {:type :positive
:icon-color colors/success-50-opa-40
:text :text
"This is an example multiline toast This is an example multiline toast This is an example multiline toast" "This is an example multiline toast This is an example multiline toast This is an example multiline toast"
:undo-duration 4 :undo-duration 4
@ -57,15 +53,14 @@
#(do #(do
(rf/dispatch (rf/dispatch
[:toasts/upsert [:toasts/upsert
{:icon :i/correct :icon-color colors/success-50-opa-40 :text "Undo pressed"}]) {:type :positive :text "Undo pressed"}])
(rf/dispatch [:toasts/close "Toast: with undo action"]))}]) (rf/dispatch [:toasts/close "Toast: with undo action"]))}])
(defn toast-button-30s-duration (defn toast-button-30s-duration
[] []
[toast-button [toast-button
"Toast: 30s duration" "Toast: 30s duration"
{:icon :correct {:type :positive
:icon-color colors/success-50-opa-40
:text "This is an example toast" :text "This is an example toast"
:duration 30000}]) :duration 30000}])
@ -90,8 +85,7 @@
#(rf/dispatch #(rf/dispatch
[:toasts/upsert [:toasts/upsert
{:id "Toast: 30s duration" {:id "Toast: 30s duration"
:icon :i/info :type :negative
:icon-color colors/danger-50-opa-40
:text (str "This is an updated example toast" " - " (swap! suffix inc)) :text (str "This is an updated example toast" " - " (swap! suffix inc))
:duration 3000}])} :duration 3000}])}
"update above toast"]]))))) "update above toast"]])))))

View File

@ -1,6 +1,5 @@
(ns status-im.contexts.shell.share.events (ns status-im.contexts.shell.share.events
(:require (:require
[quo.foundations.colors :as colors]
[status-im.common.toasts.events :as toasts] [status-im.common.toasts.events :as toasts]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -10,8 +9,7 @@
(rf/merge cofx (rf/merge cofx
{:copy-to-clipboard text-to-copy} {:copy-to-clipboard text-to-copy}
(toasts/upsert (toasts/upsert
{:icon :correct {:id :successful-copy-toast-message
:id :successful-copy-toast-message :type :positive
:icon-color colors/success-50
:override-theme :dark :override-theme :dark
:text post-copy-message}))) :text post-copy-message})))

View File

@ -69,8 +69,7 @@
@sync-code-value] @sync-code-value]
300) 300)
(rf/dispatch [:toasts/upsert (rf/dispatch [:toasts/upsert
{:icon :i/info {:type :negative
:icon-color colors/danger-50
:theme :dark :theme :dark
:text (i18n/label :text (i18n/label
:t/error-this-is-not-a-sync-qr-code)}])))} :t/error-this-is-not-a-sync-qr-code)}])))}

View File

@ -4,7 +4,6 @@
[legacy.status-im.data-store.settings :as data-store.settings] [legacy.status-im.data-store.settings :as data-store.settings]
[legacy.status-im.node.core :as node] [legacy.status-im.node.core :as node]
[native-module.core :as native-module] [native-module.core :as native-module]
[quo.foundations.colors :as colors]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[react-native.platform :as platform] [react-native.platform :as platform]
[status-im.config :as config] [status-im.config :as config]
@ -52,8 +51,7 @@
(str "generic-error: " res))] (str "generic-error: " res))]
(when (some? error) (when (some? error)
(rf/dispatch [:toasts/upsert (rf/dispatch [:toasts/upsert
{:icon :i/alert {:type :negative
:icon-color colors/danger-50
:text error}])))) :text error}]))))
(rf/defn preflight-outbound-check-for-local-pairing (rf/defn preflight-outbound-check-for-local-pairing

View File

@ -232,8 +232,7 @@
(on-failed-scan) (on-failed-scan)
(debounce/debounce-and-dispatch (debounce/debounce-and-dispatch
[:toasts/upsert [:toasts/upsert
{:icon :i/info {:type :negative
:icon-color colors/danger-50
:theme :dark :theme :dark
:text (i18n/label :t/error-this-is-not-a-sync-qr-code)}] :text (i18n/label :t/error-this-is-not-a-sync-qr-code)}]
300))))) 300)))))

View File

@ -109,8 +109,7 @@
{:on-press (fn [] {:on-press (fn []
(clipboard/set-string @code) (clipboard/set-string @code)
(rf/dispatch [:toasts/upsert (rf/dispatch [:toasts/upsert
{:icon :correct {:type :positive
:icon-color colors/success-50
:text (i18n/label :text (i18n/label
:t/sharing-copied-to-clipboard)}])) :t/sharing-copied-to-clipboard)}]))
:type :grey :type :grey

View File

@ -70,8 +70,7 @@
:label (i18n/label :t/copy-address) :label (i18n/label :t/copy-address)
:on-press (fn [] :on-press (fn []
(rf/dispatch [:toasts/upsert (rf/dispatch [:toasts/upsert
{:icon :i/correct {:type :positive
:icon-color (colors/resolve-color :success theme)
:text (i18n/label :t/address-copied)}]) :text (i18n/label :t/address-copied)}])
(clipboard/set-string address))} (clipboard/set-string address))}
{:icon :i/share {:icon :i/share

View File

@ -1,7 +1,5 @@
(ns status-im.contexts.wallet.edit-account.view (ns status-im.contexts.wallet.edit-account.view
(:require [quo.core :as quo] (:require [quo.core :as quo]
[quo.foundations.colors :as colors]
[quo.theme :as quo.theme]
[react-native.core :as rn] [react-native.core :as rn]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.contexts.wallet.common.screen-base.create-or-edit-account.view [status-im.contexts.wallet.common.screen-base.create-or-edit-account.view
@ -13,7 +11,7 @@
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
(defn- show-save-account-toast (defn- show-save-account-toast
[updated-key theme] [updated-key]
(let [message (case updated-key (let [message (case updated-key
:name :t/edit-wallet-account-name-updated-message :name :t/edit-wallet-account-name-updated-message
:color :t/edit-wallet-account-colour-updated-message :color :t/edit-wallet-account-colour-updated-message
@ -22,39 +20,34 @@
nil)] nil)]
(rf/dispatch [:toasts/upsert (rf/dispatch [:toasts/upsert
{:id :edit-account {:id :edit-account
:icon :i/correct :type :positive
:icon-color (colors/resolve-color :success theme)
:text (i18n/label message)}]))) :text (i18n/label message)}])))
(defn- save-account (defn- save-account
[{:keys [account updated-key new-value theme]}] [{:keys [account updated-key new-value]}]
(let [edited-account-data (assoc account updated-key new-value)] (let [edited-account-data (assoc account updated-key new-value)]
(rf/dispatch [:wallet/save-account (rf/dispatch [:wallet/save-account
{:account edited-account-data {:account edited-account-data
:on-success #(show-save-account-toast updated-key theme)}]))) :on-success #(show-save-account-toast updated-key)}])))
(defn- view-internal (def view
[{:keys [theme]}]
(let [edited-account-name (reagent/atom nil) (let [edited-account-name (reagent/atom nil)
show-confirm-button? (reagent/atom false) show-confirm-button? (reagent/atom false)
on-change-color (fn [edited-color {:keys [color] :as account}] on-change-color (fn [edited-color {:keys [color] :as account}]
(when (not= edited-color color) (when (not= edited-color color)
(save-account {:account account (save-account {:account account
:updated-key :color :updated-key :color
:new-value edited-color :new-value edited-color})))
:theme theme})))
on-change-emoji (fn [edited-emoji {:keys [emoji] :as account}] on-change-emoji (fn [edited-emoji {:keys [emoji] :as account}]
(when (not= edited-emoji emoji) (when (not= edited-emoji emoji)
(save-account {:account account (save-account {:account account
:updated-key :emoji :updated-key :emoji
:new-value edited-emoji :new-value edited-emoji})))
:theme theme})))
on-confirm-name (fn [account] on-confirm-name (fn [account]
(rn/dismiss-keyboard!) (rn/dismiss-keyboard!)
(save-account {:account account (save-account {:account account
:updated-key :name :updated-key :name
:new-value @edited-account-name :new-value @edited-account-name}))]
:theme theme}))]
(fn [] (fn []
(let [{:keys [name emoji address color] :as account} (rf/sub [:wallet/current-viewing-account]) (let [{:keys [name emoji address color] :as account} (rf/sub [:wallet/current-viewing-account])
network-details (rf/sub [:wallet/network-preference-details]) network-details (rf/sub [:wallet/network-preference-details])
@ -102,8 +95,5 @@
(save-account (save-account
{:account account {:account account
:updated-key :prod-preferred-chain-ids :updated-key :prod-preferred-chain-ids
:new-value chain-ids :new-value chain-ids}))}])}]))
:theme theme}))}])}]))
:container-style style/data-item}]])))) :container-style style/data-item}]]))))
(def view (quo.theme/with-theme view-internal))

View File

@ -3,7 +3,6 @@
[camel-snake-kebab.core :as csk] [camel-snake-kebab.core :as csk]
[camel-snake-kebab.extras :as cske] [camel-snake-kebab.extras :as cske]
[clojure.string :as string] [clojure.string :as string]
[quo.foundations.colors :as colors]
[react-native.background-timer :as background-timer] [react-native.background-timer :as background-timer]
[status-im.common.data-store.wallet :as data-store] [status-im.common.data-store.wallet :as data-store]
[status-im.contexts.wallet.item-types :as item-types] [status-im.contexts.wallet.item-types :as item-types]
@ -24,8 +23,7 @@
:fx [[:dispatch :fx [[:dispatch
[:toasts/upsert [:toasts/upsert
{:id :new-wallet-account-created {:id :new-wallet-account-created
:icon :i/correct :type :positive
:icon-color colors/success-50
:text (i18n/label :t/account-created {:name (:name account)})}]]]}))) :text (i18n/label :t/account-created {:name (:name account)})}]]]})))
(rf/reg-event-fx :wallet/navigate-to-account (rf/reg-event-fx :wallet/navigate-to-account