Follow up to fix color picker on wallet (#17748)

This commit is contained in:
Ibrahem Khalil 2023-11-01 15:18:53 +02:00 committed by GitHub
parent 94a3e266a9
commit 6c2b437e62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 41 deletions

View File

@ -1,7 +1,7 @@
(ns quo.components.colors.color.style (ns quo.components.colors.color.style
(:require (:require
[quo.components.colors.color.constants :as constants] [quo.foundations.colors :as colors]
[quo.foundations.colors :as colors])) [utils.responsiveness :as responsiveness]))
(defn color-button-common (defn color-button-common
[window-width] [window-width]
@ -10,7 +10,7 @@
:border-width 4 :border-width 4
:border-radius 24 :border-radius 24
:margin-right (-> window-width :margin-right (-> window-width
(- constants/IPHONE_11_PRO_VIEWPORT_WIDTH) ;We want the design to be 100% (- responsiveness/IPHONE_11_PRO_VIEWPORT_WIDTH) ;We want the design to be 100%
;identical to Figma on iPhone 11 ;identical to Figma on iPhone 11
;Pro, So we're using it's VW here. ;Pro, So we're using it's VW here.
(/ 6) ;Dividing by an appropriate factor to get a reasonable value for each VW (/ 6) ;Dividing by an appropriate factor to get a reasonable value for each VW
@ -25,14 +25,12 @@
([color selected?] ([color selected?]
(color-button color selected? nil nil)) (color-button color selected? nil nil))
([color selected? idx window-width] ([color selected? idx window-width]
(merge (color-button-common window-width) (cond-> (color-button-common window-width)
(when selected? selected? (assoc :border-top-color (colors/alpha color 0.4)
{:border-top-color (colors/alpha color 0.4)
:border-end-color (colors/alpha color 0.4) :border-end-color (colors/alpha color 0.4)
:border-bottom-color (colors/alpha color 0.2) :border-bottom-color (colors/alpha color 0.2)
:border-start-color (colors/alpha color 0.2)} :border-start-color (colors/alpha color 0.2))
(when (zero? idx) (zero? idx) (assoc :margin-left -4))))
{:margin-left -4})))))
(defn color-circle (defn color-circle
[color border?] [color border?]

View File

@ -17,8 +17,9 @@
- `default-selected` Default selected color name. - `default-selected` Default selected color name.
- `on-change` Callback called when a color is selected `(fn [color-name])`. - `on-change` Callback called when a color is selected `(fn [color-name])`.
- `blur?` Boolean to enable blur background support.}" - `blur?` Boolean to enable blur background support.}"
[{:keys [default-selected window-width]}] [{:keys [default-selected]}]
(let [selected (reagent/atom default-selected)] (let [selected (reagent/atom default-selected)
{window-width :width} (rn/get-window)]
(fn [{:keys [blur? on-change feng-shui? container-style]}] (fn [{:keys [blur? on-change feng-shui? container-style]}]
[rn/scroll-view [rn/scroll-view
{:horizontal true {:horizontal true

View File

@ -2,7 +2,6 @@
(:require (:require
[clojure.string :as string] [clojure.string :as string]
[oops.core :as oops] [oops.core :as oops]
[quo.components.colors.color.constants :as constants]
[quo.core :as quo] [quo.core :as quo]
[quo.foundations.colors :as colors] [quo.foundations.colors :as colors]
[react-native.blur :as blur] [react-native.blur :as blur]
@ -15,7 +14,8 @@
[status-im2.contexts.onboarding.create-profile.style :as style] [status-im2.contexts.onboarding.create-profile.style :as style]
[status-im2.contexts.onboarding.select-photo.method-menu.view :as method-menu] [status-im2.contexts.onboarding.select-photo.method-menu.view :as method-menu]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]
[utils.responsiveness :as responsiveness]))
;; NOTE - validation should match with Desktop ;; NOTE - validation should match with Desktop
;; https://github.com/status-im/status-desktop/blob/2ba96803168461088346bf5030df750cb226df4c/ui/imports/utils/Constants.qml#L468 ;; https://github.com/status-im/status-desktop/blob/2ba96803168461088346bf5030df750cb226df4c/ui/imports/utils/Constants.qml#L468
@ -34,12 +34,6 @@
(defn length-not-valid [s] (< (count (string/trim (str s))) min-length)) (defn length-not-valid [s] (< (count (string/trim (str s))) min-length))
(def scroll-view-height (reagent/atom 0)) (def scroll-view-height (reagent/atom 0))
(def content-container-height (reagent/atom 0)) (def content-container-height (reagent/atom 0))
(defn iphone-11-Pro-20-pixel-from-width
[window-width]
;; Divide iPhone 11 Pro VW by the desired value
(let [calculate-ratio (/ constants/IPHONE_11_PRO_VIEWPORT_WIDTH 20)]
;; Divide window width by the ratio to get a dynamic value. Based on the VW width
(int (/ window-width calculate-ratio))))
(defn validation-message (defn validation-message
[s] [s]
@ -208,7 +202,8 @@
:default-selected :blue :default-selected :blue
:on-change on-change :on-change on-change
:window-width window-width :window-width window-width
:container-style {:padding-left (iphone-11-Pro-20-pixel-from-width window-width)}}]]] :container-style {:padding-left (responsiveness/iphone-11-Pro-20-pixel-from-width
window-width)}}]]]
[rn/keyboard-avoiding-view [rn/keyboard-avoiding-view
{:style {:position :absolute {:style {:position :absolute

View File

@ -13,7 +13,8 @@
on-change-emoji section-label bottom-action? bottom-action-label bottom-action-props on-change-emoji section-label bottom-action? bottom-action-label bottom-action-props
custom-bottom-action]} & children] custom-bottom-action]} & children]
(let [{:keys [top bottom]} (safe-area/get-insets) (let [{:keys [top bottom]} (safe-area/get-insets)
margin-top (if (false? margin-top?) 0 top)] margin-top (if (false? margin-top?) 0 top)
{window-width :width} (rn/get-window)]
[rn/keyboard-avoiding-view [rn/keyboard-avoiding-view
{:style (style/root-container margin-top) {:style (style/root-container margin-top)
:keyboard-vertical-offset (- bottom)} :keyboard-vertical-offset (- bottom)}
@ -58,7 +59,8 @@
[quo/color-picker [quo/color-picker
{:default-selected account-color {:default-selected account-color
:on-change on-change-color :on-change on-change-color
:container-style style/color-picker}]] :container-style style/color-picker
:window-width window-width}]]
[quo/divider-line {:container-style style/divider-2}] [quo/divider-line {:container-style style/divider-2}]
(when section-label (when section-label
[quo/section-label [quo/section-label

View File

@ -9,7 +9,8 @@
[status-im2.contexts.wallet.common.utils :as utils] [status-im2.contexts.wallet.common.utils :as utils]
[status-im2.contexts.wallet.create-account.style :as style] [status-im2.contexts.wallet.create-account.style :as style]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]
[utils.responsiveness :refer [iphone-11-Pro-20-pixel-from-width]]))
(def diamond-emoji "\uD83D\uDC8E") (def diamond-emoji "\uD83D\uDC8E")
@ -50,7 +51,8 @@
derivation-path (reagent/atom (utils/get-derivation-path number-of-accounts)) derivation-path (reagent/atom (utils/get-derivation-path number-of-accounts))
{:keys [public-key]} (rf/sub [:profile/profile]) {:keys [public-key]} (rf/sub [:profile/profile])
on-change-text #(reset! account-name %) on-change-text #(reset! account-name %)
display-name (first (rf/sub [:contacts/contact-two-names-by-identity public-key]))] display-name (first (rf/sub [:contacts/contact-two-names-by-identity public-key]))
{window-width :width} (rn/get-window)]
(fn [{:keys [theme]}] (fn [{:keys [theme]}]
[rn/view [rn/view
{:style {:flex 1 {:style {:flex 1
@ -100,8 +102,8 @@
[quo/color-picker [quo/color-picker
{:default-selected @account-color {:default-selected @account-color
:on-change #(reset! account-color %) :on-change #(reset! account-color %)
:container-style {:padding-horizontal 12 :container-style {:padding-vertical 12
:padding-vertical 12}}]] :padding-left (iphone-11-Pro-20-pixel-from-width window-width)}}]]
[quo/divider-line] [quo/divider-line]
[quo/category [quo/category
{:list-type :settings {:list-type :settings

View File

@ -0,0 +1,10 @@
(ns utils.responsiveness)
(def ^:const IPHONE_11_PRO_VIEWPORT_WIDTH 375)
(defn iphone-11-Pro-20-pixel-from-width
[window-width]
;; Divide iPhone 11 Pro VW by the desired value
(let [calculate-ratio (/ IPHONE_11_PRO_VIEWPORT_WIDTH 20)]
;; Divide window width by the ratio to get a dynamic value. Based on the VW width
(int (/ window-width calculate-ratio))))