Compare commits

...
Author SHA1 Message Date
Roman Volosovskyi 73d1a243b5 - 2023-04-13 18:00:32 +02:00
Roman Volosovskyi 37a58e1ff2 + 2023-04-13 16:50:49 +02:00
Roman Volosovskyi 7e7c6c645e + 2023-04-13 16:24:35 +02:00
Roman Volosovskyi f50c66a019 + 2023-04-13 16:12:06 +02:00
Roman Volosovskyi 2b0760de00 _+ 2023-04-13 16:00:47 +02:00
Roman Volosovskyi a4e037eba0 _ 2023-04-13 15:42:14 +02:00
Roman Volosovskyi 5ae4c89231 _ 2023-04-13 15:03:25 +02:00
Roman Volosovskyi e01eb4b2fe _ 2023-04-13 14:36:14 +02:00
Roman Volosovskyi 50a9fbf808 _ 2023-04-13 14:24:04 +02:00
Roman Volosovskyi 2b115ee276 _ 2023-04-13 14:13:08 +02:00
Roman Volosovskyi 9619723ccb + 2023-04-13 13:55:00 +02:00
Roman Volosovskyi 449f8f562e [#15609] Debug perf issues 2023-04-13 13:10:13 +02:00
Jamie Caprani cddf127674 feat: add qr and share qr components to quo2 (#15583)
feat: add qr and share qr components to quo2
2023-04-11 02:35:51 -07:00
Ibrahem Khalil a46a3e2a93 Bump go version to work with latest status-go changes (#15614) 2023-04-11 10:11:06 +02:00
Icaro Motta bfc7a2d88b Implement new URL Preview component (#15607)
Fix https://github.com/status-im/status-mobile/issues/15592

Notes:

- The red border around the icon has been reported in issue
  https://github.com/status-im/status-mobile/issues/15606
- The loading state doesn't have a spinning icon on purpose. This will be done
  separately.
2023-04-10 22:02:39 -03:00
Ulises Manuel Cárdenas ccb20d7994 [#15578] fix code snippet 2023-04-10 12:24:22 -06:00
yqrashawn a261628b83 feat: support ens profile name in lock screen (#15554) 2023-04-10 12:23:40 +08:00
John Ngei e1bbf4bc75 redirect user to communities home after finishing onboarding 2023-04-08 02:45:55 +03:00
30 changed files with 817 additions and 243 deletions
+3 -3
View File
@@ -53,9 +53,9 @@ in {
version = "13.3";
allowHigher = true;
};
go = super.go_1_18;
buildGoPackage = super.buildGo118Package;
buildGoModule = super.buildGo118Module;
go = super.go_1_19;
buildGoPackage = super.buildGo119Package;
buildGoModule = super.buildGo119Module;
gomobile = (super.gomobile.overrideAttrs (old: {
patches = self.fetchurl { # https://github.com/golang/mobile/pull/84
url = "https://github.com/golang/mobile/commit/f20e966e05b8f7e06bed500fa0da81cf6ebca307.patch";
Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

+87
View File
@@ -0,0 +1,87 @@
(ns quo2.components.code.code.style
(:require [quo2.foundations.colors :as colors]))
;; Example themes:
;; https://github.com/react-syntax-highlighter/react-syntax-highlighter/tree/master/src/styles/hljs
(defn theme
[theme-key]
(case theme-key
:hljs-comment (colors/theme-colors colors/neutral-40 colors/neutral-60)
:hljs-title (colors/custom-color-by-theme :sky 50 60)
:hljs-keyword (colors/custom-color-by-theme :green 50 60)
:hljs-string (colors/custom-color-by-theme :turquoise 50 60)
:hljs-literal (colors/custom-color-by-theme :turquoise 50 60)
:hljs-number (colors/custom-color-by-theme :turquoise 50 60)
:line-number colors/neutral-40
nil))
(defn text-style
[class-names]
(let [text-color (->> class-names
(map keyword)
(some (fn [class-name]
(when-let [text-color (theme class-name)]
text-color))))]
(cond-> {:flex-shrink 1
:line-height 18}
text-color (assoc :color text-color))))
(defn border-color
[]
(colors/theme-colors colors/neutral-20 colors/neutral-80))
(defn container
[]
{:overflow :hidden
:padding 8
:background-color (colors/theme-colors colors/white colors/neutral-80-opa-40)
:border-color (border-color)
:border-width 1
:border-radius 16})
(def gradient-container
{:position :absolute
:bottom 0
:left 0
:right 0
:z-index 1})
(def gradient {:height 48})
(defn line-number-container
[line-number-width]
{:position :absolute
:bottom 0
:top 0
:left 0
:width (+ line-number-width 8 7)
:background-color (colors/theme-colors colors/neutral-5 colors/neutral-80)})
(defn divider
[line-number-width]
{:position :absolute
:bottom 0
:top 0
:left (+ line-number-width 7 7)
:width 1
:z-index 2
:background-color (border-color)})
(def line {:flex-direction :row})
(defn line-number
[width]
{:margin-right 20 ; 8+12 margin
:width width})
(def copy-button
{:position :absolute
:bottom 8
:right 8
:z-index 1})
(defn gradient-color [] (colors/theme-colors colors/white colors/neutral-80))
(defn button-background-color
[]
(colors/theme-colors colors/neutral-80-opa-5 colors/white-opa-5))
+79 -144
View File
@@ -1,175 +1,110 @@
(ns quo2.components.code.snippet
(:require [cljs-bean.core :as bean]
[clojure.string :as string]
[oops.core :as oops]
[quo2.components.buttons.button :as button]
[quo2.components.code.code.style :as style]
[quo2.components.markdown.text :as text]
[quo2.foundations.colors :as colors]
[quo2.theme :as theme]
[react-native.core :as rn]
[react-native.linear-gradient :as linear-gradient]
[react-native.masked-view :as masked-view]
[react-native.syntax-highlighter :as highlighter]
[reagent.core :as reagent]))
;; Example themes:
;; https://github.com/react-syntax-highlighter/react-syntax-highlighter/tree/master/src/styles/hljs
(def ^:private themes
{:light {:hljs-comment {:color colors/neutral-40}
:hljs-title {:color (colors/custom-color :blue 50)}
:hljs-keyword {:color (colors/custom-color :green 50)}
:hljs-string {:color (colors/custom-color :turquoise 50)}
:hljs-literal {:color (colors/custom-color :turquoise 50)}
:hljs-number {:color (colors/custom-color :turquoise 50)}
:line-number {:color colors/neutral-40}}
:dark {:hljs-comment {:color colors/neutral-60}
:hljs-title {:color (colors/custom-color :blue 60)}
:hljs-keyword {:color (colors/custom-color :green 60)}
:hljs-string {:color (colors/custom-color :turquoise 60)}
:hljs-literal {:color (colors/custom-color :turquoise 60)}
:hljs-number {:color (colors/custom-color :turquoise 60)}
:line-number {:color colors/neutral-40}}})
(defn- text-style
[class-names]
(->> class-names
(map keyword)
(reduce #(merge %1 (get-in themes [(theme/get-theme) %2]))
{:flex-shrink 1
;; Round to a nearest whole number to achieve consistent
;; spacing (also important for calculating `max-text-height`).
;; Line height seems to be inconsistent between text being
;; wrapped and text being rendered on a newline using Flexbox
;; layout.
:line-height 18})))
(defn- render-nodes
[nodes]
(map (fn [{:keys [children value] :as node}]
;; Node can have :children or a :value.
(map (fn [{:keys [children value last-line?] :as node}]
(if children
(into [text/text
{:weight :code
:size :paragraph-2
:style (text-style (get-in node [:properties :className]))}]
(cond-> {:weight :code
:size :paragraph-2
:style (style/text-style (get-in node [:properties :className]))}
last-line? (assoc :number-of-lines 1))]
(render-nodes children))
;; Remove newlines as we already render each line separately.
(-> value string/trim-newline)))
(string/trim-newline value)))
nodes))
(defn- line
[{:keys [line-number line-number-width]} children]
[rn/view {:style style/line}
[rn/view {:style (style/line-number line-number-width)}
[text/text
{:style (style/text-style ["line-number"])
:weight :code
:size :paragraph-2}
line-number]]
children])
(defn- code-block
[{:keys [rows line-number-width]}]
[into [:<>]
[rn/view
(->> rows
(render-nodes)
;; Line numbers
(map-indexed (fn [idx row]
(conj [rn/view {:style {:flex-direction :row}}
[rn/view
{:style {:width line-number-width
;; 8+12 margin
:margin-right 20}}
[text/text
{:weight :code
:size :paragraph-2
:style (text-style ["line-number"])}
(inc idx)]]]
row))))])
(map-indexed (fn [idx row-content]
[line
{:line-number (inc idx)
:line-number-width line-number-width}
row-content]))
(into [:<>]))])
(defn- mask-view
[{:keys [apply-mask?]} child]
(if apply-mask?
[:<>
[rn/view {:style style/gradient-container}
[linear-gradient/linear-gradient
{:style style/gradient
:colors [:transparent (style/gradient-color)]}
[rn/view {:style style/gradient}]]]
child]
child))
(defn- calc-line-number-width
[font-scale rows-to-show]
(let [max-line-digits (-> rows-to-show str count)]
(if (= 1 max-line-digits)
18 ;; ~ 9 is char width, 18 is width used in Figma.
(* 9 max-line-digits font-scale))))
(defn- native-renderer
[]
(let [text-height (reagent/atom nil)]
(fn [{:keys [rows max-lines on-copy-press]}]
(let [background-color (colors/theme-colors
colors/white
colors/neutral-80-opa-40)
background-color-left (colors/theme-colors
colors/neutral-5
colors/neutral-80)
border-color (colors/theme-colors
colors/neutral-20
colors/neutral-80)
rows (bean/->clj rows)
font-scale (:font-scale (rn/use-window-dimensions))
max-rows (or max-lines (count rows)) ;; Cut down on rows to process.
max-line-digits (-> rows count (min max-rows) str count)
;; ~ 9 is char width, 18 is width used in Figma.
line-number-width (* font-scale (max 18 (* 9 max-line-digits)))
max-text-height (some-> max-lines
(* font-scale 18)) ;; 18 is font's line height.
truncated? (and max-text-height (< max-text-height @text-height))
maybe-mask-wrapper (if truncated?
[masked-view/masked-view
{:mask-element
(reagent/as-element
[linear-gradient/linear-gradient
{:colors ["black" "transparent"]
:locations [0.75 1]
:style {:flex 1}}])}]
[:<>])]
[rn/view
{:style {:overflow :hidden
:padding 8
:background-color background-color
:border-color border-color
:border-width 1
:border-radius 8
;; Hide on intial render to avoid flicker when mask-wrapper is shown.
:opacity (if @text-height 1 0)}}
;; Line number container
[rn/view
{:style {:position :absolute
:bottom 0
:top 0
:left 0
:width (+ line-number-width 8 8)
:background-color background-color-left
:border-right-color border-color
:border-right-width 1}}]
(conj maybe-mask-wrapper
[rn/view {:max-height max-text-height}
[rn/view
{:on-layout (fn [evt]
(let [height (oops/oget evt "nativeEvent.layout.height")]
(reset! text-height height)))}
[code-block
{:rows (take max-rows rows)
:line-number-width line-number-width}]]])
;; Copy button
[rn/view
{:style {:position :absolute
:bottom 8
:right 8}}
[button/button
{:icon true
:type :grey
:size 24
:on-press on-copy-press}
:main-icons/copy]]]))))
(defn- wrap-renderer-fn
[f {:keys [max-lines on-copy-press]}]
(fn [^js props]
(reagent/as-element [:f> f
{:rows (.-rows props)
:max-lines max-lines
:on-copy-press on-copy-press}])))
[{:keys [rows max-lines on-copy-press]
:or {max-lines ##Inf}}]
(let [font-scale (:font-scale (rn/use-window-dimensions))
total-rows (count rows)
number-rows-to-show (min (count rows) max-lines)
line-number-width (calc-line-number-width font-scale number-rows-to-show)
truncated? (< number-rows-to-show total-rows)
rows-to-show-coll (if truncated?
(as-> rows $
(update $ number-rows-to-show assoc :last-line? true)
(take (inc number-rows-to-show) $))
rows)]
[rn/view {:style (style/container)}
[rn/view {:style (style/line-number-container line-number-width)}]
[rn/view {:style (style/divider line-number-width)}]
[mask-view {:apply-mask? truncated?}
[code-block
{:rows rows-to-show-coll
:line-number-width line-number-width}]]
[rn/view {:style style/copy-button}
[button/button
{:icon true
:type :grey
:size 24
:on-press on-copy-press
:override-background-color (style/button-background-color)}
:main-icons/copy]]]))
(defn snippet
[{:keys [language max-lines on-copy-press]} children]
[highlighter/highlighter
{:language language
:renderer (wrap-renderer-fn
native-renderer
{:max-lines max-lines
:on-copy-press #(when on-copy-press
(on-copy-press children))})
;; Default props to adapt Highlighter for react-native.
;;:CodeTag react-native/View
;;:PreTag react-native/View
:renderer (fn [^js/Object props]
(reagent/as-element
[:f> native-renderer
{:rows (-> props .-rows bean/->clj)
:on-copy-press #(when on-copy-press (on-copy-press children))
:max-lines max-lines}]))
:show-line-numbers false
:style #js {}
:custom-style #js {:backgroundColor nil}}
:style {}
:custom-style {:background-color nil}}
children])
@@ -0,0 +1,29 @@
(ns quo2.components.links.url-preview.component-spec
(:require
[quo2.components.links.url-preview.view :as view]
[test-helpers.component :as h]))
(h/describe "Links - URL Preview"
(h/test "default render"
(h/render [view/view])
(h/is-truthy (h/query-by-label-text :title))
(h/is-truthy (h/query-by-label-text :logo))
(h/is-truthy (h/query-by-label-text :button-clear-preview))
(h/is-null (h/query-by-label-text :url-preview-loading)))
(h/test "on-clear event"
(let [on-clear (h/mock-fn)]
(h/render [view/view {:on-clear on-clear}])
(h/fire-event :press (h/get-by-label-text :button-clear-preview))
(h/was-called on-clear)))
(h/describe "loading state"
(h/test "shows a loading container"
(h/render [view/view {:loading? true :loading-message "Hello"}])
(h/is-null (h/query-by-label-text :title))
(h/is-truthy (h/query-by-label-text :url-preview-loading)))
(h/test "renders if `loading-message` is not passed"
(h/render [view/view {:loading? true}])
(h/is-null (h/query-by-label-text :title))
(h/is-truthy (h/query-by-label-text :url-preview-loading)))))
@@ -0,0 +1,58 @@
(ns quo2.components.links.url-preview.style
(:require [quo2.foundations.colors :as colors]))
(def horizontal-padding 12)
(defn container
[]
{:height 56
:background-color (colors/theme-colors colors/neutral-5 colors/neutral-90)
:padding-vertical 10
:padding-horizontal horizontal-padding
:border-radius 12
:align-self :stretch
:flex-direction :row})
(defn loading-container
[]
{:height 56
:border-width 1
:border-radius 12
:border-style :dashed
:align-items :center
:justify-content :center
:align-self :stretch
:padding horizontal-padding
:border-color (colors/theme-colors colors/neutral-30 colors/neutral-80)})
(defn loading-message
[]
{:color (colors/theme-colors colors/neutral-50 colors/neutral-40)})
(def logo
{:width 16
:height 16
:top 1
:border-radius 8})
(def content-container
{:margin-left 6
:flex 1})
(defn title
[]
{:color (colors/theme-colors colors/neutral-100 colors/white)})
(defn body
[]
{:text-transform :lowercase
:color (colors/theme-colors colors/neutral-50 colors/neutral-40)})
(def clear-button
{:border-color colors/danger-50
:border-width 1})
(def clear-button-container
{:width 20
:height 20
:margin-left 6})
@@ -0,0 +1,63 @@
(ns quo2.components.links.url-preview.view
(:require
[quo2.components.icon :as icon]
[quo2.components.links.url-preview.style :as style]
[quo2.components.markdown.text :as text]
[quo2.foundations.colors :as colors]
[react-native.core :as rn]))
(defn- logo-component
[{:keys [logo]}]
[rn/image
{:accessibility-label :logo
:source logo
:style style/logo}])
(defn- content
[{:keys [title body]}]
[rn/view {:style style/content-container}
[text/text
{:accessibility-label :title
:size :paragraph-2
:weight :semi-bold
:number-of-lines 1
:style (style/title)}
title]
[text/text
{:accessibility-label :body
:size :paragraph-2
:weight :medium
:number-of-lines 1
:style (style/body)}
body]])
(defn- clear-button
[{:keys [on-press]}]
[rn/touchable-opacity
{:on-press on-press
:style style/clear-button-container
:hit-slop {:top 3 :right 3 :bottom 3 :left 3}
:accessibility-label :button-clear-preview}
[icon/icon :i/clear
{:size 20
:container-style style/clear-button
:color (colors/theme-colors colors/neutral-50 colors/neutral-60)}]])
(defn view
[{:keys [title body logo on-clear loading? loading-message container-style]}]
(if loading?
[rn/view
{:accessibility-label :url-preview-loading
:style (merge (style/loading-container) container-style)}
[rn/text
{:size :paragraph-2
:weight :medium
:number-of-lines 1
:style (style/loading-message)}
loading-message]]
[rn/view
{:accessibility-label :url-preview
:style (merge (style/container) container-style)}
[logo-component {:logo logo}]
[content {:title title :body body}]
[clear-button {:on-press on-clear}]]))
@@ -0,0 +1,12 @@
(ns quo2.components.share.qr-code.style)
(def container
{:flex-direction :row
:justify-content :center})
(defn image
[width height]
{:width width
:height height
:border-radius 12
:aspect-ratio 1})
@@ -0,0 +1,11 @@
(ns quo2.components.share.qr-code.view
(:require [quo2.components.share.qr-code.style :as style]
[react-native.core :as rn]))
(defn qr-code
[{:keys [source width height]}]
[rn/view
{:style style/container}
[rn/image
{:source source
:style (style/image width height)}]])
@@ -0,0 +1,33 @@
(ns quo2.components.share.share-qr-code.component-spec
(:require [quo2.components.share.share-qr-code.view :as share-qr-code]
[test-helpers.component :as h]))
(h/describe "Share QR Code component"
(h/test "renders share qr code component"
(h/render [share-qr-code/view
{:link-title " A test title"}])
(-> (js/expect (h/get-by-text "A test title"))
(.toBeTruthy)))
(h/test "renders share qr code url"
(h/render [share-qr-code/view
{:qr-url " A test url"}])
(-> (js/expect (h/get-by-text "A test url"))
(.toBeTruthy)))
(h/test "on press link event fires"
(let [event (h/mock-fn)]
(h/render [share-qr-code/view
{:url-on-press event
:qr-url " A test url"}])
(h/fire-event :press (h/get-by-text "A test url"))
(-> (js/expect event)
(.toHaveBeenCalledTimes 1))))
(h/test "on press share event fires"
(let [event (h/mock-fn)]
(h/render [share-qr-code/view
{:share-on-press event}])
(h/fire-event :press (h/get-by-label-text :share-profile))
(-> (js/expect event)
(.toHaveBeenCalledTimes 1)))))
@@ -0,0 +1,44 @@
(ns quo2.components.share.share-qr-code.style
(:require [quo2.foundations.colors :as colors]))
(def qr-code-container
{:padding-top 12
:padding-horizontal 12
:padding-bottom 8
:border-radius 16
:background-color colors/white-opa-5
:flex-direction :column
:justify-content :center
:align-items :center})
(def profile-address-column
{:margin-horizontal :auto
:flex 4})
(def profile-address-container
{:flex-direction :row
:justify-content :space-between
:margin-top 6})
(def profile-address-content-container
{:padding-top 2
:align-self :flex-start})
(def profile-address-content
{:color colors/white})
(def profile-address-label
{:color colors/white-opa-40})
(def share-button-container
{:flex 1
:flex-direction :column
:justify-content :center
:align-items :flex-end})
(def icon-container
{:height 36
:flex-direction :row
:align-items :center
:justify-content :space-between
:padding-bottom 12})
@@ -0,0 +1,49 @@
(ns quo2.components.share.share-qr-code.view
(:require [quo2.components.share.share-qr-code.style :as style]
[quo2.components.share.qr-code.view :as qr-code]
[react-native.blur :as blur]
[quo2.components.markdown.text :as text]
[quo2.foundations.colors :as colors]
[quo2.components.buttons.button :as button]
[react-native.core :as rn]))
(defn view
[{:keys [source link-title
url-on-press url-on-long-press qr-url share-on-press]}]
[blur/ios-view
{:style style/qr-code-container
:blur-type :light}
[qr-code/qr-code
{:source source
:width "100%"
:height 311}]
[rn/view {:style style/profile-address-container}
[rn/view {:style style/profile-address-column}
[text/text
{:size :paragraph-2
:weight :medium
:style style/profile-address-label}
link-title]
[rn/touchable-highlight
{:active-opacity 1
:underlay-color colors/neutral-80-opa-1-blur
:background-color :transparent
:on-press url-on-press
:on-long-press url-on-long-press
:style style/profile-address-content-container}
[text/text
{:style style/profile-address-content
:size :paragraph-1
:weight :medium
:ellipsize-mode :middle
:number-of-lines 1}
qr-url]]]
[rn/view {:style style/share-button-container}
[button/button
{:icon true
:type :blur-bg
:size 32
:accessibility-label :share-profile
:override-theme :dark
:on-press share-on-press}
:i/share]]]])
+16 -3
View File
@@ -33,6 +33,7 @@
quo2.components.inputs.input.view
quo2.components.inputs.title-input.view
quo2.components.inputs.profile-input.view
quo2.components.links.url-preview.view
quo2.components.list-items.channel
quo2.components.list-items.menu-item
quo2.components.list-items.preview-list
@@ -59,6 +60,8 @@
quo2.components.separator
quo2.components.settings.accounts.view
quo2.components.settings.privacy-option
quo2.components.share.qr-code.view
quo2.components.share.share-qr-code.view
quo2.components.onboarding.small-option-card.view
quo2.components.tabs.segmented-tab
quo2.components.tabs.account-selector
@@ -91,9 +94,7 @@
(def group-avatar-tag quo2.components.tags.context-tags/group-avatar-tag)
(def audio-tag quo2.components.tags.context-tags/audio-tag)
(def community-tag quo2.components.tags.context-tags/community-tag)
(def tabs quo2.components.tabs.tabs/tabs)
(def segmented-control quo2.components.tabs.segmented-tab/segmented-control)
(def account-selector quo2.components.tabs.account-selector/account-selector)
(def floating-shell-button quo2.components.navigation.floating-shell-button/floating-shell-button)
(def page-nav quo2.components.navigation.page-nav/page-nav)
(def disclaimer quo2.components.selectors.disclaimer.view/view)
@@ -176,9 +177,21 @@
(def privacy-option quo2.components.settings.privacy-option/card)
(def account quo2.components.settings.accounts.view/account)
;;;; SHARE
(def qr-code quo2.components.share.qr-code.view/qr-code)
(def share-qr-code quo2.components.share.share-qr-code.view/view)
;;;; TABS
(def tabs quo2.components.tabs.tabs/tabs)
(def segmented-control quo2.components.tabs.segmented-tab/segmented-control)
(def account-selector quo2.components.tabs.account-selector/account-selector)
;;;; TAGS
(def tag quo2.components.tags.tag/tag)
(def tags quo2.components.tags.tags/tags)
(def permission-tag quo2.components.tags.permission-tag/tag)
(def status-tag quo2.components.tags.status-tags/status-tag)
(def token-tag quo2.components.tags.token-tag/tag)
;;;; LINKS
(def url-preview quo2.components.links.url-preview.view/view)
+26 -23
View File
@@ -1,24 +1,27 @@
(ns quo2.core-spec
(:require [quo2.components.avatars.user-avatar.component-spec]
[quo2.components.banners.banner.component-spec]
[quo2.components.buttons.--tests--.buttons-component-spec]
[quo2.components.colors.color-picker.component-spec]
[quo2.components.counter.--tests--.counter-component-spec]
[quo2.components.dividers.--tests--.divider-label-component-spec]
[quo2.components.dividers.strength-divider.component-spec]
[quo2.components.drawers.action-drawers.component-spec]
[quo2.components.drawers.drawer-buttons.component-spec]
[quo2.components.drawers.permission-context.component-spec]
[quo2.components.inputs.input.component-spec]
[quo2.components.inputs.profile-input.component-spec]
[quo2.components.inputs.title-input.component-spec]
[quo2.components.markdown.--tests--.text-component-spec]
[quo2.components.onboarding.small-option-card.component-spec]
[quo2.components.password.tips.component-spec]
[quo2.components.profile.select-profile.component-spec]
[quo2.components.record-audio.record-audio.--tests--.record-audio-component-spec]
[quo2.components.record-audio.soundtrack.--tests--.soundtrack-component-spec]
[quo2.components.selectors.--tests--.selectors-component-spec]
[quo2.components.selectors.disclaimer.component-spec]
[quo2.components.selectors.filter.component-spec]
[quo2.components.tags.--tests--.status-tags-component-spec]))
(:require
[quo2.components.avatars.user-avatar.component-spec]
[quo2.components.banners.banner.component-spec]
[quo2.components.buttons.--tests--.buttons-component-spec]
[quo2.components.colors.color-picker.component-spec]
[quo2.components.counter.--tests--.counter-component-spec]
[quo2.components.dividers.--tests--.divider-label-component-spec]
[quo2.components.dividers.strength-divider.component-spec]
[quo2.components.drawers.action-drawers.component-spec]
[quo2.components.drawers.drawer-buttons.component-spec]
[quo2.components.drawers.permission-context.component-spec]
[quo2.components.inputs.input.component-spec]
[quo2.components.inputs.profile-input.component-spec]
[quo2.components.inputs.title-input.component-spec]
[quo2.components.links.url-preview.component-spec]
[quo2.components.markdown.--tests--.text-component-spec]
[quo2.components.onboarding.small-option-card.component-spec]
[quo2.components.password.tips.component-spec]
[quo2.components.profile.select-profile.component-spec]
[quo2.components.record-audio.record-audio.--tests--.record-audio-component-spec]
[quo2.components.record-audio.soundtrack.--tests--.soundtrack-component-spec]
[quo2.components.selectors.--tests--.selectors-component-spec]
[quo2.components.selectors.disclaimer.component-spec]
[quo2.components.selectors.filter.component-spec]
[quo2.components.share.share-qr-code.component-spec]
[quo2.components.tags.--tests--.status-tags-component-spec]))
+9 -3
View File
@@ -1,5 +1,11 @@
(ns react-native.syntax-highlighter
(:require ["react-syntax-highlighter" :default Highlighter]
[reagent.core :as reagent]))
(:require ["react-native" :as react-native]
["react-syntax-highlighter" :default Highlighter]))
(def highlighter (reagent/adapt-react-class Highlighter))
(defn highlighter
[props code-string]
[:> Highlighter
;; Default props to adapt Highlighter for react-native.
(assoc props :Code-tag react-native/View :Pre-tag react-native/View)
code-string])
+37 -21
View File
@@ -1,17 +1,29 @@
(ns status-im.multiaccounts.update.core
(:require [status-im2.constants :as constants]
[utils.re-frame :as rf]
[status-im.utils.types :as types]
[taoensso.timbre :as log]))
(:require [status-im.utils.types :as types]
[status-im2.constants :as constants]
[taoensso.timbre :as log]
[utils.re-frame :as rf]))
(rf/defn send-multiaccount-update
[{:keys [db] :as cofx}]
(let [multiaccount (:multiaccount db)
{:keys [name preferred-name address]} multiaccount]
(rf/defn send-contact-update
[{:keys [db]}]
(let [{:keys [name preferred-name display-name address]} (:multiaccount db)]
{:json-rpc/call [{:method "wakuext_sendContactUpdates"
:params [(or preferred-name name) ""]
:params [(or preferred-name display-name name) ""]
:on-success #(log/debug "sent contact update")}]}))
(rf/defn update-multiaccount-account-name
"This updates the profile name in the profile list before login"
{:events [:multiaccounts.ui/update-name]}
[{:keys [db] :as cofx} raw-multiaccounts-from-status-go]
(let [{:keys [key-uid name preferred-name
display-name]} (:multiaccount db)
account (some #(and (= (:key-uid %) key-uid) %) raw-multiaccounts-from-status-go)]
(when-let [new-name (and account (or preferred-name display-name name))]
(rf/merge cofx
{:json-rpc/call [{:method "multiaccounts_updateAccount"
:params [(assoc account :name new-name)]
:on-success #(log/debug "sent multiaccount update")}]}))))
(rf/defn multiaccount-update
"Takes effects (containing :db) + new multiaccount fields, adds all effects necessary for multiaccount update.
Optionally, one can specify a success-event to be dispatched after fields are persisted."
@@ -25,17 +37,21 @@
(throw
(js/Error.
"Please shake the phone to report this error and restart the app. multiaccount is currently empty, which means something went wrong when trying to update it with"))
(rf/merge cofx
{:db (if setting-value
(assoc-in db [:multiaccount setting] setting-value)
(update db :multiaccount dissoc setting))
:json-rpc/call
[{:method "settings_saveSetting"
:params [setting setting-value]
:on-success on-success}]}
(when (and (not dont-sync?)
(#{:name :prefered-name} setting))
(send-multiaccount-update))))))
(rf/merge
cofx
{:db (if setting-value
(assoc-in db [:multiaccount setting] setting-value)
(update db :multiaccount dissoc setting))
:json-rpc/call
[{:method "settings_saveSetting"
:params [setting setting-value]
:on-success on-success}]}
(when (#{:name :preferred-name} setting)
(constantly {:setup/open-multiaccounts #(rf/dispatch [:multiaccounts.ui/update-name %])}))
(when (and (not dont-sync?) (#{:name :preferred-name} setting))
(send-contact-update))))))
(rf/defn clean-seed-phrase
"A helper function that removes seed phrase from storage."
@@ -44,7 +60,7 @@
(defn augment-synchronized-recent-stickers
"Add 'url' parameter to stickers that are synchronized from other devices.
It is not sent from aanother devices but we have it in our db."
It is not sent from another devices but we have it in our db."
[synced-stickers stickers-from-db]
(mapv #(assoc %
:url
@@ -1,5 +1,5 @@
(ns status-im.multiaccounts.update.core-test
(:require [clojure.test :refer-macros [deftest is]]
(:require [clojure.test :refer-macros [deftest is testing]]
[status-im.multiaccounts.update.core :as multiaccounts.update]))
(deftest test-multiaccount-update
@@ -21,3 +21,36 @@
json-rpc (into #{} (map :method (:json-rpc/call efx)))]
(is (json-rpc "settings_saveSetting"))
(is (nil? (get-in efx [:db :multiaccount :mnemonic])))))
(deftest test-update-multiaccount-account-name
(let [cofx {:db {:multiaccount {:key-uid 1
:name "name"
:preferred-name "preferred-name"
:display-name "display-name"}}}
raw-multiaccounts-from-status-go [{:key-uid 1 :name "old-name"}]]
(testing "wrong account"
(is (nil? (multiaccounts.update/update-multiaccount-account-name cofx []))))
(testing "name priority preferred-name > display-name > name"
(let [new-account-name= (fn [efx new-name]
(-> efx
:json-rpc/call
first
:params
first
:name
(= new-name)))]
(is (new-account-name=
(multiaccounts.update/update-multiaccount-account-name
cofx
raw-multiaccounts-from-status-go)
"preferred-name"))
(is (new-account-name=
(multiaccounts.update/update-multiaccount-account-name
(update-in cofx [:db :multiaccount] dissoc :preferred-name)
raw-multiaccounts-from-status-go)
"display-name"))
(is (new-account-name=
(multiaccounts.update/update-multiaccount-account-name
(update-in cofx [:db :multiaccount] dissoc :preferred-name :display-name)
raw-multiaccounts-from-status-go)
"name"))))))
+2 -2
View File
@@ -247,11 +247,11 @@
[cofx installation-id]
(rf/merge cofx
(enable installation-id)
(multiaccounts.update/send-multiaccount-update)))
(multiaccounts.update/send-contact-update)))
(rf/defn disable-installation-success
{:events [:pairing.callback/disable-installation-success]}
[cofx installation-id]
(rf/merge cofx
(disable installation-id)
(multiaccounts.update/send-multiaccount-update)))
(multiaccounts.update/send-contact-update)))
+1
View File
@@ -21,6 +21,7 @@
:photo1 (js/require "../resources/images/mock2/photo1.png")
:photo2 (js/require "../resources/images/mock2/photo2.png")
:photo3 (js/require "../resources/images/mock2/photo3.png")
:qr-code (js/require "../resources/images/mock2/qr-code.png")
:small-opt-card-icon (js/require "../resources/images/mock2/small_opt_card_icon.png")
:small-opt-card-main (js/require "../resources/images/mock2/small_opt_card_main.png")
:status-logo (js/require "../resources/images/mock2/status-logo.png")
@@ -8,7 +8,8 @@
[react-native.platform :as platform]
[status-im.notifications.core :as notifications]
[status-im2.contexts.onboarding.common.background.view :as background]
[status-im2.contexts.onboarding.enable-notifications.style :as style]))
[status-im2.contexts.onboarding.enable-notifications.style :as style]
[status-im2.contexts.shell.animation :as shell.animation]))
(defn navigation-bar
[]
@@ -44,6 +45,7 @@
[rn/view {:style style/enable-notifications-buttons}
[quo/button
{:on-press (fn []
(shell.animation/change-selected-stack-id :communities-stack true)
(rf/dispatch [::notifications/switch true platform/ios?])
(rf/dispatch [:init-root :welcome]))
:type :primary
@@ -52,7 +54,9 @@
:override-background-color (colors/custom-color :magenta 60)}
(i18n/label :t/intro-wizard-title6)]
[quo/button
{:on-press #(rf/dispatch [:init-root :welcome])
{:on-press (fn []
(shell.animation/change-selected-stack-id :communities-stack true)
(rf/dispatch [:init-root :welcome]))
:accessibility-label :enable-notifications-later-button
:override-background-color colors/white-opa-5
:style {:margin-top 12}}
@@ -68,4 +72,3 @@
[quo/text
"[Illustration here]"]]
[enable-notification-buttons]])
@@ -26,6 +26,23 @@
s.logger.Error(\"failed to set Server.port\", zap.Error(err))
return
}
if s.afterPortChanged != nil {
s.afterPortChanged(s.port)
}
s.run = true
err = s.server.Serve(listener)
if err != http.ErrServerClosed {
s.logger.Error(\"server failed unexpectedly, restarting\", zap.Error(err))
err = s.Start()
if err != nil {
s.logger.Error(\"server start failed, giving up\", zap.Error(err))
}
return
}
s.run = false
}")
(def clojure-example
@@ -59,9 +76,13 @@
:value :clojure}
{:key :go
:value :go}]}
{:label "Max lines:"
:key :max-lines
:type :text}
{:label "Max lines:"
:key :max-lines
:type :select
:options (map (fn [n]
{:key n
:value (str n " lines")})
(range 0 41 5))}
{:label "Syntax highlight:"
:key :syntax
:type :boolean}])
@@ -69,7 +90,7 @@
(defn cool-preview
[]
(let [state (reagent/atom {:language :clojure
:max-lines ""
:max-lines 40
:syntax true})]
(fn []
(let [language (if (:syntax @state) (:language @state) :text)
@@ -0,0 +1,56 @@
(ns status-im2.contexts.quo-preview.links.url-preview
(:require
[quo2.core :as quo]
[quo2.foundations.colors :as colors]
[react-native.core :as rn]
[reagent.core :as reagent]
[status-im2.common.resources :as resources]
[status-im2.contexts.quo-preview.preview :as preview]))
(def descriptor
[{:label "Title"
:key :title
:type :text}
{:label "Body"
:key :body
:type :text}
{:label "Loading?"
:key :loading?
:type :boolean}
{:label "Loading message"
:key :loading-message
:type :text}])
(defn cool-preview
[]
(let [state (reagent/atom
{:title "Status - Private, Secure Communication"
:body "Status.im"
:loading? false
:loading-message "Generating preview"})]
(fn []
[rn/touchable-without-feedback {:on-press rn/dismiss-keyboard!}
[rn/view {:style {:padding-bottom 150}}
[preview/customizer state descriptor]
[rn/view
{:style {:align-items :center
:padding-horizontal 16
:margin-top 50}}
[quo/url-preview
{:title (:title @state)
:body (:body @state)
:logo (resources/get-mock-image :status-logo)
:loading? (:loading? @state)
:loading-message (:loading-message @state)
:on-clear #(js/alert "Clear button pressed")}]]]])))
(defn preview
[]
[rn/view
{:style {:background-color (colors/theme-colors colors/white colors/neutral-95)
:flex 1}}
[rn/flat-list
{:flex 1
:keyboard-should-persist-taps :always
:header [cool-preview]
:key-fn str}]])
@@ -39,6 +39,7 @@
[status-im2.contexts.quo-preview.info.information-box :as information-box]
[status-im2.contexts.quo-preview.inputs.profile-input :as profile-input]
[status-im2.contexts.quo-preview.inputs.title-input :as title-input]
[status-im2.contexts.quo-preview.links.url-preview :as url-preview]
[status-im2.contexts.quo-preview.list-items.channel :as channel]
[status-im2.contexts.quo-preview.list-items.preview-lists :as preview-lists]
[status-im2.contexts.quo-preview.markdown.text :as text]
@@ -64,6 +65,8 @@
[status-im2.contexts.quo-preview.selectors.selectors :as selectors]
[status-im2.contexts.quo-preview.settings.accounts :as accounts]
[status-im2.contexts.quo-preview.settings.privacy-option :as privacy-option]
[status-im2.contexts.quo-preview.share.qr-code :as qr-code]
[status-im2.contexts.quo-preview.share.share-qr-code :as share-qr-code]
[status-im2.contexts.quo-preview.switcher.switcher-cards :as switcher-cards]
[status-im2.contexts.quo-preview.tabs.account-selector :as account-selector]
[status-im2.contexts.quo-preview.tabs.segmented-tab :as segmented]
@@ -177,6 +180,9 @@
{:name :title-input
:insets {:top false}
:component title-input/preview-title-input}]
:links [{:name :url-preview
:options {:insets {:top? true}}
:component url-preview/preview}]
:list-items [{:name :channel
:insets {:top false}
:component channel/preview-channel}
@@ -258,6 +264,12 @@
{:name :accounts
:insets {:top false}
:component accounts/preview-accounts}]
:share [{:name :qr-code
:insets {:top false}
:component qr-code/preview-qr-code}
{:name :share-qr-code
:insets {:top false}
:component share-qr-code/preview-share-qr-code}]
:tabs [{:name :segmented
:insets {:top false}
:component segmented/preview-segmented}
@@ -0,0 +1,32 @@
(ns status-im2.contexts.quo-preview.share.qr-code
(:require [quo2.foundations.colors :as colors]
[react-native.core :as rn]
[quo2.core :as quo]
[status-im2.common.resources :as resources]))
(defn cool-preview
[]
(fn []
[rn/touchable-without-feedback {:on-press rn/dismiss-keyboard!}
[rn/view {:style {:padding-bottom 150}}
[rn/view {:style {:flex 1}}]
[rn/view
{:style {:padding-vertical 60
:flex-direction :row
:justify-content :center}}
[quo/qr-code
{:source (resources/get-mock-image :qr-code)
:height 250
:width 250}]]]]))
(defn preview-qr-code
[]
[rn/view
{:style {:background-color (colors/theme-colors colors/white
colors/neutral-90)
:flex 1}}
[rn/flat-list
{:flex 1
:keyboard-should-persist-taps :always
:header [cool-preview]
:key-fn str}]])
@@ -0,0 +1,54 @@
(ns status-im2.contexts.quo-preview.share.share-qr-code
(:require [quo2.foundations.colors :as colors]
[react-native.core :as rn]
[quo2.core :as quo]
[status-im2.contexts.quo-preview.preview :as preview]
[status-im2.common.resources :as resources]
[reagent.core :as reagent]))
(def descriptor
[{:label "URL"
:key :url
:type :text}
{:label "Link title"
:key :link-title
:type :text}])
(defn cool-preview
[]
(let [state (reagent/atom {:info-button? true
:link-title "Link to profile"
:url "status.app/u/zQ34e1zlOdas0pKnvrweeedsasas12adjie8"})]
(fn []
[rn/touchable-without-feedback {:on-press rn/dismiss-keyboard!}
[rn/view {:style {:padding-bottom 150}}
[rn/view {:style {:flex 1}}]
[preview/customizer state descriptor]
[rn/view
{:style {:padding-vertical 60
:justify-content :center}}
[preview/blur-view
{:show-blur-background? true
:height 600
:blur-view-props {:padding-top 20
:padding-horizontal 20}}
[quo/share-qr-code
{:source (resources/get-mock-image :qr-code)
:link-title (:link-title @state)
:url-on-press #(js/alert "url pressed")
:url-on-long-press #(js/alert "url long pressed")
:share-on-press #(js/alert "share pressed")
:qr-url (:url @state)}]]]]])))
(defn preview-share-qr-code
[]
[rn/view
{:style {:background-color (colors/theme-colors colors/white
colors/neutral-90)
:flex 1}}
[rn/flat-list
{:flex 1
:keyboard-should-persist-taps :always
:header [cool-preview]
:key-fn str}]])
+32 -31
View File
@@ -181,37 +181,38 @@
on-press on-close content banner]}]
(let [color-50 (colors/custom-color customization-color 50)
color-60 (colors/custom-color customization-color 60)]
[rn/touchable-without-feedback {:on-press on-press}
[rn/view {:style (style/base-container color-50)}
(when banner
[rn/image
{:source (:source banner)
:style {:width 160}}])
[rn/view {:style style/secondary-container}
[quo/text
{:size :paragraph-1
:weight :semi-bold
:number-of-lines 1
:ellipsize-mode :tail
:style style/title}
title]
[quo/text
{:size :paragraph-2
:weight :medium
:style style/subtitle}
(subtitle type content)]
[bottom-container type (merge {:color-50 color-50 :color-60 color-60} content)]]
(when avatar-params
[rn/view {:style style/avatar-container}
[avatar avatar-params type customization-color]])
[quo/button
{:size 24
:type :grey
:icon true
:on-press on-close
:override-theme :dark
:style style/close-button}
:i/close]]]))
[rn/view [rn/text {:style {:color :red}} "SOME TEXT"]]
#_[rn/touchable-without-feedback {:on-press on-press}
[rn/view {:style (style/base-container color-50)}
(when banner
[rn/image
{:source (:source banner)
:style {:width 160}}])
#_[rn/view {:style style/secondary-container}
[quo/text
{:size :paragraph-1
:weight :semi-bold
:number-of-lines 1
:ellipsize-mode :tail
:style style/title}
title]
[quo/text
{:size :paragraph-2
:weight :medium
:style style/subtitle}
(subtitle type content)]
[bottom-container type (merge {:color-50 color-50 :color-60 color-60} content)]]
#_(when avatar-params
[rn/view {:style style/avatar-container}
[avatar avatar-params type customization-color]])
#_[quo/button
{:size 24
:type :grey
:icon true
:on-press on-close
:override-theme :dark
:style style/close-button}
:i/close]]]))
;; browser Card
(defn browser-card
+2
View File
@@ -49,6 +49,8 @@
(defn render-card
[{:keys [type screen-id] :as card}]
[rn/view [rn/text {:style {:color :red}} "SOME TEXT"]]
#_
(let [card-data (case type
shell.constants/one-to-one-chat-card
(rf/sub [:shell/one-to-one-chat-card screen-id])
+2 -2
View File
@@ -186,5 +186,5 @@
(.toBeNull (js/expect element)))
(defn was-called
[element]
(.toHaveBeenCalled (js/expect element)))
[mock]
(.toHaveBeenCalled (js/expect mock)))
+3 -3
View File
@@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.143.1",
"commit-sha1": "ee01fe4e0c14f03fb32dda15365da3c73470cde0",
"src-sha256": "0l5rld1p5nsvfahn8iymyn87a8h6wrllcx2jngcy7pxffbgk3619"
"version": "v0.144.0",
"commit-sha1": "ba1ba1ac0203948339be5877ea6e970efb7b8ee0",
"src-sha256": "0r2gxivnx201zfnm69g2mk1izcjid4lf9s4ln721kwrnc1v288sf"
}