-
Notifications
You must be signed in to change notification settings - Fork 987
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f433d6
commit 67c6a50
Showing
5 changed files
with
166 additions
and
13 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
src/status_im2/contexts/syncing/enter_sync_code/style.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
(ns status-im2.contexts.syncing.enter-sync-code.style | ||
(:require [quo2.foundations.colors :as colors] | ||
[quo2.foundations.typography :as typography] | ||
[react-native.platform :as platform])) | ||
|
||
(def container-text-input | ||
{:flex-direction :row | ||
:justify-content :space-between | ||
:padding-horizontal 20}) | ||
|
||
(defn text-input-container | ||
[invalid?] | ||
{:padding-top 1 | ||
:padding-left 12 | ||
:padding-right 7 | ||
:padding-bottom 7 | ||
:flex 1 | ||
:flex-direction :row | ||
:background-color colors/neutral-95 | ||
:border-width 1 | ||
:border-radius 12 | ||
:border-color (if invalid? | ||
colors/danger-50-opa-40 | ||
colors/neutral-80)}) | ||
|
||
(defn text-input | ||
[] | ||
(merge typography/monospace | ||
typography/paragraph-1 | ||
{:flex 1 | ||
:margin-top (if platform/android? | ||
4 | ||
0) | ||
:padding 0 | ||
:color colors/white})) | ||
|
||
(def label-texts-container | ||
{:flex-direction :row | ||
:height 18 | ||
:margin-bottom 8}) | ||
|
||
(def button-paste | ||
{:margin-top 6}) | ||
|
||
(def clear-icon | ||
{:size 20 | ||
:color colors/neutral-80-opa-30}) | ||
|
||
(def right-icon-touchable-area | ||
{:margin-left 8 | ||
:padding-right 4 | ||
:padding-top 6 | ||
:margin-bottom 4}) | ||
|
||
(def button-confirm | ||
{:margin-left 20 | ||
:margin-right 20 | ||
:margin-top 12}) | ||
|
||
(def label-pairing | ||
{:color "rgba(255, 255, 255, 0.40)" | ||
:font-size 13 | ||
:font-weight "500"}) | ||
|
||
(def label-container | ||
{:flex-direction :row | ||
:margin-left 20 | ||
:margin-top 20 | ||
:margin-bottom 8}) | ||
|
||
(def continue-button-container | ||
{:margin-top 12 | ||
:padding-horizontal 22}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
(ns status-im2.contexts.syncing.enter-sync-code.view | ||
(:require [clojure.string :as string] | ||
[quo2.core :as quo] | ||
[quo2.foundations.colors :as colors] | ||
[reagent.core :as reagent] | ||
[react-native.core :as rn] | ||
[react-native.clipboard :as clipboard] | ||
[utils.i18n :as i18n] | ||
[status-im2.contexts.syncing.enter-sync-code.style :as style] | ||
[quo2.components.icon :as icon] | ||
[utils.debounce :as debounce] | ||
[utils.re-frame :as rf] | ||
[status-im2.contexts.syncing.utils :as sync-utils])) | ||
|
||
(defn view | ||
[] | ||
(let [default-value (reagent/atom nil) | ||
clipboard (reagent/atom nil) | ||
submit-button-disabled? (reagent/atom true) | ||
profile-color (rf/sub [:profile/customization-color])] | ||
(fn [] | ||
(clipboard/get-string #(reset! clipboard %)) | ||
(let [invalid? false | ||
show-paste-button? (string/blank? @default-value)] | ||
[:<> | ||
[rn/view | ||
{:style style/label-container} | ||
[rn/text {:style style/label-pairing} | ||
(i18n/label :t/type-pairing-code)]] | ||
[rn/view {:style style/container-text-input} | ||
[rn/view {:style (style/text-input-container invalid?)} | ||
[rn/text-input | ||
{:style (style/text-input) | ||
:default-value @default-value | ||
:placeholder (i18n/label :t/type-some-chat-key) | ||
:on-change-text (fn [scan-code] | ||
(reset! default-value scan-code) | ||
(reset! submit-button-disabled? false)) | ||
:blur-on-submit true | ||
:return-key-type :done | ||
:accessibility-label :enter-contact-code-input | ||
:auto-capitalize :none | ||
:placeholder-text-color (colors/theme-colors | ||
colors/neutral-40 | ||
colors/neutral-50) | ||
:multiline true}] | ||
(if show-paste-button? | ||
[rn/view {:style style/button-paste} | ||
[quo/button | ||
{:on-press (fn [] | ||
(reset! default-value @clipboard) | ||
(reset! submit-button-disabled? false)) | ||
:type :outline | ||
:size 24} | ||
(i18n/label :t/paste)]] | ||
|
||
[rn/touchable-opacity | ||
{:accessibility-label :input-right-icon | ||
:style style/right-icon-touchable-area | ||
:on-press (fn [_] | ||
(reset! default-value nil) | ||
(reset! submit-button-disabled? true))} | ||
[icon/icon :i/clear style/clear-icon]])]] | ||
[rn/view {:style style/continue-button-container} | ||
[quo/button | ||
{:type :primary | ||
:disabled @submit-button-disabled? | ||
:theme :dark | ||
:customization-color profile-color | ||
:style style/button-confirm | ||
:on-press (fn [_] | ||
(if (sync-utils/valid-connection-string? @default-value) | ||
(debounce/debounce-and-dispatch | ||
[:syncing/input-connection-string-for-bootstrapping | ||
@default-value] | ||
300) | ||
(rf/dispatch [:toasts/upsert | ||
{:icon :i/info | ||
:icon-color colors/danger-50 | ||
:theme :dark | ||
:text (i18n/label | ||
:t/error-this-is-not-a-sync-qr-code)}])))} | ||
(i18n/label :t/confirm)]]])))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters