|
4 | 4 | [quo2.components.markdown.text :as text]
|
5 | 5 | [quo2.components.notifications.count-down-circle :as count-down-circle]
|
6 | 6 | [quo2.components.notifications.toast.style :as style]
|
7 |
| - [quo2.theme :as theme] |
| 7 | + [quo2.theme :as quo.theme] |
8 | 8 | [react-native.blur :as blur]
|
9 | 9 | [react-native.core :as rn]
|
10 | 10 | [utils.i18n :as i18n]))
|
11 | 11 |
|
12 | 12 | (defn toast-action-container
|
13 |
| - [{:keys [on-press style]} & children] |
| 13 | + [{:keys [on-press style theme]} & children] |
14 | 14 | [rn/touchable-highlight
|
15 | 15 | {:on-press on-press
|
16 | 16 | :underlay-color :transparent}
|
17 | 17 | [into
|
18 | 18 | [rn/view
|
19 |
| - {:style (merge (style/action-container (theme/get-theme)) style)}] |
| 19 | + {:style (merge (style/action-container theme) style)}] |
20 | 20 | children]])
|
21 | 21 |
|
22 |
| -(defn toast-undo-action |
23 |
| - [duration on-press theme] |
24 |
| - [toast-action-container {:on-press on-press :accessibility-label :toast-undo-action} |
| 22 | +(defn toast-undo-action-internal |
| 23 | + [{:keys [undo-duration undo-on-press theme]}] |
| 24 | + [toast-action-container |
| 25 | + {:on-press undo-on-press |
| 26 | + :accessibility-label :toast-undo-action |
| 27 | + :theme theme} |
25 | 28 | [rn/view {:style {:margin-right 5}}
|
26 |
| - [count-down-circle/circle-timer {:duration duration}]] |
| 29 | + [count-down-circle/circle-timer {:duration undo-duration}]] |
27 | 30 | [text/text
|
28 |
| - {:size :paragraph-2 :weight :medium :style (style/text theme)} |
| 31 | + {:size :paragraph-2 |
| 32 | + :weight :medium |
| 33 | + :style (style/text theme)} |
29 | 34 | [i18n/label :t/undo]]])
|
30 | 35 |
|
31 |
| -(defn- toast-container |
| 36 | +(def ^:private toast-undo-action (quo.theme/with-theme toast-undo-action-internal)) |
| 37 | + |
| 38 | +(defn- toast-container-internal |
32 | 39 | [{:keys [left title text right container-style theme]}]
|
33 | 40 | [rn/view {:style (merge style/box-container container-style)}
|
34 | 41 | [blur/view
|
|
58 | 65 | text])]
|
59 | 66 | right]])
|
60 | 67 |
|
| 68 | +(def ^:private toast-container (quo.theme/with-theme toast-container-internal)) |
| 69 | + |
61 | 70 | (defn toast
|
62 | 71 | [{:keys [icon icon-color title text action undo-duration undo-on-press container-style
|
63 | 72 | theme user]}]
|
64 |
| - [toast-container |
65 |
| - {:left (cond icon |
66 |
| - [icon/icon icon |
67 |
| - (cond-> (style/icon theme) |
68 |
| - icon-color |
69 |
| - (assoc :color icon-color))] |
| 73 | + (let [context-theme (or theme (quo.theme/get-theme))] |
| 74 | + [quo.theme/provider {:theme context-theme} |
| 75 | + [toast-container |
| 76 | + {:left (cond icon |
| 77 | + [icon/icon icon |
| 78 | + (cond-> (style/icon context-theme) |
| 79 | + icon-color |
| 80 | + (assoc :color icon-color))] |
70 | 81 |
|
71 |
| - user |
72 |
| - [user-avatar/user-avatar user]) |
73 |
| - :title title |
74 |
| - :text text |
75 |
| - :right (if undo-duration |
76 |
| - [toast-undo-action undo-duration undo-on-press theme] |
77 |
| - action) |
78 |
| - :container-style container-style |
79 |
| - :theme theme}]) |
| 82 | + user |
| 83 | + [user-avatar/user-avatar user]) |
| 84 | + :title title |
| 85 | + :text text |
| 86 | + :right (if undo-duration |
| 87 | + [toast-undo-action |
| 88 | + {:undo-duration undo-duration |
| 89 | + :undo-on-press undo-on-press}] |
| 90 | + action) |
| 91 | + :container-style container-style}]])) |
0 commit comments