Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9761cb66f0 | ||
|
|
a46a3e2a93 | ||
|
|
bfc7a2d88b | ||
|
|
ccb20d7994 | ||
|
|
a261628b83 | ||
|
|
7a28c0c120 | ||
|
|
cb4d8cd899 | ||
|
|
b242f4a94c | ||
|
|
6296530810 | ||
|
|
e1bbf4bc75 | ||
|
|
90095c84f7 | ||
|
|
2f53a5ca2c | ||
|
|
d7afbb6a86 |
+3
-3
@@ -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";
|
||||
|
||||
@@ -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))
|
||||
@@ -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}]]))
|
||||
@@ -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
|
||||
@@ -182,3 +183,6 @@
|
||||
(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)
|
||||
|
||||
+25
-23
@@ -1,24 +1,26 @@
|
||||
(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.tags.--tests--.status-tags-component-spec]))
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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"))))))
|
||||
|
||||
@@ -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)))
|
||||
|
||||
@@ -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
|
||||
[]
|
||||
@@ -41,22 +42,26 @@
|
||||
|
||||
(defn enable-notification-buttons
|
||||
[]
|
||||
[rn/view {:style style/enable-notifications-buttons}
|
||||
[quo/button
|
||||
{:on-press (fn []
|
||||
(rf/dispatch [::notifications/switch true platform/ios?])
|
||||
(rf/dispatch [:init-root :welcome]))
|
||||
:type :primary
|
||||
:before :i/notifications
|
||||
:accessibility-label :enable-notifications-button
|
||||
:override-background-color (colors/custom-color :magenta 60)}
|
||||
(i18n/label :t/intro-wizard-title6)]
|
||||
[quo/button
|
||||
{:on-press #(rf/dispatch [:init-root :welcome])
|
||||
:accessibility-label :enable-notifications-later-button
|
||||
:override-background-color colors/white-opa-5
|
||||
:style {:margin-top 12}}
|
||||
(i18n/label :t/maybe-later)]])
|
||||
(let [{profile-color :color} (rf/sub [:onboarding-2/profile])]
|
||||
[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
|
||||
:before :i/notifications
|
||||
:accessibility-label :enable-notifications-button
|
||||
:override-background-color (colors/custom-color profile-color 60)}
|
||||
(i18n/label :t/intro-wizard-title6)]
|
||||
[quo/button
|
||||
{: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}}
|
||||
(i18n/label :t/maybe-later)]]))
|
||||
|
||||
(defn enable-notifications
|
||||
[]
|
||||
@@ -68,4 +73,3 @@
|
||||
[quo/text
|
||||
"[Illustration here]"]]
|
||||
[enable-notification-buttons]])
|
||||
|
||||
|
||||
@@ -163,8 +163,7 @@
|
||||
constants/auth-method-biometric
|
||||
(get-in db [:onboarding-2/profile :auth-method]))]
|
||||
|
||||
(cond-> {:db (dissoc db :onboarding-2/profile)
|
||||
:dispatch [:navigate-to :enable-notifications]}
|
||||
(cond-> {:dispatch [:navigate-to :enable-notifications]}
|
||||
biometric-enabled?
|
||||
(assoc :biometric/enable-and-save-password
|
||||
{:key-uid key-uid
|
||||
|
||||
@@ -39,17 +39,18 @@
|
||||
|
||||
(defn view
|
||||
[]
|
||||
[rn/view {:style style/welcome-container}
|
||||
[background/view true]
|
||||
[navigation-bar :enable-notifications]
|
||||
[page-title]
|
||||
[rn/view {:style style/page-illustration}
|
||||
[quo/text
|
||||
"Illustration here"]]
|
||||
[quo/button
|
||||
{:on-press #(rf/dispatch [:init-root :shell-stack])
|
||||
:type :primary
|
||||
:accessibility-label :welcome-button
|
||||
:override-background-color (colors/custom-color :magenta 60)
|
||||
:style {:margin 20}}
|
||||
(i18n/label :t/start-using-status)]])
|
||||
(let [{profile-color :color} (rf/sub [:onboarding-2/profile])]
|
||||
[rn/view {:style style/welcome-container}
|
||||
[background/view true]
|
||||
[navigation-bar :enable-notifications]
|
||||
[page-title]
|
||||
[rn/view {:style style/page-illustration}
|
||||
[quo/text
|
||||
"Illustration here"]]
|
||||
[quo/button
|
||||
{:on-press #(rf/dispatch [:init-root :shell-stack])
|
||||
:type :primary
|
||||
:accessibility-label :welcome-button
|
||||
:override-background-color (colors/custom-color profile-color 60)
|
||||
:style {:margin 20}}
|
||||
(i18n/label :t/start-using-status)]]))
|
||||
|
||||
@@ -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]
|
||||
@@ -177,6 +178,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}
|
||||
|
||||
@@ -186,5 +186,5 @@
|
||||
(.toBeNull (js/expect element)))
|
||||
|
||||
(defn was-called
|
||||
[element]
|
||||
(.toHaveBeenCalled (js/expect element)))
|
||||
[mock]
|
||||
(.toHaveBeenCalled (js/expect mock)))
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user