From 3b7e92230b687d955e94528977d4a0d47fcf6e29 Mon Sep 17 00:00:00 2001 From: Julien Eluard Date: Thu, 20 Jun 2019 16:11:24 +0200 Subject: [PATCH] [Fix #8067] Added screens for ENS preferred name selection Signed-off-by: Julien Eluard --- src/status_im/accounts/core.cljs | 9 ++ src/status_im/chat/db.cljs | 3 +- src/status_im/chat/models/message.cljs | 2 +- .../realm/schemas/base/account.cljs | 3 + .../data_store/realm/schemas/base/core.cljs | 8 ++ src/status_im/ens/core.cljs | 30 +++++- src/status_im/ethereum/core.cljs | 2 +- src/status_im/ethereum/ens.cljs | 2 +- src/status_im/ethereum/stateofus.cljs | 2 +- src/status_im/notifications/core.cljs | 3 +- src/status_im/subs.cljs | 26 ++++- src/status_im/ui/components/list/views.cljs | 3 +- .../ui/screens/chat/message/message.cljs | 14 +-- .../screens/chat/styles/message/message.cljs | 4 +- src/status_im/ui/screens/chat/utils.cljs | 23 ++--- src/status_im/ui/screens/ens/views.cljs | 98 ++++++++++++++----- .../ui/screens/profile/components/styles.cljs | 11 ++- .../ui/screens/profile/components/views.cljs | 6 +- .../ui/screens/profile/user/views.cljs | 35 +++---- test/cljs/status_im/test/ethereum/core.cljs | 5 + translations/en.json | 5 + 21 files changed, 208 insertions(+), 86 deletions(-) diff --git a/src/status_im/accounts/core.cljs b/src/status_im/accounts/core.cljs index aeddda2d5f..b2f39844d8 100644 --- a/src/status_im/accounts/core.cljs +++ b/src/status_im/accounts/core.cljs @@ -1,15 +1,24 @@ (ns status-im.accounts.core (:require [re-frame.core :as re-frame] [status-im.accounts.update.core :as accounts.update] + [status-im.ethereum.stateofus :as stateofus] [status-im.i18n :as i18n] [status-im.native-module.core :as native-module] [status-im.ui.screens.navigation :as navigation] [status-im.utils.build :as build] [status-im.utils.config :as config] [status-im.utils.fx :as fx] + [status-im.utils.gfycat.core :as gfycat] [status-im.utils.platform :as platform] [status-im.utils.utils :as utils])) +(defn displayed-name [{:keys [ens-name nickname public-key]}] + (or nickname + (when ens-name + (let [username (stateofus/username ens-name)] + (str "@" (or username ens-name)))) + (gfycat/generate-gfy public-key))) + (re-frame/reg-fx ::chaos-mode-changed (fn [on] diff --git a/src/status_im/chat/db.cljs b/src/status_im/chat/db.cljs index b7be011716..7b8fc8248c 100644 --- a/src/status_im/chat/db.cljs +++ b/src/status_im/chat/db.cljs @@ -3,6 +3,7 @@ [clojure.string :as string] [status-im.chat.commands.core :as commands] [status-im.chat.commands.input :as commands.input] + [status-im.accounts.core :as accounts] [status-im.contact.db :as contact.db] [status-im.group-chats.db :as group-chats.db] [status-im.mailserver.constants :as mailserver.constants] @@ -36,7 +37,7 @@ random-name (gfycat/generate-gfy chat-id)] (-> chat (assoc :contact contact - :chat-name (or contact-name random-name) + :chat-name (accounts/displayed-name contact) :name contact-name :random-name random-name) (update :tags clojure.set/union (:tags contact)))))) diff --git a/src/status_im/chat/models/message.cljs b/src/status_im/chat/models/message.cljs index 8861636101..a262f35287 100644 --- a/src/status_im/chat/models/message.cljs +++ b/src/status_im/chat/models/message.cljs @@ -344,7 +344,7 @@ (and group-chat (not public?)) (assoc :message-type :group-user-message))) -(def ^:private transport-keys [:content :content-type :message-type :clock-value :timestamp]) +(def ^:private transport-keys [:content :content-type :message-type :clock-value :timestamp :name]) (defn remove-icon "Coin's icon's resource is represented as a function, diff --git a/src/status_im/data_store/realm/schemas/base/account.cljs b/src/status_im/data_store/realm/schemas/base/account.cljs index 1e8de824cd..59d16aafea 100644 --- a/src/status_im/data_store/realm/schemas/base/account.cljs +++ b/src/status_im/data_store/realm/schemas/base/account.cljs @@ -248,3 +248,6 @@ {:type :string :optional true})) (def v24 (update v23 :properties merge {:usernames {:type "string[]" :optional true}})) + +(def v25 (update v24 :properties merge {:preferred-name {:type :string :optional true} + :show-name? {:type :bool :optional true}})) diff --git a/src/status_im/data_store/realm/schemas/base/core.cljs b/src/status_im/data_store/realm/schemas/base/core.cljs index 880f646285..b59eee8648 100644 --- a/src/status_im/data_store/realm/schemas/base/core.cljs +++ b/src/status_im/data_store/realm/schemas/base/core.cljs @@ -118,6 +118,11 @@ extension/v12 account/v24]) +(def v30 [network/v1 + bootnode/v4 + extension/v12 + account/v25]) + ;; put schemas ordered by version (def schemas [{:schema v1 :schemaVersion 1 @@ -205,4 +210,7 @@ :migration (constantly nil)} {:schema v29 :schemaVersion 29 + :migration (constantly nil)} + {:schema v30 + :schemaVersion 30 :migration (constantly nil)}]) diff --git a/src/status_im/ens/core.cljs b/src/status_im/ens/core.cljs index 09445591f8..15af4d52c5 100644 --- a/src/status_im/ens/core.cljs +++ b/src/status_im/ens/core.cljs @@ -116,14 +116,34 @@ {:db (-> (update-in db [:ens/registration :custom-domain?] not) (empty-username-candidate))}) +(fx/defn save-preferred-name + {:events [:ens/save-preferred-name]} + [{:keys [db] :as cofx} name] + (fx/merge (assoc-in cofx [:db :account/account :preferred-name] name) + (accounts.update/account-update cofx + {:preferred-name name}))) + (fx/defn save-username {:events [:ens/save-username]} [{:keys [db] :as cofx} custom-domain? username] - (let [name (fullname custom-domain? username) - db (update-in db [:account/account :usernames] #((fnil conj []) %1 %2) name)] - (accounts.update/account-update cofx - {:usernames (get-in db [:account/account :usernames])} - {:success-event [:ens/set-state username :saved]}))) + (let [name (fullname custom-domain? username) + new-db (update-in db [:account/account :usernames] #((fnil conj []) %1 %2) name) + names (get-in new-db [:account/account :usernames])] + (fx/merge {:db new-db} + (accounts.update/account-update cofx + {:usernames names} + {:success-event [:ens/set-state username :saved]}) + (when (= 1 (count names)) + ;; First name, save it as default + (save-preferred-name cofx name))))) + +(fx/defn switch-show-username + {:events [:ens/switch-show-username]} + [{:keys [db] :as cofx} _] + (let [new-db (update-in db [:account/account :show-name?] not)] + (fx/merge {:db new-db} + (accounts.update/account-update cofx + {:show-name? (get-in new-db [:account/account :show-name?])})))) (fx/defn on-registration-failure {:events [:ens/on-registration-failure]} diff --git a/src/status_im/ethereum/core.cljs b/src/status_im/ethereum/core.cljs index ca062dee10..f535e3bdf1 100644 --- a/src/status_im/ethereum/core.cljs +++ b/src/status_im/ethereum/core.cljs @@ -70,7 +70,7 @@ (defn coordinates [public-key] (when-let [hex (naked-address public-key)] (when (= public-key-length (count (subs hex 2))) - {:x (normalized-address (subs hex 1 65)) + {:x (normalized-address (subs hex 2 66)) :y (normalized-address (subs hex 66))}))) (defn address? [s] diff --git a/src/status_im/ethereum/ens.cljs b/src/status_im/ethereum/ens.cljs index 0640dc3a2f..eceea4f67e 100644 --- a/src/status_im/ethereum/ens.cljs +++ b/src/status_im/ethereum/ens.cljs @@ -142,7 +142,7 @@ :outputs ["bytes32" "bytes32"] :on-success (fn [[x y]] - (when-let [public-key (uncompressed-public-key x y)] + (let [public-key (uncompressed-public-key x y)] (when-not (= public-key default-key) (cb public-key))))})) diff --git a/src/status_im/ethereum/stateofus.cljs b/src/status_im/ethereum/stateofus.cljs index d26bf6eb08..1bcf0a834c 100644 --- a/src/status_im/ethereum/stateofus.cljs +++ b/src/status_im/ethereum/stateofus.cljs @@ -7,7 +7,7 @@ (str username "." domain)) (defn username [name] - (when (string/ends-with? name domain) + (when (and name (string/ends-with? name domain)) (first (string/split name ".")))) (def registrars diff --git a/src/status_im/notifications/core.cljs b/src/status_im/notifications/core.cljs index 7f075b532a..11f712b64d 100644 --- a/src/status_im/notifications/core.cljs +++ b/src/status_im/notifications/core.cljs @@ -4,6 +4,7 @@ [status-im.react-native.js-dependencies :as rn] [taoensso.timbre :as log] [status-im.i18n :as i18n] + [status-im.accounts.core :as accounts] [status-im.accounts.model :as accounts.model] [status-im.contact.db :as contact.db] [status-im.chat.models :as chat-model] @@ -150,7 +151,7 @@ (defn- get-contact-name [{:keys [db] :as cofx} from] (if (accounts.model/logged-in? cofx) - (:name (hash->contact from (-> db :contacts/contacts vals))) + (accounts/displayed-name (hash->contact from (-> db :contacts/contacts vals))) (anonymize-pubkey from))) (defn- build-notification [{:keys [title body decoded-payload]}] diff --git a/src/status_im/subs.cljs b/src/status_im/subs.cljs index 49bf48c524..db032799dd 100644 --- a/src/status_im/subs.cljs +++ b/src/status_im/subs.cljs @@ -1847,13 +1847,25 @@ (fn [account] (:usernames account))) +(re-frame/reg-sub + :ens/preferred-name + :<- [:account/account] + (fn [account] + (:preferred-name account))) + +(re-frame/reg-sub + :ens/show? + :<- [:account/account] + (fn [account] + (:show-name? account))) + (re-frame/reg-sub :ens.registration/screen :<- [:ens/registration] :<- [:ens.stateofus/registrar] :<- [:account/account] (fn [[{:keys [custom-domain? username-candidate] :as ens} registrar {:keys [address public-key]}] _] - {:state (get-in ens [:states username-candidate]) + {:state (or (get-in ens [:states username-candidate]) :initial) :username username-candidate :custom-domain? (or custom-domain? false) :contract registrar @@ -1870,6 +1882,18 @@ :address address :public-key public-key}))) +(re-frame/reg-sub + :ens.main/screen + :<- [:account/usernames] + :<- [:account/account] + :<- [:ens/preferred-name] + :<- [:ens/show?] + (fn [[names account preferred-name show?] _] + {:names names + :account account + :preferred-name preferred-name + :show? (or show? false)})) + ;;SIGNING ============================================================================================================= (re-frame/reg-sub diff --git a/src/status_im/ui/components/list/views.cljs b/src/status_im/ui/components/list/views.cljs index 487a3fcacd..97c1919279 100644 --- a/src/status_im/ui/components/list/views.cljs +++ b/src/status_im/ui/components/list/views.cljs @@ -122,8 +122,7 @@ value "" active? true style {}}}] - {:pre [(or icon image-source activity-indicator) - text + {:pre [text (or (nil? accessibility-label) (keyword? accessibility-label))]} [react/touchable-highlight {:on-press action-fn diff --git a/src/status_im/ui/screens/chat/message/message.cljs b/src/status_im/ui/screens/chat/message/message.cljs index 999d458ea7..97c44d0c0f 100644 --- a/src/status_im/ui/screens/chat/message/message.cljs +++ b/src/status_im/ui/screens/chat/message/message.cljs @@ -215,19 +215,19 @@ (if outgoing-status [text-status outgoing-status])))))) -(defview message-author-name [from message-username] +(defview message-author-name [from message-username name] (letsubs [username [:contacts/contact-name-by-identity from]] - (chat.utils/format-author from (or username message-username) style/message-author-name))) + (chat.utils/format-author from (or username message-username) style/message-author-name name))) (defn message-body [{:keys [last-in-group? display-photo? display-username? - message-type from outgoing modal? - username] :as message} content] + username + name] :as message} content] [react/view (style/group-message-wrapper message) [react/view (style/message-body message) (when display-photo? @@ -236,11 +236,11 @@ [react/touchable-highlight {:on-press #(when-not modal? (re-frame/dispatch [:chat.ui/show-profile from]))} [react/view [photos/member-photo from]]])]) - [react/view (style/group-message-view outgoing message-type display-photo?) + [react/view (style/group-message-view outgoing display-photo?) (when display-username? [react/touchable-opacity {:on-press #(re-frame/dispatch [:chat.ui/show-profile from])} - [message-author-name from username]]) - [react/view {:style (style/timestamp-content-wrapper outgoing message-type)} + [message-author-name from username name]]) + [react/view {:style (style/timestamp-content-wrapper outgoing)} content]]] [react/view (style/delivery-status outgoing) [message-delivery-status message]]]) diff --git a/src/status_im/ui/screens/chat/styles/message/message.cljs b/src/status_im/ui/screens/chat/styles/message/message.cljs index 879030769a..25056c8085 100644 --- a/src/status_im/ui/screens/chat/styles/message/message.cljs +++ b/src/status_im/ui/screens/chat/styles/message/message.cljs @@ -70,11 +70,11 @@ {:margin-right 64}) (last-message-padding message))) -(defn timestamp-content-wrapper [outgoing message-type] +(defn timestamp-content-wrapper [outgoing] {:flex-direction (if outgoing :row-reverse :row)}) (defn group-message-view - [outgoing message-type display-photo?] + [outgoing display-photo?] (let [align (if outgoing :flex-end :flex-start)] (merge {:flex-direction :column :max-width (if platform/desktop? 500 320) diff --git a/src/status_im/ui/screens/chat/utils.cljs b/src/status_im/ui/screens/chat/utils.cljs index 1c450df3f2..ac99454570 100644 --- a/src/status_im/ui/screens/chat/utils.cljs +++ b/src/status_im/ui/screens/chat/utils.cljs @@ -1,31 +1,28 @@ (ns status-im.ui.screens.chat.utils (:require [re-frame.core :as re-frame] + [status-im.ethereum.stateofus :as stateofus] [status-im.utils.gfycat.core :as gfycat] [status-im.utils.platform :as platform] [status-im.i18n :as i18n] - [status-im.constants :as constants] [status-im.utils.core :as core-utils] [status-im.ui.components.react :as react] [status-im.ui.components.colors :as colors] [status-im.utils.http :as http])) -(defn format-author [from username style] - ;; TODO: We defensively generate the name for now, to be revisited when new protocol is defined - [react/nested-text {:style (style false) - :number-of-lines 1 - :ellipsize-mode :tail} - (when username - [{:style (style true) - :number-of-lines 1 - :ellipsize-mode :tail} - (str username " • ")]) - (gfycat/generate-gfy from)]) +(defn format-author [from username style ens-name] + (cond + ens-name + [react/text {:style {:color colors/blue :font-size 13 :font-weight "500"}} + (str "@" (or (stateofus/username ens-name) ens-name))] + :else + [react/text {:style {:color colors/gray :font-size 12 :font-weight "400"}} + (gfycat/generate-gfy from)])) (defn format-reply-author [from username current-public-key style] (or (and (= from current-public-key) [react/text {:style (style true)} (i18n/label :t/You)]) - (format-author from username style))) + (format-author from username style nil))) (def ^:private styling->prop {:bold {:style {:font-weight "700"}} diff --git a/src/status_im/ui/screens/ens/views.cljs b/src/status_im/ui/screens/ens/views.cljs index 6fc449be82..d599e2565d 100644 --- a/src/status_im/ui/screens/ens/views.cljs +++ b/src/status_im/ui/screens/ens/views.cljs @@ -56,10 +56,13 @@ [status-im.ui.components.common.common :as components.common] [status-im.ui.components.icons.vector-icons :as vector-icons] [status-im.ui.components.list.views :as list] + [status-im.ui.components.radio :as radio] [status-im.ui.components.react :as react] [status-im.ui.components.status-bar.view :as status-bar] [status-im.ui.components.toolbar.actions :as actions] - [status-im.ui.components.toolbar.view :as toolbar]) + [status-im.ui.components.toolbar.view :as toolbar] + [status-im.ui.screens.chat.message.message :as message] + [status-im.ui.screens.profile.components.views :as profile.components]) (:require-macros [status-im.utils.views :as views])) @@ -124,7 +127,7 @@ :icon :main-icons/close :icon-color colors/gray :hide-chevron? true}] - [react/view {:style {:margin-top 10}} + [react/view {:style {:margin-top 18}} [list/big-list-item {:text (i18n/label :t/ens-release-username) :text-color colors/gray :text-style {:font-weight "500"} @@ -205,7 +208,7 @@ icon]) (defn- input-action [{:keys [state custom-domain? username]}] - (if (= :connected state) + (if (= state :connected) ;; Already registered, just need to save the contact [:ens/save-username custom-domain? username] [:ens/set-state username :registering])) @@ -487,35 +490,78 @@ [button {:on-press #(re-frame/dispatch [:navigate-to :ens-register]) :label (i18n/label :t/get-started)}]]]) -(defn- registered [names] - [react/scroll-view {:style {:flex 1}} +(defn- name-item [{:keys [name action hide-chevron?]}] + (let [stateofus-username (stateofus/username name) + s (or stateofus-username name)] + [list/big-list-item {:text s + :subtext (when stateofus-username stateofus/domain) + :action-fn action + :icon :main-icons/username + :hide-chevron? hide-chevron?}])) + +(defn- name-list [names preferred-name] + [react/view {:style {:flex 1 :margin-top 16}} + [react/view {:style {:margin-horizontal 16 :align-items :center :justify-content :center}} + [react/nested-text + {:style {:color colors/gray}} + (i18n/label :t/ens-displayed-with) + [{:style {:color colors/black :text-align :center}} + (str "\n@" preferred-name)]]] [react/view {:style {:flex 1 :margin-top 8}} - [list/big-list-item {:text (i18n/label :t/ens-add-username) - :action-fn #(re-frame/dispatch [:navigate-to :ens-register]) - :icon :main-icons/add}]] - [react/view {:style {:margin-top 22}} - [react/text {:style {:color colors/gray :margin-horizontal 16}} - (i18n/label :t/ens-your-usernames)] - (if (seq names) - [react/view {:style {:margin-top 8}} - (for [name names] - ^{:key name} - [react/view - (let [stateofus-username (stateofus/username name) - s (or stateofus-username name)] - [list/big-list-item {:text s - :subtext (when stateofus-username stateofus/domain) - :action-fn #(re-frame/dispatch [:ens/navigate-to-name name]) - :icon :main-icons/username}])])] - [react/text {:style {:color colors/gray :font-size 15}} - (i18n/label :t/ens-no-usernames)])]]) + [react/scroll-view {:style {:flex 1}} + [react/view {:style {:flex 1}} + (for [name names] + (let [action #(do (re-frame/dispatch [:ens/save-preferred-name name]) + (re-frame/dispatch [:bottom-sheet/hide-sheet]))] + ^{:key name} + [react/touchable-highlight {:on-press action} + [react/view {:style {:flex 1 :flex-direction :row :align-items :center :justify-content :center :margin-right 16}} + [react/view {:style {:flex 1}} + [name-item {:name name :hide-chevron? true :action action}]] + [radio/radio (= name preferred-name)]]]))]]]]) + +(defn- registered [names {:keys [preferred-name address public-key name]} show?] + [react/view {:style {:flex 1}} + [react/scroll-view + [react/view {:style {:margin-top 8}} + [list/big-list-item {:text (i18n/label :t/ens-add-username) + :action-fn #(re-frame/dispatch [:navigate-to :ens-register]) + :icon :main-icons/add}]] + [react/view {:style {:margin-top 22 :margin-bottom 8}} + [react/text {:style {:color colors/gray :margin-horizontal 16}} + (i18n/label :t/ens-your-usernames)] + (if (seq names) + [react/view {:style {:margin-top 8}} + (for [name names] + ^{:key name} + [name-item {:name name :action #(re-frame/dispatch [:ens/navigate-to-name name])}])] + [react/text {:style {:color colors/gray :font-size 15}} + (i18n/label :t/ens-no-usernames)])] + [react/view {:style {:padding-top 22 :border-color colors/gray-lighter :border-top-width 1}} + [react/text {:style {:color colors/gray :margin-horizontal 16}} + (i18n/label :t/ens-chat-settings)] + (when (> (count names) 1) + [profile.components/settings-item {:label-kw :ens-primary-username + :value preferred-name + :action-fn #(re-frame/dispatch [:bottom-sheet/show-sheet + {:content (fn [] (name-list names preferred-name)) + :content-height (+ 72 (* (min 4 (count names)) 64))}])}]) + [profile.components/settings-switch-item {:label-kw :ens-show-username + :action-fn #(re-frame/dispatch [:ens/switch-show-username]) + :value show?}]] + (let [message (merge {:from public-key :last-in-group? true :display-username? true :display-photo? true :username name + :content {:text (i18n/label :t/ens-test-message)} :content-type "text/plain" :timestamp-str "9:41 AM"} + (when show? + {:name preferred-name}))] + [message/message-body message + [message/text-message message]])]]) (views/defview main [] - (views/letsubs [names [:account/usernames]] + (views/letsubs [{:keys [names account preferred-name show?]} [:ens.main/screen]] [react/view {:style {:flex 1}} [status-bar/status-bar {:type :main}] [toolbar/simple-toolbar (i18n/label :t/ens-usernames)] (if (seq names) - [registered names] + [registered names account show?] [welcome])])) diff --git a/src/status_im/ui/screens/profile/components/styles.cljs b/src/status_im/ui/screens/profile/components/styles.cljs index cdec57bc43..e6cda1a33a 100644 --- a/src/status_im/ui/screens/profile/components/styles.cljs +++ b/src/status_im/ui/screens/profile/components/styles.cljs @@ -46,11 +46,12 @@ {:margin-left 16}) (def settings-item - {:padding-horizontal 16 - :flex 1 - :flex-direction :row - :align-items :center - :height 52}) + {:padding-left 16 + :padding-right 8 + :flex 1 + :flex-direction :row + :align-items :center + :height 52}) (def settings-item-icon {:background-color colors/blue-light diff --git a/src/status_im/ui/screens/profile/components/views.cljs b/src/status_im/ui/screens/profile/components/views.cljs index 2d94feace7..d6dd445366 100644 --- a/src/status_im/ui/screens/profile/components/views.cljs +++ b/src/status_im/ui/screens/profile/components/views.cljs @@ -1,6 +1,8 @@ (ns status-im.ui.screens.profile.components.views (:require [clojure.string :as string] [re-frame.core :as re-frame] + [status-im.accounts.core :as accounts] + [status-im.ethereum.stateofus :as stateofus] [status-im.i18n :as i18n] [status-im.ui.components.chat-icon.screen :as chat-icon.screen] [status-im.ui.components.colors :as colors] @@ -38,7 +40,7 @@ [react/view styles/profile-header-name-container [react/text {:style styles/profile-name-text :number-of-lines 1} - name] + (accounts/displayed-name contact)] (when (and public-key (not= generated-name name)) [react/text {:style styles/profile-three-words :number-of-lines 1} @@ -101,7 +103,7 @@ (if icon-content icon-content (when (and active? (not hide-arrow?)) - [vector-icons/icon :main-icons/next {:color colors/gray}]))]]) + [vector-icons/icon :main-icons/next {:color colors/gray-transparent-40}]))]]) (defn settings-switch-item [{:keys [label-kw value action-fn active?] diff --git a/src/status_im/ui/screens/profile/user/views.cljs b/src/status_im/ui/screens/profile/user/views.cljs index f164bd446e..b02bd512e0 100644 --- a/src/status_im/ui/screens/profile/user/views.cljs +++ b/src/status_im/ui/screens/profile/user/views.cljs @@ -276,21 +276,22 @@ :accessory-value active-contacts-count :action-fn #(re-frame/dispatch [:navigate-to :contacts-list])}]) -(defn- ens-item [ens {:keys [registrar] :as props}] - [list.views/big-list-item - (let [enabled? (not (nil? registrar))] - (merge - {:text (or ens (i18n/label :t/ens-usernames)) - :subtext (if enabled? - (if ens (i18n/label :t/ens-your-your-name) (i18n/label :t/ens-usernames-details)) - (i18n/label :t/ens-network-restriction)) - :icon :main-icons/username - :accessibility-label :ens-button} - (if enabled? - {:action-fn #(re-frame/dispatch [:navigate-to :ens-main props])} - {:icon-color colors/gray - :active? false - :hide-chevron? (not enabled?)})))]) +(defn- ens-item [name {:keys [registrar] :as props}] + [react/view {:style {:margin-top 8}} + [list.views/big-list-item + (let [enabled? (not (nil? registrar))] + (merge + {:text (or name (i18n/label :t/ens-usernames)) + :subtext (if enabled? + (if name (i18n/label :t/ens-your-your-name) (i18n/label :t/ens-usernames-details)) + (i18n/label :t/ens-network-restriction)) + :icon :main-icons/username + :accessibility-label :ens-button} + (if enabled? + {:action-fn #(re-frame/dispatch [:navigate-to :ens-main props])} + {:icon-color colors/gray + :active? false + :hide-chevron? (not enabled?)})))]]) (defn tribute-to-talk-item [opts] @@ -310,7 +311,7 @@ [view]]])) (defview my-profile [] - (letsubs [{:keys [public-key photo-path] :as current-account} [:account/account] + (letsubs [{:keys [public-key photo-path preferred-name] :as current-account} [:account/account] editing? [:my-profile/editing?] extensions [:extensions/profile] changed-account [:my-profile/profile] @@ -351,7 +352,7 @@ profile-icon-options) :on-change-text-event :my-profile/update-name}]] [share-profile-item (dissoc current-account :mnemonic)] - [ens-item nil {:registrar stateofus-registrar}] + [ens-item preferred-name {:registrar stateofus-registrar}] [contacts-list-item active-contacts-count] (when tribute-to-talk [tribute-to-talk-item tribute-to-talk]) diff --git a/test/cljs/status_im/test/ethereum/core.cljs b/test/cljs/status_im/test/ethereum/core.cljs index 969edc3ecc..77cf1d9e0e 100644 --- a/test/cljs/status_im/test/ethereum/core.cljs +++ b/test/cljs/status_im/test/ethereum/core.cljs @@ -7,3 +7,8 @@ (is (= (ethereum/chain-id->chain-keyword 3) :testnet)) (is (= (ethereum/chain-id->chain-keyword 4) :rinkeby)) (is (= (ethereum/chain-id->chain-keyword 5777) :custom))) + +(deftest coordinates + (is (= {:x "0x46fa4851f3cccd01e3b8d96c130c00bf812502354939eacf06a68fa519ebcbd1" + :y "0xeb08bebe7403856c0d9686210b9b2e324aa0179747bbba56d53f304a002f31c3"} + (ethereum/coordinates "0x0446fa4851f3cccd01e3b8d96c130c00bf812502354939eacf06a68fa519ebcbd1eb08bebe7403856c0d9686210b9b2e324aa0179747bbba56d53f304a002f31c3")))) diff --git a/translations/en.json b/translations/en.json index e4d50037bd..b664bf06f5 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1136,8 +1136,13 @@ "ens-release-username": "Release username", "ens-your-usernames": "Your usernames", "ens-no-usernames": "You don't have any username connected", + "ens-chat-settings": "Chat settings", + "ens-primary-username": "Primary username", + "ens-show-username": "Show my ENS username in chats", "ens-understand": "I understand that my wallet address will be publicly connected to my username.", "ens-transaction-pending": "Transaction pending...", + "ens-test-message": "Hey", + "ens-displayed-with": "Your messages are displayed to others with", "add-account" : "Add account", "add-an-account" : "Add an account", "back-up-your-seed-phrase" : "Back up your seed phrase",