diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dac84464f..50ccd2b456 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [0.9.26 - Unreleased] ### Added - +- Allow user to remove custom avatar ### Fixed ### Changed diff --git a/src/status_im/translations/en.cljs b/src/status_im/translations/en.cljs index e30c408d39..d275502335 100644 --- a/src/status_im/translations/en.cljs +++ b/src/status_im/translations/en.cljs @@ -195,6 +195,7 @@ :image-source-title "Edit picture" :image-source-make-photo "Capture" :image-source-gallery "Select from gallery" + :image-remove-current "Remove current photo" ;;sharing :sharing-copy-to-clipboard "Copy to clipboard" diff --git a/src/status_im/ui/screens/profile/events.cljs b/src/status_im/ui/screens/profile/events.cljs index 0760f9e48f..2f3bca57e2 100644 --- a/src/status_im/ui/screens/profile/events.cljs +++ b/src/status_im/ui/screens/profile/events.cljs @@ -2,6 +2,7 @@ (:require [re-frame.core :as re-frame] [status-im.ui.screens.profile.navigation] [status-im.utils.handlers :as handlers] + [status-im.utils.identicon :as identicon] [status-im.ui.screens.profile.models :as profile.models])) (re-frame/reg-fx @@ -25,6 +26,14 @@ (fn [cofx [this-event base64-image]] (profile.models/update-picture this-event base64-image cofx))) +(handlers/register-handler-fx + :my-profile/remove-current-photo + (fn [{:keys [db]}] + {:db (-> db + (assoc-in [:my-profile/profile :photo-path] + (identicon/identicon (:current-public-key db))) + (assoc :my-profile/editing? true))})) + (handlers/register-handler-fx :my-profile/start-editing-profile (fn [cofx _] diff --git a/src/status_im/ui/screens/profile/user/views.cljs b/src/status_im/ui/screens/profile/user/views.cljs index 68ce89d472..7eaf9dd54f 100644 --- a/src/status_im/ui/screens/profile/user/views.cljs +++ b/src/status_im/ui/screens/profile/user/views.cljs @@ -21,6 +21,7 @@ [status-im.utils.utils :as utils] [status-im.ui.components.icons.vector-icons :as icons] [status-im.ui.components.common.common :as components.common] + [status-im.utils.identicon :as identicon] [clojure.string :as string])) (defn my-profile-toolbar [] @@ -59,6 +60,10 @@ (i18n/label :t/camera-access-error)) 50))}]))}]) +(defn- profile-icon-options-ext [] + (conj profile-icon-options {:label (i18n/label :t/image-remove-current) + :action #(re-frame/dispatch [:my-profile/remove-current-photo])})) + (defn qr-viewer-toolbar [label value] [toolbar/toolbar {} [toolbar/default-done {:icon-opts {:color colors/black} @@ -182,7 +187,7 @@ [advanced-settings params on-show])])) (defview my-profile [] - (letsubs [{:keys [public-key] :as current-account} [:get-current-account] + (letsubs [{:keys [public-key photo-path] :as current-account} [:get-current-account] editing? [:get :my-profile/editing?] changed-account [:get :my-profile/profile] currency [:wallet/currency] @@ -210,7 +215,9 @@ :edited-contact changed-account :editing? editing? :allow-icon-change? true - :options profile-icon-options + :options (if (not= (identicon/identicon public-key) photo-path) + (profile-icon-options-ext) + profile-icon-options) :on-change-text-event :my-profile/update-name}]] [react/view action-button.styles/actions-list [share-contact-code current-account public-key]]