Fix WalletConnect header alignment on Android (#20860)

* fix: header align and max width for summary-tag

* fix: standard-title show ellipse when text is long

* fix: summary-tag long name overflowing
This commit is contained in:
Lungu Cristian 2024-07-25 14:21:19 +03:00 committed by GitHub
parent cee21241d4
commit ff88049a08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 63 additions and 38 deletions

View File

@ -4,7 +4,7 @@
(defn main (defn main
[{:keys [type customization-color]} theme] [{:keys [type customization-color]} theme]
{:justify-content :center {:justify-content :flex-start
:align-items :center :align-items :center
:height 32 :height 32
:padding-left 4 :padding-left 4
@ -16,6 +16,7 @@
(defn label (defn label
[type theme] [type theme]
{:color (colors/theme-colors colors/neutral-100 colors/white theme) {:color (colors/theme-colors colors/neutral-100 colors/white theme)
:flex-shrink 1
:margin-left (if (= type :address) 6 4)}) :margin-left (if (= type :address) 6 4)})
(def collectible-image (def collectible-image

View File

@ -58,16 +58,19 @@
- :emoji - string - emoji used for displaying account avatar - :emoji - string - emoji used for displaying account avatar
- :image-source - resource - image to display on :network, :collectible and :user - :image-source - resource - image to display on :network, :collectible and :user
- :theme - :light / :dark" - :theme - :light / :dark"
[{:keys [label customization-color type] [{:keys [label customization-color type container-style]
:as props :as props
:or {customization-color colors/neutral-80-opa-5}}] :or {customization-color colors/neutral-80-opa-5}}]
(let [theme (quo.theme/use-theme)] (let [theme (quo.theme/use-theme)]
[rn/view [rn/view
{:accessibility-label :container {:accessibility-label :container
:style (style/main (assoc props :customization-color customization-color) theme)} :style (merge (style/main (assoc props :customization-color customization-color)
theme)
container-style)}
[left-view props] [left-view props]
[text/text [text/text
{:style (style/label type theme) {:style (style/label type theme)
:weight :semi-bold :weight :semi-bold
:number-of-lines 1
:size :heading-1} :size :heading-1}
label]])) label]]))

View File

@ -21,3 +21,8 @@
(if blur? (if blur?
(colors/theme-colors colors/neutral-80-opa-70 colors/white-opa-70 theme) (colors/theme-colors colors/neutral-80-opa-70 colors/white-opa-70 theme)
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme))) (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)))
(def text
{:flex 1
;; NOTE: assures the ellipses are not cut off when text is too long
:padding-right 2})

View File

@ -59,7 +59,9 @@
[rn/view {:style (merge style/container container-style)} [rn/view {:style (merge style/container container-style)}
[text/text [text/text
{:size :heading-1 {:size :heading-1
:number-of-lines 1
:weight :semi-bold :weight :semi-bold
:style style/text
:accessibility-label accessibility-label} :accessibility-label accessibility-label}
title] title]
(case right (case right

View File

@ -1,10 +1,23 @@
(ns status-im.contexts.wallet.wallet-connect.modals.common.header.style) (ns status-im.contexts.wallet.wallet-connect.modals.common.header.style
(:require [quo.foundations.typography :as typography]))
(def ^:private line-height (:line-height typography/heading-1))
(def header-container (def header-container
{:padding-vertical 12}) {:padding-vertical 12
:justify-content :flex-start
:align-items :center
:flex-direction :row
:flex-wrap :wrap
:row-gap 2})
(def header-dapp-name (def word-container
{:margin-top -4}) {:height line-height
:justify-content :center})
(def header-account-name (def dapp-container
{:padding-top 4}) {:margin-top 0
:height line-height})
(def account-container
{:height line-height})

View File

@ -1,30 +1,31 @@
(ns status-im.contexts.wallet.wallet-connect.modals.common.header.view (ns status-im.contexts.wallet.wallet-connect.modals.common.header.view
(:require (:require [clojure.string :as string]
[quo.core :as quo] [quo.core :as quo]
[react-native.core :as rn] [react-native.core :as rn]
[status-im.contexts.wallet.wallet-connect.core :as core] [status-im.contexts.wallet.wallet-connect.core :as core]
[status-im.contexts.wallet.wallet-connect.modals.common.header.style :as style] [status-im.contexts.wallet.wallet-connect.modals.common.header.style :as style]))
[utils.string]))
(defn view (defn view
[{:keys [label dapp account]}] [{:keys [label dapp account]}]
[rn/view [rn/view {:style style/header-container}
{:style style/header-container}
[quo/text
{:size :heading-1
:weight :semi-bold}
(let [{:keys [name iconUrl url]} dapp (let [{:keys [name iconUrl url]} dapp
image-source (core/compute-dapp-icon-path iconUrl url)] image-source (core/compute-dapp-icon-path iconUrl url)]
[rn/view {:style style/header-dapp-name} [rn/view {:style style/dapp-container}
[quo/summary-tag [quo/summary-tag
{:type :dapp {:type :dapp
:label name :label name
:image-source image-source}]]) :image-source image-source}]])
(str " " label " ") (for [word (string/split label #" ")]
^{:key word}
[rn/view {:style style/word-container}
[quo/text
{:size :heading-1
:weight :semi-bold}
(str " " word)]])
(let [{:keys [emoji customization-color name]} account] (let [{:keys [emoji customization-color name]} account]
[rn/view {:style style/header-account-name} [rn/view {:style style/account-container}
[quo/summary-tag [quo/summary-tag
{:type :account {:type :account
:emoji emoji :emoji emoji
:label name :label name
:customization-color customization-color}]])]]) :customization-color customization-color}]])])