Skip to content

Commit

Permalink
qa
Browse files Browse the repository at this point in the history
  • Loading branch information
flexsurfer committed Oct 16, 2023
1 parent 03bc273 commit bb5e5e2
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 92 deletions.
70 changes: 36 additions & 34 deletions src/status_im/ui/components/button/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -66,43 +66,45 @@
:else theme)
{:keys [icon-color background-color text-color border-color]}
(themes theme')]
(println "theme" theme' background-color)
[rn/touchable-without-feedback
(merge {:bg-color background-color
:border-radius border-radius
:type type
:disabled disabled
:accessibility-label accessibility-label}
(when border-color
{:border-color border-color
:border-width 1})
(when on-press
(merge (when on-press
{:on-press on-press})
(when on-long-press
{:on-long-press on-long-press}))
[rn/view {:test-ID test-ID :style (merge (style-container type) style)}
(when before
[rn/view
[icons/icon before {:color icon-color}]])
(when loading
[rn/view {:style {:position :absolute}}
[rn/activity-indicator]])
[rn/view
{:style (merge (content-style type)
(when loading
{:opacity 0}))}
(cond
(= type :icon)
[icons/icon children {:color icon-color}]
[rn/view
(merge {:background-color background-color
:border-radius border-radius
:type type
:disabled disabled
:accessibility-label accessibility-label}
(when border-color
{:border-color border-color
:border-width 1}))
[rn/view {:test-ID test-ID :style (merge (style-container type) style)}
(when before
[rn/view
[icons/icon before {:color icon-color}]])
(when loading
[rn/view {:style {:position :absolute}}
[rn/activity-indicator]])
[rn/view
{:style (merge (content-style type)
(when loading
{:opacity 0}))}
(cond
(= type :icon)
[icons/icon children {:color icon-color}]

(string? children)
[text/text
{:weight :medium
:number-of-lines 1
:style {:color text-color}}
children]
(string? children)
[text/text
{:weight :medium
:number-of-lines 1
:style {:color text-color}}
children]

(vector? children)
children)]
(when after
[rn/view
[icons/icon after {:color icon-color}]])]]))
(vector? children)
children)]
(when after
[rn/view
[icons/icon after {:color icon-color}]])]]]))
69 changes: 16 additions & 53 deletions src/status_im/ui/components/controls/view.cljs
Original file line number Diff line number Diff line change
@@ -1,67 +1,30 @@
(ns status-im.ui.components.controls.view
(:require [cljs-bean.core :as bean]
[react-native.reanimated :as animated]
[status-im.ui.components.controls.styles :as styles]
(:require [status-im.ui.components.controls.styles :as styles]
[status-im.ui.components.colors :as colors]
[react-native.core :as rn]
[reagent.core :as reagent]
[status-im.ui.components.icons.icons :as icons]))

(defn control-builder
[component]
(fn [props]
(let [{:keys [value onChange disabled]}
(bean/bean props)]
(reagent/as-element
[rn/touchable-without-feedback
{:on-press (fn []
(when (and (not disabled) onChange)
(onChange (not value))))
:enabled (boolean (and onChange (not disabled)))}
[rn/view
[component
{:disabled disabled}]]]))))

(defn switch-view
[{:keys [transition hold disabled value]}]
[animated/view
{:style (styles/switch-style transition disabled)
(defn switch
[{:keys [disabled value]}]
[rn/view
{:style (styles/switch-style value disabled)
:accessibility-label (str "switch-" (if value "on" "off"))
:accessibility-role :switch}
[animated/view {:style (styles/switch-bullet-style transition hold)}]])
[rn/view {:style (styles/switch-bullet-style value false)}]])

(defn radio-view
[{:keys [transition hold disabled value]}]
[animated/view
{:style (styles/radio-style transition disabled)
(defn radio
[{:keys [disabled value]}]
[rn/view
{:style (styles/radio-style value disabled)
:accessibility-label (str "radio-" (if value "on" "off"))
:accessibility-role :radio}
[animated/view {:style (styles/radio-bullet-style transition hold)}]])

(defn checkbox-view
[props]
(let [{:keys [value onChange disabled]} (bean/bean props)]
(reagent/as-element
[rn/touchable-without-feedback
{:on-press (when (and onChange (not disabled)) onChange)}
[rn/view
{:style (styles/checkbox-style value disabled)
:accessibility-label (str "checkbox-" (if value "on" "off"))
:accessibility-role :checkbox}
[rn/view {:style (styles/check-icon-style value)}
[icons/tiny-icon :tiny-icons/tiny-check {:color colors/white}]]]])))
[rn/view {:style (styles/radio-bullet-style value false)}]])

(defn animated-checkbox-view
[{:keys [transition hold disabled value]}]
[animated/view
{:style (styles/animated-checkbox-style transition disabled)
(defn checkbox
[{:keys [value disabled]}]
[rn/view
{:style (styles/checkbox-style value disabled)
:accessibility-label (str "checkbox-" (if value "on" "off"))
:accessibility-role :checkbox}
[animated/view {:style (styles/animated-check-icon-style transition hold)}
[rn/view {:style (styles/check-icon-style value)}
[icons/tiny-icon :tiny-icons/tiny-check {:color colors/white}]]])

(def switch (reagent/adapt-react-class (control-builder switch-view)))
(def radio (reagent/adapt-react-class (control-builder radio-view)))
(def animated-checkbox
(reagent/adapt-react-class (control-builder animated-checkbox-view)))
(def checkbox (reagent/adapt-react-class checkbox-view))
7 changes: 2 additions & 5 deletions src/status_im/ui/components/list/item.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
[title-column props]])

(defn right-side
[{:keys [chevron active disabled accessory accessory-text accessory-style animated-accessory?]}]
[{:keys [chevron active disabled accessory accessory-text accessory-style]}]
(when (or chevron accessory)
[rn/view
{:style (merge {:align-items :center
Expand All @@ -191,10 +191,7 @@
[rn/view {:style (:tiny spacing/padding-horizontal)}
(case accessory
:radio [controls/radio {:value active :disabled disabled}]
:checkbox [(if animated-accessory?
controls/animated-checkbox
controls/checkbox)
{:value active :disabled disabled}]
:checkbox [controls/checkbox {:value active :disabled disabled}]
:switch [controls/switch {:value active :disabled disabled}]
:text [text/text
{:color :secondary
Expand Down

0 comments on commit bb5e5e2

Please sign in to comment.