From 9122719830aef5b6fbea66ecaf0393f93a77a2a3 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Thu, 19 Dec 2024 12:46:14 -0600 Subject: [PATCH 01/22] Add `buttons-style` prop to bottom actions to allow same button dimensions --- src/quo/components/drawers/bottom_actions/view.cljs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/quo/components/drawers/bottom_actions/view.cljs b/src/quo/components/drawers/bottom_actions/view.cljs index 320d17ef163..c9e13b496b8 100644 --- a/src/quo/components/drawers/bottom_actions/view.cljs +++ b/src/quo/components/drawers/bottom_actions/view.cljs @@ -31,7 +31,8 @@ [:scroll? {:optional true} [:maybe :boolean]] [:blur? {:optional true} [:maybe :boolean]] [:container-style {:optional true} [:maybe :map]] - [:buttons-container-style {:optional true} [:maybe :map]]]]] + [:buttons-container-style {:optional true} [:maybe :map]] + [:buttons-style {:optional true} [:maybe :map]]]]] :any]) (def ^:private role-icon @@ -43,10 +44,9 @@ (defn- view-internal [{:keys [actions description description-text description-top-text error-message role button-one-label button-two-label blur? button-one-props button-two-props scroll? container-style - buttons-container-style context-tag-props]}] + buttons-container-style buttons-style context-tag-props]}] (let [theme (quo.theme/use-theme)] - [rn/view - {:style (merge (style/container scroll? blur? theme) container-style)} + [rn/view {:style (merge (style/container scroll? blur? theme) container-style)} (when (= description :top-error) [rn/view {:style style/error-message} [icon/icon @@ -82,7 +82,7 @@ [button/button (merge {:size 40 - :container-style style/button-container + :container-style (merge style/button-container buttons-style) :background (when (or blur? scroll?) :blur) :theme theme :accessibility-label :button-two} @@ -91,7 +91,7 @@ [button/button (merge {:size 40 - :container-style style/button-container + :container-style (merge style/button-container buttons-style) :background (when (or blur? scroll?) :blur) :theme theme :accessibility-label :button-one} From 40bdd5424bde9ed1050475064b05a09c7a505acb Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Fri, 20 Dec 2024 17:03:09 -0600 Subject: [PATCH 02/22] Make events to update a profile more generic --- .../profile/edit/accent_colour/events.cljs | 25 ++++++----- .../profile/edit/accent_colour/view.cljs | 3 +- .../contexts/profile/edit/header/events.cljs | 42 +++++++++++-------- .../contexts/profile/edit/header/view.cljs | 2 +- .../contexts/profile/edit/name/events.cljs | 29 +++++++------ .../contexts/profile/edit/name/view.cljs | 2 +- 6 files changed, 60 insertions(+), 43 deletions(-) diff --git a/src/status_im/contexts/profile/edit/accent_colour/events.cljs b/src/status_im/contexts/profile/edit/accent_colour/events.cljs index 8ce5ec7298d..3bc263384ba 100644 --- a/src/status_im/contexts/profile/edit/accent_colour/events.cljs +++ b/src/status_im/contexts/profile/edit/accent_colour/events.cljs @@ -4,27 +4,32 @@ [utils.re-frame :as rf])) (rf/reg-event-fx :profile/edit-accent-colour-success - (fn [_ [customization-color]] + (fn [_ [customization-color navigate-back? show-toast?]] {:fx [[:dispatch [:profile/save-local-accent-color customization-color]] - [:dispatch [:navigate-back]] - [:dispatch - [:toasts/upsert - {:type :positive - :theme :dark - :text (i18n/label :t/accent-colour-updated)}]]]})) + (when navigate-back? + [:dispatch [:navigate-back]]) + (when show-toast? + [:dispatch + [:toasts/upsert + {:type :positive + :theme :dark + :text (i18n/label :t/accent-colour-updated)}]])]})) (rf/reg-event-fx :profile/save-local-accent-color (fn [{:keys [db]} [customization-color]] {:db (assoc-in db [:profile/profile :customization-color] customization-color)})) (defn edit-accent-colour - [{:keys [db]} [customization-color]] + [{:keys [db]} + [{:keys [color navigate-back? show-toast?] + :or {navigate-back? true + show-toast? true}}]] (let [key-uid (get-in db [:profile/profile :key-uid])] {:fx [[:json-rpc/call [{:method "wakuext_setCustomizationColor" - :params [{:customizationColor customization-color + :params [{:customizationColor color :keyUid key-uid}] - :on-success [:profile/edit-accent-colour-success customization-color] + :on-success [:profile/edit-accent-colour-success color navigate-back? show-toast?] :on-error #(log/error "failed to edit accent color." {:error %})}]]]})) (rf/reg-event-fx :profile/edit-accent-colour edit-accent-colour) diff --git a/src/status_im/contexts/profile/edit/accent_colour/view.cljs b/src/status_im/contexts/profile/edit/accent_colour/view.cljs index b64648c78f1..8ed57cadc88 100644 --- a/src/status_im/contexts/profile/edit/accent_colour/view.cljs +++ b/src/status_im/contexts/profile/edit/accent_colour/view.cljs @@ -58,7 +58,8 @@ {:type :primary :customization-color @unsaved-custom-color :on-press (fn [] - (rf/dispatch [:profile/edit-accent-colour @unsaved-custom-color]))} + (rf/dispatch [:profile/edit-accent-colour + {:color @unsaved-custom-color}]))} (i18n/label :t/save-colour)]]]])))) (defn view diff --git a/src/status_im/contexts/profile/edit/header/events.cljs b/src/status_im/contexts/profile/edit/header/events.cljs index 5e1f787ca31..ca826bc92e0 100644 --- a/src/status_im/contexts/profile/edit/header/events.cljs +++ b/src/status_im/contexts/profile/edit/header/events.cljs @@ -11,19 +11,22 @@ (update db :profile/profile dissoc :images))})) (rf/reg-event-fx :profile/edit-profile-picture-success - (fn [_ [images]] + (fn [_ [show-toast? images]] (let [has-picture? (rf/sub [:profile/has-picture])] {:fx [[:dispatch [:profile/update-local-picture (reverse images)]] - [:dispatch - [:toasts/upsert - {:type :positive - :theme :dark - :text (i18n/label (if has-picture? - :t/profile-picture-updated - :t/profile-picture-added))}]]]}))) + (when show-toast? + [:dispatch + [:toasts/upsert + {:type :positive + :theme :dark + :text (i18n/label (if has-picture? + :t/profile-picture-updated + :t/profile-picture-added))}]])]}))) (defn edit-profile-picture - [{:keys [db]} [picture crop-width crop-height]] + [{:keys [db]} + [{:keys [picture crop-width crop-height show-toast?] + :or {show-toast? true}}]] (let [key-uid (get-in db [:profile/profile :key-uid]) crop-width (or crop-width profile-picture-picker/crop-size) crop-height (or crop-height profile-picture-picker/crop-size) @@ -31,25 +34,28 @@ {:fx [[:json-rpc/call [{:method "multiaccounts_storeIdentityImage" :params [key-uid path 0 0 crop-width crop-height] - :on-success [:profile/edit-profile-picture-success]}]]]})) + :on-success [:profile/edit-profile-picture-success show-toast?]}]]]})) (rf/reg-event-fx :profile/edit-picture edit-profile-picture) (rf/reg-event-fx :profile/delete-profile-picture-success - (fn [_] + (fn [_ [show-toast?]] {:fx [[:dispatch [:profile/update-local-picture nil]] - [:dispatch - [:toasts/upsert - {:type :positive - :theme :dark - :text (i18n/label :t/profile-picture-removed)}]]]})) + (when show-toast? + [:dispatch + [:toasts/upsert + {:type :positive + :theme :dark + :text (i18n/label :t/profile-picture-removed)}]])]})) (defn delete-profile-picture - [{:keys [db]}] + [{:keys [db]} + [{:keys [show-toast?] + :or {show-toast? true}}]] (let [key-uid (get-in db [:profile/profile :key-uid])] {:fx [[:json-rpc/call [{:method "multiaccounts_deleteIdentityImage" :params [key-uid] - :on-success [:profile/delete-profile-picture-success]}]]]})) + :on-success [:profile/delete-profile-picture-success show-toast?]}]]]})) (rf/reg-event-fx :profile/delete-picture delete-profile-picture) diff --git a/src/status_im/contexts/profile/edit/header/view.cljs b/src/status_im/contexts/profile/edit/header/view.cljs index 8aa42a98bab..981d71de509 100644 --- a/src/status_im/contexts/profile/edit/header/view.cljs +++ b/src/status_im/contexts/profile/edit/header/view.cljs @@ -16,7 +16,7 @@ has-picture? (rf/sub [:profile/has-picture]) on-change-profile-pic (fn [picture] (if picture - (rf/dispatch [:profile/edit-picture picture]) + (rf/dispatch [:profile/edit-picture {:picture picture}]) (rf/dispatch [:profile/delete-picture])))] [rn/view {:key :edit-profile diff --git a/src/status_im/contexts/profile/edit/name/events.cljs b/src/status_im/contexts/profile/edit/name/events.cljs index c69b2608320..e651769da1a 100644 --- a/src/status_im/contexts/profile/edit/name/events.cljs +++ b/src/status_im/contexts/profile/edit/name/events.cljs @@ -5,21 +5,26 @@ [utils.re-frame :as rf])) (rf/reg-event-fx :profile/edit-profile-name-success - (fn [_] - {:fx [[:dispatch [:navigate-back]] - [:dispatch - [:toasts/upsert - {:type :positive - :theme :dark - :text (i18n/label :t/name-updated)}]]]})) + (fn [{:keys [db]} [display-name navigate-back? show-toast?]] + {:db (assoc-in db [:profile/profile :display-name] display-name) + :fx [(when navigate-back? + [:dispatch [:navigate-back]]) + (when show-toast? + [:dispatch + [:toasts/upsert + {:type :positive + :theme :dark + :text (i18n/label :t/name-updated)}]])]})) (defn edit-profile-name - [{:keys [db]} [name]] - {:db (assoc-in db [:profile/profile :display-name] name) - :fx [[:json-rpc/call + [_ + [{:keys [display-name navigate-back? show-toast?] + :or {navigate-back? true + show-toast? true}}]] + {:fx [[:json-rpc/call [{:method "wakuext_setDisplayName" - :params [name] - :on-success [:profile/edit-profile-name-success]}]]]}) + :params [display-name] + :on-success [:profile/edit-profile-name-success display-name navigate-back? show-toast?]}]]]}) (rf/reg-event-fx :profile/edit-name edit-profile-name) diff --git a/src/status_im/contexts/profile/edit/name/view.cljs b/src/status_im/contexts/profile/edit/name/view.cljs index 4d98c7dad6f..b891c10d0a8 100644 --- a/src/status_im/contexts/profile/edit/name/view.cljs +++ b/src/status_im/contexts/profile/edit/name/view.cljs @@ -67,7 +67,7 @@ {:type :primary :customization-color customization-color :on-press (fn [] - (rf/dispatch [:profile/edit-name @full-name])) + (rf/dispatch [:profile/edit-name {:display-name @full-name}])) :disabled? (boolean (or @typing? (string/blank? @full-name) (not (string/blank? @error-msg))))} From 41826fb0ff3fb7374f84a47b8d78ef82ab408887 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Fri, 20 Dec 2024 17:07:19 -0600 Subject: [PATCH 03/22] Fix tests --- .../contexts/profile/edit/header/events_test.cljs | 2 +- src/tests/integration_test/profile_test.cljs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/status_im/contexts/profile/edit/header/events_test.cljs b/src/status_im/contexts/profile/edit/header/events_test.cljs index f445759d6e2..41971d2cf08 100644 --- a/src/status_im/contexts/profile/edit/header/events_test.cljs +++ b/src/status_im/contexts/profile/edit/header/events_test.cljs @@ -24,4 +24,4 @@ :params [key-uid] :on-success [:profile/delete-profile-picture-success]}]]]}] (is (match? expected - (sut/delete-profile-picture cofx))))) + (sut/delete-profile-picture cofx false))))) diff --git a/src/tests/integration_test/profile_test.cljs b/src/tests/integration_test/profile_test.cljs index b15649275e0..05a9cf11d91 100644 --- a/src/tests/integration_test/profile_test.cljs +++ b/src/tests/integration_test/profile_test.cljs @@ -14,7 +14,7 @@ (fn [] (let [new-name "John Doe"] (promesa/do - (rf/dispatch [:profile/edit-name new-name]) + (rf/dispatch [:profile/edit-name {:display-name new-name}]) (h/wait-for [:navigate-back :toasts/upsert]) (let [profile (rf/sub [:profile/profile]) display-name (profile.utils/displayed-name profile)] @@ -26,7 +26,10 @@ (let [mock-image "resources/images/mock2/monkey.png" absolute-path (.resolve test-utils/path mock-image)] (promesa/do - (rf/dispatch [:profile/edit-picture absolute-path 80 80]) + (rf/dispatch [:profile/edit-picture + {:picture absolute-path + :crop-width 80 + :crop-height 80}]) (h/wait-for [:profile/update-local-picture :toasts/upsert]) (let [profile (rf/sub [:profile/profile])] (is (not (nil? (:images profile)))))))))) From 46962837cf1a365c03dac6004e976512cbd29a70 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Fri, 20 Dec 2024 17:08:59 -0600 Subject: [PATCH 04/22] Add modal screen to update the profile --- .../contexts/profile/edit/modal/events.cljs | 51 ++++ .../contexts/profile/edit/modal/style.cljs | 60 ++++ .../contexts/profile/edit/modal/view.cljs | 266 ++++++++++++++++++ 3 files changed, 377 insertions(+) create mode 100644 src/status_im/contexts/profile/edit/modal/events.cljs create mode 100644 src/status_im/contexts/profile/edit/modal/style.cljs create mode 100644 src/status_im/contexts/profile/edit/modal/view.cljs diff --git a/src/status_im/contexts/profile/edit/modal/events.cljs b/src/status_im/contexts/profile/edit/modal/events.cljs new file mode 100644 index 00000000000..dc0809e0015 --- /dev/null +++ b/src/status_im/contexts/profile/edit/modal/events.cljs @@ -0,0 +1,51 @@ +(ns status-im.contexts.profile.edit.modal.events + (:require [status-im.contexts.profile.edit.introduce-yourself.view :as introduce-yourself] + [utils.re-frame :as rf])) + +(rf/reg-event-fx + :profile/edit-profile + (fn [_ [{:keys [display-name picture color on-success]}]] + {:fx (cond-> [] + display-name + (conj [:dispatch + [:profile/edit-name + {:display-name display-name + :navigate-back? false + :show-toast? false}]]) + color + (conj [:dispatch + [:profile/edit-accent-colour + {:color color + :navigate-back? false + :show-toast? false}]]) + picture + (conj [:dispatch + [:profile/edit-picture + {:picture picture + :show-toast? false}]]) + + (nil? picture) + (conj [:dispatch [:profile/delete-picture {:show-toast? false}]]) + + :always + (conj [:dispatch-n [[:navigate-back] on-success]]))})) + + +(rf/reg-event-fx + :profile/ask-profile-update + (fn [_ [pending-event]] + {:fx [[:effects.async-storage/set {:update-profile-asked? true}] + [:dispatch + [:show-bottom-sheet + {:content (fn [] + [introduce-yourself/sheet {:pending-event pending-event}])}]]]})) + +(rf/reg-event-fx + :profile/check-profile-update-prompt + (fn [_ [pending-event]] + {:fx [[:effects.async-storage/get + {:keys [:update-profile-asked?] + :cb (fn [{:keys [update-profile-asked?]}] + (rf/dispatch (if update-profile-asked? + pending-event + [:profile/ask-profile-update pending-event])))}]]})) diff --git a/src/status_im/contexts/profile/edit/modal/style.cljs b/src/status_im/contexts/profile/edit/modal/style.cljs new file mode 100644 index 00000000000..6bdf51d993c --- /dev/null +++ b/src/status_im/contexts/profile/edit/modal/style.cljs @@ -0,0 +1,60 @@ +(ns status-im.contexts.profile.edit.modal.style + (:require + [quo.foundations.colors :as colors] + [react-native.platform :as platform])) + +(def continue-button + {:width "100%" + :margin-left :auto + :margin-top (if platform/android? :auto 0) + :margin-right :auto}) + +(def button-container + {:width "100%" + :padding-left 20 + :padding-right 20 + :padding-top 12 + :align-self :flex-end + :height 64}) + +(defn view-button-container + [keyboard-shown?] + (merge button-container + (if platform/ios? + {:margin-bottom (if keyboard-shown? 0 34)} + {:margin-bottom (if keyboard-shown? 12 34)}))) + +(def blur-button-container + (merge button-container + (when platform/android? {:padding-bottom 12}))) + +(def page-container + {:position :absolute + :top 0 + :bottom 0 + :left 0 + :right 0 + :z-index 100}) + +(def info-message + {:margin-top 8}) + +(def title + {:color colors/white + :margin-top 12 + :margin-bottom 18}) + +(def color-title + {:color colors/white-70-blur + :margin-top 20 + :margin-bottom 16}) + +(def content-container + {:padding-horizontal 20}) + +(def input-container + {:align-items :flex-start}) + +(def profile-input-container + {:flex-direction :row + :justify-content :center}) diff --git a/src/status_im/contexts/profile/edit/modal/view.cljs b/src/status_im/contexts/profile/edit/modal/view.cljs new file mode 100644 index 00000000000..67858f6d360 --- /dev/null +++ b/src/status_im/contexts/profile/edit/modal/view.cljs @@ -0,0 +1,266 @@ +(ns status-im.contexts.profile.edit.modal.view + (:require + [clojure.string :as string] + [oops.core :as oops] + [quo.core :as quo] + [quo.foundations.colors :as colors] + [react-native.core :as rn] + [react-native.hooks :as hooks] + [react-native.platform :as platform] + [react-native.safe-area :as safe-area] + [reagent.core :as reagent] + [status-im.common.avatar-picture-picker.view :as profile-picture-picker] + [status-im.common.events-helper :as events-helper] + [status-im.common.validation.profile :as profile-validator] + [status-im.constants :as c] + [status-im.contexts.profile.edit.modal.events] + [status-im.contexts.profile.edit.modal.style :as style] + [utils.i18n :as i18n] + [utils.re-frame :as rf] + [utils.responsiveness :as responsiveness])) + +(def scroll-view-height (reagent/atom 0)) +(def content-container-height (reagent/atom 0)) +(def set-scroll-view-height #(reset! scroll-view-height %)) + +(defn set-content-container-height + [e] + (reset! content-container-height (oops/oget e "nativeEvent.layout.height"))) + +(defn show-button-background? + [keyboard-height keyboard-shown content-scroll-y] + (let [button-container-height 64 + keyboard-view-height (+ keyboard-height button-container-height)] + (when keyboard-shown + (cond + platform/android? + (< (- @scroll-view-height button-container-height) @content-container-height) + + platform/ios? + (< (- @scroll-view-height keyboard-view-height) (- @content-container-height content-scroll-y)) + + :else + false)))) + +(defn button-container + [show-keyboard? keyboard-shown show-background? keyboard-height children] + (let [height (reagent/atom 0)] + (reset! height (if show-keyboard? (if keyboard-shown keyboard-height 0) 0)) + [rn/view {:style {:margin-top :auto}} + (cond + (and (> @height 0) show-background?) + [quo/blur + (when keyboard-shown + {:blur-amount 34 + :blur-type :transparent + :overlay-color :transparent + :background-color (if platform/android? + colors/neutral-100 + colors/neutral-80-opa-1-blur) + :style style/blur-button-container}) + children] + + (and (> @height 0) (not show-background?)) + [rn/view {:style (style/view-button-container true)} + children] + + (not show-keyboard?) + [rn/view {:style (style/view-button-container false)} + children])])) + +(defn- add-keyboard-listener + [e callback] + (oops/ocall rn/keyboard "addListener" e callback)) + +(defn- on-keyboard-show + [f] + (add-keyboard-listener (if platform/android? "keyboardDidShow" "keyboardWillShow") f)) + +(defn- on-keyboard-hide + [f] + (add-keyboard-listener (if platform/android? "keyboardDidHide" "keyboardWillHide") f)) + +(defn floating-button + [{:keys [custom-color scroll-y on-submit disabled?]}] + (reagent/with-let [show-keyboard? (reagent/atom false) + show-listener (on-keyboard-show #(reset! show-keyboard? true)) + hide-listener (on-keyboard-hide #(reset! show-keyboard? false))] + (let [{:keys [keyboard-shown keyboard-height]} (hooks/use-keyboard) + show-background? (show-button-background? keyboard-height + keyboard-shown + scroll-y)] + [rn/keyboard-avoiding-view + {:style {:position :absolute + :top 0 + :bottom 0 + :left 0 + :right 0} + :pointer-events :box-none} + [button-container @show-keyboard? keyboard-shown show-background? keyboard-height + [quo/button + {:accessibility-label :submit-create-profile-button + :type :primary + :customization-color custom-color + :on-press on-submit + :container-style style/continue-button + :disabled? disabled?} + (i18n/label :t/continue)]]]) + (finally + (oops/ocall show-listener "remove") + (oops/ocall hide-listener "remove")))) + +(defn- content + [{:keys [set-display-name set-validation-msg picture-picker]}] + (let [open-picture-picker (fn [] + (rf/dispatch [:dismiss-keyboard]) + (rf/dispatch [:show-bottom-sheet + {:content picture-picker + :shell? true + :theme :dark}])) + on-change-text (fn [s] + (set-validation-msg s) + (set-display-name s))] + (fn [{:keys [profile-image custom-color display-name validation-msg valid-name? + name-too-short? initial-display-name set-scroll set-scroll-height + set-custom-color]}] + (let [{window-width :width} (rn/get-window) + info-type (cond + validation-msg :error + name-too-short? :default + :else :success) + info-message (or validation-msg + (i18n/label :t/minimum-characters + {:min-chars profile-validator/min-length})) + full-name (if (seq display-name) + display-name + initial-display-name)] + [rn/scroll-view + {:on-layout set-scroll-height + :on-scroll set-scroll + :scroll-event-throttle 64 + :content-container-style {:flex-grow 1}} + [rn/view {:on-layout set-content-container-height} + [rn/view {:style style/content-container} + [quo/text + {:style style/title + :size :heading-1 + :weight :semi-bold} + (i18n/label :t/edit-profile)] + [rn/view {:style style/input-container} + [rn/view {:style style/profile-input-container} + [quo/profile-input + {:customization-color custom-color + :placeholder initial-display-name + :on-press open-picture-picker + :image-picker-props {:profile-picture profile-image + :full-name full-name + :customization-color custom-color} + :title-input-props {:default-value "" + :auto-focus true + :max-length c/profile-name-max-length + :on-change-text on-change-text}}]] + [quo/info-message + {:status info-type + :size :default + :icon (if valid-name? :i/positive-state :i/info) + :color (when (= :default info-type) colors/white-70-blur) + :container-style style/info-message} + info-message] + [quo/text + {:size :paragraph-2 + :weight :medium + :style style/color-title} + (i18n/label :t/colour)]]] + [quo/color-picker + {:blur? true + :default-selected custom-color + :on-change set-custom-color + :window-width window-width + :container-style {:padding-left (responsiveness/iphone-11-Pro-20-pixel-from-width + window-width)}}]]])))) + +(defn- submittable-state? + [{:keys [new-color? new-picture? new-name? valid-name?]}] + (let [acceptable-name? (or (not new-name?) valid-name?)] + (or (and new-color? acceptable-name?) + (and new-picture? acceptable-name?) + (and new-name? valid-name?)))) + +(defn view + [] + (let [{:keys [pending-event]} (rf/sub [:get-screen-params]) + {initial-display-name :display-name + initial-color :customization-color + [initial-image] :images} (rf/sub [:profile/profile]) + top (safe-area/get-top) + scroll-y (reagent/atom 0) + display-name (reagent/atom "") + validation-msg (reagent/atom (profile-validator/validation-name @display-name)) + custom-color (reagent/atom (or initial-color c/profile-default-color)) + profile-image (reagent/atom initial-image) + set-display-name #(reset! validation-msg (profile-validator/validation-name %)) + set-validation-msg #(reset! display-name (string/trim %)) + set-custom-color #(reset! custom-color %) + set-scroll (fn [e] + (reset! scroll-y (oops/oget e "nativeEvent.contentOffset.y"))) + set-scroll-height (fn [e] + (reset! scroll-y 0) + (-> e + (oops/oget "nativeEvent.layout.height") + set-scroll-view-height)) + picture-picker (fn [] + [profile-picture-picker/view + {:on-result #(reset! profile-image %) + :has-picture? (some? @profile-image)}]) + update-profile (fn [] ;; TODO: check image not updated in communities and + ;; profile + (rf/dispatch + [:profile/edit-profile + (cond-> {:on-success pending-event} + (and (seq @display-name) + (not= initial-display-name @display-name)) + (assoc :display-name @display-name) + + (and (not= initial-image @profile-image)) + (assoc :picture @profile-image) + + (not= initial-color @custom-color) + (assoc :color @custom-color))])) + on-close (fn [] + (events-helper/navigate-back) + (rf/dispatch pending-event))] + (fn [] + (let [name-too-short? (profile-validator/name-too-short? @display-name) + valid-name? (and (not @validation-msg) (not name-too-short?)) + disabled? (not + (submittable-state? + {:new-color? (not= initial-color @custom-color) + :new-picture? (not= @profile-image initial-image) + :new-name? (and (not= initial-display-name @display-name) + (seq @display-name)) + :valid-name? valid-name?}))] + [rn/view {:style style/page-container} + [quo/page-nav + {:margin-top top + :background :blur + :icon-name :i/close + :on-press on-close}] + [content + {:profile-image @profile-image + :custom-color @custom-color + :display-name @display-name + :validation-msg @validation-msg + :valid-name? valid-name? + :name-too-short? name-too-short? + :picture-picker picture-picker + :initial-display-name initial-display-name + :set-scroll set-scroll + :set-scroll-height set-scroll-height + :set-custom-color set-custom-color + :set-display-name set-display-name + :set-validation-msg set-validation-msg}] + [floating-button + {:custom-color @custom-color + :scroll-y @scroll-y + :on-submit update-profile + :disabled? disabled?}]])))) From 850b773b1da1dd2de4b7d9038984c3810c4b5bac Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Fri, 20 Dec 2024 17:09:51 -0600 Subject: [PATCH 05/22] Add introduce yourself modal --- .../profile/edit/introduce_yourself/view.cljs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/status_im/contexts/profile/edit/introduce_yourself/view.cljs diff --git a/src/status_im/contexts/profile/edit/introduce_yourself/view.cljs b/src/status_im/contexts/profile/edit/introduce_yourself/view.cljs new file mode 100644 index 00000000000..365ffc211d4 --- /dev/null +++ b/src/status_im/contexts/profile/edit/introduce_yourself/view.cljs @@ -0,0 +1,32 @@ +(ns status-im.contexts.profile.edit.introduce-yourself.view + (:require [quo.core :as quo] + [react-native.core :as rn] + [utils.re-frame :as rf])) + +(defn sheet + [{:keys [pending-event]}] + (let [on-accept (fn [] + (rf/dispatch [:open-modal :screen/profile.edit-profile-modal + {:pending-event pending-event}])) + on-reject #(rf/dispatch pending-event)] + [:<> + [rn/view {:style {:padding-horizontal 20}} + [quo/text + {:style {:padding-bottom 4} + :size :heading-2 + :weight :semi-bold} + "Introduce yourself"] + [quo/text + {:style {:padding-top 4 :padding-bottom 12} + :size :paragraph-1 + :weight :regular} + "Add an optional display name and profile picture so others can easily recognize you"]] + [quo/bottom-actions + {:actions :two-actions + :buttons-style {:flex-shrink 1 :flex-basis 0} + :button-one-label "Edit Profile" + :button-one-props {:type :primary + :on-press on-accept} + :button-two-label "Skip" + :button-two-props {:type :grey + :on-press on-reject}}]])) From 875d10290770ce805195c8cb5821dd1c78d8d709 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Fri, 20 Dec 2024 17:10:17 -0600 Subject: [PATCH 06/22] squash with modal --- src/status_im/navigation/screens.cljs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/status_im/navigation/screens.cljs b/src/status_im/navigation/screens.cljs index 20d94b2fb76..54e9f18c008 100644 --- a/src/status_im/navigation/screens.cljs +++ b/src/status_im/navigation/screens.cljs @@ -64,6 +64,7 @@ [status-im.contexts.profile.contact.view :as contact-profile] [status-im.contexts.profile.edit.accent-colour.view :as edit-accent-colour] [status-im.contexts.profile.edit.bio.view :as edit-bio] + [status-im.contexts.profile.edit.modal.view :as edit-profile-modal] [status-im.contexts.profile.edit.name.view :as edit-name] [status-im.contexts.profile.edit.view :as edit-profile] [status-im.contexts.profile.profiles.view :as profiles] @@ -1127,7 +1128,12 @@ :options {:theme :dark :layout options/onboarding-layout} :on-focus [:onboarding/overlay-dismiss] - :component profiles/view}] + :component profiles/view} + + {:name :screen/profile.edit-profile-modal + :options {:theme :dark + :layout options/onboarding-layout} + :component edit-profile-modal/view}] [{:name :shell :metrics {:track? true} From 0c93edd5f15f19f26259ebd3149061efa0092778 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Fri, 20 Dec 2024 17:11:47 -0600 Subject: [PATCH 07/22] Ask user to update their profile before sending a message or contact request --- src/status_im/contexts/chat/home/view.cljs | 8 ++- .../contexts/profile/contact/header/view.cljs | 61 +++++++++---------- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/status_im/contexts/chat/home/view.cljs b/src/status_im/contexts/chat/home/view.cljs index 54b40b78dc6..b09decf6189 100644 --- a/src/status_im/contexts/chat/home/view.cljs +++ b/src/status_im/contexts/chat/home/view.cljs @@ -114,13 +114,17 @@ {:scroll-input (oops/oget % "nativeEvent.contentOffset.y") :shared-value scroll-shared-value})}]))) +(defn- on-new-message-press + [] + (let [main-event [:show-bottom-sheet {:content chat.actions.view/new-chat}]] + (rf/dispatch [:profile/check-profile-update-prompt main-event]))) + (defn- banner-data [profile-link] {:title-props {:beta? true :label (i18n/label :t/messages) - :handler #(rf/dispatch - [:show-bottom-sheet {:content chat.actions.view/new-chat}]) + :handler on-new-message-press :accessibility-label :new-chat-button} :card-props {:on-press #(rf/dispatch [:open-share {:options {:url profile-link}}]) diff --git a/src/status_im/contexts/profile/contact/header/view.cljs b/src/status_im/contexts/profile/contact/header/view.cljs index e65c54db3e9..2ce280a1d98 100644 --- a/src/status_im/contexts/profile/contact/header/view.cljs +++ b/src/status_im/contexts/profile/contact/header/view.cljs @@ -14,15 +14,14 @@ [utils.i18n :as i18n] [utils.re-frame :as rf])) -(defn on-contact-request +(defn on-send-contact-request [] - (rf/dispatch [:show-bottom-sheet - {:content (fn [] [contact-request/view])}])) + (let [main-event [:show-bottom-sheet {:content contact-request/view}]] + (rf/dispatch [:profile/check-profile-update-prompt main-event]))) (defn on-contact-review [] - (rf/dispatch [:show-bottom-sheet - {:content (fn [] [contact-review/view])}])) + (rf/dispatch [:show-bottom-sheet {:content contact-review/view}])) (defn view [{:keys [scroll-y]}] @@ -34,27 +33,27 @@ profile-picture (profile.utils/photo contact) online? (rf/sub [:visibility-status-updates/online? public-key]) theme (quo.theme/use-theme) - contact-status (rn/use-memo (fn [] - (cond - (= contact-request-state - constants/contact-request-state-mutual) :contact - blocked? :blocked - :else nil)) - [blocked? contact-request-state]) - on-start-chat (rn/use-callback #(rf/dispatch [:chat.ui/start-chat - public-key - ens-name]) - [ens-name public-key]) - on-unblock-press (rn/use-callback (fn [] - (rf/dispatch [:contact/unblock-contact - public-key]) - (rf/dispatch [:toasts/upsert - {:id :user-unblocked - :type :positive - :text (i18n/label :t/user-unblocked - {:username - full-name})}])) - [public-key full-name])] + contact-status (rn/use-memo + (fn [] + (cond + (= contact-request-state + constants/contact-request-state-mutual) :contact + blocked? :blocked + :else nil)) + [blocked? contact-request-state]) + on-start-chat (rn/use-callback + #(rf/dispatch [:chat.ui/start-chat public-key ens-name]) + [ens-name public-key]) + on-unblock-press (rn/use-callback + (fn [] + (rf/dispatch [:contact/unblock-contact + public-key]) + (rf/dispatch [:toasts/upsert + {:id :user-unblocked + :type :positive + :text (i18n/label :t/user-unblocked + {:username full-name})}])) + [public-key full-name])] [rn/view {:style style/header-container} [rn/view {:style style/header-top-wrapper} [rn/view {:style style/avatar-wrapper} @@ -93,14 +92,12 @@ (cond (and (not blocked?) - (or - (not contact-request-state) - (= contact-request-state constants/contact-request-state-none) - (= contact-request-state constants/contact-request-state-dismissed))) - + (or (not contact-request-state) + (= contact-request-state constants/contact-request-state-none) + (= contact-request-state constants/contact-request-state-dismissed))) [quo/button {:container-style style/button-wrapper - :on-press on-contact-request + :on-press on-send-contact-request :customization-color customization-color :icon-left :i/add-user} (i18n/label :t/send-contact-request)] From 80445216c9184c569f0abde89b9b7b21b4123117 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Fri, 20 Dec 2024 17:12:10 -0600 Subject: [PATCH 08/22] Fix color picker selected styles --- src/quo/components/colors/color/style.cljs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/quo/components/colors/color/style.cljs b/src/quo/components/colors/color/style.cljs index 773bf2776b9..1099ec3d795 100644 --- a/src/quo/components/colors/color/style.cljs +++ b/src/quo/components/colors/color/style.cljs @@ -30,7 +30,8 @@ selected? (assoc :border-top-color (colors/alpha color 0.4) :border-end-color (colors/alpha color 0.4) :border-bottom-color (colors/alpha color 0.2) - :border-start-color (colors/alpha color 0.2)) + :border-start-color (colors/alpha color 0.2) + :border-color nil) (zero? idx) (assoc :margin-left -4)))) (defn color-circle From 60714785398a459194d40b171b5a7e9e55fdc4c5 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Fri, 20 Dec 2024 17:43:07 -0600 Subject: [PATCH 09/22] Fix test 1 --- .../contexts/profile/edit/accent_colour/events_test.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs b/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs index af1642666ce..3cda78c1628 100644 --- a/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs +++ b/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs @@ -11,7 +11,7 @@ [{:method "wakuext_setCustomizationColor" :params [{:customizationColor new-color :keyUid key-uid}] - :on-success [:profile/edit-accent-colour-success new-color] + :on-success [:profile/edit-accent-colour-success new-color true true] :on-error fn?}]]]}] (is (match? expected (sut/edit-accent-colour cofx [new-color]))))) From 160ab065adee6c972d5ec036dbf5473e7a188a07 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Thu, 9 Jan 2025 20:49:36 -0600 Subject: [PATCH 10/22] Fix subscription inside `ref-event-fx` --- src/status_im/contexts/profile/edit/header/events.cljs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/status_im/contexts/profile/edit/header/events.cljs b/src/status_im/contexts/profile/edit/header/events.cljs index ca826bc92e0..5e6a724cc59 100644 --- a/src/status_im/contexts/profile/edit/header/events.cljs +++ b/src/status_im/contexts/profile/edit/header/events.cljs @@ -11,8 +11,8 @@ (update db :profile/profile dissoc :images))})) (rf/reg-event-fx :profile/edit-profile-picture-success - (fn [_ [show-toast? images]] - (let [has-picture? (rf/sub [:profile/has-picture])] + (fn [{db :db} [show-toast? images]] + (let [has-picture? (-> db :profile/profile :images count pos?)] {:fx [[:dispatch [:profile/update-local-picture (reverse images)]] (when show-toast? [:dispatch From 94e2431a4402502de39063349cf40f0f62c7b295 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Thu, 9 Jan 2025 20:50:03 -0600 Subject: [PATCH 11/22] Remove some `:f>` now unnecessary --- src/status_im/common/home/banner/view.cljs | 6 +++--- src/status_im/contexts/shell/home_stack/view.cljs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/status_im/common/home/banner/view.cljs b/src/status_im/common/home/banner/view.cljs index a02026fa2d2..6024003333a 100644 --- a/src/status_im/common/home/banner/view.cljs +++ b/src/status_im/common/home/banner/view.cljs @@ -73,10 +73,10 @@ [{:keys [scroll-ref tabs selected-tab on-tab-change scroll-shared-value content customization-color]}] (let [theme (quo.theme/use-theme)] [:<> - [:f> banner-card-blur-layer scroll-shared-value - [:f> banner-card-hiding-layer + [banner-card-blur-layer scroll-shared-value + [banner-card-hiding-layer (assoc content :scroll-shared-value scroll-shared-value :theme theme)]] - [:f> banner-card-tabs-layer + [banner-card-tabs-layer {:scroll-shared-value scroll-shared-value :selected-tab selected-tab :tabs tabs diff --git a/src/status_im/contexts/shell/home_stack/view.cljs b/src/status_im/contexts/shell/home_stack/view.cljs index 294678c8ded..8ebaacf5cc0 100644 --- a/src/status_im/contexts/shell/home_stack/view.cljs +++ b/src/status_im/contexts/shell/home_stack/view.cljs @@ -29,8 +29,8 @@ :z-index (get shared-values (get shell.constants/stacks-z-index-keywords stack-id))})} (case stack-id - :communities-stack [:f> communities/view] - :chats-stack [:f> chat/view] + :communities-stack [communities/view] + :chats-stack [chat/view] :wallet-stack [wallet/view] :browser-stack [browser.stack/browser-stack] [:<>])]) @@ -38,7 +38,7 @@ (defn lazy-screen [stack-id shared-values] (when (load-stack? stack-id) - [:f> f-stack-view stack-id shared-values])) + [f-stack-view stack-id shared-values])) (defn view [shared-values] From bb1a7fd78d35e808bff2aba870eed9450cc47ecb Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Thu, 9 Jan 2025 21:10:09 -0600 Subject: [PATCH 12/22] Remove comment --- src/status_im/contexts/profile/edit/modal/view.cljs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/status_im/contexts/profile/edit/modal/view.cljs b/src/status_im/contexts/profile/edit/modal/view.cljs index 67858f6d360..18ecb910165 100644 --- a/src/status_im/contexts/profile/edit/modal/view.cljs +++ b/src/status_im/contexts/profile/edit/modal/view.cljs @@ -212,8 +212,7 @@ [profile-picture-picker/view {:on-result #(reset! profile-image %) :has-picture? (some? @profile-image)}]) - update-profile (fn [] ;; TODO: check image not updated in communities and - ;; profile + update-profile (fn [] (rf/dispatch [:profile/edit-profile (cond-> {:on-success pending-event} From d72ee2ee1ac9d071f4d849b4bf3b291bfa2be468 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Thu, 9 Jan 2025 21:15:24 -0600 Subject: [PATCH 13/22] Move texts to i18n --- .../contexts/profile/edit/introduce_yourself/view.cljs | 9 +++++---- translations/en.json | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/status_im/contexts/profile/edit/introduce_yourself/view.cljs b/src/status_im/contexts/profile/edit/introduce_yourself/view.cljs index 365ffc211d4..573d8cdf458 100644 --- a/src/status_im/contexts/profile/edit/introduce_yourself/view.cljs +++ b/src/status_im/contexts/profile/edit/introduce_yourself/view.cljs @@ -1,6 +1,7 @@ (ns status-im.contexts.profile.edit.introduce-yourself.view (:require [quo.core :as quo] [react-native.core :as rn] + [utils.i18n :as i18n] [utils.re-frame :as rf])) (defn sheet @@ -15,18 +16,18 @@ {:style {:padding-bottom 4} :size :heading-2 :weight :semi-bold} - "Introduce yourself"] + (i18n/label :t/just-introduce-yourself)] [quo/text {:style {:padding-top 4 :padding-bottom 12} :size :paragraph-1 :weight :regular} - "Add an optional display name and profile picture so others can easily recognize you"]] + (i18n/label :t/add-display-name-and-picture)]] [quo/bottom-actions {:actions :two-actions :buttons-style {:flex-shrink 1 :flex-basis 0} - :button-one-label "Edit Profile" + :button-one-label (i18n/label :t/edit-profile) :button-one-props {:type :primary :on-press on-accept} - :button-two-label "Skip" + :button-two-label (i18n/label :t/skip) :button-two-props {:type :grey :on-press on-reject}}]])) diff --git a/translations/en.json b/translations/en.json index 01e1646b9d4..d20796c5849 100644 --- a/translations/en.json +++ b/translations/en.json @@ -59,6 +59,7 @@ "add-bootnode": "Add bootnode", "add-contact": "Add contact", "add-custom-token": "Add custom token", + "add-display-name-and-picture": "Add an optional display name and profile picture so others can easily recognize you", "add-eth": "Add ETH", "add-favourite": "Add favourite", "add-mailserver": "Add Status node", @@ -1270,6 +1271,7 @@ "intro-wizard-title5": "Confirm the passcode", "intro-wizard-title6": "Enable notifications", "introduce-yourself": "Introduce yourself with a brief message", + "just-introduce-yourself": "Introduce yourself", "invalid-address": "It’s not Ethereum address or ENS name", "invalid-address-qr-code": "Scanned QR code doesn't contain a valid address", "invalid-characters-bio": "Invalid characters. Standard keyboard characters and emojis only.", From fac06099d7df0c09f645f170970bdbb67890698c Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Thu, 9 Jan 2025 22:12:07 -0600 Subject: [PATCH 14/22] Fix tests --- .../profile/edit/accent_colour/events_test.cljs | 10 +++++----- .../contexts/profile/edit/header/events_test.cljs | 8 ++++---- .../contexts/profile/edit/name/events_test.cljs | 7 +++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs b/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs index 3cda78c1628..6f9af926cec 100644 --- a/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs +++ b/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs @@ -8,10 +8,10 @@ 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}] + [{:method "wakuext_setCustomizationColor" + :params [{:customizationColor new-color + :keyUid key-uid}] :on-success [:profile/edit-accent-colour-success new-color true true] - :on-error fn?}]]]}] + :on-error fn?}]]]}] (is (match? expected - (sut/edit-accent-colour cofx [new-color]))))) + (sut/edit-accent-colour cofx [{:color new-color}]))))) diff --git a/src/status_im/contexts/profile/edit/header/events_test.cljs b/src/status_im/contexts/profile/edit/header/events_test.cljs index 41971d2cf08..3555887c761 100644 --- a/src/status_im/contexts/profile/edit/header/events_test.cljs +++ b/src/status_im/contexts/profile/edit/header/events_test.cljs @@ -12,9 +12,9 @@ [{:method "multiaccounts_storeIdentityImage" :params [key-uid picture 0 0 profile-picture-picker/crop-size profile-picture-picker/crop-size] - :on-success [:profile/edit-profile-picture-success]}]]]}] + :on-success [:profile/edit-profile-picture-success true]}]]]}] (is (match? expected - (sut/edit-profile-picture cofx [picture]))))) + (sut/edit-profile-picture cofx [{:picture picture}]))))) (deftest delete-picture-test (let [key-uid "key-uid" @@ -22,6 +22,6 @@ expected {:fx [[:json-rpc/call [{:method "multiaccounts_deleteIdentityImage" :params [key-uid] - :on-success [:profile/delete-profile-picture-success]}]]]}] + :on-success [:profile/delete-profile-picture-success true]}]]]}] (is (match? expected - (sut/delete-profile-picture cofx false))))) + (sut/delete-profile-picture cofx [{}]))))) diff --git a/src/status_im/contexts/profile/edit/name/events_test.cljs b/src/status_im/contexts/profile/edit/name/events_test.cljs index 121cdd94cfc..d9a439ec222 100644 --- a/src/status_im/contexts/profile/edit/name/events_test.cljs +++ b/src/status_im/contexts/profile/edit/name/events_test.cljs @@ -6,10 +6,9 @@ (deftest edit-name-test (let [new-name "John Doe" cofx {:db {:profile/profile {:display-name "Old name"}}} - expected {:db {:profile/profile {:display-name new-name}} - :fx [[:json-rpc/call + expected {:fx [[:json-rpc/call [{:method "wakuext_setDisplayName" :params [name] - :on-success [:profile/edit-profile-name-success]}]]]}] + :on-success [:profile/edit-profile-name-success new-name true true]}]]]}] (is (match? expected - (sut/edit-profile-name cofx [new-name]))))) + (sut/edit-profile-name cofx [{:display-name new-name}]))))) From cfce7f6ed298dc47c407ac6202ad179556889985 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Thu, 9 Jan 2025 22:14:19 -0600 Subject: [PATCH 15/22] Lint fix --- .../contexts/profile/edit/accent_colour/events_test.cljs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs b/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs index 6f9af926cec..0c9f2788180 100644 --- a/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs +++ b/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs @@ -8,10 +8,10 @@ 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}] + [{:method "wakuext_setCustomizationColor" + :params [{:customizationColor new-color + :keyUid key-uid}] :on-success [:profile/edit-accent-colour-success new-color true true] - :on-error fn?}]]]}] + :on-error fn?}]]]}] (is (match? expected (sut/edit-accent-colour cofx [{:color new-color}]))))) From ac4e5fdb91de7058287edae4e2e386a03f6acbc4 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Fri, 10 Jan 2025 21:38:36 -0600 Subject: [PATCH 16/22] Fix iOS modal presentation --- .../contexts/profile/edit/modal/style.cljs | 7 +-- .../contexts/profile/edit/modal/view.cljs | 51 ++++++++++--------- src/status_im/navigation/screens.cljs | 4 +- 3 files changed, 29 insertions(+), 33 deletions(-) diff --git a/src/status_im/contexts/profile/edit/modal/style.cljs b/src/status_im/contexts/profile/edit/modal/style.cljs index 6bdf51d993c..48a647de5dd 100644 --- a/src/status_im/contexts/profile/edit/modal/style.cljs +++ b/src/status_im/contexts/profile/edit/modal/style.cljs @@ -29,12 +29,7 @@ (when platform/android? {:padding-bottom 12}))) (def page-container - {:position :absolute - :top 0 - :bottom 0 - :left 0 - :right 0 - :z-index 100}) + {:flex 1}) (def info-message {:margin-top 8}) diff --git a/src/status_im/contexts/profile/edit/modal/view.cljs b/src/status_im/contexts/profile/edit/modal/view.cljs index 18ecb910165..5c16f34546b 100644 --- a/src/status_im/contexts/profile/edit/modal/view.cljs +++ b/src/status_im/contexts/profile/edit/modal/view.cljs @@ -238,28 +238,29 @@ :new-name? (and (not= initial-display-name @display-name) (seq @display-name)) :valid-name? valid-name?}))] - [rn/view {:style style/page-container} - [quo/page-nav - {:margin-top top - :background :blur - :icon-name :i/close - :on-press on-close}] - [content - {:profile-image @profile-image - :custom-color @custom-color - :display-name @display-name - :validation-msg @validation-msg - :valid-name? valid-name? - :name-too-short? name-too-short? - :picture-picker picture-picker - :initial-display-name initial-display-name - :set-scroll set-scroll - :set-scroll-height set-scroll-height - :set-custom-color set-custom-color - :set-display-name set-display-name - :set-validation-msg set-validation-msg}] - [floating-button - {:custom-color @custom-color - :scroll-y @scroll-y - :on-submit update-profile - :disabled? disabled?}]])))) + [quo/overlay {:type :shell} + [rn/view {:style style/page-container} + [quo/page-nav + {:margin-top top + :background :blur + :icon-name :i/close + :on-press on-close}] + [content + {:profile-image @profile-image + :custom-color @custom-color + :display-name @display-name + :validation-msg @validation-msg + :valid-name? valid-name? + :name-too-short? name-too-short? + :picture-picker picture-picker + :initial-display-name initial-display-name + :set-scroll set-scroll + :set-scroll-height set-scroll-height + :set-custom-color set-custom-color + :set-display-name set-display-name + :set-validation-msg set-validation-msg}] + [floating-button + {:custom-color @custom-color + :scroll-y @scroll-y + :on-submit update-profile + :disabled? disabled?}]]])))) diff --git a/src/status_im/navigation/screens.cljs b/src/status_im/navigation/screens.cljs index 54e9f18c008..0341a4e2732 100644 --- a/src/status_im/navigation/screens.cljs +++ b/src/status_im/navigation/screens.cljs @@ -1131,8 +1131,8 @@ :component profiles/view} {:name :screen/profile.edit-profile-modal - :options {:theme :dark - :layout options/onboarding-layout} + :metrics {:track? true} + :options options/transparent-screen-options :component edit-profile-modal/view}] [{:name :shell From 4c94787b387bce517ee6e14256d178580fdefabb Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Fri, 10 Jan 2025 22:24:52 -0600 Subject: [PATCH 17/22] Fix different keys for different users --- .../contexts/profile/edit/modal/events.cljs | 30 +++++++++++-------- translations/en.json | 2 +- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/status_im/contexts/profile/edit/modal/events.cljs b/src/status_im/contexts/profile/edit/modal/events.cljs index dc0809e0015..8425e74ffbd 100644 --- a/src/status_im/contexts/profile/edit/modal/events.cljs +++ b/src/status_im/contexts/profile/edit/modal/events.cljs @@ -30,22 +30,26 @@ :always (conj [:dispatch-n [[:navigate-back] on-success]]))})) +(defn- profile-update-asked-storage-key [key-uid] + (keyword :update-profile-asked key-uid)) (rf/reg-event-fx :profile/ask-profile-update - (fn [_ [pending-event]] - {:fx [[:effects.async-storage/set {:update-profile-asked? true}] - [:dispatch - [:show-bottom-sheet - {:content (fn [] - [introduce-yourself/sheet {:pending-event pending-event}])}]]]})) + (fn [{db :db} [pending-event]] + (let [storage-key (-> db :profile/profile :key-uid profile-update-asked-storage-key)] + {:fx [[:effects.async-storage/set {storage-key true}] + [:dispatch + [:show-bottom-sheet + {:content (fn [] + [introduce-yourself/sheet {:pending-event pending-event}])}]]]}))) (rf/reg-event-fx :profile/check-profile-update-prompt - (fn [_ [pending-event]] - {:fx [[:effects.async-storage/get - {:keys [:update-profile-asked?] - :cb (fn [{:keys [update-profile-asked?]}] - (rf/dispatch (if update-profile-asked? - pending-event - [:profile/ask-profile-update pending-event])))}]]})) + (fn [{db :db} [pending-event]] + (let [storage-key (-> db :profile/profile :key-uid profile-update-asked-storage-key)] + {:fx [[:effects.async-storage/get + {:keys [storage-key] + :cb (fn [profile-updated-data] + (rf/dispatch (if (storage-key profile-updated-data) + pending-event + [:profile/ask-profile-update pending-event])))}]]}))) diff --git a/translations/en.json b/translations/en.json index d20796c5849..8a182472bb6 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1271,7 +1271,6 @@ "intro-wizard-title5": "Confirm the passcode", "intro-wizard-title6": "Enable notifications", "introduce-yourself": "Introduce yourself with a brief message", - "just-introduce-yourself": "Introduce yourself", "invalid-address": "It’s not Ethereum address or ENS name", "invalid-address-qr-code": "Scanned QR code doesn't contain a valid address", "invalid-characters-bio": "Invalid characters. Standard keyboard characters and emojis only.", @@ -1350,6 +1349,7 @@ "joined-group-chat-description": "You've joined {{group-name}} from invitation by {{username}}", "jul": "Jul", "jun": "Jun", + "just-introduce-yourself": "Introduce yourself", "K": "K", "keep-card-steady": "Keep the card steady under the phone", "keep-key": "KeepKey", From 822b510bb022c8b1c32435d427b9d66a332b5fbd Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Fri, 10 Jan 2025 22:47:03 -0600 Subject: [PATCH 18/22] Lint fix --- src/status_im/contexts/profile/edit/modal/events.cljs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/status_im/contexts/profile/edit/modal/events.cljs b/src/status_im/contexts/profile/edit/modal/events.cljs index 8425e74ffbd..f8a211fa16f 100644 --- a/src/status_im/contexts/profile/edit/modal/events.cljs +++ b/src/status_im/contexts/profile/edit/modal/events.cljs @@ -30,7 +30,8 @@ :always (conj [:dispatch-n [[:navigate-back] on-success]]))})) -(defn- profile-update-asked-storage-key [key-uid] +(defn- profile-update-asked-storage-key + [key-uid] (keyword :update-profile-asked key-uid)) (rf/reg-event-fx From 21538170973e4cdf3f28b07555ef86a31e492ed6 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Tue, 21 Jan 2025 16:50:21 -0600 Subject: [PATCH 19/22] Add maps to pass params --- .../contexts/profile/edit/accent_colour/events.cljs | 7 +++++-- .../contexts/profile/edit/accent_colour/events_test.cljs | 5 ++++- src/status_im/contexts/profile/edit/header/events.cljs | 8 ++++---- .../contexts/profile/edit/header/events_test.cljs | 4 ++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/status_im/contexts/profile/edit/accent_colour/events.cljs b/src/status_im/contexts/profile/edit/accent_colour/events.cljs index 3bc263384ba..ef7b5197a6b 100644 --- a/src/status_im/contexts/profile/edit/accent_colour/events.cljs +++ b/src/status_im/contexts/profile/edit/accent_colour/events.cljs @@ -4,7 +4,7 @@ [utils.re-frame :as rf])) (rf/reg-event-fx :profile/edit-accent-colour-success - (fn [_ [customization-color navigate-back? show-toast?]] + (fn [_ [{:keys [customization-color navigate-back? show-toast?]}]] {:fx [[:dispatch [:profile/save-local-accent-color customization-color]] (when navigate-back? [:dispatch [:navigate-back]]) @@ -29,7 +29,10 @@ [{:method "wakuext_setCustomizationColor" :params [{:customizationColor color :keyUid key-uid}] - :on-success [:profile/edit-accent-colour-success color navigate-back? show-toast?] + :on-success [:profile/edit-accent-colour-success + {:customization-color color + :navigate-back? navigate-back? + :show-toast? show-toast?}] :on-error #(log/error "failed to edit accent color." {:error %})}]]]})) (rf/reg-event-fx :profile/edit-accent-colour edit-accent-colour) diff --git a/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs b/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs index 0c9f2788180..0c042442556 100644 --- a/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs +++ b/src/status_im/contexts/profile/edit/accent_colour/events_test.cljs @@ -11,7 +11,10 @@ [{:method "wakuext_setCustomizationColor" :params [{:customizationColor new-color :keyUid key-uid}] - :on-success [:profile/edit-accent-colour-success new-color true true] + :on-success [:profile/edit-accent-colour-success + {:customization-color new-color + :navigate-back? true + :show-toast? true}] :on-error fn?}]]]}] (is (match? expected (sut/edit-accent-colour cofx [{:color new-color}]))))) diff --git a/src/status_im/contexts/profile/edit/header/events.cljs b/src/status_im/contexts/profile/edit/header/events.cljs index 5e6a724cc59..5082d416b39 100644 --- a/src/status_im/contexts/profile/edit/header/events.cljs +++ b/src/status_im/contexts/profile/edit/header/events.cljs @@ -11,7 +11,7 @@ (update db :profile/profile dissoc :images))})) (rf/reg-event-fx :profile/edit-profile-picture-success - (fn [{db :db} [show-toast? images]] + (fn [{db :db} [{:keys [show-toast?]} images]] (let [has-picture? (-> db :profile/profile :images count pos?)] {:fx [[:dispatch [:profile/update-local-picture (reverse images)]] (when show-toast? @@ -34,12 +34,12 @@ {:fx [[:json-rpc/call [{:method "multiaccounts_storeIdentityImage" :params [key-uid path 0 0 crop-width crop-height] - :on-success [:profile/edit-profile-picture-success show-toast?]}]]]})) + :on-success [:profile/edit-profile-picture-success {:show-toast? show-toast?}]}]]]})) (rf/reg-event-fx :profile/edit-picture edit-profile-picture) (rf/reg-event-fx :profile/delete-profile-picture-success - (fn [_ [show-toast?]] + (fn [_ [{:keys [show-toast?]}]] {:fx [[:dispatch [:profile/update-local-picture nil]] (when show-toast? [:dispatch @@ -56,6 +56,6 @@ {:fx [[:json-rpc/call [{:method "multiaccounts_deleteIdentityImage" :params [key-uid] - :on-success [:profile/delete-profile-picture-success show-toast?]}]]]})) + :on-success [:profile/delete-profile-picture-success {:show-toast? show-toast?}]}]]]})) (rf/reg-event-fx :profile/delete-picture delete-profile-picture) diff --git a/src/status_im/contexts/profile/edit/header/events_test.cljs b/src/status_im/contexts/profile/edit/header/events_test.cljs index 3555887c761..e250542dc7f 100644 --- a/src/status_im/contexts/profile/edit/header/events_test.cljs +++ b/src/status_im/contexts/profile/edit/header/events_test.cljs @@ -12,7 +12,7 @@ [{:method "multiaccounts_storeIdentityImage" :params [key-uid picture 0 0 profile-picture-picker/crop-size profile-picture-picker/crop-size] - :on-success [:profile/edit-profile-picture-success true]}]]]}] + :on-success [:profile/edit-profile-picture-success {:show-toast? true}]}]]]}] (is (match? expected (sut/edit-profile-picture cofx [{:picture picture}]))))) @@ -22,6 +22,6 @@ expected {:fx [[:json-rpc/call [{:method "multiaccounts_deleteIdentityImage" :params [key-uid] - :on-success [:profile/delete-profile-picture-success true]}]]]}] + :on-success [:profile/delete-profile-picture-success {:show-toast? true}]}]]]}] (is (match? expected (sut/delete-profile-picture cofx [{}]))))) From 2eb884dcd38dbe992f76a294f6b9ba00f72a5535 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Tue, 21 Jan 2025 16:59:38 -0600 Subject: [PATCH 20/22] Improvement: remove `dispatch-n` --- src/status_im/contexts/profile/edit/modal/events.cljs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/status_im/contexts/profile/edit/modal/events.cljs b/src/status_im/contexts/profile/edit/modal/events.cljs index f8a211fa16f..c6e0ee661e7 100644 --- a/src/status_im/contexts/profile/edit/modal/events.cljs +++ b/src/status_im/contexts/profile/edit/modal/events.cljs @@ -28,7 +28,8 @@ (conj [:dispatch [:profile/delete-picture {:show-toast? false}]]) :always - (conj [:dispatch-n [[:navigate-back] on-success]]))})) + (conj [:dispatch [:navigate-back]] + [:dispatch on-success]))})) (defn- profile-update-asked-storage-key [key-uid] From e12482e4c415b951c4b948b6c87d8c15d8c74ec6 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Fri, 24 Jan 2025 17:50:40 -0600 Subject: [PATCH 21/22] No longer shows the modal if the user manually updates their profile --- .../contexts/profile/edit/modal/events.cljs | 19 ++++++++++++------- .../contexts/profile/edit/name/view.cljs | 3 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/status_im/contexts/profile/edit/modal/events.cljs b/src/status_im/contexts/profile/edit/modal/events.cljs index c6e0ee661e7..a459c2b1b7f 100644 --- a/src/status_im/contexts/profile/edit/modal/events.cljs +++ b/src/status_im/contexts/profile/edit/modal/events.cljs @@ -36,14 +36,19 @@ (keyword :update-profile-asked key-uid)) (rf/reg-event-fx - :profile/ask-profile-update - (fn [{db :db} [pending-event]] + :profile/set-profile-update-as-asked + (fn [{db :db}] (let [storage-key (-> db :profile/profile :key-uid profile-update-asked-storage-key)] - {:fx [[:effects.async-storage/set {storage-key true}] - [:dispatch - [:show-bottom-sheet - {:content (fn [] - [introduce-yourself/sheet {:pending-event pending-event}])}]]]}))) + {:fx [[:effects.async-storage/set {storage-key true}]]}))) + +(rf/reg-event-fx + :profile/ask-profile-update + (fn [_ [pending-event]] + {:fx [[:profile/set-profile-update-as-asked] + [:dispatch + [:show-bottom-sheet + {:content (fn [] + [introduce-yourself/sheet {:pending-event pending-event}])}]]]})) (rf/reg-event-fx :profile/check-profile-update-prompt diff --git a/src/status_im/contexts/profile/edit/name/view.cljs b/src/status_im/contexts/profile/edit/name/view.cljs index b891c10d0a8..c17ceef348a 100644 --- a/src/status_im/contexts/profile/edit/name/view.cljs +++ b/src/status_im/contexts/profile/edit/name/view.cljs @@ -67,7 +67,8 @@ {:type :primary :customization-color customization-color :on-press (fn [] - (rf/dispatch [:profile/edit-name {:display-name @full-name}])) + (rf/dispatch [:profile/edit-name {:display-name @full-name}]) + (rf/dispatch [:profile/set-profile-update-as-asked])) :disabled? (boolean (or @typing? (string/blank? @full-name) (not (string/blank? @error-msg))))} From 01c61081309df1bd020fca3fe15fc8efe014dea0 Mon Sep 17 00:00:00 2001 From: Ulises M <ulises.ssb@hotmail.com> Date: Mon, 27 Jan 2025 16:51:07 -0600 Subject: [PATCH 22/22] Add missing `:dispatch` keyword --- src/status_im/contexts/profile/edit/modal/events.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/status_im/contexts/profile/edit/modal/events.cljs b/src/status_im/contexts/profile/edit/modal/events.cljs index a459c2b1b7f..4ef066e24c7 100644 --- a/src/status_im/contexts/profile/edit/modal/events.cljs +++ b/src/status_im/contexts/profile/edit/modal/events.cljs @@ -44,7 +44,7 @@ (rf/reg-event-fx :profile/ask-profile-update (fn [_ [pending-event]] - {:fx [[:profile/set-profile-update-as-asked] + {:fx [[:dispatch [:profile/set-profile-update-as-asked]] [:dispatch [:show-bottom-sheet {:content (fn []