Skip to content

Commit 4fefa62

Browse files
authored
Use static background screen for onboarding screens with dark overlay (#15666)
1 parent 41e2fff commit 4fefa62

File tree

4 files changed

+63
-45
lines changed

4 files changed

+63
-45
lines changed

src/status_im2/contexts/onboarding/common/background/view.cljs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
[dark-overlay?]
1010
[:f>
1111
(fn []
12-
(carousel.animation/initialize-animation)
13-
[rn/view
14-
{:style style/background-container}
15-
[carousel/view dark-overlay?]
16-
(when dark-overlay?
17-
[blur/view
18-
{:style style/background-blur-overlay
19-
:blur-amount 30
20-
:blur-radius 25
21-
:blur-type :transparent
22-
:overlay-color :transparent}])])])
12+
(let [animate? (not dark-overlay?)]
13+
(when animate? (carousel.animation/initialize-animation))
14+
[rn/view
15+
{:style style/background-container}
16+
[carousel/view animate?]
17+
(when dark-overlay?
18+
[blur/view
19+
{:style style/background-blur-overlay
20+
:blur-amount 30
21+
:blur-radius 25
22+
:blur-type :transparent
23+
:overlay-color :transparent}])]))])

src/status_im2/contexts/onboarding/common/carousel/animation.cljs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,22 @@
3535

3636
(defn initialize-animation
3737
[]
38-
(when-not @progress
39-
(reset! progress (reanimated/use-shared-value 0))
40-
(reset! paused (reanimated/use-shared-value false))
41-
(animate-progress @progress @paused)))
38+
(reset! progress (reanimated/use-shared-value 0))
39+
(reset! paused (reanimated/use-shared-value false))
40+
(animate-progress @progress @paused))
4241

43-
;; Derived Values
4442
(defn carousel-left-position
45-
[window-width]
46-
(worklets.onboarding-carousel/carousel-left-position window-width @progress))
43+
[window-width animate?]
44+
(if animate?
45+
(worklets.onboarding-carousel/carousel-left-position window-width @progress)
46+
(-> (or (reanimated/get-shared-value @progress) 0)
47+
(quot -25)
48+
(* window-width))))
4749

4850
(defn dynamic-progress-bar-width
49-
[progress-bar-width]
50-
(worklets.onboarding-carousel/dynamic-progress-bar-width progress-bar-width @progress))
51+
[progress-bar-width animate?]
52+
(if animate?
53+
(worklets.onboarding-carousel/dynamic-progress-bar-width progress-bar-width @progress)
54+
(-> (or (reanimated/get-shared-value @progress) 0)
55+
(* progress-bar-width)
56+
(/ 100))))

src/status_im2/contexts/onboarding/common/carousel/style.cljs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@
4848
:flex-direction :row})
4949

5050
(defn dynamic-progress-bar
51-
[width]
52-
(reanimated/apply-animations-to-style
53-
{:width width}
54-
{:height 2
55-
:border-radius 4
56-
:overflow :hidden}))
51+
[width animate?]
52+
(let [normal-style {:height 2
53+
:border-radius 4
54+
:overflow :hidden
55+
:width width}]
56+
(if animate?
57+
(reanimated/apply-animations-to-style
58+
{:width width}
59+
normal-style)
60+
normal-style)))
5761

5862
(defn progress-bar-container
5963
[progress-bar-width status-bar-height]
@@ -63,11 +67,15 @@
6367
:top (+ 12 status-bar-height)})
6468

6569
(defn carousel-container
66-
[left]
67-
(reanimated/apply-animations-to-style
68-
{:left left}
69-
{:position :absolute
70-
:right 0
71-
:top 0
72-
:bottom 0
73-
:flex-direction :row}))
70+
[left animate?]
71+
(let [normal-style {:position :absolute
72+
:right 0
73+
:top 0
74+
:bottom 0
75+
:flex-direction :row
76+
:left left}]
77+
(if animate?
78+
(reanimated/apply-animations-to-style
79+
{:left left}
80+
normal-style)
81+
normal-style)))

src/status_im2/contexts/onboarding/common/carousel/view.cljs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,33 @@
5454
[rn/view {:style (style/progress-bar-item static? true)}]])
5555

5656
(defn dynamic-progress-bar
57-
[progress-bar-width]
57+
[progress-bar-width animate?]
5858
[:f>
5959
(fn []
60-
(let [width (animation/dynamic-progress-bar-width progress-bar-width)]
61-
[reanimated/view {:style (style/dynamic-progress-bar width)}
60+
(let [width (animation/dynamic-progress-bar-width progress-bar-width animate?)
61+
container-view (if animate? reanimated/view rn/view)]
62+
[container-view {:style (style/dynamic-progress-bar width animate?)}
6263
[progress-bar
6364
{:static? false
6465
:progress-bar-width progress-bar-width}]]))])
6566

6667
(defn view
67-
[]
68+
[animate?]
6869
[:f>
6970
(fn []
7071
(let [window-width (rf/sub [:dimensions/window-width])
7172
view-id (rf/sub [:view-id])
7273
status-bar-height (:status-bar-height @navigation/constants)
7374
progress-bar-width (- window-width 40)
74-
carousel-left (animation/carousel-left-position window-width)]
75-
(rn/use-effect
76-
(fn []
77-
(reanimated/set-shared-value @animation/paused (not= view-id :intro)))
78-
[view-id])
75+
carousel-left (animation/carousel-left-position window-width animate?)
76+
container-view (if animate? reanimated/view rn/view)]
77+
(when animate?
78+
(rn/use-effect
79+
(fn []
80+
(reanimated/set-shared-value @animation/paused (not= view-id :intro)))
81+
[view-id]))
7982
[:<>
80-
[reanimated/view {:style (style/carousel-container carousel-left)}
83+
[container-view {:style (style/carousel-container carousel-left animate?)}
8184
(for [index (range 2)]
8285
^{:key index}
8386
[content-view
@@ -91,5 +94,5 @@
9194
[progress-bar
9295
{:static? true
9396
:progress-bar-width progress-bar-width}]
94-
[dynamic-progress-bar progress-bar-width]]]))])
97+
[dynamic-progress-bar progress-bar-width animate?]]]))])
9598

0 commit comments

Comments
 (0)