Skip to content

Commit 4f04476

Browse files
authored
[#16278] fix tips in white camera border (#16716)
* Remove unnecessary wrapper * Fix border tips and refactor * Add comment about using 1.9 width
1 parent 7cd9f76 commit 4f04476

File tree

2 files changed

+64
-74
lines changed

2 files changed

+64
-74
lines changed

src/status_im2/contexts/syncing/scan_sync_code/style.cljs

+31-23
Original file line numberDiff line numberDiff line change
@@ -77,29 +77,37 @@
7777
:top (- (+ (:y viewfinder) (:height viewfinder)) flash-button-size flash-button-spacing)
7878
:right (+ screen-padding flash-button-spacing)})
7979

80-
(defn border
81-
[border1 border2 corner]
82-
(assoc {:border-color colors/white
83-
:width 78
84-
:height 78}
85-
border1
86-
2
87-
border2
88-
2
89-
corner
90-
16))
91-
92-
(defn border-tip
93-
[top bottom right left]
94-
{:background-color colors/white
95-
:position :absolute
96-
:top top
97-
:bottom bottom
98-
:right right
99-
:left left
100-
:height 2
101-
:width 2
102-
:border-radius 2})
80+
(defn- get-border
81+
[border-vertical-width border-horizontal-width corner-radius]
82+
{:border-color colors/white
83+
:width 78
84+
:height 78
85+
border-vertical-width 2
86+
border-horizontal-width 2
87+
corner-radius 16})
88+
89+
(def white-border
90+
(let [base-tip {:background-color colors/white
91+
:position :absolute
92+
:height 1.9 ; 1.9 instead of 2 to fix the tips protruding
93+
:width 1.9
94+
:border-radius 1}]
95+
{:top-left
96+
{:border (get-border :border-top-width :border-left-width :border-top-left-radius)
97+
:tip-1 (assoc base-tip :right -1 :top 0)
98+
:tip-2 (assoc base-tip :left 0 :bottom -1)}
99+
:top-right
100+
{:border (get-border :border-top-width :border-right-width :border-top-right-radius)
101+
:tip-1 (assoc base-tip :right 0 :bottom -1)
102+
:tip-2 (assoc base-tip :left -1 :top 0)}
103+
:bottom-left
104+
{:border (get-border :border-bottom-width :border-left-width :border-bottom-left-radius)
105+
:tip-1 (assoc base-tip :right -1 :bottom 0)
106+
:tip-2 (assoc base-tip :left 0 :top -1)}
107+
:bottom-right
108+
{:border (get-border :border-bottom-width :border-right-width :border-bottom-right-radius)
109+
:tip-1 (assoc base-tip :right 0 :top -1)
110+
:tip-2 (assoc base-tip :left -1 :bottom 0)}}))
103111

104112
(def viewfinder-text
105113
{:color colors/white-opa-70

src/status_im2/contexts/syncing/scan_sync_code/view.cljs

+33-51
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
[]
3737
(rf/dispatch [:syncing/preflight-outbound-check #(reset! preflight-check-passed? %)]))
3838

39-
(defn- f-header
39+
(defn- header
4040
[{:keys [active-tab read-qr-once? title title-opacity subtitle-opacity reset-animations-fn animated?]}]
4141
(let [subtitle-translate-x (reanimated/interpolate subtitle-opacity [0 1] [-13 0])
4242
subtitle-translate-y (reanimated/interpolate subtitle-opacity [0 1] [-85 0])
@@ -110,10 +110,6 @@
110110
(reset! active-tab id)
111111
(reset! read-qr-once? false))}]]]))
112112

113-
(defn- header
114-
[props]
115-
[:f> f-header props])
116-
117113
(defn get-labels-and-on-press-method
118114
[]
119115
(if @camera-permission-granted?
@@ -169,55 +165,42 @@
169165
view-finder (assoc layout :height (:width layout))]
170166
(reset! qr-view-finder view-finder)))}])
171167

172-
(defn- border
173-
[border1 border2 corner]
174-
[rn/view {:style (style/border border1 border2 corner)}])
168+
(defn- white-border
169+
[corner]
170+
(let [border-styles (style/white-border corner)]
171+
[rn/view
172+
[rn/view {:style (border-styles :border)}]
173+
[rn/view {:style (border-styles :tip-1)}]
174+
[rn/view {:style (border-styles :tip-2)}]]))
175175

