File tree 4 files changed +63
-45
lines changed
src/status_im2/contexts/onboarding/common 4 files changed +63
-45
lines changed Original file line number Diff line number Diff line change 9
9
[dark-overlay?]
10
10
[:f>
11
11
(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 }])]))])
Original file line number Diff line number Diff line change 35
35
36
36
(defn initialize-animation
37
37
[]
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))
42
41
43
- ; ; Derived Values
44
42
(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))))
47
49
48
50
(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 ))))
Original file line number Diff line number Diff line change 48
48
:flex-direction :row })
49
49
50
50
(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)))
57
61
58
62
(defn progress-bar-container
59
63
[progress-bar-width status-bar-height]
63
67
:top (+ 12 status-bar-height)})
64
68
65
69
(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)))
Original file line number Diff line number Diff line change 54
54
[rn/view {:style (style/progress-bar-item static? true )}]])
55
55
56
56
(defn dynamic-progress-bar
57
- [progress-bar-width]
57
+ [progress-bar-width animate? ]
58
58
[:f>
59
59
(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?)}
62
63
[progress-bar
63
64
{:static? false
64
65
:progress-bar-width progress-bar-width}]]))])
65
66
66
67
(defn view
67
- []
68
+ [animate? ]
68
69
[:f>
69
70
(fn []
70
71
(let [window-width (rf/sub [:dimensions/window-width ])
71
72
view-id (rf/sub [:view-id ])
72
73
status-bar-height (:status-bar-height @navigation/constants)
73
74
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]))
79
82
[:<>
80
- [reanimated/ view {:style (style/carousel-container carousel-left)}
83
+ [container- view {:style (style/carousel-container carousel-left animate? )}
81
84
(for [index (range 2 )]
82
85
^{:key index}
83
86
[content-view
91
94
[progress-bar
92
95
{:static? true
93
96
:progress-bar-width progress-bar-width}]
94
- [dynamic-progress-bar progress-bar-width]]]))])
97
+ [dynamic-progress-bar progress-bar-width animate? ]]]))])
95
98
You can’t perform that action at this time.
0 commit comments