fix #10052 make finding the public key easier in profile

Signed-off-by: yenda <eric@status.im>
This commit is contained in:
yenda 2020-03-25 01:30:29 +01:00
parent 035e07f7be
commit 23af624305
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
8 changed files with 99 additions and 83 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 B

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 B

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

After

Width:  |  Height:  |  Size: 886 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 B

View File

@ -29,61 +29,68 @@
props)]]) props)]])
(defn- names [{:keys [usernames name public-key] :as contact}] (defn- names [{:keys [usernames name public-key] :as contact}]
(let [generated-name (when public-key (gfy/generate-gfy public-key)) (let [generated-name (when public-key (gfy/generate-gfy public-key))]
with-subtitle? (seq usernames)] [react/view styles/profile-header-name-container-with-subtitle
[react/view (if with-subtitle? styles/profile-header-name-container-with-subtitle [react/text {:style styles/profile-name-text-with-subtitle
styles/profile-header-name-container)
[react/text {:style (if with-subtitle? styles/profile-name-text-with-subtitle
styles/profile-name-text)
:number-of-lines 2 :number-of-lines 2
:ellipsize-mode :tail} :ellipsize-mode :tail}
(multiaccounts/displayed-name contact)] (multiaccounts/displayed-name contact)]
(when with-subtitle? [react/text {:style styles/profile-three-words
[react/text {:style styles/profile-three-words :number-of-lines 1}
:number-of-lines 1} (if (seq usernames)
generated-name])])) generated-name
public-key)]]))
(defn- profile-header-display [{:keys [name public-key] :as contact} (defn chat-key-popover [public-key ens-name]
allow-icon-change? include-remove-action?] (re-frame/dispatch [:show-popover
[react/view (merge styles/profile-header-display {:padding-horizontal 16}) {:view :share-chat-key
(if allow-icon-change? :address public-key
[react/view {:align-items :center :ens-name ens-name}]))
:align-self :stretch
:justify-content :center} (defn- profile-header-display
[react/touchable-highlight [{:keys [name public-key preferred-name ens-name] :as contact}
{:accessibility-label :edit-profile-photo-button allow-icon-change? include-remove-action?]
:on-press [react/touchable-opacity
#(re-frame/dispatch {:on-press #(chat-key-popover public-key (or ens-name
[:bottom-sheet/show-sheet preferred-name))}
{:content (sheets/profile-icon-actions include-remove-action?) [react/view (merge styles/profile-header-display {:padding-horizontal 16})
:content-height (if include-remove-action? 192 128)}])} (if allow-icon-change?
[react/view [react/view {:align-items :center
[react/view {:background-color colors/white :align-self :stretch
:border-radius 15 :justify-content :center}
:width 30 [react/touchable-highlight
:height 30 {:accessibility-label :edit-profile-photo-button
:justify-content :center :on-press
:align-items :center #(re-frame/dispatch
:position :absolute [:bottom-sheet/show-sheet
:z-index 1 {:content (sheets/profile-icon-actions include-remove-action?)
:top -5 :content-height (if include-remove-action? 192 128)}])}
:right -5} [react/view
[react/view {:background-color colors/blue [react/view {:background-color colors/white
:border-radius 12 :border-radius 15
:width 24 :width 30
:height 24 :height 30
:justify-content :center :justify-content :center
:align-items :center} :align-items :center
[vector-icons/icon :tiny-edit {:color colors/white :position :absolute
:width 16 :z-index 1
:height 16}]]] :top -5
[chat-icon.screen/my-profile-icon {:multiaccount contact :right -5}
:edit? false}]]]] [react/view {:background-color colors/blue
;; else :border-radius 12
[chat-icon.screen/my-profile-icon {:multiaccount contact :width 24
:edit? false}]) :height 24
[names contact]]) :justify-content :center
:align-items :center}
[vector-icons/icon :tiny-edit {:color colors/white
:width 16
:height 16}]]]
[chat-icon.screen/my-profile-icon {:multiaccount contact
:edit? false}]]]]
;; else
[chat-icon.screen/my-profile-icon {:multiaccount contact
:edit? false}])
[names contact]]])
(defn group-header-display [{:keys [chat-name color contacts]}] (defn group-header-display [{:keys [chat-name color contacts]}]
[react/view (merge styles/profile-header-display {:padding-horizontal 16}) [react/view (merge styles/profile-header-display {:padding-horizontal 16})

View File

@ -89,12 +89,13 @@
(i18n/label :t/unblock-contact) (i18n/label :t/unblock-contact)
(i18n/label :t/block-contact))]]) (i18n/label :t/block-contact))]])
(defn- header-in-toolbar [account] (defn- header-in-toolbar [{:keys [public-key ens-name] :as account}]
(let [displayed-name (multiaccounts/displayed-name account)] (let [displayed-name (multiaccounts/displayed-name account)]
[react/view {:flex 1 [react/touchable-opacity {:on-press #(profile.components/chat-key-popover public-key ens-name)
:flex-direction :row :style {:flex 1
:align-items :center :flex-direction :row
:align-self :stretch} :align-items :center
:align-self :stretch}}
;;TODO this should be done in a subscription ;;TODO this should be done in a subscription
[photos/photo (multiaccounts/displayed-photo account) [photos/photo (multiaccounts/displayed-photo account)
{:size 40}] {:size 40}]
@ -112,15 +113,25 @@
:allow-icon-change? false :allow-icon-change? false
:include-remove-action? false}]) :include-remove-action? false}])
(defn- toolbar-action-items [public-key ens-name]
[toolbar/actions
[{:icon :main-icons/share
:icon-opts {:width 24
:height 24}
:handler #(profile.components/chat-key-popover public-key ens-name)}]])
;;TO-DO Rework generate-view to use 3 functions from large-toolbar ;;TO-DO Rework generate-view to use 3 functions from large-toolbar
(views/defview profile [] (views/defview profile []
(views/letsubs [list-ref (reagent/atom nil) (views/letsubs [list-ref (reagent/atom nil)
{:keys [ens-verified name] :as contact} [:contacts/current-contact]] {:keys [ens-verified name public-key] :as contact} [:contacts/current-contact]]
(when contact (when contact
(let [header-in-toolbar (header-in-toolbar contact) (let [ens-name (when (and ens-verified name) name)
header (header (cond-> contact contact (cond-> contact
(and ens-verified name) ens-name
(assoc :usernames [name]))) (assoc :usernames [ens-name]
:ens-name ens-name))
header-in-toolbar (header-in-toolbar contact)
header (header contact)
content content
[[react/view {:padding-top 12} [[react/view {:padding-top 12}
(for [{:keys [label subtext accessibility-label icon action disabled?]} (actions contact)] (for [{:keys [label subtext accessibility-label icon action disabled?]} (actions contact)]
@ -132,14 +143,12 @@
:disabled? disabled? :disabled? disabled?
:on-press action}])] :on-press action}])]
[react/view styles/contact-profile-details-container [react/view styles/contact-profile-details-container
[profile-details (cond-> contact [profile-details contact]]
(and ens-verified name)
(assoc :ens-name name))]]
[block-contact-action contact]] [block-contact-action contact]]
generated-view (large-toolbar/generate-view generated-view (large-toolbar/generate-view
header-in-toolbar header-in-toolbar
toolbar/default-nav-back toolbar/default-nav-back
nil (toolbar-action-items public-key ens-name)
header header
content content
list-ref)] list-ref)]

View File

@ -61,37 +61,37 @@
;:icon :main-icons/link ;:icon :main-icons/link
:accessibility-label :share-my-contact-code-button}]]]))) :accessibility-label :share-my-contact-code-button}]]])))
(defn- header [{:keys [photo-path] :as account} photo-added?] (defn- header [{:keys [photo-path public-key ens-name] :as account} photo-added?]
[profile.components/profile-header [profile.components/profile-header
{:contact account {:contact account
;;set to true if we want to re-enable custom icon ;;set to true if we want to re-enable custom icon
:allow-icon-change? false :allow-icon-change? false
:include-remove-action? photo-added?}]) :include-remove-action? photo-added?}])
(defn- header-in-toolbar [account] (defn- header-in-toolbar [{:keys [public-key preferred-name] :as account}]
(let [displayed-name (multiaccounts/displayed-name account)] (let [displayed-name (multiaccounts/displayed-name account)]
[react/view {:flex 1 [react/touchable-opacity
:flex-direction :row {:on-press #(profile.components/chat-key-popover public-key preferred-name)
:align-items :center :style {:flex 1}}
:align-self :stretch} [react/view {:style {:flex 1
;;TODO this should be done in a subscription :flex-direction :row
[photos/photo (multiaccounts/displayed-photo account) {:size 40}] :align-items :center
[react/text {:style {:typography :title-bold :align-self :stretch}}
:line-height 21 ;;TODO this should be done in a subscription
:margin-right 40 [photos/photo (multiaccounts/displayed-photo account) {:size 40}]
:margin-left 16 [react/text {:style {:typography :title-bold
:text-align :left}} :line-height 21
displayed-name]])) :margin-right 40
:margin-left 16
:text-align :left}}
displayed-name]]]))
(defn- toolbar-action-items [public-key ens-name] (defn- toolbar-action-items [public-key preferred-name]
[toolbar/actions [toolbar/actions
[{:icon :main-icons/share [{:icon :main-icons/share
:icon-opts {:width 24 :icon-opts {:width 24
:height 24} :height 24}
:handler #(re-frame/dispatch [:show-popover :handler #(profile.components/chat-key-popover public-key preferred-name)}]])
{:view :share-chat-key
:address public-key
:ens-name ens-name}])}]])
(defn tribute-to-talk-item (defn tribute-to-talk-item
[opts] [opts]