176-
(defn- border-tip
177-
[{:keys [top bottom left right]}]
178-
[rn/view
179-
{:style (style/border-tip top bottom right left)}])
176+
(defn- white-square
177+
[layout-size]
178+
[rn/view {:style (style/qr-view-finder-container layout-size)}
179+
[rn/view {:style style/view-finder-border-container}
180+
[white-border :top-left]
181+
[white-border :top-right]]
182+
[rn/view {:style style/view-finder-border-container}
183+
[white-border :bottom-left]
184+
[white-border :bottom-right]]])
180185

181186
(defn- viewfinder
182187
[qr-view-finder]
183-
(let [size (+ (:width qr-view-finder) 2)]
184-
[:<>
185-
[rn/view {:style (style/viewfinder-container qr-view-finder)}
186-
[rn/view
187-
{:style (style/qr-view-finder-container size)}
188-
[rn/view
189-
{:style style/view-finder-border-container}
190-
[rn/view
191-
[border :border-top-width :border-left-width :border-top-left-radius]
192-
[border-tip {:right -1 :top 0}]
193-
[border-tip {:left 0 :bottom -1}]]
194-
[rn/view
195-
[border :border-top-width :border-right-width :border-top-right-radius]
196-
[border-tip {:right 0 :bottom -1}]
197-
[border-tip {:left -1 :top 0}]]]
198-
[rn/view {:flex-direction :row :justify-content :space-between}
199-
[rn/view
200-
[border :border-bottom-width :border-left-width :border-bottom-left-radius]
201-
[border-tip {:right -1 :bottom 0}]
202-
[border-tip {:left 0 :top -1}]]
203-
[rn/view
204-
[border :border-bottom-width :border-right-width :border-bottom-right-radius]
205-
[border-tip {:right 0 :top -1}]
206-
[border-tip {:left -1 :bottom 0}]]]]
207-
[quo/text
208-
{:size :paragraph-2
209-
:weight :regular
210-
:style style/viewfinder-text}
211-
(i18n/label :t/ensure-qr-code-is-in-focus-to-scan)]]]))
188+
(let [layout-size (+ (:width qr-view-finder) 2)]
189+
[rn/view {:style (style/viewfinder-container qr-view-finder)}
190+
[white-square layout-size]
191+
[quo/text
192+
{:size :paragraph-2
193+
:weight :regular
194+
:style style/viewfinder-text}
195+
(i18n/label :t/ensure-qr-code-is-in-focus-to-scan)]]))
212196

213197
(defn- scan-qr-code-tab
214198
[qr-view-finder]
215-
[:<>
216-
(if (and @preflight-check-passed?
217-
@camera-permission-granted?
218-
(boolean (not-empty @qr-view-finder)))
219-
[viewfinder @qr-view-finder]
220-
[camera-and-local-network-access-permission-view])])
199+
(if (and @preflight-check-passed?
200+
@camera-permission-granted?
201+
(boolean (not-empty qr-view-finder)))
202+
[viewfinder qr-view-finder]
203+
[camera-and-local-network-access-permission-view]))
221204

222205
(defn- enter-sync-code-tab
223206
[]
@@ -273,8 +256,7 @@
273256
:on-read-code on-read-code}]]
274257
[hole-view/hole-view
275258
{:style style/hole
276-
:holes [(merge qr-view-finder
277-
{:borderRadius 16})]}
259+
:holes [(assoc qr-view-finder :borderRadius 16)]}
278260
[blur/view
279261
{:style style/absolute-fill
280262
:blur-amount 10
@@ -388,7 +370,7 @@
388370
(when (or (not animated?) @render-camera?)
389371
[render-camera show-camera? torch-mode @qr-view-finder camera-ref on-read-code])
390372
[rn/view {:style (style/root-container (:top insets))}
391-
[header
373+
[:f> header
392374
{:active-tab active-tab
393375
:read-qr-once? read-qr-once?
394376
:title title
@@ -406,7 +388,7 @@
406388
:transform [{:translate-y content-translate-y}]}
407389
{})}
408390
(case @active-tab
409-
1 [scan-qr-code-tab qr-view-finder]
391+
1 [scan-qr-code-tab @qr-view-finder]
410392
2 [enter-sync-code-tab]
411393
nil)]
412394
[rn/view {:style style/flex-spacer}]

0 commit comments

Comments
 (0)