Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new keycard component #15892

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,11 @@ SPEC CHECKSUMS:
boost: a7c83b31436843459a1961bfd74b96033dc77234
BVLinearGradient: e3aad03778a456d77928f594a649e96995f1c872
CryptoSwift: c4f2debceb38bf44c80659afe009f71e23e4a082
DoubleConversion: cde416483dac037923206447da6e1454df403714
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
codemaster115 marked this conversation as resolved.
Show resolved Hide resolved
FBLazyVector: d2db9d00883282819d03bbd401b2ad4360d47580
FBReactNativeSpec: 94da4d84ba3b1acf459103320882daa481a2b62d
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 997518ea2aa2d8cd5df9797b641b758d52ecf2bc
glog: 3ac2326f7fee4840a3066c90eb135ecd20496ded
HMSegmentedControl: 34c1f54d822d8308e7b24f5d901ec674dfa31352
Keycard: ac6df4d91525c3c82635ac24d4ddd9a80aca5fc8
libwebp: f62cb61d0a484ba548448a4bd52aabf150ff6eef
Expand Down
Binary file added resources/images/ui2/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/images/ui2/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/images/ui2/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/images/ui2/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/images/ui2/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/images/ui2/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/images/ui2/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/images/ui2/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/quo2/components/keycard/component_spec.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(ns quo2.components.keycard.component-spec
(:require [quo2.components.keycard.view :as keycard]
[test-helpers.component :as h]
[utils.i18n :as i18n]))

(h/describe "keycard component"
(h/test "Render of keycard component when: Status = Empty, Locked = False"
(h/render [keycard/keycard])
(-> (h/expect (h/query-by-label-text :holder-name))
(h/is-equal (i18n/label :t/empty-keycard))))
codemaster115 marked this conversation as resolved.
Show resolved Hide resolved

(h/test "Render of keycard component when: Status = Filled, Locked = False"
(h/render [keycard/keycard {:holder-name? "Alisha"}])
(-> (h/expect (h/query-by-label-text :holder-name))
(h/is-equal (i18n/label :t/user-keycard {:name :holder-name}))))

(h/test "Render of keycard component when: Status = Filled, Locked = True"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this last test is missing a prop to make it locked and the evaluators in the test do not check for any locked properties.

(h/render [keycard/keycard {:holder-name? "Alisha"}])
(-> (h/expect (h/query-by-label-text :holder-name))
(h/is-equal (i18n/label :t/user-keycard {:name :holder-name})))))
42 changes: 42 additions & 0 deletions src/quo2/components/keycard/style.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(ns quo2.components.keycard.style
(:require [quo2.foundations.colors :as colors]))

(def keycard-height 210)
(def keycard-chip-height 28)

(defn card-container
[locked?]
{:overflow :hidden
:height keycard-height
:align-items :flex-start
:justify-content :space-between
:border-width 1
:border-color (if locked?
colors/white-opa-5
(colors/theme-colors colors/neutral-20 colors/neutral-80))
:border-style :solid
:border-radius 16
:padding 16
:background-color (if locked?
(colors/theme-colors colors/danger colors/danger-opa-40)
(colors/theme-colors colors/neutral-5 colors/neutral-90))})

(defn keycard-logo
[locked?]
{:tint-color (if locked? colors/white (colors/theme-colors colors/neutral-100 colors/white))})

(defn keycard-watermark
[locked?]
{:position :absolute
:tint-color (if locked? colors/white-opa-5 (colors/theme-colors colors/neutral-100 colors/white))
:align-self :center
:height 280.48
:transform [{:rotate "-30deg"} {:translateY -30}]
:opacity (when-not locked? 0.02)
:z-index 1})

(def keycard-chip
{:height keycard-chip-height
:position :absolute
:right 16
:top (/ (- keycard-height 28) 2)})
38 changes: 38 additions & 0 deletions src/quo2/components/keycard/view.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(ns quo2.components.keycard.view
(:require [react-native.core :as rn]
[quo2.components.keycard.style :as style]
[quo2.components.tags.tag :as tag]
[quo2.foundations.colors :as colors]
[quo2.foundations.resources :as resources]
[utils.i18n :as i18n]))

(defn keycard
"This component based on the following properties:
- :holder-name - Can be owner's name. Default is Empty
- :locked? - Boolean to specify whether the keycard is locked or not
"
[{:keys [holder-name locked?]}]
(let [label (if (boolean holder-name)
(i18n/label :t/user-keycard {:name holder-name})
(i18n/label :t/empty-keycard))]
[rn/view {:style (style/card-container locked?)}
[rn/image
{:source (resources/get-image :keycard-logo)
:style (style/keycard-logo locked?)}]
[rn/image
{:source (resources/get-image
(if (or locked? (colors/dark?)) :keycard-chip-dark :keycard-chip-light))
:style style/keycard-chip}]
[rn/image
{:source (resources/get-image :keycard-watermark)
:style (style/keycard-watermark locked?)}]
[tag/tag
{:size 32
:type (when locked? :icon)
:label label
:labelled? true
:blurred? true
:resource (when locked? :i/locked)
:accessibility-label :holder-name
:icon-color colors/white-70-blur
:override-theme (when locked? :dark)}]]))
2 changes: 2 additions & 0 deletions src/quo2/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
quo2.components.inputs.recovery-phrase.view
quo2.components.inputs.search-input.view
quo2.components.inputs.title-input.view
quo2.components.keycard.view
quo2.components.links.url-preview-list.view
quo2.components.links.url-preview.view
quo2.components.links.link-preview.view
Expand Down Expand Up @@ -126,6 +127,7 @@

