Compare commits

...
Author SHA1 Message Date
alwx 615810e7f4 Offsets for composer + dynamic height calculation 2023-07-28 12:45:44 +02:00
alwx 9a5b2859c8 Offsets for composer + dynamic height calculation 2023-07-28 12:39:11 +02:00
Ulises Manuel Cárdenas 4f044765e1 [#16278] fix tips in white camera border (#16716)
* Remove unnecessary wrapper
* Fix border tips and refactor
* Add comment about using 1.9 width
2023-07-26 14:08:57 -06:00
Parvesh Monu 7cd9f76043 Fix UI freezing when image is opened from activity center (#16707) 2023-07-26 18:19:10 +05:30
Icaro Motta 238e35a281 Unshadow more Clojure core vars (#16777)
This is a continuation of https://github.com/status-im/status-mobile/pull/16500 (Lint
& fix some shadowed core Clojure(Script) vars).

Notes: As a reminder, the goal is to eventually disallow shadowing core Clojure
vars entirely, but to get there and avoid rebase hell and regressions, we need
to do in smaller steps, especially because we can't safely automate the process
of unshadowing vars.

We are already down from ~500 shadowed core vars to 350 in total.

Why is this PR is using names such as "s", "v" or "sym"? Names such as s or v
are the so called idiomatic names, and are listed in the Clojure Style Guide
https://guide.clojure.style/#idiomatic-names. I used them whenever I felt
appropriate. For the var cljs.core/symbol I opted to use sym, even though the
symbol in question is not necessarily a Clojure symbol, I think the alias
conveys the meaning well enough
(https://www.clojure.org/guides/learn/syntax#_symbols_and_idents).

New vars linted:

- comparator
- identity
- str
- symbol
- val

Outstanding shadowed vars include type, name, hash, comp.
2023-07-26 11:26:12 +00:00
Alexander 57c538e9d0 Update navigation bar to support dark mode (#16762)
* Dark mode top bar

* Fixes

* Style fix
2023-07-26 09:48:51 +02:00
Omar BasemandMilad e49a3ab5cd feat: category reorder component (#16719)
* feat: category reorder component

---------

Co-authored-by: Milad <mmilad.sanati@gmail.com>
2023-07-26 11:11:17 +04:00
64 changed files with 773 additions and 583 deletions
+9 -1
View File
@@ -20,7 +20,15 @@
;; future, as we progressively fix shadowed
;; vars, we should be able to delete this
;; option and lint all vars.
:include [count iter key time]}
:include [comparator
count
identity
iter
key
str
symbol
time
val]}
:invalid-arity {:skip-args [status-im.utils.fx/defn utils.re-frame/defn]}
;; TODO remove number when this is fixed
;; https://github.com/borkdude/clj-kondo/issues/867
+1 -1
View File
@@ -44,7 +44,7 @@
"react-native-camera-kit": "^13.0.0",
"react-native-config": "^1.5.0",
"react-native-dialogs": "^1.0.4",
"react-native-draggable-flatlist": "^3.0.3",
"react-native-draggable-flatlist": "^4.0.1",
"react-native-fast-image": "^8.5.11",
"react-native-fetch-polyfill": "^1.1.2",
"react-native-fs": "^2.14.1",
Binary file not shown.

After

Width:  |  Height:  |  Size: 421 KiB

+6 -6
View File
@@ -461,19 +461,19 @@
(.numberToHex ^js (status) (str num)))
(defn sha3
[str]
[s]
(log/debug "[native-module] sha3")
(.sha3 ^js (status) str))
(.sha3 ^js (status) s))
(defn utf8-to-hex
[str]
[s]
(log/debug "[native-module] utf8-to-hex")
(.utf8ToHex ^js (status) str))
(.utf8ToHex ^js (status) s))
(defn hex-to-utf8
[str]
[s]
(log/debug "[native-module] hex-to-utf8")
(.hexToUtf8 ^js (status) str))
(.hexToUtf8 ^js (status) s))
(defn check-address-checksum
[address]
+14 -14
View File
@@ -82,8 +82,8 @@
:restDisplacementThreshold 0.001}})
(defn set-value
[anim val]
(ocall anim "setValue" val))
[anim v]
(ocall anim "setValue" v))
(def Value (oget animated "Value"))
@@ -178,20 +178,20 @@
(.withOffset ^js redash (clj->js config)))
(defn with-spring-transition
[val config]
(.withSpringTransition ^js redash val (clj->js config)))
[v config]
(.withSpringTransition ^js redash v (clj->js config)))
(defn with-timing-transition
[val config]
(.withTimingTransition ^js redash val (clj->js config)))
[v config]
(.withTimingTransition ^js redash v (clj->js config)))
(defn use-spring-transition
[val config]
(.useSpringTransition ^js redash val (clj->js config)))
[v config]
(.useSpringTransition ^js redash v (clj->js config)))
(defn use-timing-transition
[val config]
(.useTimingTransition ^js redash val (clj->js config)))
[v config]
(.useTimingTransition ^js redash v (clj->js config)))
(defn re-timing
[config]
@@ -232,11 +232,11 @@
:onGestureEvent (.-onGestureEvent ^js gesture)}))
(defn snap-point
[value velocity snap-points]
(.snapPoint ^js redash value velocity (to-array snap-points)))
[v velocity snap-points]
(.snapPoint ^js redash v velocity (to-array snap-points)))
(defn with-easing
[{val :value
[{v :value
:keys [snap-points velocity offset state easing duration
animation-over]
:or {duration 250
@@ -257,7 +257,7 @@
(set position offset))
(cond* (neq state (:end gh/states))
[(set animation-over 0)
(set position (add offset val))])
(set position (add offset v))])
(cond* (and* (eq state (:end gh/states))
(not* animation-over))
[(set position
+5 -5
View File
@@ -12,9 +12,9 @@
;; Inspired from UIX, Rum and Rumext
(defn set-ref-val!
[ref val]
(oset! ref "current" val)
val)
[ref v]
(oset! ref "current" v)
v)
(defn set-native-props
[^js ref ^js props]
@@ -54,8 +54,8 @@
#js [value set-value])))
(defn use-ref
[val]
(let [ref (react/useRef val)]
[v]
(let [ref (react/useRef v)]
(reify
cljs.core/IHash
(-hash [_] (goog/getUid ref))
@@ -12,11 +12,11 @@
{:style (style/token-row padding?)}
(doall
(map-indexed (fn [token-index token]
(let [{:keys [img-src symbol amount sufficient? purchasable? loading?]} token]
(let [{:keys [img-src amount sufficient? purchasable? loading?]} token]
^{:key token-index}
[rn/view {:style style/token-tag-spacing}
[token-tag/token-tag
{:symbol symbol
{:symbol (:symbol token)
:value amount
:size 24
:sufficient? sufficient?
+3 -2
View File
@@ -82,11 +82,12 @@
:border-radius 50}])
(defn timestamp
[str]
[s]
[text/text
{:size :label
:style {:text-transform :none
:color (get-color :time)}} str])
:color (get-color :time)}}
s])
(defn info-button
[on-press]
@@ -25,11 +25,12 @@
(def message-body
{:color colors/white})
(def message-container
(defn message-container
[attachment]
{:border-radius 12
:margin-top 12
:padding-horizontal 12
:padding-vertical 8
:padding-vertical (if (#{:photo :gif} attachment) 12 8)
:background-color colors/white-opa-5})
(def footer-container
@@ -74,8 +74,8 @@
context))))
(defn- activity-message
[{:keys [title body title-number-of-lines body-number-of-lines]}]
[rn/view {:style style/message-container}
[{:keys [title body title-number-of-lines body-number-of-lines attachment]}]
[rn/view {:style (style/message-container attachment)}
(when title
[text/text
{:size :paragraph-2
@@ -1,20 +1,53 @@
(ns quo2.components.settings.category.component-spec
(:require [test-helpers.component :as h]
[quo2.components.settings.category.view :as category]))
(:require
[quo2.components.settings.category.view :as category]
[test-helpers.component :as h]))
(h/describe "category tests"
(h/describe "Settings Category tests"
(h/test "category label renders"
(h/render [category/category
{:label "label"
:data [{:title "Item 1"
:left-icon :i/browser
:chevron? true}]}])
(h/is-truthy (h/get-by-text "label")))
{:list-type :settings
:label "Label"
:data [{:title "Item 1"
:left-icon :i/browser
:chevron? true}]}])
(h/is-truthy (h/get-by-text "Label")))
(h/test "category item renders"
(h/render [category/category
{:label "label"
:data [{:title "Item 1"
:left-icon :i/browser
:chevron? true}]}])
{:list-type :settings
:label "Label"
:data [{:title "Item 1"
:left-icon :i/browser
:chevron? true}]}])
(h/is-truthy (h/get-by-text "Item 1"))))
(h/describe "Reorder Category tests"
(h/test "category label renders"
(h/render [category/category
{:list-type :reorder
:label "Label"
:data [{:title "Item 1"
:right-icon :i/globe
:chevron? true}]}])
(h/is-truthy (h/get-by-text "Label")))
(h/test "category item renders"
(h/render [category/category
{:list-type :reorder
:label "Label"
:data [{:title "Item 1"
:right-icon :i/globe
:chevron? true}]}])
(h/is-truthy (h/get-by-text "Item 1")))
(h/test "category item subtitle renders"
(h/render [category/category
{:list-type :reorder
:label "Label"
:data [{:title "Item 1"
:subtitle "subtitle"
:right-icon :i/globe
:chevron? true}]}])
(h/is-truthy (h/get-by-text "subtitle"))))
@@ -0,0 +1,41 @@
(ns quo2.components.settings.category.reorder.view
(:require
[quo2.components.markdown.text :as text]
[quo2.components.settings.reorder-item.types :as types]
[quo2.components.settings.reorder-item.view :as reorder-item]
[quo2.foundations.colors :as colors]
[react-native.blur :as blur]
[react-native.core :as rn]
[quo2.components.settings.category.style :as style]
[quo2.theme :as quo.theme]
[react-native.draggable-flatlist :as draggable-flatlist]
[reagent.core :as reagent]))
(defn on-drag-end-fn
[data atom-data]
(reset! atom-data data)
(reagent/flush))
(defn- reorder-category-internal
[{:keys [label data blur? theme]}]
(reagent/with-let [atom-data (reagent/atom data)]
[rn/view {:style style/container}
(when blur?
[rn/view (style/blur-container) [blur/view (style/blur-view)]])
[text/text
{:weight :medium
:size :paragraph-2
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}}
label]
[draggable-flatlist/draggable-flatlist
{:data @atom-data
:key-fn (fn [item index] (str (:title item) index))
:style style/reorder-items
:render-fn (fn [item _ _ _ _ drag] [reorder-item/reorder-item item types/item
{:blur? blur? :drag drag}])
:on-drag-end-fn (fn [_ _ data]
(on-drag-end-fn data atom-data))
:separator [rn/view
{:style (style/reorder-separator blur? theme)}]}]]))
(def reorder-category (quo.theme/with-theme reorder-category-internal))
@@ -0,0 +1,27 @@
(ns quo2.components.settings.category.settings.view
(:require
[quo2.components.markdown.text :as text]
[quo2.components.settings.settings-list.view :as settings-list]
[quo2.foundations.colors :as colors]
[react-native.blur :as blur]
[react-native.core :as rn]
[quo2.components.settings.category.style :as style]
[quo2.theme :as quo.theme]))
(defn- category-internal
[{:keys [label data blur? theme]}]
[rn/view {:style style/container}
(when blur?
[rn/view (style/blur-container) [blur/view (style/blur-view)]])
[text/text
{:weight :medium
:size :paragraph-2
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}}
label]
[rn/flat-list
{:data data
:style (style/settings-items theme blur?)
:render-fn (fn [item] [settings-list/settings-list item])
:separator [rn/view {:style (style/settings-separator theme blur?)}]}]])
(def settings-category (quo.theme/with-theme category-internal))
@@ -8,7 +8,7 @@
:padding-top 12
:padding-bottom 8})
(defn items
(defn settings-items
[theme blur?]
{:margin-top 12
:border-radius 16
@@ -20,13 +20,23 @@
colors/white-opa-5
(colors/theme-colors colors/neutral-10 colors/neutral-80 theme))})
(defn separator
(def reorder-items
{:margin-top 12})
(defn settings-separator
[theme blur?]
{:height 1
:background-color (if blur?
colors/white-opa-5
(colors/theme-colors colors/neutral-10 colors/neutral-80 theme))})
(defn reorder-separator
[blur? theme]
{:height 4
:background-color (if blur?
:transparent
(colors/theme-colors colors/neutral-5 colors/neutral-95 theme))})
(defn blur-container
[]
{:position :absolute
@@ -1,27 +1,9 @@
(ns quo2.components.settings.category.view
(:require
[quo2.components.markdown.text :as text]
[quo2.components.settings.settings-list.view :as settings-list]
[quo2.foundations.colors :as colors]
[react-native.blur :as blur]
[react-native.core :as rn]
[quo2.components.settings.category.style :as style]
[quo2.theme :as quo.theme]))
(:require [quo2.components.settings.category.settings.view :as settings]
[quo2.components.settings.category.reorder.view :as reorder]))
(defn- category-internal
[{:keys [label data blur? theme]}]
[rn/view {:style style/container}
(when blur?
[rn/view (style/blur-container) [blur/view (style/blur-view)]])
[text/text
{:weight :medium
:size :paragraph-2
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}}
label]
[rn/flat-list
{:data data
:style (style/items theme blur?)
:render-fn (fn [item] [settings-list/settings-list item])
:separator [rn/view {:style (style/separator theme blur?)}]}]])
(def category (quo.theme/with-theme category-internal))
(defn category
[{:keys [list-type] :as props}]
(if (= list-type :settings)
[settings/settings-category props]
[reorder/reorder-category props]))
@@ -1,11 +1,14 @@
(ns quo2.components.settings.reorder-item.items.item
(:require [react-native.core :as rn]
[quo2.components.settings.reorder-item.style :as style]
[quo2.components.markdown.text :as text]
[quo2.components.icon :as icon]
[quo2.foundations.colors :as colors]))
(:require
[quo2.theme :as quo.theme]
[react-native.core :as rn]
[quo2.components.settings.reorder-item.style :as style]
[quo2.components.markdown.text :as text]
[quo2.components.icon :as icon]
[quo2.foundations.colors :as colors]
[react-native.fast-image :as fast-image]))
(defn view
(defn- view-internal
[{:keys
[title
subtitle
@@ -13,10 +16,14 @@
image-size
right-text
right-icon
on-press]}]
on-press
theme]}
blur?
drag]
[rn/touchable-opacity
{:on-press on-press
:style (merge (style/item-container) (when subtitle style/item-container-extended))}
{:on-press on-press
:on-long-press drag
:style (merge (style/item-container blur?) (when subtitle style/item-container-extended))}
[icon/icon :main-icons/drag
{:color (colors/theme-colors
colors/neutral-50
@@ -25,23 +32,25 @@
{:style style/body-container}
[rn/view
{:style style/image-container}
[rn/image
[fast-image/fast-image
{:source image
:style (style/image image-size)}]]
[rn/view
{:style style/text-container}
[rn/view
[text/text
{:style style/item-text
:weight :medium}
{:weight :medium}
title]
(when subtitle
[text/text
{:style style/item-subtitle
:weight :regular}
{:style style/item-subtitle
:size :paragraph-2}
subtitle])]
(when right-text
[text/text {:style style/right-text} right-text])
(when right-icon
[rn/view {:style style/right-icon-container} [icon/icon right-icon (style/right-icon)]])]]
[icon/icon :tiny-icons/chevron-right (style/chevron)]])
[icon/icon :tiny-icons/chevron-right (style/chevron theme)]])
(def view (quo.theme/with-theme view-internal))
@@ -2,19 +2,21 @@
(:require [quo2.foundations.colors :as colors]))
(defn item-container
[]
[blur?]
{:flex-direction :row
:align-items :center
:padding-horizontal 10
:border-radius 14
:margin-bottom 23
:height 45
:background-color (colors/theme-colors
colors/white
colors/neutral-90)})
:border-radius 16
:padding-horizontal 12
:padding-vertical 12
:height 48
:background-color (if blur?
colors/white-opa-5
(colors/theme-colors
colors/white
colors/neutral-90))})
(def item-container-extended
{:height 52})
{:height 56})
(def body-container
{:flex 1
@@ -31,20 +33,17 @@
{:width size
:height size})
(def item-text
{:font-size 14})
(defn chevron
[]
[theme]
{:color (colors/theme-colors
colors/neutral-50
colors/neutral-40)
colors/neutral-40
theme)
:height 14
:width 14})
(def item-subtitle
{:color colors/neutral-50
:font-size 13})
{:color colors/neutral-50})
(def right-text
{:font-size 15
@@ -7,9 +7,9 @@
[quo2.components.settings.reorder-item.types :as types]))
(defn reorder-item
[item type]
[item type {:keys [blur? drag]}]
(case type
types/item [item/view item]
types/item [item/view item blur? drag]
types/placeholder [placeholder/view item]
types/skeleton [skeleton/view]
types/tab [tab/view item]
+6 -5
View File
@@ -105,10 +105,11 @@
:loading? true/false
}"
[_ _]
(fn [{:keys [symbol value size img-src border-color purchasable? sufficient? loading?]
:or
{size :small}}]
(let [sufficient? (when-not loading? sufficient?)
(fn [{:keys [value size img-src border-color purchasable? sufficient? loading?]
:or {size :small}
:as props}]
(let [sym (:symbol props)
sufficient? (when-not loading? sufficient?)
border-color (if sufficient? colors/success-50 border-color)]
[tag
{:size size
@@ -119,4 +120,4 @@
[loading-icon]
(when (or purchasable? sufficient?)
[icon size border-color sufficient?]))}
(str value " " symbol)])))
(str value " " sym)])))
+11
View File
@@ -0,0 +1,11 @@
(ns react-native.draggable-flatlist
(:require
[react-native.flat-list :as rn-flat-list]
[reagent.core :as reagent]
["react-native-draggable-flatlist" :default DraggableFlatList]))
(def rn-draggable-flatlist (reagent/adapt-react-class DraggableFlatList))
(defn draggable-flatlist
[props]
[rn-draggable-flatlist (rn-flat-list/base-list-props props)])
+21 -21
View File
@@ -91,9 +91,9 @@
(.-value anim)))
(defn set-shared-value
[anim val]
(when (and anim (some? val))
(set! (.-value anim) val)))
[anim v]
(when (and anim (some? v))
(set! (.-value anim) v)))
(defn interpolate
([shared-value input-range output-range]
@@ -112,47 +112,47 @@
;; Animators
(defn animate-shared-value-with-timing
[anim val duration easing]
[anim v duration easing]
(set-shared-value anim
(with-timing val
(with-timing v
(js-obj "duration" duration
"easing" (get easings easing)))))
(defn animate-shared-value-with-delay
[anim val duration easing delay]
[anim v duration easing delay]
(set-shared-value anim
(with-delay delay
(with-timing val
(with-timing v
(js-obj "duration" duration
"easing" (get easings easing))))))
(defn animate-delay
([animation val delay]
(animate-delay animation val delay default-duration))
([animation val delay duration]
([animation v delay]
(animate-delay animation v delay default-duration))
([animation v delay duration]
(set-shared-value animation
(with-delay delay
(with-timing val
(with-timing v
(clj->js {:duration duration
:easing (default-easing)}))))))
(defn animate-shared-value-with-repeat
[anim val duration easing number-of-repetitions reverse?]
[anim v duration easing number-of-repetitions reverse?]
(set-shared-value anim
(with-repeat (with-timing val
(with-repeat (with-timing v
(js-obj "duration" duration
"easing" (get easings easing)))
number-of-repetitions
reverse?)))
(defn animate-shared-value-with-delay-repeat
([anim val duration easing delay number-of-repetitions]
(animate-shared-value-with-delay-repeat anim val duration easing delay number-of-repetitions false))
([anim val duration easing delay number-of-repetitions reverse?]
([anim v duration easing delay number-of-repetitions]
(animate-shared-value-with-delay-repeat anim v duration easing delay number-of-repetitions false))
([anim v duration easing delay number-of-repetitions reverse?]
(set-shared-value anim
(with-delay delay
(with-repeat
(with-timing val
(with-timing v
#js
{:duration duration
:easing (get easings easing)})
@@ -160,9 +160,9 @@
reverse?)))))
(defn animate-shared-value-with-spring
[anim val {:keys [mass stiffness damping]}]
[anim v {:keys [mass stiffness damping]}]
(set-shared-value anim
(with-spring val
(with-spring v
(js-obj "mass" mass
"damping" damping
"stiffness" stiffness))))
@@ -183,7 +183,7 @@
:easing (default-easing)})))))
(defn with-timing-duration
[val duration]
(with-timing val
[v duration]
(with-timing v
(clj->js {:duration duration
:easing (in-out (.-quad ^js Easing))})))
+3 -2
View File
@@ -40,10 +40,10 @@
; referenced function: contact-list-item
(defn- rename-mentionable-users
[mentionable-users]
(reduce (fn [acc [id val]]
(reduce (fn [acc [id v]]
(assoc acc
id
(set/rename-keys val
(set/rename-keys v
{:id :public-key
:primaryName :primary-name
:secondaryName :secondary-name
@@ -55,6 +55,7 @@
{}
mentionable-users))
(defn- transfer-mention-result
[result]
(let [{:keys [input-segments mentionable-users state chat-id new-text]}
+2 -1
View File
@@ -83,7 +83,8 @@
(update :chats <-chats-rpc)
(update :categories <-categories-rpc)
(assoc :token-images
(reduce (fn [acc {:keys [symbol image]}] (assoc acc symbol image))
(reduce (fn [acc {sym :symbol image :image}]
(assoc acc sym image))
{}
(:communityTokensMetadata c)))))
+2 -2
View File
@@ -143,8 +143,8 @@
(defn generate-erc20-uri
"Generate a EIP 681 URI encapsulating ERC20 token transfer"
[address {:keys [symbol value] :as m} all-tokens]
(when-let [token (tokens/symbol->token all-tokens symbol)]
[address {sym :symbol value :value :as m} all-tokens]
(when-let [token (tokens/symbol->token all-tokens sym)]
(generate-uri (:address token)
(merge (dissoc m :value :symbol)
{:function-name "transfer"
+12 -7
View File
@@ -190,18 +190,23 @@
(is (.equals (money/bignumber "111122223333441239") (eip681/parse-eth-value "111122223333441239"))))
(deftest extract-request-details
(let [{:keys [value symbol address]} (eip681/extract-request-details
{:address "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7"
:value "1ETH"}
{})]
(let [{value :value
sym :symbol
address :address}
(eip681/extract-request-details
{:address "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7"
:value "1ETH"}
{})]
(is (.equals (money/ether->wei (money/bignumber 1)) value))
(is (= :ETH symbol))
(is (= :ETH sym))
(is (= "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7" address)))
(is (= (eip681/extract-request-details
{:address "0x744d70fdbe2ba4cf95131626614a1763df805b9e" :chain-id 1 :function-name "unknown"}
{})
{:address "0x744d70fdbe2ba4cf95131626614a1763df805b9e" :chain-id 1 :function-name "unknown"}))
(let [{:keys [value symbol address]}
(let [{value :value
sym :symbol
address :address}
(eip681/extract-request-details
{:address "0x744d70fdbe2ba4cf95131626614a1763df805b9e"
:chain-id 1
@@ -213,5 +218,5 @@
:symbol :SNT
:decimals 18}})]
(is (.equals (money/bignumber 1000) value))
(is (= :SNT symbol))
(is (= :SNT sym))
(is (= "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7" address))))
+12 -12
View File
@@ -5,10 +5,10 @@
(def default-native-currency
(memoize
(fn [symbol]
(fn [sym]
{:name "Native"
:symbol :ETH
:symbol-display symbol
:symbol-display sym
:decimals 18
:icon {:source (js/require "../resources/images/tokens/default-token.png")}})))
@@ -41,13 +41,13 @@
(set (map #(-> % val :symbol) all-native-currencies)))
(defn native-currency
[{:keys [symbol] :as current-network}]
[{sym :symbol :as current-network}]
(let [chain (ethereum/network->chain-keyword current-network)]
(get all-native-currencies chain (default-native-currency symbol))))
(get all-native-currencies chain (default-native-currency sym))))
(defn ethereum?
[symbol]
(native-currency-symbols symbol))
[sym]
(native-currency-symbols sym))
(def token-icons
{:mainnet (resolve-icons :mainnet)
@@ -74,17 +74,17 @@
(string/lower-case (:name %2))))))
(defn symbol->token
[all-tokens symbol]
(some #(when (= symbol (:symbol %)) %) (vals all-tokens)))
[all-tokens sym]
(some #(when (= sym (:symbol %)) %) (vals all-tokens)))
(defn address->token
[all-tokens address]
(get all-tokens (string/lower-case address)))
(defn asset-for
[all-tokens current-network symbol]
[all-tokens current-network sym]
(let [native-coin (native-currency current-network)]
(if (or (= (:symbol-display native-coin) symbol)
(= (:symbol native-coin) symbol))
(if (or (= (:symbol-display native-coin) sym)
(= (:symbol native-coin) sym))
native-coin
(symbol->token all-tokens symbol))))
(symbol->token all-tokens sym))))
@@ -52,10 +52,8 @@
(defn- parse-token-transfer
[chain-tokens contract]
(let [{:keys [symbol] :as token} (get chain-tokens
contract
default-erc20-token)]
{:symbol symbol
(let [token (get chain-tokens contract default-erc20-token)]
{:symbol (:symbol token)
:token token
;; NOTE(goranjovic) - just a flag we need when we merge this entry
;; with the existing entry in the app, e.g. transaction info with
@@ -387,11 +385,10 @@
:addresses [address]
:before-block min-known-block
:fetch-more? (utils.mobile-sync/syncing-allowed? cofx)
;; Transfers are requested before and including `min-known-block` because
;; there is no guarantee that all transfers from that block are shown
;; already. To make sure that we fetch the whole `default-transfers-limit`
;; of transfers the number of transfers already received for
;; `min-known-block` is added to the page size.
;; Transfers are requested before and including `min-known-block` because there is no
;; guarantee that all transfers from that block are shown already. To make sure that we fetch
;; the whole `default-transfers-limit` of transfers the number of transfers already received
;; for `min-known-block` is added to the page size.
:limit-per-address {address (+ default-transfers-limit
min-block-transfers-count)}}}
(tx-fetching-in-progress [address]))))
+8 -8
View File
@@ -34,18 +34,18 @@
(or display-name primary-name alias (gfycat/generate-gfy public-key)))))
(defn contact-by-identity
[contacts identity]
(or (get contacts identity)
(contact.db/public-key->new-contact identity)))
[contacts contact-identity]
(or (get contacts contact-identity)
(contact.db/public-key->new-contact contact-identity)))
(defn contact-two-names-by-identity
[contact profile identity]
(let [me? (= (:public-key profile) identity)]
[contact profile contact-identity]
(let [me? (= (:public-key profile) contact-identity)]
(if me?
[(or (:preferred-name profile)
(:display-name profile)
(:primary-name contact)
(gfycat/generate-gfy identity))]
(gfycat/generate-gfy contact-identity))]
[(:primary-name contact) (:secondary-name contact)])))
(defn displayed-photo
@@ -212,8 +212,8 @@
(rf/merge cofx
{:json-rpc/call [{:method "multiaccounts_deleteIdentityImage"
:params [key-uid]
;; NOTE: In case of an error we could fallback to previous image in UI
;; with a toast error
;; NOTE: In case of an error we could fallback to previous image in
;; UI with a toast error
:on-success #(log/info "[multiaccount] Delete profile image" %)}]}
(multiaccounts.update/optimistic :images nil)
(bottom-sheet/hide-bottom-sheet-old))))
+2 -2
View File
@@ -158,7 +158,7 @@
:on-success #(re-frame/dispatch [:navigate-back])}]}))
(defn new-network
[random-id network-name symbol upstream-url chain-type chain-id]
[random-id network-name sym upstream-url chain-type chain-id]
(let [data-dir (str "/ethereum/" (name chain-type) "_rpc")
config {:NetworkId (or (when chain-id (int chain-id))
(ethereum/chain-keyword->chain-id chain-type))
@@ -167,7 +167,7 @@
:URL upstream-url}}]
{:id random-id
:name network-name
:symbol symbol
:symbol sym
:config config}))
(rf/defn save
+2 -2
View File
@@ -181,7 +181,7 @@
(defn get-transfer-token
[db to data]
(let [{:keys [symbol decimals] :as token} (tokens/address->token (:wallet/all-tokens db) to)]
(let [{:keys [decimals] :as token} (tokens/address->token (:wallet/all-tokens db) to)]
(when (and token data (string? data))
(when-let [type (get-method-type data)]
(let [[address value _] (native-module/decode-parameters
@@ -197,7 +197,7 @@
:value value
:amount (money/to-fixed (money/token->unit value decimals))
:token token
:symbol symbol}))))))
:symbol (:symbol token)}))))))
(defn parse-tx-obj
[db {:keys [from to value data cancel? hash]}]
@@ -140,11 +140,11 @@
nil)))})))
(views/defview animated-bottom-panel
[val view on-close on-touch-outside show-overlay?]
[m view on-close on-touch-outside show-overlay?]
(views/letsubs [{window-height :height} [:dimensions/window]]
[bottom-panel
(when val
(select-keys val
(when m
(select-keys m
[:from :contact :amount :token :approve? :message :cancel? :hash :name :url :icons
:wc-version :params :connector :description :topic :relay :self :peer :permissions
:state])) view window-height on-close on-touch-outside
+4 -2
View File
@@ -298,8 +298,10 @@
(i18n/label :t/save)]]]))
(defn gwei
[val]
(str (money/to-fixed val 2) " " (i18n/label :t/gwei)))
[amount]
(str (money/to-fixed amount 2)
" "
(i18n/label :t/gwei)))
(defn fees-warning
[]
@@ -23,102 +23,104 @@
(defview add-custom-token
[]
(letsubs [{:keys [contract name symbol decimals in-progress? error error-name error-symbol]}
(letsubs [{:keys [contract name decimals in-progress? error error-name error-symbol]
:as m}
[:wallet/custom-token-screen]]
[react/keyboard-avoiding-view {:flex 1 :background-color colors/white}
[react/scroll-view
{:keyboard-should-persist-taps :handled
:style {:flex 1
:padding-horizontal 16}}
[react/view {:padding-vertical 8}
[react/view
{:style {:flex-direction :row
:justify-content :space-between
:padding-vertical 10}}
[react/text (i18n/label :t/contract-address)]
(when in-progress?
[react/view {:flex-direction :row :justify-content :center}
[react/view {:height 20}
[react/activity-indicator {:width 24 :height 24 :animating true}]]
[react/text {:style {:color colors/gray :margin-left 5}}
(i18n/label :t/processing)]])]
(when-not in-progress?
;;tooltip covers button
[react/view {:position :absolute :z-index 1000 :right 0 :top 10}
[react/touchable-highlight
{:on-press #(re-frame/dispatch [:wallet.custom-token.ui/contract-address-paste])}
[react/text {:style {:color colors/blue}}
(i18n/label :t/paste)]]])
[quo/text-input
{:on-change-text #(debounce-and-save :contract %)
:error error
:default-value contract
:monospace true
:multiline true
:height 78
:auto-focus false
:placeholder (i18n/label :t/specify-address)}]]
[react/view {:padding-vertical 8}
[quo/text-input
{:on-change-text #(debounce-and-save :name %)
:label (i18n/label :t/name)
:default-value name
:error error-name
:auto-focus false
:placeholder (i18n/label :t/name-of-token)}]]
[react/view {:padding-vertical 8}
[react/view {:style {:flex-direction :row}}
[react/view
{:flex 1
:padding-right 8}
(let [sym (:symbol m)]
[react/keyboard-avoiding-view {:flex 1 :background-color colors/white}
[react/scroll-view
{:keyboard-should-persist-taps :handled
:style {:flex 1
:padding-horizontal 16}}
[react/view {:padding-vertical 8}
[react/view
{:style {:flex-direction :row
:justify-content :space-between
:padding-vertical 10}}
[react/text (i18n/label :t/contract-address)]
(when in-progress?
[react/view {:flex-direction :row :justify-content :center}
[react/view {:height 20}
[react/activity-indicator {:width 24 :height 24 :animating true}]]
[react/text {:style {:color colors/gray :margin-left 5}}
(i18n/label :t/processing)]])]
(when-not in-progress?
;;tooltip covers button
[react/view {:position :absolute :z-index 1000 :right 0 :top 10}
[react/touchable-highlight
{:on-press #(re-frame/dispatch [:wallet.custom-token.ui/contract-address-paste])}
[react/text {:style {:color colors/blue}}
(i18n/label :t/paste)]]])
[quo/text-input
{:on-change-text #(debounce-and-save :symbol %)
:label (i18n/label :t/symbol)
:error error-symbol
:default-value symbol
{:on-change-text #(debounce-and-save :contract %)
:error error
:default-value contract
:monospace true
:multiline true
:height 78
:auto-focus false
:show-cancel false
:placeholder "ABC"}]]
[react/view
{:flex 1
:padding-left 8}
:placeholder (i18n/label :t/specify-address)}]]
[react/view {:padding-vertical 8}
[quo/text-input
{:label (i18n/label :t/decimals)
:on-change-text #(debounce-and-save :decimals %)
:default-value decimals
:keyboard-type :number-pad
:max-length 2
{:on-change-text #(debounce-and-save :name %)
:label (i18n/label :t/name)
:default-value name
:error error-name
:auto-focus false
:show-cancel false
:placeholder "18"}]]]]
#_[quo/text-input
{:label (i18n/label :t/balance)
:default-value (when (and balance decimals)
(wallet.utils/format-amount balance decimals))
:editable false
:placeholder (i18n/label :t/no-tokens-found)}]]
:placeholder (i18n/label :t/name-of-token)}]]
[react/view {:padding-vertical 8}
[react/view {:style {:flex-direction :row}}
[react/view
{:flex 1
:padding-right 8}
[quo/text-input
{:on-change-text #(debounce-and-save :symbol %)
:label (i18n/label :t/symbol)
:error error-symbol
:default-value sym
:auto-focus false
:show-cancel false
:placeholder "ABC"}]]
[react/view
{:flex 1
:padding-left 8}
[quo/text-input
{:label (i18n/label :t/decimals)
:on-change-text #(debounce-and-save :decimals %)
:default-value decimals
:keyboard-type :number-pad
:max-length 2
:auto-focus false
:show-cancel false
:placeholder "18"}]]]]
#_[quo/text-input
{:label (i18n/label :t/balance)
:default-value (when (and balance decimals)
(wallet.utils/format-amount balance decimals))
:editable false
:placeholder (i18n/label :t/no-tokens-found)}]]
[toolbar/toolbar
{:show-border? true
:right
[quo/button
{:type :secondary
:after :main-icon/next
:disabled (boolean
(or in-progress?
error
error-name
error-symbol
(string/blank? contract)
(string/blank? name)
(string/blank? symbol)
(string/blank? decimals)))
:on-press #(re-frame/dispatch [:wallet.custom-token.ui/add-pressed])}
(i18n/label :t/add)]}]]))
[toolbar/toolbar
{:show-border? true
:right
[quo/button
{:type :secondary
:after :main-icon/next
:disabled (boolean
(or in-progress?
error
error-name
error-symbol
(string/blank? contract)
(string/blank? name)
(string/blank? sym)
(string/blank? decimals)))
:on-press #(re-frame/dispatch [:wallet.custom-token.ui/add-pressed])}
(i18n/label :t/add)]}]])))
(defview custom-token-details
[]
(letsubs [{:keys [address name symbol decimals custom?] :as token}
(letsubs [{:keys [address name decimals custom?] :as token}
[:get-screen-params]]
[react/keyboard-avoiding-view
{:style {:flex 1}
@@ -149,7 +151,7 @@
{:label (i18n/label :t/symbol)
:editable false
:show-cancel false
:default-value symbol}]]
:default-value (:symbol token)}]]
[react/view {:flex 1 :padding-left 8}
[quo/text-input
{:label (i18n/label :t/decimals)
@@ -112,8 +112,8 @@
[react/text {:style {:color colors/blue}} (i18n/label :t/set-max)]]])
(defn fiat-value
[amount {:keys [symbol]} prices wallet-currency]
(when-let [price (get-in prices [(keyword symbol) (keyword (:code wallet-currency)) :price])]
[amount {sym :symbol} prices wallet-currency]
(when-let [price (get-in prices [(keyword sym) (keyword (:code wallet-currency)) :price])]
(let [norm-amount (js/parseFloat (money/normalize amount))
amount (if (js/isNaN norm-amount) 0 norm-amount)]
[react/text
@@ -51,7 +51,12 @@
(fn [_ [_ old-token] [_ new-token]]
(not= (:checked? old-token) (:checked? new-token)))
:reagent-render
(fn [{:keys [symbol name icon color checked?] :as token}]
(fn [{sym :symbol
title :name
icon :icon
color :color
checked? :checked?
:as token}]
[quo/list-item
{:active checked?
:accessory :checkbox
@@ -59,14 +64,13 @@
:animated false
:icon (if icon
[wallet.components/token-icon icon]
[chat-icon/custom-icon-view-list name color])
:title name
:subtitle (clojure.core/name symbol)
:on-press #(re-frame/dispatch
[:wallet.settings/toggle-visible-token (keyword symbol) (not checked?)])
:on-long-press #(re-frame/dispatch
[:bottom-sheet/show-sheet-old
{:content (custom-token-actions-view token)}])}])}))
[chat-icon/custom-icon-view-list title color])
:title title
:subtitle (name sym)
:on-press #(re-frame/dispatch [:wallet.settings/toggle-visible-token (keyword sym)
(not checked?)])
:on-long-press #(re-frame/dispatch [:bottom-sheet/show-sheet-old
{:content (custom-token-actions-view token)}])}])}))
(defn- render-token-wrapper
[token]
+2 -2
View File
@@ -132,9 +132,9 @@
(catch :default _ nil)))
(defn url?
[str]
[s]
(try
(when-let [host (.getDomain ^js (goog.Uri. str))]
(when-let [host (.getDomain ^js (goog.Uri. s))]
(not (string/blank? host)))
(catch :default _ nil)))
+10 -8
View File
@@ -191,12 +191,14 @@
(PersistentPriorityMap. (sorted-map) {} {} identity nil))
(defn- pm-empty-by
[comparator]
(PersistentPriorityMap. (sorted-map-by comparator) {} {} identity nil))
[f-comparator]
(PersistentPriorityMap. (sorted-map-by f-comparator) {} {} identity nil))
(defn- pm-empty-keyfn
([keyfn] (PersistentPriorityMap. (sorted-map) {} {} keyfn nil))
([keyfn comparator] (PersistentPriorityMap. (sorted-map-by comparator) {} {} keyfn nil)))
([keyfn]
(PersistentPriorityMap. (sorted-map) {} {} keyfn nil))
([keyfn f-comparator]
(PersistentPriorityMap. (sorted-map-by f-comparator) {} {} keyfn nil)))
(defn- read-priority-map
[elems]
@@ -221,9 +223,9 @@
"keyval => key val
Returns a new priority map with supplied
mappings, using the supplied comparator."
([comparator & keyvals]
([f-comparator & keyvals]
(loop [in (seq keyvals)
out (pm-empty-by comparator)]
out (pm-empty-by f-comparator)]
(if in
(recur (nnext in) (assoc out (first in) (second in)))
out))))
@@ -243,9 +245,9 @@
"keyval => key val
Returns a new priority map with supplied
mappings, using the supplied keyfn and comparator."
([keyfn comparator & keyvals]
([keyfn f-comparator & keyvals]
(loop [in (seq keyvals)
out (pm-empty-keyfn keyfn comparator)]
out (pm-empty-keyfn keyfn f-comparator)]
(if in
(recur (nnext in) (assoc out (first in) (second in)))
out))))
+1 -1
View File
@@ -120,7 +120,7 @@
(fn [address] (.checkAddressChecksum native-status address))
:sha3
(fn [str] (.sha3 native-status str))
(fn [s] (.sha3 native-status s))
:toChecksumAddress
(fn [address] (.toChecksumAddress native-status address))
+16 -10
View File
@@ -53,8 +53,14 @@
(defn- fill-prepare-transaction-details
[db
{:keys [address name value symbol gas gasPrice gasLimit]
:or {symbol :ETH}}
{address :address
name :name
value :value
sym :symbol
gas :gas
gas-price :gasPrice
gas-limit :gasLimit
:or {sym :ETH}}
all-tokens]
(assoc db
:wallet/prepare-transaction
@@ -62,14 +68,14 @@
:to-name (or name (find-address-name db address))
:from (ethereum/get-default-account
(get db :profile/wallet-accounts))}
gas (assoc :gas (money/bignumber gas))
gasLimit (assoc :gas (money/bignumber gasLimit))
gasPrice (assoc :gasPrice (money/bignumber gasPrice))
value (assoc :amount-text
(if (= :ETH symbol)
(str (money/internal->formatted value symbol (get all-tokens symbol)))
(str value)))
symbol (assoc :symbol symbol))))
gas (assoc :gas (money/bignumber gas))
gas-limit (assoc :gas (money/bignumber gas-limit))
gas-price (assoc :gasPrice (money/bignumber gas-price))
value (assoc :amount-text
(if (= :ETH sym)
(str (money/internal->formatted value sym (get all-tokens sym)))
(str value)))
sym (assoc :symbol sym))))
(rf/defn request-uri-parsed
{:events [:wallet/request-uri-parsed]}
+4 -4
View File
@@ -987,15 +987,15 @@
{::get-pending-transactions nil})
(defn normalize-transaction
[db {:keys [symbol gasPrice gasLimit value from to] :as transaction}]
(let [symbol (keyword symbol)
token (tokens/symbol->token (:wallet/all-tokens db) symbol)]
[db {:keys [gasPrice gasLimit value from to] :as transaction}]
(let [sym (-> transaction :symbol keyword)
token (tokens/symbol->token (:wallet/all-tokens db) sym)]
(-> transaction
(select-keys [:timestamp :hash :data])
(assoc :from (eip55/address->checksum from)
:to (eip55/address->checksum to)
:type :pending
:symbol symbol
:symbol sym
:token token
:value (money/bignumber value)
:gas-price (money/bignumber gasPrice)
+7 -5
View File
@@ -12,13 +12,15 @@
;; some sidechains have different names for this native currency, which we handle with `symbol-display`
;; override.
(defn display-symbol
[{:keys [symbol-display symbol]}]
(when-let [name (or symbol-display symbol)]
(clojure.core/name name)))
[m]
(when-let [some-symbol (or (:symbol-display m) (:symbol m))]
(name some-symbol)))
;;NOTE(goranjovic) - in addition to custom symbol display, some sidechain native currencies are listed
;;under a different
;; ticker on exchange networks. We handle that with `symbol-exchange` override.
(defn exchange-symbol
[{:keys [symbol-exchange symbol-display symbol]}]
(clojure.core/name (or symbol-exchange symbol-display symbol)))
[m]
(name (or (:symbol-exchange m)
(:symbol-display m)
(:symbol m))))
+1
View File
@@ -57,6 +57,7 @@
:community-banner (js/require "../resources/images/mock2/community-banner.png")
:community-logo (js/require "../resources/images/mock2/community-logo.png")
:community-cover (js/require "../resources/images/mock2/community-cover.png")
:dark-blur-bg (js/require "../resources/images/mock2/dark_blur_bg.png")
:decentraland (js/require "../resources/images/mock2/decentraland.png")
:gif (js/require "../resources/images/mock2/gif.png")
:monkey (js/require "../resources/images/mock2/monkey.png")
@@ -11,8 +11,8 @@
[utils.re-frame :as rf]))
(defn bounded-val
[val min-val max-val]
(max min-val (min val max-val)))
[v min-v max-v]
(max min-v (min v max-v)))
(defn update-height?
[content-size height max-height maximized?]
+13 -14
View File
@@ -69,16 +69,15 @@
(defn map-chats
[{:keys [db] :as cofx}]
(fn [val]
(let [chat (or (get (:chats db) (:chat-id val))
(create-new-chat (:chat-id val) cofx))]
(assoc
(merge
(cond-> chat
(comp not :muted) (dissoc chat :muted-till))
val)
:invitation-admin
(:invitation-admin val)))))
(fn [chat]
(let [base-chat (or (get (:chats db) (:chat-id chat))
(create-new-chat (:chat-id chat) cofx))]
(assoc (merge
(cond-> base-chat
(comp not :muted) (dissoc base-chat :muted-till))
chat)
:invitation-admin
(:invitation-admin chat)))))
(rf/defn leave-removed-chat
[{{:keys [view-id current-chat-id chats]} :db
@@ -180,8 +179,8 @@
(let [community-id (get-in db [:chats chat-id :community-id])]
;; When navigating back from community chat to community, update switcher card
;; A close chat event is also called while opening any chat.
;; That might lead to duplicate :dispatch keys in fx/merge, that's why dispatch-n is
;; used here.
;; That might lead to duplicate :dispatch keys in fx/merge, that's why dispatch-n
;; is used here.
(when (and community-id config/shell-navigation-disabled? (not navigate-to-shell?))
{:dispatch-n [[:shell/add-switcher-card
:community-overview community-id]]})))
@@ -251,8 +250,8 @@
{:events [:chat/decrease-unviewed-count]}
[{:keys [db]} chat-id {:keys [count countWithMentions]}]
{:db (-> db
;; There might be some other requests being fired,
;; so we need to make sure the count has not been set to
;; There might be some other requests being fired, so we need to make sure the count has
;; not been set to
;; 0 in the meantime
(update-in [:chats chat-id :unviewed-messages-count]
#(max (- % count) 0))
@@ -35,16 +35,10 @@
(defn list-key-fn [{:keys [message-id value]}] (or message-id value))
(defn list-ref [ref] (reset! messages-list-ref ref))
(defn scroll-to-offset
[position]
(some-> ^js @messages-list-ref
(.scrollToOffset #js
{:offset position
:animated true})))
(defn scroll-to-bottom
[]
(scroll-to-offset (- 0 style/messages-list-bottom-offset)))
(some-> ^js @messages-list-ref
(.scrollToIndex #js {:index 0 :viewPosition 1})))
(defn on-scroll
[evt]
@@ -126,13 +120,13 @@
loading-indicator-page-loading-height)]])))
(defn list-header
[insets]
[insets composer-height]
[rn/view
{:background-color (colors/theme-colors colors/white colors/neutral-95)
:margin-bottom (- 0
(:top insets)
(when platform/ios? style/overscroll-cover-height))
:height (+ composer.constants/composer-default-height
:height (+ composer-height
(:bottom insets)
spacing-between-composer-and-content
(when platform/ios? style/overscroll-cover-height))}])
@@ -283,13 +277,14 @@
context (rf/sub [:chats/current-chat-message-list-view-context])
messages (rf/sub [:chats/raw-chat-messages-stream (:chat-id chat)])
recording? (rf/sub [:chats/recording?])
all-loaded? (rf/sub [:chats/all-loaded? (:chat-id chat)])]
all-loaded? (rf/sub [:chats/all-loaded? (:chat-id chat)])
composer-height (rf/sub [:chats/composer-height])]
[rn/view {:style {:flex 1}}
[rn/flat-list
{:key-fn list-key-fn
:ref list-ref
:header [:<>
[list-header insets]
[list-header insets composer-height]
(when (= (:chat-type chat) constants/private-group-chat-type)
[list-group-chat-header chat])]
:footer [list-footer
@@ -308,9 +303,9 @@
;; which is needed because by default the chat is scrolled to the
;; bottom
;; and no initial `on-scroll` event is getting triggered
(let [scroll-y-shared (reanimated/get-shared-value scroll-y)
(let [scroll-y-shared (reanimated/get-shared-value scroll-y)
content-height-shared (reanimated/get-shared-value
content-height)]
content-height)]
(when (or (= scroll-y-shared 0)
(> (Math/abs (- content-height-shared y))
min-message-height))
@@ -322,7 +317,7 @@
(reanimated/set-shared-value content-height y))))
:on-end-reached #(list-on-end-reached scroll-y)
:on-scroll-to-index-failed identity
:scroll-indicator-insets {:top (- composer.constants/composer-default-height 16)}
:scroll-indicator-insets {:top (- composer-height 12)}
:keyboard-dismiss-mode :interactive
:keyboard-should-persist-taps :always
:on-scroll-begin-drag rn/dismiss-keyboard!
@@ -334,13 +329,13 @@
(when on-scroll
(on-scroll event)))
:style (add-inverted-y-android
{:background-color (if all-loaded?
(colors/theme-colors
(colors/custom-color cover-bg-color 50 20)
(colors/custom-color cover-bg-color 50 40))
(colors/theme-colors
colors/white
colors/neutral-95))})
{:background-color (if all-loaded?
(colors/theme-colors
(colors/custom-color cover-bg-color 50 20)
(colors/custom-color cover-bg-color 50 40))
(colors/theme-colors
colors/white
colors/neutral-95))})
;;TODO(rasom) https://github.com/facebook/react-native/issues/30034
:inverted (when platform/ios? true)
:on-layout (fn [e]
@@ -351,8 +346,8 @@
(defn message-list-content-view
[props]
(let [chat-screen-loaded? (rf/sub [:shell/chat-screen-loaded?])
window-height (:height (rn/get-window))
content-height (- window-height composer.constants/composer-default-height)]
window-height (:height (rn/get-window))
content-height (- window-height composer.constants/composer-default-height)]
(if chat-screen-loaded?
[:f> f-messages-list-content props]
[rn/view {:style {:flex 1}}
@@ -362,20 +357,20 @@
(defn f-messages-list
[{:keys [chat cover-bg-color header-comp footer-comp]}]
(let [insets (safe-area/get-insets)
scroll-y (reanimated/use-shared-value 0)
content-height (reanimated/use-shared-value 0)
(let [insets (safe-area/get-insets)
scroll-y (reanimated/use-shared-value 0)
content-height (reanimated/use-shared-value 0)
{:keys [keyboard-height keyboard-shown]} (hooks/use-keyboard)]
(rn/use-effect
(fn []
(if keyboard-shown
(reanimated/set-shared-value scroll-y
(+ (reanimated/get-shared-value scroll-y)
keyboard-height))
(reanimated/set-shared-value scroll-y
(- (reanimated/get-shared-value scroll-y)
keyboard-height))))
[keyboard-shown keyboard-height])
(fn []
(if keyboard-shown
(reanimated/set-shared-value scroll-y
(+ (reanimated/get-shared-value scroll-y)
keyboard-height))
(reanimated/set-shared-value scroll-y
(- (reanimated/get-shared-value scroll-y)
keyboard-height))))
[keyboard-shown keyboard-height])
;; Note - Don't pass `behavior :height` to keyboard avoiding view,
;; It breaks composer - https://github.com/status-im/status-mobile/issues/16595
[rn/keyboard-avoiding-view
@@ -16,23 +16,24 @@
:background-color (colors/theme-colors colors/white-opa-40 colors/neutral-80-opa-40)}
position))
(def background-view
(defn background-view
[theme]
{:position :absolute
:top 0
:left 0
:right 0
:height navigation-bar-height
:background-color (colors/theme-colors colors/white-opa-70 :transparent)
:background-color (colors/theme-colors colors/white-opa-70 colors/neutral-100-opa-70 theme)
:display :flex
:flex-direction :row
:overflow :hidden})
(defn animated-background-view
[enabled? animation]
[enabled? animation theme]
(reanimated/apply-animations-to-style
(when enabled?
{:opacity animation})
background-view))
(background-view theme)))
(def blur-view
{:position :absolute
@@ -1,6 +1,7 @@
(ns status-im2.contexts.chat.messages.navigation.view
(:require [quo2.core :as quo]
[quo2.foundations.colors :as colors]
[quo2.theme :as theme]
[re-frame.db]
[react-native.blur :as blur]
[react-native.core :as rn]
@@ -14,7 +15,7 @@
[utils.i18n :as i18n]
[status-im2.common.home.actions.view :as actions]))
(defn f-navigation-view
(defn f-view
[{:keys [scroll-y]}]
(let [{:keys [group-chat chat-id chat-name emoji
chat-type]
@@ -55,7 +56,7 @@
:extrapolateRight "clamp"})]
[rn/view {:style style/navigation-view}
[reanimated/view
{:style (style/animated-background-view all-loaded? opacity-animation)}]
{:style (style/animated-background-view all-loaded? opacity-animation nil)}]
[reanimated/view {:style (style/animated-blur-view all-loaded? opacity-animation)}
[blur/view
@@ -114,3 +115,9 @@
:opacity-animation banner-opacity-animation
:all-loaded? all-loaded?
:top-offset style/navigation-bar-height}]]))
(defn- internal-navigation-view
[params]
[:f> f-view params])
(def navigation-view (theme/with-theme internal-navigation-view))
@@ -17,9 +17,7 @@
{:cover-bg-color :turquoise
:chat chat
:header-comp (fn [{:keys [scroll-y]}]
[:f>
messages.navigation/f-navigation-view
{:scroll-y scroll-y}])
[messages.navigation/navigation-view {:scroll-y scroll-y}])
:footer-comp (fn [{:keys [insets]}]
(if-not able-to-send-message?
[contact-requests.bottom-drawer/view chat-id contact-request-state
@@ -80,6 +80,7 @@
[status-im2.contexts.quo-preview.settings.settings-list :as settings-list]
[status-im2.contexts.quo-preview.settings.privacy-option :as privacy-option]
[status-im2.contexts.quo-preview.settings.reorder-item :as reorder-item]
[status-im2.contexts.quo-preview.settings.category :as category]
[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]
@@ -97,7 +98,6 @@
[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.settings.category :as category]
[status-im2.contexts.quo-preview.keycard.keycard :as keycard]
[status-im2.contexts.quo-preview.loaders.skeleton :as skeleton]
[status-im2.contexts.quo-preview.community.channel-actions :as channel-actions]))
@@ -6,60 +6,91 @@
[react-native.core :as rn]
[react-native.fast-image :as fast-image]
[reagent.core :as reagent]
[status-im2.common.resources :as resources]
[status-im2.contexts.quo-preview.preview :as preview]))
(def item
{:title "Item 1"
:left-icon :i/browser
:chevron? true})
(defn create-item-array
[n {:keys [right-icon? image? subtitle?]}]
(vec (for [i (range n)]
{:title (str "Item " i)
:subtitle (when subtitle? "subtitle")
:chevron? true
:right-icon (when right-icon? :i/globe)
:left-icon :i/browser
:image-size (if image? 32 0)
:image (when image? (resources/get-mock-image :diamond))})))
(def descriptor
[{:label "Category label:"
:key :label
:type :text}
{:label "Category size:"
:key :size
:type :text}
(def reorder-descriptor
[{:label "Right icon:"
:key :right-icon?
:type :boolean}
{:label "Image:"
:key :image?
:type :boolean}
{:label "Subtitle:"
:key :subtitle?
:type :boolean}
{:label "Blur:"
:key :blur?
:type :boolean}])
:type :boolean}
{:label "List type:"
:key :list-type
:type :select
:options [{:key :settings :value :settings} {:key :reorder :value :reorder}]}])
(def image-uri
"https://4kwallpapers.com/images/wallpapers/giau-pass-mountain-pass-italy-dolomites-landscape-mountain-750x1334-4282.jpg")
(def label "Label")
(def settings-descriptor
[{:label "Blur:"
:key :blur?
:type :boolean}
{:label "List type:"
:key :list-type
:type :select
:options [{:key :settings :value :settings} {:key :reorder :value :reorder}]}])
(defn preview
[]
(let [state (reagent/atom {:label "Label"
:size "5"
:blur? false})
(let [state (reagent/atom {:label "Label"
:size "5"
:blur? false
:right-icon? true
:image? true
:subtitle? true
:list-type :settings})
{:keys [width height]} (rn/get-window)]
[:f>
(fn []
(let [data (repeat (js/parseInt (:size @state)) item)]
(rn/use-effect (fn []
(if (:blur? @state)
(theme/set-theme :dark)
(theme/set-theme :light)))
[(:blur? @state)])
[rn/touchable-without-feedback {:on-press rn/dismiss-keyboard!}
[rn/view
{:style {:flex 1
:padding-bottom 150
:margin-bottom 50
:background-color (colors/theme-colors colors/neutral-5 colors/neutral-95)}}
[rn/view
{:style {:min-height 180
:z-index 1}} [preview/customizer state descriptor]]
(when (:blur? @state)
[fast-image/fast-image
{:source {:uri image-uri}
:style {:width width
:height height
:position :absolute}}])
[rn/view
{:style {:background-color (if (:blur? @state)
colors/neutral-80-opa-80
(colors/theme-colors colors/neutral-5 colors/neutral-95))}}
[quo/category {:label (:label @state) :data data :blur? (:blur? @state)}]]]]))]))
(fn []
(let [data (reagent/atom (create-item-array (max (js/parseInt (:size @state)) 1) @state))]
[:f>
(fn []
(rn/use-effect (fn []
(if (:blur? @state)
(theme/set-theme :dark)
(theme/set-theme :light))
(reset! data (create-item-array (max (js/parseInt (:size @state)) 1)
@state)))
[(:blur? @state) (:right-icon? @state) (:image? @state) (:subtitle? @state)])
[rn/touchable-without-feedback {:on-press rn/dismiss-keyboard!}
[rn/view
{:style {:flex 1
:padding-bottom 150
:margin-bottom 50
:background-color (colors/theme-colors colors/neutral-5 colors/neutral-95)}}
[rn/view
{:style {:min-height 200
:z-index 1}}
[preview/customizer state
(if (= (:list-type @state) :settings) settings-descriptor reorder-descriptor)]]
(when (:blur? @state)
[fast-image/fast-image
{:source (resources/get-mock-image :dark-blur-bg)
:style {:width width
:height height
:position :absolute}}])
[rn/view
{:style {:background-color (if (:blur? @state)
colors/neutral-80-opa-80
(colors/theme-colors colors/neutral-5 colors/neutral-95))}}
[quo/category
{:list-type (:list-type @state)
:label (:label @state)
:data @data
:blur? (:blur? @state)}]]]])]))))
@@ -10,7 +10,7 @@
[utils.datetime :as datetime]
[utils.i18n :as i18n]
[utils.re-frame :as rf]
[status-im2.contexts.chat.messages.content.image.view :as image]))
[status-im.utils.http :as http]))
;; NOTE: Replies support text, image and stickers only.
(defn- get-message-content
@@ -19,7 +19,11 @@
constants/content-type-text [quo/text {:style style/tag-text}
(get-in message [:content :text])]
constants/content-type-image [image/image-message 0 message nil]
constants/content-type-image
(let [image (get-in message [:content :image])
image-local-url (http/replace-port image (rf/sub [:mediaserver/port]))
photos (when image-local-url [{:uri image-local-url}])]
[quo/activity-logs-photos {:photos photos}])
constants/content-type-sticker [old-message/sticker message]
@@ -72,4 +76,19 @@
[quo/context-tag common/tag-params community-image community-name chat-name]
[quo/group-avatar-tag chat-name common/tag-params])]
:message {:body-number-of-lines 1
:attachment (cond
(= (:content-type message) constants/content-type-text)
:text
(= (:content-type message) constants/content-type-image)
:photo
(= (:content-type message) constants/content-type-sticker)
:sticker
(= (:content-type message) constants/content-type-gif)
:gif
:else
nil)
:body (get-message-content message)}}]]]))
@@ -77,29 +77,37 @@
:top (- (+ (:y viewfinder) (:height viewfinder)) flash-button-size flash-button-spacing)
:right (+ screen-padding flash-button-spacing)})
(defn border
[border1 border2 corner]
(assoc {:border-color colors/white
:width 78
:height 78}
border1
2
border2
2
corner
16))
(defn- get-border
[border-vertical-width border-horizontal-width corner-radius]
{:border-color colors/white
:width 78
:height 78
border-vertical-width 2
border-horizontal-width 2
corner-radius 16})
(defn border-tip
[top bottom right left]
{:background-color colors/white
:position :absolute
:top top
:bottom bottom
:right right
:left left
:height 2
:width 2
:border-radius 2})
(def white-border
(let [base-tip {:background-color colors/white
:position :absolute
:height 1.9 ; 1.9 instead of 2 to fix the tips protruding
:width 1.9
:border-radius 1}]
{:top-left
{:border (get-border :border-top-width :border-left-width :border-top-left-radius)
:tip-1 (assoc base-tip :right -1 :top 0)
:tip-2 (assoc base-tip :left 0 :bottom -1)}
:top-right
{:border (get-border :border-top-width :border-right-width :border-top-right-radius)
:tip-1 (assoc base-tip :right 0 :bottom -1)
:tip-2 (assoc base-tip :left -1 :top 0)}
:bottom-left
{:border (get-border :border-bottom-width :border-left-width :border-bottom-left-radius)
:tip-1 (assoc base-tip :right -1 :bottom 0)
:tip-2 (assoc base-tip :left 0 :top -1)}
:bottom-right
{:border (get-border :border-bottom-width :border-right-width :border-bottom-right-radius)
:tip-1 (assoc base-tip :right 0 :top -1)
:tip-2 (assoc base-tip :left -1 :bottom 0)}}))
(def viewfinder-text
{:color colors/white-opa-70
@@ -36,7 +36,7 @@
[]
(rf/dispatch [:syncing/preflight-outbound-check #(reset! preflight-check-passed? %)]))
(defn- f-header
(defn- header
[{:keys [active-tab read-qr-once? title title-opacity subtitle-opacity reset-animations-fn animated?]}]
(let [subtitle-translate-x (reanimated/interpolate subtitle-opacity [0 1] [-13 0])
subtitle-translate-y (reanimated/interpolate subtitle-opacity [0 1] [-85 0])
@@ -110,10 +110,6 @@
(reset! active-tab id)
(reset! read-qr-once? false))}]]]))
(defn- header
[props]
[:f> f-header props])
(defn get-labels-and-on-press-method
[]
(if @camera-permission-granted?
@@ -169,55 +165,42 @@
view-finder (assoc layout :height (:width layout))]
(reset! qr-view-finder view-finder)))}])
(defn- border
[border1 border2 corner]
[rn/view {:style (style/border border1 border2 corner)}])
(defn- white-border
[corner]
(let [border-styles (style/white-border corner)]
[rn/view
[rn/view {:style (border-styles :border)}]
[rn/view {:style (border-styles :tip-1)}]
[rn/view {:style (border-styles :tip-2)}]]))
(defn- border-tip
[{:keys [top bottom left right]}]
[rn/view
{:style (style/border-tip top bottom right left)}])
(defn- white-square
[layout-size]
[rn/view {:style (style/qr-view-finder-container layout-size)}
[rn/view {:style style/view-finder-border-container}
[white-border :top-left]
[white-border :top-right]]
[rn/view {:style style/view-finder-border-container}
[white-border :bottom-left]
[white-border :bottom-right]]])
(defn- viewfinder
[qr-view-finder]
(let [size (+ (:width qr-view-finder) 2)]
[:<>
[rn/view {:style (style/viewfinder-container qr-view-finder)}
[rn/view
{:style (style/qr-view-finder-container size)}
[rn/view
{:style style/view-finder-border-container}
[rn/view
[border :border-top-width :border-left-width :border-top-left-radius]
[border-tip {:right -1 :top 0}]
[border-tip {:left 0 :bottom -1}]]
[rn/view
[border :border-top-width :border-right-width :border-top-right-radius]
[border-tip {:right 0 :bottom -1}]
[border-tip {:left -1 :top 0}]]]
[rn/view {:flex-direction :row :justify-content :space-between}
[rn/view
[border :border-bottom-width :border-left-width :border-bottom-left-radius]
[border-tip {:right -1 :bottom 0}]
[border-tip {:left 0 :top -1}]]
[rn/view
[border :border-bottom-width :border-right-width :border-bottom-right-radius]
[border-tip {:right 0 :top -1}]
[border-tip {:left -1 :bottom 0}]]]]
[quo/text
{:size :paragraph-2
:weight :regular
:style style/viewfinder-text}
(i18n/label :t/ensure-qr-code-is-in-focus-to-scan)]]]))
(let [layout-size (+ (:width qr-view-finder) 2)]
[rn/view {:style (style/viewfinder-container qr-view-finder)}
[white-square layout-size]
[quo/text
{:size :paragraph-2
:weight :regular
:style style/viewfinder-text}
(i18n/label :t/ensure-qr-code-is-in-focus-to-scan)]]))
(defn- scan-qr-code-tab
[qr-view-finder]
[:<>
(if (and @preflight-check-passed?
@camera-permission-granted?
(boolean (not-empty @qr-view-finder)))
[viewfinder @qr-view-finder]
[camera-and-local-network-access-permission-view])])
(if (and @preflight-check-passed?
@camera-permission-granted?
(boolean (not-empty qr-view-finder)))
[viewfinder qr-view-finder]
[camera-and-local-network-access-permission-view]))
(defn- enter-sync-code-tab
[]
@@ -273,8 +256,7 @@
:on-read-code on-read-code}]]
[hole-view/hole-view
{:style style/hole
:holes [(merge qr-view-finder
{:borderRadius 16})]}
:holes [(assoc qr-view-finder :borderRadius 16)]}
[blur/view
{:style style/absolute-fill
:blur-amount 10
@@ -388,7 +370,7 @@
(when (or (not animated?) @render-camera?)
[render-camera show-camera? torch-mode @qr-view-finder camera-ref on-read-code])
[rn/view {:style (style/root-container (:top insets))}
[header
[:f> header
{:active-tab active-tab
:read-qr-once? read-qr-once?
:title title
@@ -406,7 +388,7 @@
:transform [{:translate-y content-translate-y}]}
{})}
(case @active-tab
1 [scan-qr-code-tab qr-view-finder]
1 [scan-qr-code-tab @qr-view-finder]
2 [enter-sync-code-tab]
nil)]
[rn/view {:style style/flex-spacer}]
+2 -2
View File
@@ -145,9 +145,9 @@
:chats/composer-height
:<- [:chats/current-chat-input]
:<- [:chats/link-previews-unfurled]
(fn [[{:keys [input-content-height metadata]} link-previews]]
(fn [[{:keys [input-content-height metadata focused?]} link-previews]]
(let [{:keys [responding-to-message editing-message sending-image]} metadata]
(+ (max composer.constants/input-height input-content-height)
(+ composer.constants/input-height
(when responding-to-message
composer.constants/reply-container-height)
(when editing-message
+16 -16
View File
@@ -56,14 +56,15 @@
members (re-frame/subscribe [:communities/community-members community-id])]
[contacts multiaccount members]))
(fn [[contacts multiaccount members] _]
(let [names (reduce (fn [acc identity]
(let [me? (= (:public-key multiaccount) identity)
(let [names (reduce (fn [acc contact-identity]
(let [me? (= (:public-key multiaccount) contact-identity)
contact (when-not me?
(multiaccounts/contact-by-identity contacts identity))
name (first (multiaccounts/contact-two-names-by-identity contact
multiaccount
identity))]
(assoc acc identity name)))
(multiaccounts/contact-by-identity contacts contact-identity))
name (first (multiaccounts/contact-two-names-by-identity
contact
multiaccount
contact-identity))]
(assoc acc contact-identity name)))
{}
(keys members))]
(->> members
@@ -95,10 +96,9 @@
:<- [:view-id]
:<- [:communities]
:<- [:communities/my-pending-requests-to-join]
;; Return communities splitted by level of user participation. Some communities user
;; already joined, to some of them join request sent and others were opened one day
;; and their data remained in app-db.
;; Result map has form: {:joined [id1, id2] :pending [id3, id5] :opened [id4]}"
;; Return communities splitted by level of user participation. Some communities user already
;; joined, to some of them join request sent and others were opened one day and their data remained
;; in app-db. Result map has form: {:joined [id1, id2] :pending [id3, id5] :opened [id4]}"
(fn [[view-id communities requests]]
(if (or (empty? @memo-communities-stack-items) (= view-id :communities-stack))
(let [grouped-communities (reduce (fn [acc community]
@@ -128,9 +128,9 @@
(fn [[_ community-id]]
[(re-frame/subscribe [:communities])
(re-frame/subscribe [:communities/unviewed-counts community-id])])
(fn [[communities counts] [_ identity]]
(fn [[communities counts] [_ community-identity]]
(community->home-item
(get communities identity)
(get communities community-identity)
counts)))
(re-frame/reg-sub
@@ -288,12 +288,12 @@
(let [check-criteria (get-in token-permissions-check
[:permissions perm-key :criteria])]
(map
(fn [{:keys [symbol amount]} sufficient?]
{:symbol symbol
(fn [{sym :symbol amount :amount} sufficient?]
{:symbol sym
:sufficient? (when (seq check-criteria) sufficient?)
:loading? checking-permissions?
:amount amount
:img-src (get token-images symbol)})
:img-src (get token-images sym)})
token_criteria
(or check-criteria token_criteria))))
token-permissions)}))
+30 -32
View File
@@ -32,16 +32,16 @@
(get multiaccount :profile-pictures-visibility)))
(defn- replace-contact-image-uri
[contact port identity]
[contact port contact-identity]
(let [theme (theme/get-theme)
contact-images (:images contact)
contact-images (reduce (fn [acc image]
(let [image-name (:type image)
; We pass the clock so that we reload the image if the image is
; updated
; We pass the clock so that we reload the image if the image
; is updated
clock (:clock image)
uri (image-server/get-contact-image-uri port
identity
contact-identity
image-name
clock
theme)]
@@ -175,10 +175,10 @@
contacts)))))
(defn- enrich-contact
[_ identity ens-name port]
[_ contact-identity ens-name port]
(let [contact (contact.db/enrich-contact
(contact.db/public-key-and-ens-name->new-contact identity ens-name))]
(replace-contact-image-uri contact port identity)))
(contact.db/public-key-and-ens-name->new-contact contact-identity ens-name))]
(replace-contact-image-uri contact port contact-identity)))
(re-frame/reg-sub
:contacts/current-contact
@@ -186,46 +186,46 @@
:<- [:contacts/current-contact-identity]
:<- [:contacts/current-contact-ens-name]
:<- [:mediaserver/port]
(fn [[contacts identity ens-name port]]
(let [contact (get contacts identity)]
(fn [[contacts contact-identity ens-name port]]
(let [contact (get contacts contact-identity)]
(cond-> contact
(nil? contact)
(enrich-contact identity ens-name port)))))
(enrich-contact contact-identity ens-name port)))))
(re-frame/reg-sub
:contacts/contact-by-identity
:<- [:contacts/contacts]
(fn [contacts [_ identity]]
(multiaccounts/contact-by-identity contacts identity)))
(fn [contacts [_ contact-identity]]
(multiaccounts/contact-by-identity contacts contact-identity)))
(re-frame/reg-sub
:contacts/contact-added?
(fn [[_ identity] _]
[(re-frame/subscribe [:contacts/contact-by-identity identity])])
(fn [[_ contact-identity] _]
[(re-frame/subscribe [:contacts/contact-by-identity contact-identity])])
(fn [[contact] _]
(:added? contact)))
(re-frame/reg-sub
:contacts/contact-blocked?
(fn [[_ identity] _]
[(re-frame/subscribe [:contacts/contact-by-identity identity])])
(fn [[_ contact-identity] _]
[(re-frame/subscribe [:contacts/contact-by-identity contact-identity])])
(fn [[contact] _]
(:blocked contact)))
(re-frame/reg-sub
:contacts/contact-two-names-by-identity
(fn [[_ identity] _]
[(re-frame/subscribe [:contacts/contact-by-identity identity])
(fn [[_ contact-identity] _]
[(re-frame/subscribe [:contacts/contact-by-identity contact-identity])
(re-frame/subscribe [:profile/profile])])
(fn [[contact current-multiaccount] [_ identity]]
(fn [[contact current-multiaccount] [_ contact-identity]]
(multiaccounts/contact-two-names-by-identity contact
current-multiaccount
identity)))
contact-identity)))
(re-frame/reg-sub
:contacts/contact-name-by-identity
(fn [[_ identity] _]
[(re-frame/subscribe [:contacts/contact-two-names-by-identity identity])])
(fn [[_ contact-identity] _]
[(re-frame/subscribe [:contacts/contact-two-names-by-identity contact-identity])])
(fn [[names] _]
(first names)))
@@ -236,21 +236,21 @@
:<- [:profile/profile]
(fn [[messages contacts current-multiaccount] [_ message-id]]
(when-let [message (get messages message-id)]
(let [identity (:from message)
me? (= (:public-key current-multiaccount) identity)]
(let [from-identity (:from message)
me? (= (:public-key current-multiaccount) from-identity)]
(if me?
{:quote {:from identity
{:quote {:from from-identity
:text (get-in message [:content :text])}
:ens-name (:preferred-name current-multiaccount)
:alias (gfycat/generate-gfy identity)}
(let [contact (or (contacts identity)
(contact.db/public-key->new-contact identity))]
{:quote {:from identity
:alias (gfycat/generate-gfy from-identity)}
(let [contact (or (contacts from-identity)
(contact.db/public-key->new-contact from-identity))]
{:quote {:from from-identity
:text (get-in message [:content :text])}
:ens-name (when (:ens-verified contact)
(:name contact))
:alias (or (:alias contact)
(gfycat/generate-gfy identity))}))))))
(gfycat/generate-gfy from-identity))}))))))
(re-frame/reg-sub
:contacts/all-contacts-not-in-current-chat
@@ -323,5 +323,3 @@
(seq admins) (assoc :owner {:title (i18n/label :t/owner) :data admins})
(seq online) (assoc :online {:title (i18n/label :t/online) :data online})
(seq offline) (assoc :offline {:title (i18n/label :t/offline) :data offline}))))))
+1 -2
View File
@@ -52,8 +52,7 @@
(defn extract-token-attributes
[token]
(let [{:keys [symbol name]} token]
[symbol name]))
[(:symbol token) (:name token)])
(re-frame/reg-sub
:wallet/filtered-grouped-chain-tokens
+18 -16
View File
@@ -54,10 +54,10 @@
:<- [:prices]
:<- [:wallet/currency]
:<- [:ethereum/native-currency]
(fn [[prices {:keys [code]} {:keys [symbol]}]]
[(name symbol)
(fn [[prices {:keys [code]} {sym :symbol}]]
[(name sym)
code
(get-in prices [symbol (keyword code)])]))
(get-in prices [sym (keyword code)])]))
(re-frame/reg-sub
:signing/priority-fee-suggestions-range
@@ -131,8 +131,8 @@
:else nil))))
(defn get-sufficient-funds-error
[balance symbol amount]
(when-not (money/sufficient-funds? amount (get balance symbol))
[balance sym amount]
(when-not (money/sufficient-funds? amount (get balance sym))
{:amount-error (i18n/label :t/wallet-insufficient-funds)}))
(defn gas-required-exceeds-allowance?
@@ -143,11 +143,11 @@
"gas required exceeds allowance")))
(defn get-sufficient-gas-error
[gas-error-message balance symbol amount ^js gas ^js gasPrice]
[gas-error-message balance sym amount ^js gas ^js gasPrice]
(if (and gas gasPrice)
(let [^js fee (.times gas gasPrice)
^js available-ether (money/bignumber (get balance :ETH 0))
^js available-for-gas (if (= :ETH symbol)
^js available-for-gas (if (= :ETH sym)
(.minus available-ether (money/bignumber amount))
available-ether)]
(merge {:gas-error-state (when gas-error-message :gas-is-set)}
@@ -186,17 +186,18 @@
:<- [:offline?]
:<- [:wallet/all-tokens]
:<- [:current-network]
(fn [[{:keys [symbol from to amount-text] :as transaction}
(fn [[{:keys [from to amount-text] :as transaction}
wallet offline? all-tokens current-network]]
(let [balance (get-in wallet [:accounts (:address from) :balance])
{:keys [decimals] :as token} (tokens/asset-for all-tokens current-network symbol)
(let [sym (:symbol transaction)
balance (get-in wallet [:accounts (:address from) :balance])
{:keys [decimals] :as token} (tokens/asset-for all-tokens current-network sym)
{:keys [value error]} (wallet.db/parse-amount amount-text decimals)
amount (money/formatted->internal value symbol decimals)
amount (money/formatted->internal value sym decimals)
{:keys [amount-error] :as transaction-new}
(merge transaction
{:amount-error error}
(when amount
(get-sufficient-funds-error balance symbol amount)))]
(get-sufficient-funds-error balance sym amount)))]
(assoc transaction-new
:amount amount
:balance balance
@@ -213,12 +214,13 @@
:<- [:offline?]
:<- [:wallet/all-tokens]
:<- [:current-network]
(fn [[{:keys [symbol from to amount-text] :as transaction}
(fn [[{:keys [from to amount-text] :as transaction}
wallet offline? all-tokens current-network]]
(let [balance (get-in wallet [:accounts (:address from) :balance])
{:keys [decimals] :as token} (tokens/asset-for all-tokens current-network symbol)
(let [sym (:symbol transaction)
balance (get-in wallet [:accounts (:address from) :balance])
{:keys [decimals] :as token} (tokens/asset-for all-tokens current-network sym)
{:keys [value error]} (wallet.db/parse-amount amount-text decimals)
amount (money/formatted->internal value symbol decimals)
amount (money/formatted->internal value sym decimals)
{:keys [amount-error] :as transaction-new}
(assoc transaction :amount-error error)]
(assoc transaction-new
+2 -2
View File
@@ -44,14 +44,14 @@
[to :to-contact :from-wallet])
wallet (i18n/label :main-wallet)
contact (get contacts contact-address)
{:keys [symbol-display symbol decimals] :as asset}
{:keys [symbol-display decimals] :as asset}
(or token native-currency)
amount-text (if value
(wallet.utils/format-amount value decimals)
"...")
currency-text (when asset
(clojure.core/name (or symbol-display
symbol)))]
(:symbol asset))))]
(cond-> transaction
contact (assoc key-contact (:name contact))
:always (assoc key-wallet
+8 -7
View File
@@ -61,10 +61,10 @@
(defn get-balance-total-value
[balance prices currency token->decimals]
(reduce-kv (fn [acc symbol value]
(if-let [price (get-in prices [symbol currency])]
(reduce-kv (fn [acc sym value]
(if-let [price (get-in prices [sym currency])]
(+ acc
(or (some-> (money/internal->formatted value symbol (token->decimals symbol))
(or (some-> (money/internal->formatted value sym (token->decimals sym))
^js (money/crypto->fiat price)
.toNumber)
0))
@@ -193,13 +193,14 @@
(defn update-value
[prices currency]
(fn [{:keys [symbol decimals amount] :as token}]
(let [currency-kw (-> currency :code keyword)
price (get-in prices [symbol currency-kw])]
(fn [{:keys [decimals amount] :as token}]
(let [sym (:symbol token)
currency-kw (-> currency :code keyword)
price (get-in prices [sym currency-kw])]
(assoc token
:price price
:value (when (and amount price)
(-> (money/internal->formatted amount symbol decimals)
(-> (money/internal->formatted amount sym decimals)
(money/crypto->fiat price)
(money/with-precision 2)
str
+4 -4
View File
@@ -155,14 +155,14 @@
;; to get the amount scale right.
(defn formatted->internal
[n symbol decimals]
(if (= :ETH symbol)
[n sym decimals]
(if (= :ETH sym)
(ether->wei n)
(unit->token n decimals)))
(defn internal->formatted
[n symbol decimals]
(if (= :ETH symbol)
[n sym decimals]
(if (= :ETH sym)
(wei->ether n)
(token->unit n decimals)))
+2 -2
View File
@@ -39,8 +39,8 @@
(def ^:private mergeable-keys (atom nil))
(defn set-mergeable-keys
[val]
(reset! mergeable-keys val))
[v]
(reset! mergeable-keys v))
(defn- safe-merge
[fx new-fx]
+2
View File
@@ -76,6 +76,8 @@ jest.mock('react-native-blob-util', () => ({
},
}));
jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock'));
NativeModules.ReactLocalization = {
language: 'en',
locale: 'en',
+6 -4
View File
@@ -8813,10 +8813,12 @@ react-native-dialogs@^1.0.4:
resolved "https://registry.yarnpkg.com/react-native-dialogs/-/react-native-dialogs-1.1.0.tgz#8f7ee7f9d96574fc878fb7c1be101611fb4af517"
integrity sha512-clnxO0nMyML/6+G5dja3Yt34gPxegLY2OHTwb8BwYTEvQ2UhRKR49Uq91XqU0q6g7Ur9DiYxC0tqV3rcZWUrjQ==
react-native-draggable-flatlist@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/react-native-draggable-flatlist/-/react-native-draggable-flatlist-3.0.3.tgz#e85503585253be01ad251f78d5b341ac22f9d952"
integrity sha512-bDro6aqQMvvTm/CuHre9dAjSBKosAfZRLDx3nmrjOz799kxcn0bq+uCB6yF6m+g1Xd/gVPl7E3Ss4uX+oPUlHg==
react-native-draggable-flatlist@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/react-native-draggable-flatlist/-/react-native-draggable-flatlist-4.0.1.tgz#2f027d387ba4b8f3eb0907340e32cb85e6460df2"
integrity sha512-ZO1QUTNx64KZfXGXeXcBfql67l38X7kBcJ3rxUVZzPHt5r035GnGzIC0F8rqSXp6zgnwgUYMfB6zQc5PKmPL9Q==
dependencies:
"@babel/preset-typescript" "^7.17.12"
react-native-fast-image@^8.5.11:
version "8.5.11"