Skip to content

Commit

Permalink
feat: implement new design for the ENS registration
Browse files Browse the repository at this point in the history
  • Loading branch information
jrainville committed May 20, 2020
1 parent 7c15a43 commit d03486b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/status_im/ethereum/transactions/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
(cond
(= transaction-success true)
(fx/merge cofx
(status-im.ens.core/update-ens-tx-state :success username custom-domain? hash)
(status-im.ens.core/clear-ens-registration hash)
(status-im.ens.core/save-username custom-domain? username))
(= type :failed)
(status-im.ens.core/update-ens-tx-state :failure username custom-domain? hash)
Expand Down
35 changes: 14 additions & 21 deletions src/status_im/ui/screens/ens/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,14 @@
[button {:on-press #(re-frame/dispatch [::ens/get-started-pressed])
:label (i18n/label :t/get-started)}]]]))

(defn- name-item [{:keys [name action]}]
(defn- name-item [{:keys [name action subtitle]}]
(let [stateofus-username (stateofus/username name)
s (or stateofus-username name)]
[list-item/list-item
{:title s
:subtitle (when stateofus-username stateofus/domain)
:subtitle (if subtitle
subtitle
(when stateofus-username stateofus/domain))
:on-press action
:icon :main-icons/username}]))

Expand Down Expand Up @@ -627,30 +629,19 @@
(views/defview in-progress-registrations [registrations address]
[react/view {:style {:margin-top 8}}
(for [[hash {:keys [state username custom-domain?]}] registrations]
(when-not (= state :dismissed)
(when-not (or (= state :dismissed) (= state :success))
^{:key hash}
[list-item/list-item
{:title (let [progress-msg (str username (i18n/label :t/ens-registration-in-progress))]
(case state
:submitted progress-msg
:success (str username (i18n/label :t/ens-registration-complete))
:failure (str username (i18n/label :t/ens-registration-failure))
progress-msg))
:subtitle (i18n/label :t/ens-dismiss-message)
:on-press #(re-frame/dispatch (if (= state :submitted)
[:update-ens-tx-state :dismissed username custom-domain? hash]
[:clear-ens-registration hash]))
:icon (case state
:submitted :main-icons/change
:success :main-icons/check
:failure :main-icons/close
:main-icons/change)}]))])
[name-item {:name username
:action (when-not (= state :submitted)
#(re-frame/dispatch [:clear-ens-registration hash]))
:subtitle (case state
:submitted (i18n/label :t/ens-registration-in-progress)
:failure (i18n/label :t/ens-registration-failure)
nil)}]))])

(views/defview registered [names {:keys [preferred-name public-key name] :as account} _ registrations address]
[react/view {:style {:flex 1}}
[react/scroll-view
(when registrations
[in-progress-registrations registrations address])
[react/view {:style {:margin-top 8}}
[list-item/list-item
{:title (i18n/label :t/ens-add-username)
Expand All @@ -660,6 +651,8 @@
[react/view {:style {:margin-top 22 :margin-bottom 8}}
[react/text {:style {:color colors/gray :margin-horizontal 16}}
(i18n/label :t/ens-your-usernames)]
(when registrations
[in-progress-registrations registrations address])
(if (seq names)
[react/view {:style {:margin-top 8}}
(for [name names]
Expand Down
5 changes: 2 additions & 3 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,8 @@
"ens-powered-by": "Powered by Ethereum Name Services",
"ens-primary-username": "Primary username",
"ens-register": "Register",
"ens-registration-in-progress": ": Registration in progress",
"ens-registration-complete": ": Registration complete",
"ens-registration-failure": ": Registration failed",
"ens-registration-in-progress": "Registration in progress...",
"ens-registration-failure": "Registration failed",
"ens-dismiss-message": "Click here to dismiss",
"ens-registration-failed": "To register the username, please try again.",
"ens-registration-failed-title": "Transaction failed",
Expand Down

0 comments on commit d03486b

Please sign in to comment.