Skip to content

Commit

Permalink
Merge branch 'develop' into slideshow
Browse files Browse the repository at this point in the history
  • Loading branch information
Pau1fitz authored Jan 17, 2024
2 parents 17a90a9 + 72bf8a8 commit 97d6af0
Show file tree
Hide file tree
Showing 21 changed files with 194 additions and 181 deletions.
3 changes: 2 additions & 1 deletion src/status_im/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@
(def regx-community-universal-link #"((^https?://status.app/)|(^status-app://))c/([\x00-\x7F]+)$")
(def regx-deep-link #"((^ethereum:.*)|(^status-app://[\x00-\x7F]+$))")
(def regx-ens #"^(?=.{5,255}$)([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$")
(def regx-address #"^0x[a-fA-F0-9]{40}$")
(def regx-multichain-address #"^(?:(?:eth:|arb1:|opt:)(?=:|))*0x[0-9a-fA-F]{40}$")

(def regx-address-contains #"(?i)0x[a-fA-F0-9]{40}")
(def regx-starts-with-uuid #"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")
(def regx-full-or-partial-address #"^0x[a-fA-F0-9]{1,40}$")
Expand Down
22 changes: 14 additions & 8 deletions src/status_im/contexts/chat/messenger/composer/effects.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@
(defn reenter-screen-effect
[{:keys [text-value saved-cursor-position maximized?]}
{:keys [content-height]}
{:keys [input-content-height input-text input-maximized?]}]
(when (and (empty? @text-value) (not= input-text nil))
(reset! text-value input-text)
(reset! content-height input-content-height)
(reset! saved-cursor-position (count input-text)))
(when input-maximized?
(reset! maximized? true)))
{:keys [input-content-height input-text input-maximized?]}
{:keys [height]}]
(let [lines (utils/calc-lines input-content-height)
minimized-height (if (or (= lines 1) (empty? input-text))
constants/input-height
constants/multiline-minimized-height)]
(when (and (empty? @text-value) (not= input-text nil))
(reset! text-value input-text)
(reset! content-height input-content-height)
(reset! saved-cursor-position (count input-text))
(reanimated/set-shared-value height minimized-height))
(when input-maximized?
(reset! maximized? true))))

(defn maximized-effect
[{:keys [maximized?]}
Expand Down Expand Up @@ -101,7 +107,7 @@
[max-height])
(rn/use-effect
(fn []
(reenter-screen-effect state dimensions subscriptions))
(reenter-screen-effect state dimensions subscriptions animations))
[max-height subscriptions]))

(defn use-edit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
:position :absolute
:bottom 0
:left 0
:right 0
:z-index 2})
:right 0})

(defn bottom-gradient
[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
(when show-bottom-gradient?
[rn/pressable
{:on-press #(when @input-ref (.focus ^js @input-ref))
:style {:z-index 1}
:accessibility-label :bottom-gradient}
[linear-gradient/linear-gradient (style/bottom-gradient)]])]))

Expand Down
10 changes: 6 additions & 4 deletions src/status_im/contexts/chat/messenger/composer/handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@
(defn focus
"Animate to the `saved-height`, display background-overlay if needed, and set cursor position"
[{:keys [input-ref] :as props}
{:keys [text-value focused? lock-selection? saved-cursor-position composer-focused?]}
{:keys [text-value focused? lock-selection? saved-cursor-position composer-focused? maximized?]}
{:keys [height saved-height last-height opacity background-y container-opacity]
:as animations}
{:keys [max-height] :as dimensions}]
(reanimated/set-shared-value composer-focused? true)
(reset! focused? true)
(rf/dispatch [:chat.ui/set-input-focused true])
(let [last-height-value (reanimated/get-shared-value last-height)]
(reanimated/animate height last-height-value)
(reanimated/set-shared-value saved-height last-height-value)
(let [last-height-value (reanimated/get-shared-value last-height)
new-height (min max-height last-height-value)]
(reanimated/animate height new-height)
(reanimated/set-shared-value saved-height new-height)
(reanimated/animate container-opacity 1)
(when (> last-height-value (* constants/background-threshold max-height))
(reset! maximized? true)
(reanimated/animate opacity 1)
(reanimated/set-shared-value background-y 0)))

Expand Down
25 changes: 9 additions & 16 deletions src/status_im/contexts/wallet/account/tabs/about/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
[quo.core :as quo]
[react-native.clipboard :as clipboard]
[react-native.core :as rn]
[react-native.platform :as platform]
[react-native.share :as share]
[status-im.config :as config]
[status-im.contexts.profile.utils :as profile.utils]
[status-im.contexts.wallet.account.tabs.about.style :as style]
[status-im.contexts.wallet.common.utils :as utils]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

(defn about-options
[]
(let [{:keys [address] :as account} (rf/sub [:wallet/current-viewing-account])
share-title (str (:name account) " " (i18n/label :t/address))]
networks (rf/sub [:wallet/network-preference-details])
share-title (str (:name account) " " (i18n/label :t/address))
multichain-address (utils/get-multichain-address networks address)]
[quo/action-drawer
[[{:icon :i/link
:accessibility-label :view-on-eth
Expand Down Expand Up @@ -44,30 +45,22 @@
:accessibility-label :copy-address
:label (i18n/label :t/copy-address)
:on-press (fn []
(clipboard/set-string address)
(clipboard/set-string multichain-address)
(rf/dispatch [:toasts/upsert
{:type :positive
:text (i18n/label :t/address-copied)}]))}
{:icon :i/qr-code
:accessibility-label :show-address-qr
:label (i18n/label :t/show-address-qr)}
:label (i18n/label :t/show-address-qr)
:on-press #(rf/dispatch [:open-modal :wallet-share-address {:status :share}])}
{:icon :i/share
:accessibility-label :share-address
:label (i18n/label :t/share-address)
:on-press (fn []
(rf/dispatch [:hide-bottom-sheet])
(js/setTimeout
#(share/open
(if platform/ios?
{:activityItemSources [{:placeholderItem {:type "text"
:content address}
:item {:default {:type "text"
:content
address}}
:linkMetadata {:title share-title}}]}
{:title share-title
:subject share-title
:message address}))
#(rf/dispatch [:wallet/share-account
{:title share-title :content multichain-address}])
600))}]]]))

