mirror of
https://github.com/status-im/status-react.git
synced 2025-02-25 17:16:03 +00:00
[Fix #8067] Added screens for ENS preferred name selection
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
cd567656d6
commit
3b7e92230b
@ -1,15 +1,24 @@
|
|||||||
(ns status-im.accounts.core
|
(ns status-im.accounts.core
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[status-im.accounts.update.core :as accounts.update]
|
[status-im.accounts.update.core :as accounts.update]
|
||||||
|
[status-im.ethereum.stateofus :as stateofus]
|
||||||
[status-im.i18n :as i18n]
|
[status-im.i18n :as i18n]
|
||||||
[status-im.native-module.core :as native-module]
|
[status-im.native-module.core :as native-module]
|
||||||
[status-im.ui.screens.navigation :as navigation]
|
[status-im.ui.screens.navigation :as navigation]
|
||||||
[status-im.utils.build :as build]
|
[status-im.utils.build :as build]
|
||||||
[status-im.utils.config :as config]
|
[status-im.utils.config :as config]
|
||||||
[status-im.utils.fx :as fx]
|
[status-im.utils.fx :as fx]
|
||||||
|
[status-im.utils.gfycat.core :as gfycat]
|
||||||
[status-im.utils.platform :as platform]
|
[status-im.utils.platform :as platform]
|
||||||
[status-im.utils.utils :as utils]))
|
[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
|
(re-frame/reg-fx
|
||||||
::chaos-mode-changed
|
::chaos-mode-changed
|
||||||
(fn [on]
|
(fn [on]
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[status-im.chat.commands.core :as commands]
|
[status-im.chat.commands.core :as commands]
|
||||||
[status-im.chat.commands.input :as commands.input]
|
[status-im.chat.commands.input :as commands.input]
|
||||||
|
[status-im.accounts.core :as accounts]
|
||||||
[status-im.contact.db :as contact.db]
|
[status-im.contact.db :as contact.db]
|
||||||
[status-im.group-chats.db :as group-chats.db]
|
[status-im.group-chats.db :as group-chats.db]
|
||||||
[status-im.mailserver.constants :as mailserver.constants]
|
[status-im.mailserver.constants :as mailserver.constants]
|
||||||
@ -36,7 +37,7 @@
|
|||||||
random-name (gfycat/generate-gfy chat-id)]
|
random-name (gfycat/generate-gfy chat-id)]
|
||||||
(-> chat
|
(-> chat
|
||||||
(assoc :contact contact
|
(assoc :contact contact
|
||||||
:chat-name (or contact-name random-name)
|
:chat-name (accounts/displayed-name contact)
|
||||||
:name contact-name
|
:name contact-name
|
||||||
:random-name random-name)
|
:random-name random-name)
|
||||||
(update :tags clojure.set/union (:tags contact))))))
|
(update :tags clojure.set/union (:tags contact))))))
|
||||||
|
@ -344,7 +344,7 @@
|
|||||||
(and group-chat (not public?))
|
(and group-chat (not public?))
|
||||||
(assoc :message-type :group-user-message)))
|
(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
|
(defn remove-icon
|
||||||
"Coin's icon's resource is represented as a function,
|
"Coin's icon's resource is represented as a function,
|
||||||
|
@ -248,3 +248,6 @@
|
|||||||
{:type :string :optional true}))
|
{:type :string :optional true}))
|
||||||
|
|
||||||
(def v24 (update v23 :properties merge {:usernames {: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}}))
|
||||||
|
@ -118,6 +118,11 @@
|
|||||||
extension/v12
|
extension/v12
|
||||||
account/v24])
|
account/v24])
|
||||||
|
|
||||||
|
(def v30 [network/v1
|
||||||
|
bootnode/v4
|
||||||
|
extension/v12
|
||||||
|
account/v25])
|
||||||
|
|
||||||
;; put schemas ordered by version
|
;; put schemas ordered by version
|
||||||
(def schemas [{:schema v1
|
(def schemas [{:schema v1
|
||||||
:schemaVersion 1
|
:schemaVersion 1
|
||||||
@ -205,4 +210,7 @@
|
|||||||
:migration (constantly nil)}
|
:migration (constantly nil)}
|
||||||
{:schema v29
|
{:schema v29
|
||||||
:schemaVersion 29
|
:schemaVersion 29
|
||||||
|
:migration (constantly nil)}
|
||||||
|
{:schema v30
|
||||||
|
:schemaVersion 30
|
||||||
:migration (constantly nil)}])
|
:migration (constantly nil)}])
|
||||||
|
@ -116,14 +116,34 @@
|
|||||||
{:db (-> (update-in db [:ens/registration :custom-domain?] not)
|
{:db (-> (update-in db [:ens/registration :custom-domain?] not)
|
||||||
(empty-username-candidate))})
|
(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
|
(fx/defn save-username
|
||||||
{:events [:ens/save-username]}
|
{:events [:ens/save-username]}
|
||||||
[{:keys [db] :as cofx} custom-domain? username]
|
[{:keys [db] :as cofx} custom-domain? username]
|
||||||
(let [name (fullname custom-domain? username)
|
(let [name (fullname custom-domain? username)
|
||||||
db (update-in db [:account/account :usernames] #((fnil conj []) %1 %2) name)]
|
new-db (update-in db [:account/account :usernames] #((fnil conj []) %1 %2) name)
|
||||||
(accounts.update/account-update cofx
|
names (get-in new-db [:account/account :usernames])]
|
||||||
{:usernames (get-in db [:account/account :usernames])}
|
(fx/merge {:db new-db}
|
||||||
{:success-event [:ens/set-state username :saved]})))
|
(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
|
(fx/defn on-registration-failure
|
||||||
{:events [:ens/on-registration-failure]}
|
{:events [:ens/on-registration-failure]}
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
(defn coordinates [public-key]
|
(defn coordinates [public-key]
|
||||||
(when-let [hex (naked-address public-key)]
|
(when-let [hex (naked-address public-key)]
|
||||||
(when (= public-key-length (count (subs hex 2)))
|
(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))})))
|
:y (normalized-address (subs hex 66))})))
|
||||||
|
|
||||||
(defn address? [s]
|
(defn address? [s]
|
||||||
|
@ -142,7 +142,7 @@
|
|||||||
:outputs ["bytes32" "bytes32"]
|
:outputs ["bytes32" "bytes32"]
|
||||||
:on-success
|
:on-success
|
||||||
(fn [[x y]]
|
(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)
|
(when-not (= public-key default-key)
|
||||||
(cb public-key))))}))
|
(cb public-key))))}))
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
(str username "." domain))
|
(str username "." domain))
|
||||||
|
|
||||||
(defn username [name]
|
(defn username [name]
|
||||||
(when (string/ends-with? name domain)
|
(when (and name (string/ends-with? name domain))
|
||||||
(first (string/split name "."))))
|
(first (string/split name "."))))
|
||||||
|
|
||||||
(def registrars
|
(def registrars
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
[status-im.react-native.js-dependencies :as rn]
|
[status-im.react-native.js-dependencies :as rn]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[status-im.i18n :as i18n]
|
[status-im.i18n :as i18n]
|
||||||
|
[status-im.accounts.core :as accounts]
|
||||||
[status-im.accounts.model :as accounts.model]
|
[status-im.accounts.model :as accounts.model]
|
||||||
[status-im.contact.db :as contact.db]
|
[status-im.contact.db :as contact.db]
|
||||||
[status-im.chat.models :as chat-model]
|
[status-im.chat.models :as chat-model]
|
||||||
@ -150,7 +151,7 @@
|
|||||||
|
|
||||||
(defn- get-contact-name [{:keys [db] :as cofx} from]
|
(defn- get-contact-name [{:keys [db] :as cofx} from]
|
||||||
(if (accounts.model/logged-in? cofx)
|
(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)))
|
(anonymize-pubkey from)))
|
||||||
|
|
||||||
(defn- build-notification [{:keys [title body decoded-payload]}]
|
(defn- build-notification [{:keys [title body decoded-payload]}]
|
||||||
|
@ -1847,13 +1847,25 @@
|
|||||||
(fn [account]
|
(fn [account]
|
||||||
(:usernames 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
|
(re-frame/reg-sub
|
||||||
:ens.registration/screen
|
:ens.registration/screen
|
||||||
:<- [:ens/registration]
|
:<- [:ens/registration]
|
||||||
:<- [:ens.stateofus/registrar]
|
:<- [:ens.stateofus/registrar]
|
||||||
:<- [:account/account]
|
:<- [:account/account]
|
||||||
(fn [[{:keys [custom-domain? username-candidate] :as ens} registrar {:keys [address public-key]}] _]
|
(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
|
:username username-candidate
|
||||||
:custom-domain? (or custom-domain? false)
|
:custom-domain? (or custom-domain? false)
|
||||||
:contract registrar
|
:contract registrar
|
||||||
@ -1870,6 +1882,18 @@
|
|||||||
:address address
|
:address address
|
||||||
:public-key public-key})))
|
: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 =============================================================================================================
|
;;SIGNING =============================================================================================================
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
|
@ -122,8 +122,7 @@
|
|||||||
value ""
|
value ""
|
||||||
active? true
|
active? true
|
||||||
style {}}}]
|
style {}}}]
|
||||||
{:pre [(or icon image-source activity-indicator)
|
{:pre [text
|
||||||
text
|
|
||||||
(or (nil? accessibility-label) (keyword? accessibility-label))]}
|
(or (nil? accessibility-label) (keyword? accessibility-label))]}
|
||||||
[react/touchable-highlight
|
[react/touchable-highlight
|
||||||
{:on-press action-fn
|
{:on-press action-fn
|
||||||
|
@ -215,19 +215,19 @@
|
|||||||
(if outgoing-status
|
(if outgoing-status
|
||||||
[text-status 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]]
|
(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
|
(defn message-body
|
||||||
[{:keys [last-in-group?
|
[{:keys [last-in-group?
|
||||||
display-photo?
|
display-photo?
|
||||||
display-username?
|
display-username?
|
||||||
message-type
|
|
||||||
from
|
from
|
||||||
outgoing
|
outgoing
|
||||||
modal?
|
modal?
|
||||||
username] :as message} content]
|
username
|
||||||
|
name] :as message} content]
|
||||||
[react/view (style/group-message-wrapper message)
|
[react/view (style/group-message-wrapper message)
|
||||||
[react/view (style/message-body message)
|
[react/view (style/message-body message)
|
||||||
(when display-photo?
|
(when display-photo?
|
||||||
@ -236,11 +236,11 @@
|
|||||||
[react/touchable-highlight {:on-press #(when-not modal? (re-frame/dispatch [:chat.ui/show-profile from]))}
|
[react/touchable-highlight {:on-press #(when-not modal? (re-frame/dispatch [:chat.ui/show-profile from]))}
|
||||||
[react/view
|
[react/view
|
||||||
[photos/member-photo from]]])])
|
[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?
|
(when display-username?
|
||||||
[react/touchable-opacity {:on-press #(re-frame/dispatch [:chat.ui/show-profile from])}
|
[react/touchable-opacity {:on-press #(re-frame/dispatch [:chat.ui/show-profile from])}
|
||||||
[message-author-name from username]])
|
[message-author-name from username name]])
|
||||||
[react/view {:style (style/timestamp-content-wrapper outgoing message-type)}
|
[react/view {:style (style/timestamp-content-wrapper outgoing)}
|
||||||
content]]]
|
content]]]
|
||||||
[react/view (style/delivery-status outgoing)
|
[react/view (style/delivery-status outgoing)
|
||||||
[message-delivery-status message]]])
|
[message-delivery-status message]]])
|
||||||
|
@ -70,11 +70,11 @@
|
|||||||
{:margin-right 64})
|
{:margin-right 64})
|
||||||
(last-message-padding message)))
|
(last-message-padding message)))
|
||||||
|
|
||||||
(defn timestamp-content-wrapper [outgoing message-type]
|
(defn timestamp-content-wrapper [outgoing]
|
||||||
{:flex-direction (if outgoing :row-reverse :row)})
|
{:flex-direction (if outgoing :row-reverse :row)})
|
||||||
|
|
||||||
(defn group-message-view
|
(defn group-message-view
|
||||||
[outgoing message-type display-photo?]
|
[outgoing display-photo?]
|
||||||
(let [align (if outgoing :flex-end :flex-start)]
|
(let [align (if outgoing :flex-end :flex-start)]
|
||||||
(merge {:flex-direction :column
|
(merge {:flex-direction :column
|
||||||
:max-width (if platform/desktop? 500 320)
|
:max-width (if platform/desktop? 500 320)
|
||||||
|
@ -1,31 +1,28 @@
|
|||||||
(ns status-im.ui.screens.chat.utils
|
(ns status-im.ui.screens.chat.utils
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
|
[status-im.ethereum.stateofus :as stateofus]
|
||||||
[status-im.utils.gfycat.core :as gfycat]
|
[status-im.utils.gfycat.core :as gfycat]
|
||||||
[status-im.utils.platform :as platform]
|
[status-im.utils.platform :as platform]
|
||||||
[status-im.i18n :as i18n]
|
[status-im.i18n :as i18n]
|
||||||
[status-im.constants :as constants]
|
|
||||||
[status-im.utils.core :as core-utils]
|
[status-im.utils.core :as core-utils]
|
||||||
[status-im.ui.components.react :as react]
|
[status-im.ui.components.react :as react]
|
||||||
[status-im.ui.components.colors :as colors]
|
[status-im.ui.components.colors :as colors]
|
||||||
[status-im.utils.http :as http]))
|
[status-im.utils.http :as http]))
|
||||||
|
|
||||||
(defn format-author [from username style]
|
(defn format-author [from username style ens-name]
|
||||||
;; TODO: We defensively generate the name for now, to be revisited when new protocol is defined
|
(cond
|
||||||
[react/nested-text {:style (style false)
|
ens-name
|
||||||
:number-of-lines 1
|
[react/text {:style {:color colors/blue :font-size 13 :font-weight "500"}}
|
||||||
:ellipsize-mode :tail}
|
(str "@" (or (stateofus/username ens-name) ens-name))]
|
||||||
(when username
|
:else
|
||||||
[{:style (style true)
|
[react/text {:style {:color colors/gray :font-size 12 :font-weight "400"}}
|
||||||
:number-of-lines 1
|
(gfycat/generate-gfy from)]))
|
||||||
:ellipsize-mode :tail}
|
|
||||||
(str username " • ")])
|
|
||||||
(gfycat/generate-gfy from)])
|
|
||||||
|
|
||||||
(defn format-reply-author [from username current-public-key style]
|
(defn format-reply-author [from username current-public-key style]
|
||||||
(or (and (= from current-public-key)
|
(or (and (= from current-public-key)
|
||||||
[react/text {:style (style true)}
|
[react/text {:style (style true)}
|
||||||
(i18n/label :t/You)])
|
(i18n/label :t/You)])
|
||||||
(format-author from username style)))
|
(format-author from username style nil)))
|
||||||
|
|
||||||
(def ^:private styling->prop
|
(def ^:private styling->prop
|
||||||
{:bold {:style {:font-weight "700"}}
|
{:bold {:style {:font-weight "700"}}
|
||||||
|
@ -56,10 +56,13 @@
|
|||||||
[status-im.ui.components.common.common :as components.common]
|
[status-im.ui.components.common.common :as components.common]
|
||||||
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
||||||
[status-im.ui.components.list.views :as list]
|
[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.react :as react]
|
||||||
[status-im.ui.components.status-bar.view :as status-bar]
|
[status-im.ui.components.status-bar.view :as status-bar]
|
||||||
[status-im.ui.components.toolbar.actions :as actions]
|
[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]))
|
(:require-macros [status-im.utils.views :as views]))
|
||||||
|
|
||||||
@ -124,7 +127,7 @@
|
|||||||
:icon :main-icons/close
|
:icon :main-icons/close
|
||||||
:icon-color colors/gray
|
:icon-color colors/gray
|
||||||
:hide-chevron? true}]
|
: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)
|
[list/big-list-item {:text (i18n/label :t/ens-release-username)
|
||||||
:text-color colors/gray
|
:text-color colors/gray
|
||||||
:text-style {:font-weight "500"}
|
:text-style {:font-weight "500"}
|
||||||
@ -205,7 +208,7 @@
|
|||||||
icon])
|
icon])
|
||||||
|
|
||||||
(defn- input-action [{:keys [state custom-domain? username]}]
|
(defn- input-action [{:keys [state custom-domain? username]}]
|
||||||
(if (= :connected state)
|
(if (= state :connected)
|
||||||
;; Already registered, just need to save the contact
|
;; Already registered, just need to save the contact
|
||||||
[:ens/save-username custom-domain? username]
|
[:ens/save-username custom-domain? username]
|
||||||
[:ens/set-state username :registering]))
|
[:ens/set-state username :registering]))
|
||||||
@ -487,35 +490,78 @@
|
|||||||
[button {:on-press #(re-frame/dispatch [:navigate-to :ens-register])
|
[button {:on-press #(re-frame/dispatch [:navigate-to :ens-register])
|
||||||
:label (i18n/label :t/get-started)}]]])
|
:label (i18n/label :t/get-started)}]]])
|
||||||
|
|
||||||
(defn- registered [names]
|
(defn- name-item [{:keys [name action hide-chevron?]}]
|
||||||
[react/scroll-view {:style {:flex 1}}
|
(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}}
|
[react/view {:style {:flex 1 :margin-top 8}}
|
||||||
[list/big-list-item {:text (i18n/label :t/ens-add-username)
|
[react/scroll-view {:style {:flex 1}}
|
||||||
:action-fn #(re-frame/dispatch [:navigate-to :ens-register])
|
[react/view {:style {:flex 1}}
|
||||||
:icon :main-icons/add}]]
|
(for [name names]
|
||||||
[react/view {:style {:margin-top 22}}
|
(let [action #(do (re-frame/dispatch [:ens/save-preferred-name name])
|
||||||
[react/text {:style {:color colors/gray :margin-horizontal 16}}
|
(re-frame/dispatch [:bottom-sheet/hide-sheet]))]
|
||||||
(i18n/label :t/ens-your-usernames)]
|
^{:key name}
|
||||||
(if (seq names)
|
[react/touchable-highlight {:on-press action}
|
||||||
[react/view {:style {:margin-top 8}}
|
[react/view {:style {:flex 1 :flex-direction :row :align-items :center :justify-content :center :margin-right 16}}
|
||||||
(for [name names]
|
[react/view {:style {:flex 1}}
|
||||||
^{:key name}
|
[name-item {:name name :hide-chevron? true :action action}]]
|
||||||
[react/view
|
[radio/radio (= name preferred-name)]]]))]]]])
|
||||||
(let [stateofus-username (stateofus/username name)
|
|
||||||
s (or stateofus-username name)]
|
(defn- registered [names {:keys [preferred-name address public-key name]} show?]
|
||||||
[list/big-list-item {:text s
|
[react/view {:style {:flex 1}}
|
||||||
:subtext (when stateofus-username stateofus/domain)
|
[react/scroll-view
|
||||||
:action-fn #(re-frame/dispatch [:ens/navigate-to-name name])
|
[react/view {:style {:margin-top 8}}
|
||||||
:icon :main-icons/username}])])]
|
[list/big-list-item {:text (i18n/label :t/ens-add-username)
|
||||||
[react/text {:style {:color colors/gray :font-size 15}}
|
:action-fn #(re-frame/dispatch [:navigate-to :ens-register])
|
||||||
(i18n/label :t/ens-no-usernames)])]])
|
: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/defview main []
|
||||||
(views/letsubs [names [:account/usernames]]
|
(views/letsubs [{:keys [names account preferred-name show?]} [:ens.main/screen]]
|
||||||
[react/view {:style {:flex 1}}
|
[react/view {:style {:flex 1}}
|
||||||
[status-bar/status-bar {:type :main}]
|
[status-bar/status-bar {:type :main}]
|
||||||
[toolbar/simple-toolbar
|
[toolbar/simple-toolbar
|
||||||
(i18n/label :t/ens-usernames)]
|
(i18n/label :t/ens-usernames)]
|
||||||
(if (seq names)
|
(if (seq names)
|
||||||
[registered names]
|
[registered names account show?]
|
||||||
[welcome])]))
|
[welcome])]))
|
||||||
|
@ -46,11 +46,12 @@
|
|||||||
{:margin-left 16})
|
{:margin-left 16})
|
||||||
|
|
||||||
(def settings-item
|
(def settings-item
|
||||||
{:padding-horizontal 16
|
{:padding-left 16
|
||||||
:flex 1
|
:padding-right 8
|
||||||
:flex-direction :row
|
:flex 1
|
||||||
:align-items :center
|
:flex-direction :row
|
||||||
:height 52})
|
:align-items :center
|
||||||
|
:height 52})
|
||||||
|
|
||||||
(def settings-item-icon
|
(def settings-item-icon
|
||||||
{:background-color colors/blue-light
|
{:background-color colors/blue-light
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
(ns status-im.ui.screens.profile.components.views
|
(ns status-im.ui.screens.profile.components.views
|
||||||
(:require [clojure.string :as string]
|
(:require [clojure.string :as string]
|
||||||
[re-frame.core :as re-frame]
|
[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.i18n :as i18n]
|
||||||
[status-im.ui.components.chat-icon.screen :as chat-icon.screen]
|
[status-im.ui.components.chat-icon.screen :as chat-icon.screen]
|
||||||
[status-im.ui.components.colors :as colors]
|
[status-im.ui.components.colors :as colors]
|
||||||
@ -38,7 +40,7 @@
|
|||||||
[react/view styles/profile-header-name-container
|
[react/view styles/profile-header-name-container
|
||||||
[react/text {:style styles/profile-name-text
|
[react/text {:style styles/profile-name-text
|
||||||
:number-of-lines 1}
|
:number-of-lines 1}
|
||||||
name]
|
(accounts/displayed-name contact)]
|
||||||
(when (and public-key (not= generated-name name))
|
(when (and public-key (not= generated-name name))
|
||||||
[react/text {:style styles/profile-three-words
|
[react/text {:style styles/profile-three-words
|
||||||
:number-of-lines 1}
|
:number-of-lines 1}
|
||||||
@ -101,7 +103,7 @@
|
|||||||
(if icon-content
|
(if icon-content
|
||||||
icon-content
|
icon-content
|
||||||
(when (and active? (not hide-arrow?))
|
(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
|
(defn settings-switch-item
|
||||||
[{:keys [label-kw value action-fn active?]
|
[{:keys [label-kw value action-fn active?]
|
||||||
|
@ -276,21 +276,22 @@
|
|||||||
:accessory-value active-contacts-count
|
:accessory-value active-contacts-count
|
||||||
:action-fn #(re-frame/dispatch [:navigate-to :contacts-list])}])
|
:action-fn #(re-frame/dispatch [:navigate-to :contacts-list])}])
|
||||||
|
|
||||||
(defn- ens-item [ens {:keys [registrar] :as props}]
|
(defn- ens-item [name {:keys [registrar] :as props}]
|
||||||
[list.views/big-list-item
|
[react/view {:style {:margin-top 8}}
|
||||||
(let [enabled? (not (nil? registrar))]
|
[list.views/big-list-item
|
||||||
(merge
|
(let [enabled? (not (nil? registrar))]
|
||||||
{:text (or ens (i18n/label :t/ens-usernames))
|
(merge
|
||||||
:subtext (if enabled?
|
{:text (or name (i18n/label :t/ens-usernames))
|
||||||
(if ens (i18n/label :t/ens-your-your-name) (i18n/label :t/ens-usernames-details))
|
:subtext (if enabled?
|
||||||
(i18n/label :t/ens-network-restriction))
|
(if name (i18n/label :t/ens-your-your-name) (i18n/label :t/ens-usernames-details))
|
||||||
:icon :main-icons/username
|
(i18n/label :t/ens-network-restriction))
|
||||||
:accessibility-label :ens-button}
|
:icon :main-icons/username
|
||||||
(if enabled?
|
:accessibility-label :ens-button}
|
||||||
{:action-fn #(re-frame/dispatch [:navigate-to :ens-main props])}
|
(if enabled?
|
||||||
{:icon-color colors/gray
|
{:action-fn #(re-frame/dispatch [:navigate-to :ens-main props])}
|
||||||
:active? false
|
{:icon-color colors/gray
|
||||||
:hide-chevron? (not enabled?)})))])
|
:active? false
|
||||||
|
:hide-chevron? (not enabled?)})))]])
|
||||||
|
|
||||||
(defn tribute-to-talk-item
|
(defn tribute-to-talk-item
|
||||||
[opts]
|
[opts]
|
||||||
@ -310,7 +311,7 @@
|
|||||||
[view]]]))
|
[view]]]))
|
||||||
|
|
||||||
(defview my-profile []
|
(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?]
|
editing? [:my-profile/editing?]
|
||||||
extensions [:extensions/profile]
|
extensions [:extensions/profile]
|
||||||
changed-account [:my-profile/profile]
|
changed-account [:my-profile/profile]
|
||||||
@ -351,7 +352,7 @@
|
|||||||
profile-icon-options)
|
profile-icon-options)
|
||||||
:on-change-text-event :my-profile/update-name}]]
|
:on-change-text-event :my-profile/update-name}]]
|
||||||
[share-profile-item (dissoc current-account :mnemonic)]
|
[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]
|
[contacts-list-item active-contacts-count]
|
||||||
(when tribute-to-talk
|
(when tribute-to-talk
|
||||||
[tribute-to-talk-item tribute-to-talk])
|
[tribute-to-talk-item tribute-to-talk])
|
||||||
|
@ -7,3 +7,8 @@
|
|||||||
(is (= (ethereum/chain-id->chain-keyword 3) :testnet))
|
(is (= (ethereum/chain-id->chain-keyword 3) :testnet))
|
||||||
(is (= (ethereum/chain-id->chain-keyword 4) :rinkeby))
|
(is (= (ethereum/chain-id->chain-keyword 4) :rinkeby))
|
||||||
(is (= (ethereum/chain-id->chain-keyword 5777) :custom)))
|
(is (= (ethereum/chain-id->chain-keyword 5777) :custom)))
|
||||||
|
|
||||||
|
(deftest coordinates
|
||||||
|
(is (= {:x "0x46fa4851f3cccd01e3b8d96c130c00bf812502354939eacf06a68fa519ebcbd1"
|
||||||
|
:y "0xeb08bebe7403856c0d9686210b9b2e324aa0179747bbba56d53f304a002f31c3"}
|
||||||
|
(ethereum/coordinates "0x0446fa4851f3cccd01e3b8d96c130c00bf812502354939eacf06a68fa519ebcbd1eb08bebe7403856c0d9686210b9b2e324aa0179747bbba56d53f304a002f31c3"))))
|
||||||
|
@ -1136,8 +1136,13 @@
|
|||||||
"ens-release-username": "Release username",
|
"ens-release-username": "Release username",
|
||||||
"ens-your-usernames": "Your usernames",
|
"ens-your-usernames": "Your usernames",
|
||||||
"ens-no-usernames": "You don't have any username connected",
|
"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-understand": "I understand that my wallet address will be publicly connected to my username.",
|
||||||
"ens-transaction-pending": "Transaction pending...",
|
"ens-transaction-pending": "Transaction pending...",
|
||||||
|
"ens-test-message": "Hey",
|
||||||
|
"ens-displayed-with": "Your messages are displayed to others with",
|
||||||
"add-account" : "Add account",
|
"add-account" : "Add account",
|
||||||
"add-an-account" : "Add an account",
|
"add-an-account" : "Add an account",
|
||||||
"back-up-your-seed-phrase" : "Back up your seed phrase",
|
"back-up-your-seed-phrase" : "Back up your seed phrase",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user