[#10427] Narrow devices were causing text in the intro carousel to grow to two lines on *the first* slide but not others, causing the height to be recalculated incorrectly on the last slide (that only had one line of text).
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
41bba3b2c8
commit
095467ff51
|
@ -29,9 +29,11 @@
|
|||
:text-align :center
|
||||
:margin-bottom 16})
|
||||
|
||||
(def wizard-text
|
||||
{:color colors/gray
|
||||
:text-align :center})
|
||||
(defn wizard-text [height]
|
||||
(merge {:color colors/gray
|
||||
:text-align :center}
|
||||
(when-not (zero? height)
|
||||
{:height height})))
|
||||
|
||||
(def welcome-text-bottom-note
|
||||
{:typography :caption
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
scroll-view-ref (atom nil)
|
||||
width (r/atom 0)
|
||||
height (r/atom 0)
|
||||
text-height (r/atom 0)
|
||||
text-temp-height (atom 0)
|
||||
text-temp-timer (atom nil)
|
||||
bottom-margin (if (> window-height 600) 32 16)]
|
||||
(fn []
|
||||
[react/view {:style {:align-items :center
|
||||
|
@ -50,8 +53,7 @@
|
|||
:pinch-gesture-enabled false
|
||||
:on-scroll #(let [^js x (.-nativeEvent.contentOffset.x ^js %)]
|
||||
(reset! scroll-x x))
|
||||
:style {;:width @width
|
||||
:margin-bottom bottom-margin}}
|
||||
:style {:margin-bottom bottom-margin}}
|
||||
(doall
|
||||
(for [s slides]
|
||||
^{:key (:title s)}
|
||||
|
@ -60,17 +62,28 @@
|
|||
:justify-content :flex-end
|
||||
:align-items :center
|
||||
:padding-horizontal 32}}
|
||||
(let [size (min @width @height) #_(- (min @width @height) #_(* 2 margin))]
|
||||
(let [size (min @width @height)]
|
||||
[react/view {:style {:flex 1}
|
||||
:on-layout (fn [^js e]
|
||||
(reset! height (-> e .-nativeEvent .-layout .-height)))}
|
||||
(let [new-height (-> e .-nativeEvent .-layout .-height)]
|
||||
(swap! height #(if (pos? %) (min % new-height) new-height))))}
|
||||
[react/image {:source (:image s)
|
||||
:resize-mode :contain
|
||||
:style {:width size
|
||||
:height size}}]])
|
||||
[react/i18n-text {:style styles/wizard-title :key (:title s)}]
|
||||
[react/i18n-text {:style styles/wizard-text
|
||||
:key (:text s)}]]))]
|
||||
[react/text {:style (styles/wizard-text @text-height)
|
||||
:on-layout
|
||||
(fn [^js e]
|
||||
(let [new-height (-> e .-nativeEvent .-layout .-height)]
|
||||
(when (and (not= new-height @text-temp-height)
|
||||
(not (zero? new-height))
|
||||
(< new-height 200))
|
||||
(swap! text-temp-height #(if (pos? %) (max % new-height) new-height))
|
||||
(when @text-temp-timer (js/clearTimeout @text-temp-timer))
|
||||
(reset! text-temp-timer
|
||||
(js/setTimeout #(reset! text-height @text-temp-height) 500)))))}
|
||||
(i18n/label (:text s))]]))]
|
||||
(let [selected (hash-set (quot (int @scroll-x) (int @width)))]
|
||||
[dots-selector {:selected selected :n (count slides)
|
||||
:color colors/blue}])])))
|
||||
|
|
Loading…
Reference in New Issue