(defn view
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/contexts/wallet/account/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
(when (not watch-only?)
[quo/wallet-ctas
{:send-action #(rf/dispatch [:open-modal :wallet-select-address])
:receive-action #(rf/dispatch [:open-modal :wallet-receive])
:receive-action #(rf/dispatch [:open-modal :wallet-share-address {:status :receive}])
:buy-action #(rf/dispatch [:show-bottom-sheet
{:content buy-drawer}])
:bridge-action #(rf/dispatch [:open-modal :wallet-bridge])}])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[react-native.platform :as platform]
[reagent.core :as reagent]
[status-im.contexts.wallet.common.sheets.account-options.style :as style]
[status-im.contexts.wallet.common.utils :as utils]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

Expand All @@ -31,7 +32,11 @@
(defn- options
[{:keys [theme show-account-selector? options-height]}]
(let [{:keys [name color emoji address watch-only?]} (rf/sub [:wallet/current-viewing-account])
network-preference-details (rf/sub [:wallet/network-preference-details])]
network-preference-details (rf/sub [:wallet/network-preference-details])
multichain-address (utils/get-multichain-address
network-preference-details
address)
share-title (str name " " (i18n/label :t/address))]
[rn/view
{:on-layout #(reset! options-height (oops/oget % "nativeEvent.layout.height"))
:style (when show-account-selector? style/options-container)}
Expand Down Expand Up @@ -72,10 +77,20 @@
(rf/dispatch [:toasts/upsert
{:type :positive
:text (i18n/label :t/address-copied)}])
(clipboard/set-string address))}
(clipboard/set-string multichain-address))}
{:icon :i/qr-code
:accessibility-label :show-address-qr
:label (i18n/label :t/show-address-qr)
:on-press #(rf/dispatch [:open-modal :wallet-share-address {:status :share}])}
{:icon :i/share
:accessibility-label :share-account
:label (i18n/label :t/share-account)}
:label (i18n/label :t/share-address)
:on-press (fn []
(rf/dispatch [:hide-bottom-sheet])
(js/setTimeout
#(rf/dispatch [:wallet/share-account
{:title share-title :content address}])
600))}
{:add-divider? (not show-account-selector?)
:icon :i/delete
:accessibility-label :remove-account
Expand Down
12 changes: 12 additions & 0 deletions src/status_im/contexts/wallet/common/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,15 @@
:customization-color color
:values {:crypto-value crypto-value
:fiat-value fiat-value}}))

(defn get-multichain-address
[networks address]
(str (->> networks
(map #(str (:short-name %) ":"))
(clojure.string/join ""))
address))

(defn split-prefix-and-address
[input-string]
(let [split-result (string/split input-string #"0x")]
[(first split-result) (str "0x" (second split-result))]))
2 changes: 1 addition & 1 deletion src/status_im/contexts/wallet/common/validation.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
(:require [status-im.constants :as constants]))

(defn ens-name? [s] (re-find constants/regx-ens s))
(defn eth-address? [s] (re-find constants/regx-address s))
(defn eth-address? [s] (re-find constants/regx-multichain-address s))
7 changes: 7 additions & 0 deletions src/status_im/contexts/wallet/effects.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(ns status-im.contexts.wallet.effects
(:require [re-frame.core :as rf]
[react-native.share :as share]))

(rf/reg-fx :effects.share/open
(fn [content]
(share/open content)))
15 changes: 15 additions & 0 deletions src/status_im/contexts/wallet/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require
[clojure.string :as string]
[react-native.background-timer :as background-timer]
[react-native.platform :as platform]
[status-im.contexts.wallet.data-store :as data-store]
[status-im.contexts.wallet.events.collectibles]
[status-im.contexts.wallet.item-types :as item-types]
Expand Down Expand Up @@ -329,3 +330,17 @@
(rf/reg-event-fx :wallet/initialize
(fn []
{:fx [[:dispatch-n [[:wallet/get-ethereum-chains] [:wallet/get-accounts]]]]}))

(rf/reg-event-fx :wallet/share-account
(fn [_ [{:keys [content title]}]]
{:fx [[:effects.share/open
(if platform/ios?
{:activityItemSources
[{:placeholderItem {:type "text"
:content content}
:item {:default {:type "text"
:content content}}
:linkMetadata {:title title}}]}
{:title title
:subject title
:message content})]]}))
Loading

0 comments on commit 97d6af0

Please sign in to comment.