-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#18453] fix: address reviewer feedbacks
- Loading branch information
1 parent
1fb6c60
commit 9b7b88c
Showing
11 changed files
with
176 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/status_im/contexts/profile/edit/accent_colour/events.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(ns status-im.contexts.profile.edit.accent-colour.events | ||
(:require [taoensso.timbre :as log] | ||
[utils.i18n :as i18n] | ||
[utils.re-frame :as rf])) | ||
|
||
(rf/reg-event-fx :profile/edit-accent-colour-success | ||
(fn [_] | ||
{:fx [[:dispatch [:navigate-back]] | ||
[:dispatch | ||
[:toasts/upsert | ||
{:type :positive | ||
:theme :dark | ||
:text (i18n/label :t/accent-colour-updated)}]]]})) | ||
|
||
(defn edit-accent-colour | ||
[{:keys [db]} [customization-color]] | ||
(let [key-uid (get-in db [:profile/profile :key-uid])] | ||
{:db (assoc-in db [:profile/profile :customization-color] customization-color) | ||
:fx [[:json-rpc/call | ||
[{:method "wakuext_setCustomizationColor" | ||
:params [{:customizationColor customization-color | ||
:keyUid key-uid}] | ||
:on-success [:profile/edit-accent-colour-success] | ||
:on-error #(log/error "failed to edit accent color." {:error %})}]]]})) | ||
|
||
(rf/reg-event-fx :profile/edit-accent-colour edit-accent-colour) |
17 changes: 17 additions & 0 deletions
17
src/status_im/contexts/profile/edit/accent_colour/events_test.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(ns status-im.contexts.profile.edit.accent-colour.events-test | ||
(:require [cljs.test :refer [deftest is]] | ||
matcher-combinators.test | ||
[status-im.contexts.profile.edit.accent-colour.events :as sut])) | ||
|
||
(deftest edit-accent-color-test | ||
(let [new-color :yellow | ||
key-uid "key-uid" | ||
cofx {:db {:profile/profile {:key-uid key-uid}}} | ||
expected {:fx [[:json-rpc/call | ||
[{:method "wakuext_setCustomizationColor" | ||
:params [{:customizationColor new-color | ||
:keyUid key-uid}] | ||
:on-success [:profile/edit-accent-colour-success] | ||
:on-error fn?}]]]}] | ||
(is (match? expected | ||
(sut/edit-accent-colour cofx [new-color]))))) |
27 changes: 27 additions & 0 deletions
27
src/status_im/contexts/profile/edit/accent_colour/style.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(ns status-im.contexts.profile.edit.accent-colour.style | ||
(:require [quo.foundations.colors :as colors])) | ||
|
||
(defn page-wrapper | ||
[insets] | ||
{:padding-top (:top insets) | ||
:padding-bottom (:bottom insets) | ||
:padding-horizontal 1 | ||
:flex 1}) | ||
|
||
(def screen-container | ||
{:flex 1 | ||
:padding-top 14 | ||
:padding-horizontal 20 | ||
:justify-content :space-between}) | ||
|
||
(def color-title | ||
{:color colors/white-70-blur | ||
:margin-top 20 | ||
:margin-bottom 16}) | ||
|
||
(def button-wrapper | ||
{:margin-vertical 12}) | ||
|
||
(def profile-card | ||
{:margin-top 22 | ||
:margin-bottom 5}) |
65 changes: 65 additions & 0 deletions
65
src/status_im/contexts/profile/edit/accent_colour/view.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
(ns status-im.contexts.profile.edit.accent-colour.view | ||
(:require [quo.core :as quo] | ||
[react-native.core :as rn] | ||
[react-native.safe-area :as safe-area] | ||
[reagent.core :as reagent] | ||
[status-im.constants :as constants] | ||
[status-im.contexts.profile.edit.accent-colour.style :as style] | ||
[status-im.contexts.profile.utils :as profile.utils] | ||
[utils.i18n :as i18n] | ||
[utils.re-frame :as rf] | ||
[utils.responsiveness :as responsiveness])) | ||
|
||
(defn f-view | ||
[{:keys [customization-color]}] | ||
(let [insets (safe-area/get-insets) | ||
{window-width :width} (rn/get-window) | ||
unsaved-custom-color (reagent/atom customization-color constants/profile-default-color) | ||
on-change #(reset! unsaved-custom-color %)] | ||
(fn [{:keys [customization-color]}] | ||
(let [profile (rf/sub [:profile/profile-with-image]) | ||
profile-picture (profile.utils/photo profile) | ||
display-name (profile.utils/displayed-name profile)] | ||
(rn/use-effect | ||
#(on-change customization-color) | ||
[customization-color]) | ||
[quo/overlay | ||
{:type :shell | ||
:container-style (style/page-wrapper insets)} | ||
[quo/page-nav | ||
{:key :header | ||
:background :blur | ||
:icon-name :i/arrow-left | ||
:on-press #(rf/dispatch [:navigate-back])}] | ||
[rn/view | ||
{:key :content | ||
:style style/screen-container} | ||
[rn/view {:style {:flex 1}} | ||
[quo/text-combinations {:title (i18n/label :t/accent-colour)}] | ||
[quo/profile-card | ||
{:profile-picture profile-picture | ||
:name display-name | ||
:card-style style/profile-card | ||
:customization-color @unsaved-custom-color}] | ||
[quo/text | ||
{:size :paragraph-2 | ||
:weight :medium | ||
:style style/color-title} | ||
(i18n/label :t/accent-colour)] | ||
[quo/color-picker | ||
{:blur? true | ||
:default-selected @unsaved-custom-color | ||
:on-change on-change | ||
:window-width window-width}]] | ||
[rn/view {:style style/button-wrapper} | ||
[quo/button | ||
{:type :primary | ||
:customization-color @unsaved-custom-color | ||
:on-press (fn [] | ||
(rf/dispatch [:profile/edit-accent-colour @unsaved-custom-color]))} | ||
(i18n/label :t/save-colour)]]]])))) | ||
|
||
(defn view | ||
[] | ||
(let [customization-color (rf/sub [:profile/customization-color])] | ||
[:f> f-view {:customization-color customization-color}])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters