Skip to content

Commit 5cdc6bd

Browse files
authored
Merge branch 'develop' into mute-for-specific-amount-of-time
2 parents ba0e62d + 0503f5c commit 5cdc6bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1297
-469
lines changed

doc/new-guidelines.md

+51
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,57 @@ the source file. For a real example, see
6161
[rn/view (do-something)]])
6262
```
6363

64+
### Always add styles inside the `:style` key
65+
66+
Although when compiling ReactNative for mobile some components are able work with
67+
their styles in the top-level of the properties map, prefer to add them inside the
68+
`:style` key in order to separate styles from properties:
69+
70+
```clojure
71+
;; bad
72+
[rn/button {:flex 1
73+
:padding-vertical 10
74+
:padding-horizontal 20
75+
:on-press #(js/alert "Hi!")
76+
:title "Button"}]
77+
78+
;; good
79+
[rn/button {:style {:flex 1
80+
:padding-vertical 10
81+
:padding-horizontal 20}
82+
:on-press #(js/alert "Hi!")
83+
:title "Button"}]
84+
85+
;; better
86+
;; (define them in a style ns & place them inside `:style` key)
87+
[rn/button {:style (style/button)
88+
:on-press #(js/alert "Hi!")
89+
:title "Button"}
90+
]
91+
```
92+
93+
### Always apply animated styles in the style file
94+
95+
When implementing styles for reanimated views, we should always define
96+
them in the style file and apply animations with reanimated/apply-animations-to-style
97+
in the style definition.
98+
99+
```clojure
100+
;; bad
101+
(defn circle
102+
[]
103+
(let [opacity (reanimated/use-shared-value 1)]
104+
[reanimated/view {:style (reanimated/apply-animations-to-style
105+
{:opacity opacity}
106+
style/circle-container)}]))
107+
108+
;; good
109+
(defn circle
110+
[]
111+
(let [opacity (reanimated/use-shared-value 1)]
112+
[reanimated/view {:style (style/circle-container opacity)}]))
113+
```
114+
64115
### Don't use percents to define width/height
65116

66117
In ReactNative, all layouts use the [flexbox
-1.25 MB
Binary file not shown.
-2.38 MB
Binary file not shown.
-1.12 MB
Binary file not shown.
-2.14 MB
Binary file not shown.
-1.24 MB
Binary file not shown.
-2.4 MB
Binary file not shown.
-788 KB
Binary file not shown.
-1.47 MB
Binary file not shown.
-1.72 MB
Binary file not shown.
-1.32 MB
Binary file not shown.
-2.58 MB
Binary file not shown.
4.67 MB
Loading
8.92 MB
Loading

shadow-cljs.edn

+7-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@
4545
:devtools {:autobuild #shadow/env ["SHADOW_AUTOBUILD_ENABLED" :default true :as :bool]}
4646
:dev {:devtools {:after-load status-im2.setup.hot-reload/reload
4747
:build-notify status-im2.setup.hot-reload/build-notify
48-
:preloads [re-frisk-remote.preload]}
48+
:preloads [re-frisk-remote.preload
49+
;; In order to use component test helpers in
50+
;; the REPL we need to preload namespaces
51+
;; that are not normally required by
52+
;; production code, such as
53+
;; @testing-library/react-native.
54+
test-helpers.component]}
4955
:closure-defines
5056
{status-im2.config/POKT_TOKEN #shadow/env "POKT_TOKEN"
5157
status-im2.config/OPENSEA_API_KEY #shadow/env "OPENSEA_API_KEY"}
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { useDerivedValue, withTiming, Easing } from 'react-native-reanimated';
2+
3+
const slideAnimationDuration = 300;
4+
5+
const easeOut = {
6+
duration: slideAnimationDuration,
7+
easing: Easing.bezier(0, 0, 0.58, 1),
8+
}
9+
10+
// Derived Values
11+
export function dynamicProgressBarWidth(staticProgressBarWidth, progress) {
12+
return useDerivedValue(
13+
function () {
14+
'worklet'
15+
return staticProgressBarWidth * (progress.value || 0) / 100;
16+
}
17+
);
18+
}
19+
20+
export function carouselLeftPosition(windowWidth, progress) {
21+
return useDerivedValue(
22+
function () {
23+
'worklet'
24+
const progressValue = progress.value;
25+
switch (true) {
26+
case (progressValue < 25):
27+
return 0;
28+
case (progressValue === 25):
29+
return withTiming(-windowWidth, easeOut);
30+
case (progressValue < 50):
31+
return -windowWidth;
32+
case (progressValue === 50):
33+
return withTiming(-2 * windowWidth, easeOut);
34+
case (progressValue < 75):
35+
return -2 * windowWidth;
36+
case (progressValue === 75):
37+
return withTiming(-3 * windowWidth, easeOut);
38+
case (progressValue < 100):
39+
return -3 * windowWidth;
40+
case (progressValue === 100):
41+
return withTiming(-4 * windowWidth, easeOut);
42+
default:
43+
return 0;
44+
}
45+
});
46+
}
47+

src/mocks/js_dependencies.cljs

+6-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ globalThis.__STATUS_MOBILE_JS_IDENTITY_PROXY__ = new Proxy({}, {get() { return (
293293
:createNativeWrapper identity
294294
:default #js {}})
295295

296-
(def react-native-redash #js {:clamp nil})
296+
(def react-native-redash
297+
#js
298+
{:clamp nil
299+
:withPause (fn [])})
297300

298301
(def react-native-languages
299302
(clj->js {:default {:language "en"
@@ -370,6 +373,7 @@ globalThis.__STATUS_MOBILE_JS_IDENTITY_PROXY__ = new Proxy({}, {get() { return (
370373
"react-native-screens" (clj->js {})
371374
"react-native-reanimated" react-native-reanimated
372375
"react-native-redash/lib/module/v1" react-native-redash
376+
"react-native-redash" react-native-redash
373377
"react-native-fetch-polyfill" fetch
374378
"react-native-status-keycard" status-keycard
375379
"react-native-keychain" keychain
@@ -407,6 +411,7 @@ globalThis.__STATUS_MOBILE_JS_IDENTITY_PROXY__ = new Proxy({}, {get() { return (
407411
"../src/js/worklets/bottom_sheet.js" #js {}
408412
"../src/js/worklets/record_audio.js" #js {}
409413
"../src/js/worklets/scroll_view.js" #js {}
414+
"../src/js/worklets/onboarding_carousel.js" #js {}
410415
"../src/js/worklets/lightbox.js" #js {}
411416
"./fleets.js" default-fleets
412417
"@walletconnect/client" wallet-connect-client

src/quo2/components/inputs/input/style.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
:color (:text colors-by-status))]
9292
(if multiple-lines?
9393
(assoc base-props :text-align-vertical :top)
94-
(assoc base-props :height (if small? 30 38)))))
94+
(assoc base-props :height (if small? 30 38) :line-height nil))))
9595

9696
(defn right-icon-touchable-area
9797
[small?]

src/quo2/components/inputs/input/view.cljs

+10-6
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@
5454
(def ^:private custom-props
5555
"Custom properties that must be removed from properties map passed to InputText."
5656
[:type :blur? :override-theme :error? :right-icon :left-icon :disabled? :small? :button
57-
:label :char-limit :on-char-limit-reach :icon-name :multiline?])
57+
:label :char-limit :on-char-limit-reach :icon-name :multiline? :on-focus :on-blur])
5858

5959
(defn- base-input
6060
[{:keys [on-change-text on-char-limit-reach]}]
6161
(let [status (reagent/atom :default)
62-
on-focus #(reset! status :focus)
63-
on-blur #(reset! status :default)
62+
internal-on-focus #(reset! status :focus)
63+
internal-on-blur #(reset! status :default)
6464
multiple-lines? (reagent/atom false)
6565
set-multiple-lines! #(let [height (oops/oget % "nativeEvent.contentSize.height")]
6666
(if (> height 57)
@@ -74,7 +74,7 @@
7474
(when (>= amount-chars char-limit)
7575
(on-char-limit-reach amount-chars))))]
7676
(fn [{:keys [blur? override-theme error? right-icon left-icon disabled? small? button
77-
label char-limit multiline? clearable?]
77+
label char-limit multiline? clearable? on-focus on-blur]
7878
:as props}]
7979
(let [status-kw (cond
8080
disabled? :disabled
@@ -102,8 +102,12 @@
102102
:placeholder-text-color (:placeholder colors-by-status)
103103
:cursor-color (:cursor variant-colors)
104104
:editable (not disabled?)
105-
:on-focus on-focus
106-
:on-blur on-blur}
105+
:on-focus (fn []
106+
(when on-focus (on-focus))
107+
(internal-on-focus))
108+
:on-blur (fn []
109+
(when on-blur (on-blur))
110+
(internal-on-blur))}
107111
:always (merge clean-props)
108112
multiline? (assoc :multiline true
109113
:on-content-size-change set-multiple-lines!)

src/quo2/components/navigation/page_nav.cljs

+6-4
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,15 @@
150150
:justify-content :flex-end)}
151151
(let [last-icon-index (-> right-section-buttons count dec)]
152152
(map-indexed (fn [index
153-
{:keys [icon on-press type style icon-override-theme]
153+
{:keys [icon on-press type style icon-override-theme accessibility-label]
154154
:or {type :grey}}]
155155
^{:key index}
156156
[rn/view
157-
{:style (assoc style
158-
:margin-right
159-
(if (= index last-icon-index) 0 8))}
157+
(cond-> {:style (assoc style
158+
:margin-right
159+
(if (= index last-icon-index) 0 8))}
160+
accessibility-label (assoc :accessibility-label accessibility-label
161+
:accessible true))
160162
[button/button
161163
{:on-press on-press
162164
:icon true

src/quo2/components/password/tips/view.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
[text/text
1717
{:style (style/tip-text completed?)
1818
:weight :regular
19-
:size :paragraph-2} text]
19+
:size :paragraph-2}
20+
text]
2021
(when completed?
2122
[rn/view
2223
{:style style/strike-through
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
(ns quo2.components.selectors.disclaimer.component-spec
2+
(:require [quo2.components.selectors.disclaimer.view :as disclaimer]
3+
[test-helpers.component :as h]))
4+
5+
(h/describe "Disclaimer tests"
6+
(h/test "Default render of toggle component"
7+
(h/render [disclaimer/view {:on-change (h/mock-fn)} "test"])
8+
(h/is-truthy (h/get-by-label-text :checkbox-off)))
9+
10+
(h/test "Renders its text"
11+
(let [text "I accept this disclaimer"]
12+
(h/render [disclaimer/view {} text])
13+
(h/is-truthy (h/get-by-text text))))
14+
15+
(h/test "On change event gets fire after press"
16+
(let [mock-fn (h/mock-fn)]
17+
(h/render [disclaimer/view {:on-change mock-fn} "test"])
18+
(h/fire-event :press (h/get-by-label-text :checkbox-off))
19+
(h/was-called mock-fn)))
20+
21+
(h/describe "It's rendered according to its `checked?` property"
22+
(h/test "checked? true"
23+
(h/render [disclaimer/view {:checked? true} "test"])
24+
(h/is-null (h/query-by-label-text :checkbox-off))
25+
(h/is-truthy (h/query-by-label-text :checkbox-on)))
26+
(h/test "checked? false"
27+
(h/render [disclaimer/view {:checked? false} "test"])
28+
(h/is-null (h/query-by-label-text :checkbox-on))
29+
(h/is-truthy (h/query-by-label-text :checkbox-off)))))

src/quo2/components/selectors/disclaimer/style.cljs

+10-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
(:require [quo2.foundations.colors :as colors]))
33

44
(defn container
5-
[]
6-
{:flex-direction :row
7-
:background-color (colors/theme-colors colors/neutral-5 colors/neutral-80-opa-40)
8-
:padding 11
9-
:align-self :stretch
10-
:border-radius 12
11-
:border-width 1
12-
:border-color (colors/theme-colors colors/neutral-20 colors/neutral-70)})
5+
[blur?]
6+
(let [dark-background (if blur? colors/white-opa-5 colors/neutral-80-opa-40)
7+
dark-border (if blur? colors/white-opa-10 colors/neutral-70)]
8+
{:flex-direction :row
9+
:background-color (colors/theme-colors colors/neutral-5 dark-background)
10+
:padding 11
11+
:align-self :stretch
12+
:border-radius 12
13+
:border-width 1
14+
:border-color (colors/theme-colors colors/neutral-20 dark-border)}))
1315

1416
(def text
1517
{:margin-left 8})

src/quo2/components/selectors/disclaimer/view.cljs

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
[react-native.core :as rn]))
66

77
(defn view
8-
[{:keys [on-change accessibility-label container-style]} label]
8+
[{:keys [checked? blur? on-change accessibility-label container-style]} label]
99
[rn/view
10-
{:style (merge container-style (style/container))}
10+
{:style (merge container-style (style/container blur?))}
1111
[selectors/checkbox
1212
{:accessibility-label accessibility-label
13-
:on-change on-change}]
13+
:on-change on-change
14+
:checked? checked?}]
1415
[text/text
1516
{:size :paragraph-2
1617
:style style/text}

src/quo2/core_spec.cljs

+1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
[quo2.components.record-audio.record-audio.--tests--.record-audio-component-spec]
2020
[quo2.components.record-audio.soundtrack.--tests--.soundtrack-component-spec]
2121
[quo2.components.selectors.--tests--.selectors-component-spec]
22+
[quo2.components.selectors.disclaimer.component-spec]
2223
[quo2.components.selectors.filter.component-spec]
2324
[quo2.components.tags.--tests--.status-tags-component-spec]))

src/quo2/foundations/colors.cljs

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127

128128
;;Solid
129129
(def black "#000000")
130+
(def onboarding-header-black "#000716")
130131

131132
;;;;Primary
132133

src/react_native/reanimated.cljs

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
withDelay
1010
withSpring
1111
withRepeat
12+
withSequence
1213
withDecay
1314
Easing
1415
Keyframe
@@ -17,8 +18,8 @@
1718
SlideOutUp
1819
LinearTransition)]
1920
[reagent.core :as reagent]
21+
["react-native-redash" :refer (withPause)]
2022
[react-native.flat-list :as rn-flat-list]
21-
[utils.collection]
2223
[utils.worklets.core :as worklets.core]))
2324

2425
(def ^:const default-duration 300)
@@ -59,6 +60,8 @@
5960
(def with-decay withDecay)
6061
(def key-frame Keyframe)
6162
(def with-repeat withRepeat)
63+
(def with-sequence withSequence)
64+
(def with-pause withPause)
6265
(def cancel-animation cancelAnimation)
6366

6467
;; Easings

src/status_im/utils/utils.cljs

+5
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@
126126
(when (string? s)
127127
(string/replace s m r)))
128128

129+
(defn safe-nth
130+
[coll index]
131+
(when (number? index)
132+
(nth coll index)))
133+
129134
(defn svg?
130135
[some-string]
131136
(string/ends-with? some-string ".svg"))

src/status_im2/common/bottom_sheet/sheets.cljs

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[status-im.ui.screens.multiaccounts.key-storage.views :as key-storage]
88
[status-im.ui.screens.multiaccounts.recover.views :as recover.views]
99
[status-im2.common.bottom-sheet.view :as bottom-sheet]
10-
[status-im2.contexts.chat.messages.pin.list.view :as pin.list]
10+
[status-im2.contexts.chat.menus.pinned-messages.view :as pinned-messages-menu]
1111
[react-native.core :as rn]))
1212

1313
(defn bottom-sheet
@@ -50,7 +50,8 @@
5050
(merge key-storage/migrate-account-password)
5151

5252
(= view :pinned-messages-list)
53-
(merge {:content pin.list/pinned-messages-list}))]
53+
(merge {:content pinned-messages-menu/pinned-messages
54+
:bottom-safe-area-spacing? false}))]
5455
[:f>
5556
(fn []
5657
(rn/use-effect (fn []

0 commit comments

Comments
 (0)