;;;; CARDS
(def small-option-card quo2.components.onboarding.small-option-card.view/small-option-card)
(def keycard quo2.components.keycard.view/keycard)

;;;; COLORS
(def color-picker quo2.components.colors.color-picker.view/view)
Expand Down
11 changes: 11 additions & 0 deletions src/quo2/foundations/resources.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(ns quo2.foundations.resources)

(def ui
{:keycard-logo (js/require "../resources/images/ui2/keycard-logo.png")
:keycard-chip-light (js/require "../resources/images/ui2/keycard-chip-light.png")
:keycard-chip-dark (js/require "../resources/images/ui2/keycard-chip-dark.png")
:keycard-watermark (js/require "../resources/images/ui2/keycard-watermark.png")})

(defn get-image
[k]
(get ui k))
5 changes: 4 additions & 1 deletion src/status_im2/common/resources.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
:use-keycard (js/require "../resources/images/ui2/keycard.png")
:onboarding-illustration (js/require "../resources/images/ui2/onboarding_illustration.png")
:qr-code (js/require "../resources/images/ui2/qr-code.png")
})
:keycard-logo (js/require "../resources/images/ui2/keycard-logo.png")
:keycard-chip-light (js/require "../resources/images/ui2/keycard-chip-light.png")
:keycard-chip-dark (js/require "../resources/images/ui2/keycard-chip-dark.png")
:keycard-watermark (js/require "../resources/images/ui2/keycard-watermark.png")})

(def mock-images
{:coinbase (js/require "../resources/images/mock2/coinbase.png")
Expand Down
37 changes: 37 additions & 0 deletions src/status_im2/contexts/quo_preview/keycard/keycard.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
(ns status-im2.contexts.quo-preview.keycard.keycard
(:require [status-im2.contexts.quo-preview.preview :as preview]
[react-native.core :as rn]
[quo2.foundations.colors :as colors]
[reagent.core :as reagent]
[quo2.core :as quo]))

(def descriptor
[{:label "Holder"
:key :holder-name
:type :text}
{:label "Locked?"
:key :locked?
:type :boolean}])

(defn cool-preview
[]
(let [state (reagent/atom {:holder-name nil
:locked? true})]
(fn
[]
[rn/touchable-without-feedback {:on-press rn/dismiss-keyboard!}
[rn/view [preview/customizer state descriptor]
[quo/keycard
{:holder-name? (:holder-name @state)
:locked? (:locked? @state)}]]])))

(defn preview-keycard
[]
[rn/view
{:style {:background-color (colors/theme-colors colors/white colors/neutral-95)
:flex 1}}
[rn/flat-list
{:style {:flex 1}
:keyboard-should-persist-taps :always
:header [cool-preview]
:key-fn str}]])
Comment on lines +28 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think rn/view can be removed and apply the background-color to flat-list ?

8 changes: 6 additions & 2 deletions src/status_im2/contexts/quo_preview/main.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
[status-im2.contexts.quo-preview.wallet.lowest-price :as lowest-price]
[status-im2.contexts.quo-preview.wallet.network-amount :as network-amount]
[status-im2.contexts.quo-preview.wallet.network-breakdown :as network-breakdown]
[status-im2.contexts.quo-preview.wallet.token-overview :as token-overview]))
[status-im2.contexts.quo-preview.wallet.token-overview :as token-overview]
[status-im2.contexts.quo-preview.keycard.keycard :as keycard]))

(def screens-categories
{:foundations [{:name :shadows
Expand Down Expand Up @@ -344,7 +345,10 @@
:component network-breakdown/preview-network-breakdown}
{:name :network-amount
:options {:topBar {:visible true}}
:component network-amount/preview}]})
:component network-amount/preview}]
:keycard [{:name :keycard-component
:options {:topBar {:visible true}}
:component keycard/preview-keycard}]})

(def screens (flatten (map val screens-categories)))

Expand Down
4 changes: 3 additions & 1 deletion src/status_im2/setup/i18n_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,9 @@
:your-data-belongs-to-you
:your-data-belongs-to-you-description
:your-recovery-phrase
:your-recovery-phrase-description})
:your-recovery-phrase-description
:empty-keycard
:user-keycard})

;; NOTE: the rest checkpoints are based on the previous one, defined
;; like this:
Expand Down
2 changes: 2 additions & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,8 @@
"database-reset-content": "Chats, contacts and settings have been deleted. You can use your account with your Keycard",
"database-reset-warning": "Database will be reset. Chats, contacts and settings will be deleted",
"empty-keycard-required": "Requires an empty Keycard",
"empty-keycard": "Empty Keycard",
"user-keycard": "{{name}} Card",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually what the designers envisioned or should it just be the users name? cc @xAlisher

"current": "Current",
"choose-storage": "Choose storage",
"choose-new-location-for-keystore": "Choose a new location to save your keystore file",
Expand Down