introduce new project structure (first step) (#14356)

* introduce new project structure
This commit is contained in:
flexsurfer 2022-11-14 19:16:55 +01:00 committed by GitHub
parent 4353c4a40c
commit c7d5e90882
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
140 changed files with 3259 additions and 2329 deletions

View File

@ -38,13 +38,13 @@
:builds {:mobile
{:target :react-native
:output-dir "app"
:init-fn status-im.core/init
:init-fn status-im2.setup.core/init
;; When false, the Shadow-CLJS watcher won't automatically refresh
;; the target files (a.k.a hot reload). When false, you can manually
;; reload by calling `shadow.cljs.devtools.api/watch-compile-all!`.
:devtools {:autobuild #shadow/env ["SHADOW_AUTOBUILD_ENABLED" :default true :as :bool]}
:dev {:devtools {:after-load status-im.reloader/reload
:build-notify status-im.reloader/build-notify
:dev {:devtools {:after-load status-im2.setup.hot-reload/reload
:build-notify status-im2.setup.hot-reload/build-notify
:preloads [re-frisk-remote.preload]}
:closure-defines
{status-im.utils.config/POKT_TOKEN #shadow/env "POKT_TOKEN"

66
src/i18n/i18n.cljs Normal file
View File

@ -0,0 +1,66 @@
(ns i18n.i18n
(:require
["i18n-js" :as i18n]
[clojure.string :as string]
[status-im.goog.i18n :as goog.i18n]))
(defn init [default-device-language translations-by-locale]
(set! (.-fallbacks i18n) true)
(set! (.-defaultSeparator i18n) "/")
(set! (.-locale i18n) default-device-language)
(set! (.-translations i18n) translations-by-locale))
(defn get-translations []
(.-translations i18n))
(defn set-language [lang]
(set! (.-locale i18n) lang))
;;:zh, :zh-hans-xx, :zh-hant-xx have been added until this bug will be fixed https://github.com/fnando/i18n-js/issues/460
(def delimeters
"This function is a hack: mobile Safari doesn't support toLocaleString(), so we need to pass
this map to WKWebView to make number formatting work."
(let [n (.toLocaleString ^js (js/Number 1000.1))
delimiter? (= (count n) 7)]
(if delimiter?
{:delimiter (subs n 1 2)
:separator (subs n 5 6)}
{:delimiter ""
:separator (subs n 4 5)})))
(defn label-number [number]
(when number
(let [{:keys [delimiter separator]} delimeters]
(.toNumber i18n
(string/replace number #"," ".")
(clj->js {:precision 10
:strip_insignificant_zeros true
:delimiter delimiter
:separator separator})))))
(def default-option-value "<no value>")
(defn label-options [options]
;; i18n ignores nil value, leading to misleading messages
(into {} (for [[k v] options] [k (or v default-option-value)])))
(defn label-fn
([path] (label-fn path {}))
([path options]
(if (exists? (.t i18n))
(let [options (update options :amount label-number)]
(.t i18n (name path) (clj->js (label-options options))))
(name path))))
(def label (memoize label-fn))
(defn label-pluralize [count path & options]
(if (exists? (.t i18n))
(.p i18n count (name path) (clj->js options))
(name path)))
(def locale
(.-locale i18n))
(def format-currency goog.i18n/format-currency)

View File

@ -0,0 +1,14 @@
(ns react-native.background-timer
(:require ["react-native-background-timer" :default background-timer]))
(defn set-timeout [cb ms]
(.setTimeout background-timer cb ms))
(defn clear-timeout [id]
(.clearTimeout background-timer id))
(defn set-interval [cb ms]
(.setInterval background-timer cb ms))
(defn clear-interval [id]
(.clearInterval background-timer id))

View File

@ -0,0 +1,8 @@
(ns react-native.config
(:require ["react-native-config" :default react-native-config]))
(def config (js->clj react-native-config :keywordize-keys true))
(defn get-config
([k] (get config k))
([k not-found] (get config k not-found)))

View File

@ -3,6 +3,8 @@
["react-native" :as react-native]
[react-native.flat-list :as flat-list]))
(def app-state ^js (.-AppState ^js react-native))
(def view (reagent/adapt-react-class (.-View ^js react-native)))
(def scroll-view (reagent/adapt-react-class (.-ScrollView ^js react-native)))
(def image (reagent/adapt-react-class (.-Image ^js react-native)))
@ -28,4 +30,21 @@
{:font-scale (.-fontScale window)
:height (.-height window)
:scale (.-scale window)
:width (.-width window)}))
:width (.-width window)}))
(defn hide-splash-screen []
(.hide ^js (-> react-native .-NativeModules .-SplashScreen)))
(defn alert [title message buttons options]
(.alert (.-Alert ^js react-native) title message (clj->js buttons) (clj->js options)))
(def appearance ^js (.-Appearance ^js react-native))
(defn get-color-scheme []
(.getColorScheme appearance))
(defn appearance-add-change-listener [handler]
(.addChangeListener appearance handler))
(defn get-window []
(js->clj (.get (.-Dimensions ^js react-native) "window") :keywordize-keys true))

View File

@ -32,4 +32,4 @@
(dissoc props :data :header :footer :empty-component :separator :render-fn :key-fn :on-drag-end-fn)))
(defn flat-list [props]
[react-native-flat-list (base-list-props props)])
[react-native-flat-list (base-list-props props)])

View File

@ -1,8 +1,9 @@
(ns react-native.gesture
(:require ["react-native-gesture-handler" :refer (GestureDetector Gesture)]
(:require ["react-native-gesture-handler" :refer (GestureDetector Gesture gestureHandlerRootHOC)]
[reagent.core :as reagent]))
(def gesture-detector (reagent/adapt-react-class GestureDetector))
(def gesture-handler-root-hoc gestureHandlerRootHOC)
(defn gesture-pan [] (.Pan ^js Gesture))
@ -10,4 +11,4 @@
(defn on-start [^js pan handler] (.onStart pan handler))
(defn on-end [^js pan handler] (.onEnd pan handler))
(defn on-end [^js pan handler] (.onEnd pan handler))

View File

@ -2,4 +2,4 @@
(:require [reagent.core :as reagent]
["react-native-hole-view" :refer (RNHoleView)]))
(def hole-view (reagent/adapt-react-class RNHoleView))
(def hole-view (reagent/adapt-react-class RNHoleView))

View File

@ -0,0 +1,8 @@
(ns react-native.languages
(:require ["react-native-languages" :default react-native-languages]))
(defn add-change-listener [handler]
(.addEventListener ^js react-native-languages "change" (fn [^js event] (handler (.-language event)))))
(defn get-lang-keyword []
(keyword (.-language ^js react-native-languages)))

View File

@ -2,4 +2,4 @@
(:require ["react-native-linear-gradient" :default LinearGradient]
[reagent.core :as reagent]))
(def linear-gradient (reagent/adapt-react-class LinearGradient))
(def linear-gradient (reagent/adapt-react-class LinearGradient))

View File

@ -0,0 +1,5 @@
(ns react-native.mail
(:require ["react-native-mail" :default react-native-mail]))
(defn mail [opts callback]
(.mail react-native-mail (clj->js opts) callback))

View File

@ -2,4 +2,4 @@
(:require ["@react-native-community/masked-view" :default MaskedView]
[reagent.core :as reagent]))
(def masked-view (reagent/adapt-react-class MaskedView))
(def masked-view (reagent/adapt-react-class MaskedView))

View File

@ -0,0 +1,58 @@
(ns react-native.navigation
(:refer-clojure :exclude [pop])
(:require ["react-native-navigation" :refer (Navigation)]))
(defn set-default-options [opts]
(.setDefaultOptions ^js Navigation (clj->js opts)))
(defn register-component [arg1 arg2 arg3] (.registerComponent ^js Navigation arg1 arg2 arg3))
(defn set-lazy-component-registrator [handler] (.setLazyComponentRegistrator ^js Navigation handler))
(defn set-root [root]
(.setRoot ^js Navigation (clj->js root)))
(defn set-stack-root [stack comp]
(.setStackRoot ^js Navigation stack (clj->js comp)))
(defn push [arg1 arg2]
(.push ^js Navigation arg1 (clj->js arg2)))
(defn pop [comp] (.pop ^js Navigation comp))
(defn show-modal [arg]
(.showModal ^js Navigation (clj->js arg)))
(defn dismiss-modal [comp] (.dismissModal ^js Navigation comp))
(defn show-overlay [comp]
(.showOverlay Navigation (clj->js comp)))
(defn dissmiss-overlay [comp]
(.catch (.dismissOverlay Navigation comp) #()))
(defn reg-app-launched-listener [handler]
(.registerAppLaunchedListener ^js (.events ^js Navigation) handler))
(defn reg-button-pressed-listener [handler]
(.registerNavigationButtonPressedListener
(.events Navigation)
(fn [^js evn]
(handler (.-buttonId evn)))))
(defn reg-modal-dismissed-listener [handler]
(.registerModalDismissedListener ^js (.events ^js Navigation) handler))
(defn reg-component-did-appear-listener [handler]
(.registerComponentDidAppearListener
^js (.events ^js Navigation)
(fn [^js evn]
(handler (keyword (.-componentName evn))))))
(defn reg-component-did-disappear-listener [handler]
(.registerComponentDidDisappearListener
^js (.events ^js Navigation)
(fn [^js evn]
(handler (.-componentName evn)))))
(defn merge-options [id opts]
(.mergeOptions Navigation id (clj->js opts)))

View File

@ -6,4 +6,4 @@
(def os (when platform (.-OS ^js platform)))
(def android? (= os "android"))
(def ios? (= os "ios"))
(def ios? (= os "ios"))

View File

@ -1,6 +1,6 @@
(ns react-native.safe-area
(:require ["react-native-safe-area-context" :as safe-area-context
:refer (SafeAreaInsetsContext)]
:refer (SafeAreaProvider SafeAreaInsetsContext)]
[reagent.core :as reagent]))
(def ^:private consumer-raw (reagent/adapt-react-class (.-Consumer ^js SafeAreaInsetsContext)))
@ -10,3 +10,6 @@
(fn [insets]
(reagent/as-element
[component (js->clj insets :keywordize-keys true)]))])
(def safe-area-provider (reagent/adapt-react-class SafeAreaProvider))
(def safe-area-consumer consumer-raw)

View File

@ -0,0 +1,5 @@
(ns react-native.shake
(:require ["react-native-shake" :as react-native-shake]))
(defn add-shake-listener [handler]
(.addEventListener react-native-shake "ShakeEvent" handler))

View File

@ -2,4 +2,4 @@
(:require ["react-syntax-highlighter" :default Highlighter]
[reagent.core :as reagent]))
(def highlighter (reagent/adapt-react-class Highlighter))
(def highlighter (reagent/adapt-react-class Highlighter))

View File

@ -10,7 +10,7 @@
(defn setup []
(h/register-helper-events)
(rf/dispatch [:init/app-started]))
(rf/dispatch [:setup/app-started]))
;;;; Contact verification

View File

@ -11,7 +11,7 @@
[status-im.i18n.i18n :as i18n]
[status-im.contact.core :as contact]
[status-im.router.core :as router]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.ethereum.stateofus :as stateofus]
[status-im.utils.db :as utils.db]))

View File

@ -1,6 +1,7 @@
(ns status-im.add-new.db
(:require [status-im.ethereum.ens :as ens]
[cljs.spec.alpha :as spec]))
[cljs.spec.alpha :as spec]
[status-im.utils.db :as utils.db]))
(defn own-public-key?
[{:keys [multiaccount]} public-key]
@ -8,18 +9,19 @@
(defn validate-pub-key [db public-key]
(cond
(or (not (spec/valid? :global/public-key public-key))
(or (not (utils.db/valid-public-key? public-key))
(= public-key ens/default-key))
:invalid
(own-public-key? db public-key)
:yourself))
(spec/def ::name :global/not-empty-string)
(spec/def ::name (spec/and string? not-empty))
(spec/def ::topic (spec/and :global/not-empty-string
(spec/def ::topic (spec/and string?
not-empty
(partial re-matches #"[a-z0-9\-]+")))
(defn valid-topic? [topic]
(and topic
(spec/valid? ::topic topic)
(not (spec/valid? :global/public-key topic))))
(not (utils.db/valid-public-key? topic))))

View File

@ -3,7 +3,7 @@
[re-frame.core :as re-frame]
[status-im.i18n.i18n :as i18n]
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]))
(def address-regex #"enode://[a-zA-Z0-9]+:?(.*)\@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b:(\d{1,5})")

View File

@ -9,7 +9,7 @@
[status-im.i18n.i18n :as i18n]
[status-im.native-module.core :as status]
[status-im.ui.components.list-selection :as list-selection]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[status-im.utils.http :as http]
[status-im.utils.platform :as platform]

View File

@ -2,7 +2,7 @@
(:require [status-im.constants :as constants]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.i18n.i18n :as i18n]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.qr-scanner.core :as qr-scanner]
[status-im.utils.fx :as fx]))

View File

@ -10,8 +10,6 @@
[status-im.i18n.i18n :as i18n]
[quo.design-system.colors :as colors]
[status-im.constants :as constants]
[status-im.navigation :as navigation]
[status-im.navigation2 :as navigation2]
[status-im.utils.clocks :as utils.clocks]
[status-im.utils.fx :as fx]
[status-im.utils.utils :as utils]
@ -19,7 +17,8 @@
[status-im.add-new.db :as new-public-chat.db]
[status-im.chat.models.loading :as loading]
[status-im.ui.screens.chat.state :as chat.state]
[clojure.set :as set]))
[clojure.set :as set]
[status-im2.navigation.events :as navigation]))
(defn chats []
(:chats (types/json->clj (js/require "./chats.js"))))
@ -270,7 +269,7 @@
{:db (assoc db :current-chat-id chat-id)}
(offload-messages chat-id)
(preload-chat-data chat-id)
(navigation2/navigate-to-nav2 :chat chat-id nil from-switcher?)))
(navigation/navigate-to-nav2 :chat chat-id nil from-switcher?)))
(fx/defn handle-clear-history-response
{:events [::history-cleared]}

View File

@ -12,7 +12,7 @@
[status-im.utils.universal-links.core :as universal-links]
[status-im.ethereum.json-rpc :as json-rpc]
[quo.design-system.colors :as colors]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.handlers :refer [>evt]]
[status-im.ui.components.emoji-thumbnail.styles :as emoji-thumbnail-styles]
[status-im.notifications-center.core :as notification-center]))

View File

@ -195,3 +195,5 @@
(def ^:const sticker-pack-status-installed 1)
(def ^:const sticker-pack-status-pending 2)
(def ^:const sticker-pack-status-owned 3)
(def ^:const delete-message-for-me-undo-time-limit-ms 4000)

View File

@ -4,7 +4,7 @@
[status-im.contact.db :as contact.db]
[status-im.data-store.chats :as chats-store]
[status-im.data-store.contacts :as contacts-store]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.types :as types]
[status-im.notifications-center.core :as notification-center]
[status-im.utils.fx :as fx]))

View File

@ -1,6 +1,6 @@
(ns status-im.contact.chat
(:require [re-frame.core :as re-frame]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[status-im.chat.models :as chat]
[status-im.contact.core :as contact]

View File

@ -3,7 +3,7 @@
[status-im.contact.db :as contact.db]
[status-im.data-store.contacts :as contacts-store]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.utils.fx :as fx]
[taoensso.timbre :as log]

View File

@ -1,54 +0,0 @@
(ns status-im.core
(:require ["react-native" :refer (DevSettings LogBox)]
["react-native-languages" :default react-native-languages]
["react-native-shake" :as react-native-shake]
[re-frame.core :as re-frame]
[re-frame.interop :as interop]
[reagent.impl.batching :as batching]
status-im.events
[status-im.i18n.i18n :as i18n]
[status-im.native-module.core :as status]
status-im.navigation.core
[status-im.notifications.local :as notifications]
status-im.subs.root
[status-im.ui.components.react :as react]
[status-im.utils.config :as config]
status-im.utils.db
[status-im.utils.error-handler :as error-handler]
[status-im.utils.logging.core :as utils.logs]
[status-im.utils.platform :as platform]
[status-im.utils.snoopy :as snoopy]
[status-im.switcher.animation :as animation]
[status-im.async-storage.core :as async-storage]
[status-im.utils.universal-links.core :as utils.universal-links]))
(set! interop/next-tick js/setTimeout)
(set! batching/fake-raf #(js/setTimeout % 0))
(.ignoreAllLogs LogBox)
(defn init []
(utils.logs/init-logs config/log-level)
(error-handler/register-exception-handler!)
(when platform/android?
(status/set-soft-input-mode status/adjust-resize))
(notifications/listen-notifications)
(.addEventListener ^js react/app-state "change" #(re-frame/dispatch [:app-state-change %]))
(.addEventListener react-native-languages "change" (fn [^js event]
(i18n/set-language (.-language event))))
(.addEventListener react-native-shake "ShakeEvent" #(re-frame/dispatch [:shake-event]))
(re-frame/dispatch-sync [:init/app-started])
(utils.universal-links/initialize)
;; TODO(parvesh) - Remove while moving functionality to status-go
(async-storage/get-item :selected-stack-id #(animation/selected-stack-id-loaded %))
;;DEV
(snoopy/subscribe!)
(when (and js/goog.DEBUG platform/ios? DevSettings)
;;on Android this method doesn't work
(when-let [nm (.-_nativeModule DevSettings)]
;;there is a bug in RN, so we have to enable it first and then disable
(.setHotLoadingEnabled ^js nm true)
(js/setTimeout #(.setHotLoadingEnabled ^js nm false) 1000))))

View File

@ -7,7 +7,7 @@
[status-im.ethereum.ens :as ens]
[status-im.ethereum.stateofus :as stateofus]
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.datetime :as datetime]
[status-im.utils.fx :as fx]
[status-im.utils.random :as random]

View File

@ -5,7 +5,6 @@
[status-im.async-storage.core :as async-storage]
status-im.backup.core
status-im.bootnodes.core
[status-im.bottom-sheet.core :as bottom-sheet]
status-im.browser.core
status-im.browser.permissions
[status-im.chat.models :as chat]
@ -23,7 +22,6 @@
status-im.fleet.core
status-im.http.core
[status-im.i18n.i18n :as i18n]
status-im.init.core
[status-im.keycard.core :as keycard]
status-im.log-level.core
status-im.mailserver.constants
@ -34,11 +32,10 @@
status-im.multiaccounts.logout.core
status-im.multiaccounts.update.core
[status-im.native-module.core :as status]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
status-im.notifications-center.core
status-im.activity-center.core
status-im.pairing.core
[status-im.popover.core :as popover]
status-im.profile.core
status-im.search.core
status-im.signals.core
@ -49,23 +46,17 @@
status-im.ui.screens.privacy-and-security-settings.events
[status-im.utils.dimensions :as dimensions]
[status-im.utils.fx :as fx]
status-im.utils.logging.core
[status-im.utils.universal-links.core :as universal-links]
[status-im.utils.utils :as utils]
[status-im.visibility-status-popover.core :as visibility-status-popover]
status-im.visibility-status-updates.core
status-im.waku.core
status-im.wallet.accounts.core
status-im.wallet.choose-recipient.core
[status-im.wallet.core :as wallet]
status-im.wallet.custom-tokens.core
[status-im.navigation.core :as navigation.core]
[status-im.navigation.state :as navigation.state]
[status-im.signing.core :as signing]
status-im.wallet-connect.core
status-im.wallet-connect-legacy.core
status-im.navigation2
status-im.navigation2.core))
status-im.network.net-info))
(re-frame/reg-fx
:dismiss-keyboard
@ -119,56 +110,9 @@
(fx/defn system-theme-mode-changed
{:events [:system-theme-mode-changed]}
[{:keys [db] :as cofx} theme]
(let [cur-theme (get-in db [:multiaccount :appearance])
current-tab (get db :current-tab :chat)
view-id (:view-id db)
screen-params (get-in db [:navigation/screen-params view-id])
root-id @navigation.state/root-id
key-uid (get-in db [:multiaccounts/login :key-uid])
keycard-account? (boolean (get-in db [:multiaccounts/multiaccounts
key-uid
:keycard-pairing]))
dispatch-later (cond-> []
(= view-id :chat)
(conj {:ms 1000
:dispatch [:chat.ui/navigate-to-chat (:current-chat-id db)]})
(and
(= root-id :chat-stack)
(not-any? #(= view-id %) '(:home :empty-tab :wallet :status :my-profile :chat)))
(conj {:ms 1000
:dispatch [:navigate-to view-id screen-params]})
(some #(= view-id %) navigation.core/community-screens)
(conj {:ms 800 :dispatch
[:navigate-to :community
(get-in db [:navigation/screen-params :community])]})
(= view-id :community-emoji-thumbnail-picker)
(conj {:ms 900 :dispatch
[:navigate-to :create-community-channel
(get-in db [:navigation/screen-params :create-community-channel])]}))]
(when (and (some? root-id) (or (nil? cur-theme) (zero? cur-theme)))
(navigation.core/dismiss-all-modals)
(fx/merge cofx
(merge
{::multiaccounts/switch-theme (if (= :dark theme) 2 1)}
(when (seq dispatch-later)
{:utils/dispatch-later dispatch-later}))
(when (get-in db [:bottom-sheet/show?])
(bottom-sheet/hide-bottom-sheet))
(when (get-in db [:popover/popover])
(popover/hide-popover))
(when (get-in db [:visibility-status-popover/popover])
(visibility-status-popover/hide-visibility-status-popover))
(when (get-in db [:signing/tx])
(signing/discard))
(if (and (= root-id :multiaccounts) keycard-account?)
(navigation/init-root-with-component :multiaccounts-keycard :multiaccounts)
(navigation/init-root root-id))
(when (= root-id :chat-stack)
(navigation/change-tab current-tab))))))
[_ theme]
{::multiaccounts/switch-theme (if (= :dark theme) 2 1)
:dispatch [:reload-new-ui]})
(def authentication-options
{:reason (i18n/label :t/biometric-auth-reason-login)})
@ -195,9 +139,7 @@
(>= (- now app-in-background-since)
constants/ms-in-bg-for-require-bioauth))]
(fx/merge cofx
{:db (-> db
(dissoc :app-in-background-since)
(assoc :app-active-since now))}
{:db (dissoc db :app-in-background-since)}
(mailserver/process-next-messages-request)
(wallet/restart-wallet-service-after-background app-in-background-since)
(universal-links/process-stored-event)
@ -207,10 +149,8 @@
(biometric/authenticate % on-biometric-auth-result authentication-options)))))
(fx/defn on-going-in-background
[{:keys [db now] :as cofx}]
{:db (-> db
(dissoc :app-active-since)
(assoc :app-in-background-since now))
[{:keys [db now]}]
{:db (assoc db :app-in-background-since now)
:dispatch-n [[:audio-recorder/on-background] [:audio-message/on-background]]})
(fx/defn app-state-change

View File

@ -5,7 +5,7 @@
[re-frame.core :as re-frame]
[status-im.chat.models :as models.chat]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[status-im.constants :as constants]
[status-im.i18n.i18n :as i18n]

View File

@ -4,6 +4,8 @@
["i18n-js" :as i18n]
[status-im.i18n.i18n-resources :as i18n-resources]
[status-im.goog.i18n :as goog.i18n]))
;;TODO (14/11/22 flexsurfer) this namespace has been moved to the root level, we keep this only for old (status 1.0) code,
;; can be removed with old code later
(set! (.-locale i18n) (name i18n-resources/default-device-language))
(set! (.-fallbacks i18n) true)

View File

@ -2,6 +2,8 @@
(:require [clojure.string :as string]
["i18n-js" :as i18n-js]
["react-native-languages" :default react-native-languages]))
;;TODO (14/11/22 flexsurfer) this namespace has been moved to the status-im2 namespace, we keep this only for old (status 1.0) code,
;; can be removed with old code later
(def default-device-language
(keyword (.-language react-native-languages)))

View File

@ -5,6 +5,8 @@
[clojure.set :as set]
[cljs.spec.alpha :as spec]
[clojure.string :as string]))
;;TODO (14/11/22 flexsurfer) this namespace has been moved to the status-im2 namespace, we keep this only for old (status 1.0) code,
;; can be removed with old code later
;; english as source of truth
(def labels (set (keys (js->clj (:en i18n-resources/translations-by-locale)

View File

@ -4,11 +4,12 @@
[clojure.string :as string]
[re-frame.core :as rf]
status-im.events
status-im2.navigation.core
[status-im.chat.models :as chat.models]
[status-im.utils.security :as security]
[status-im.multiaccounts.logout.core :as logout]
[status-im.transport.core :as transport]
status-im.subs.root ;;so integration tests can run independently
status-im2.subs.root ;;so integration tests can run independently
[status-im.ethereum.core :as ethereum]
[status-im.utils.test :as utils.test]
[taoensso.timbre :as log]))
@ -22,7 +23,7 @@
(utils.test/init!)
(defn initialize-app! []
(rf/dispatch [:init/app-started]))
(rf/dispatch [:setup/app-started]))
(defn generate-and-derive-addresses! []
(rf/dispatch [:generate-and-derive-addresses]))
@ -71,11 +72,11 @@
(deftest initialize-app-test
(log/info "========= initialize-app-test ==================")
(rf-test/run-test-async
(rf/dispatch [:init/app-started])
(rf/dispatch [:setup/app-started])
(rf-test/wait-for
;; use initialize-view because it has the longest avg. time and
;; is dispatched by initialize-multiaccounts (last non-view event)
[:status-im.init.core/initialize-view]
[:setup/initialize-view]
(assert-app-initialized))))
(deftest create-account-test
@ -83,7 +84,7 @@
(rf-test/run-test-async
(initialize-app!) ; initialize app
(rf-test/wait-for
[:status-im.init.core/initialize-view]
[:setup/initialize-view]
(generate-and-derive-addresses!) ; generate 5 new keys
(rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success] ; wait for the keys
@ -101,7 +102,7 @@
(rf-test/run-test-async
(initialize-app!) ; initialize app
(rf-test/wait-for
[:status-im.init.core/initialize-view]
[:setup/initialize-view]
(generate-and-derive-addresses!) ; generate 5 new keys
(rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success]
@ -126,7 +127,7 @@
(rf-test/run-test-async
(initialize-app!)
(rf-test/wait-for
[:status-im.init.core/initialize-view]
[:setup/initialize-view]
(generate-and-derive-addresses!) ; generate 5 new keys
(rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success]
@ -148,7 +149,7 @@
(rf-test/run-test-async
(initialize-app!)
(rf-test/wait-for
[:status-im.init.core/initialize-view]
[:setup/initialize-view]
(generate-and-derive-addresses!)
(rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success]
@ -185,7 +186,7 @@
(rf-test/run-test-async
(initialize-app!)
(rf-test/wait-for
[:status-im.init.core/initialize-view]
[:setup/initialize-view]
(rf/dispatch-sync [:init-root :onboarding])
(rf/dispatch-sync [:multiaccounts.recover.ui/recover-multiaccount-button-pressed])
(rf/dispatch-sync [:status-im.multiaccounts.recover.core/enter-phrase-pressed])
@ -215,7 +216,7 @@
(rf-test/run-test-async
(initialize-app!)
(rf-test/wait-for
[:status-im.init.core/initialize-view]
[:setup/initialize-view]
(generate-and-derive-addresses!)
(rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success] ; wait for the keys
@ -237,7 +238,7 @@
(rf-test/run-test-async
(initialize-app!)
(rf-test/wait-for
[:status-im.init.core/initialize-view]
[:setup/initialize-view]
(generate-and-derive-addresses!)
(rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success] ; wait for the keys
@ -265,7 +266,7 @@
(rf-test/run-test-async
(initialize-app!)
(rf-test/wait-for
[:status-im.init.core/initialize-view]
[:setup/initialize-view]
(generate-and-derive-addresses!)
(rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success] ; wait for the keys

View File

@ -6,7 +6,7 @@
[status-im.ethereum.mnemonic :as mnemonic]
[status-im.keycard.common :as common]
[status-im.multiaccounts.recover.core :as multiaccounts.recover]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.signing.core :as signing.core]
[taoensso.timbre :as log]))

View File

@ -1,6 +1,6 @@
(ns status-im.keycard.change-pin
(:require [status-im.i18n.i18n :as i18n]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.keycard.onboarding :as onboarding]
[status-im.utils.fx :as fx]
[taoensso.timbre :as log]

View File

@ -4,7 +4,7 @@
[status-im.ethereum.core :as ethereum]
[status-im.keycard.nfc :as nfc]
[status-im.i18n.i18n :as i18n]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.ui.screens.keycard.keycard-interaction :as keycard-sheet]
[status-im.utils.fx :as fx]
[status-im.utils.keychain.core :as keychain]

View File

@ -16,7 +16,7 @@
[status-im.i18n.i18n :as i18n]
[status-im.multiaccounts.recover.core :as multiaccounts.recover]
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.datetime :as utils.datetime]
[status-im.utils.fx :as fx]
[taoensso.timbre :as log]))

View File

@ -1,5 +1,5 @@
(ns status-im.keycard.delete-key
(:require [status-im.navigation :as navigation]
(:require [status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[status-im.keycard.common :as common]))

View File

@ -1,6 +1,6 @@
(ns status-im.keycard.login
(:require [status-im.ethereum.core :as ethereum]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[status-im.utils.types :as types]
[taoensso.timbre :as log]

View File

@ -1,5 +1,5 @@
(ns status-im.keycard.mnemonic
(:require [status-im.navigation :as navigation]
(:require [status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[taoensso.timbre :as log]
[status-im.keycard.common :as common]

View File

@ -2,7 +2,7 @@
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.i18n.i18n :as i18n]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[status-im.utils.utils :as utils]
[status-im.keycard.common :as common]

View File

@ -1,5 +1,5 @@
(ns status-im.keycard.recovery
(:require [status-im.navigation :as navigation]
(:require [status-im2.navigation.events :as navigation]
[status-im.utils.datetime :as utils.datetime]
[status-im.multiaccounts.create.core :as multiaccounts.create]
[status-im.multiaccounts.model :as multiaccounts.model]

View File

@ -2,7 +2,7 @@
(:require [re-frame.core :as re-frame]
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.i18n.i18n :as i18n]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[taoensso.timbre :as log]
[status-im.keycard.common :as common]

View File

@ -7,7 +7,7 @@
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.node.core :as node]
[status-im.utils.mobile-sync :as mobile-network-utils]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[taoensso.timbre :as log]))

View File

@ -5,7 +5,7 @@
[status-im.wallet.core :as wallet]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im.multiaccounts.model :as multiaccounts.model]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.mailserver.core :as mailserver]
[status-im.utils.mobile-sync :as utils]
[taoensso.timbre :as log]))

View File

@ -8,12 +8,12 @@
[status-im.utils.fx :as fx]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[status-im.utils.theme :as utils.theme]
[status-im.theme.core :as theme]
[status-im.utils.utils :as utils]
[quo.platform :as platform]
[taoensso.timbre :as log]
[clojure.string :as string]))
[clojure.string :as string]
[status-im2.common.theme.core :as utils.theme]))
;; validate that the given mnemonic was generated from Status Dictionary
(re-frame/reg-fx
@ -164,7 +164,7 @@
(re-frame/reg-fx
::switch-theme
(fn [theme-id]
(let [theme (if (or (= 2 theme-id) (and (= 0 theme-id) (utils.theme/is-dark-mode)))
(let [theme (if (or (= 2 theme-id) (and (= 0 theme-id) (utils.theme/dark-mode?)))
:dark
:light)]
(theme/change-theme theme))))

View File

@ -5,4 +5,4 @@
(defn valid-length? [password]
(>= (count password) const/min-password-length))
(spec/def ::password (spec/and :global/not-empty-string valid-length?))
(spec/def ::password (spec/and string? not-empty valid-length?))

View File

@ -8,7 +8,7 @@
[status-im.multiaccounts.model :as multiaccounts.model]
[status-im.multiaccounts.logout.core :as multiaccounts.logout]
[status-im.native-module.core :as native-module]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.popover.core :as popover]
[status-im.utils.fx :as fx]
[status-im.utils.security :as security]

View File

@ -20,7 +20,7 @@
[status-im.mobile-sync-settings.core :as mobile-network]
[status-im.utils.fx :as fx]
[status-im.utils.keychain.core :as keychain]
[status-im.utils.logging.core :as logging]
[status-im2.setup.log :as logging]
[status-im.utils.security :as security]
[status-im.utils.types :as types]
[status-im.utils.utils :as utils]
@ -33,7 +33,7 @@
[status-im.utils.mobile-sync :as utils.mobile-sync]
[status-im.async-storage.core :as async-storage]
[status-im.notifications-center.core :as notifications-center]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.signing.eip1559 :as eip1559]
[status-im.data-store.chats :as data-store.chats]
[status-im.data-store.visibility-status-updates :as visibility-status-updates-store]

View File

@ -1,13 +1,13 @@
(ns status-im.multiaccounts.logout.core
(:require [re-frame.core :as re-frame]
[status-im.i18n.i18n :as i18n]
[status-im.init.core :as init]
[status-im.native-module.core :as status]
[status-im.utils.fx :as fx]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.utils.keychain.core :as keychain]
[status-im.notifications.core :as notifications]
[status-im.wallet.core :as wallet]))
[status-im.wallet.core :as wallet]
[status-im2.setup.events :as init]))
(fx/defn logout-method
{:events [::logout-method]}

View File

@ -10,7 +10,7 @@
[status-im.multiaccounts.create.core :as multiaccounts.create]
[status-im.native-module.core :as status]
[status-im.popover.core :as popover]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[status-im.utils.security :as security]
[status-im.utils.types :as types]

View File

@ -1,444 +0,0 @@
(ns status-im.navigation.core
(:require
["react-native" :as rn]
["react-native-gesture-handler" :refer (gestureHandlerRootHOC)]
["react-native-navigation" :refer (Navigation)]
[clojure.set :as clojure.set]
[quo.components.text-input :as quo.text-input]
[quo.design-system.colors :as quo.colors]
[re-frame.core :as re-frame]
[status-im.multiaccounts.login.core :as login-core]
[status-im.navigation.roots :as roots]
[status-im.navigation.state :as state]
[status-im.ui.components.icons.icons :as icons]
[status-im.ui.components.react :as react]
[status-im.ui.screens.views :as views]
[status-im.utils.fx :as fx]
[status-im.utils.platform :as platform]
[taoensso.encore :as enc]
[taoensso.timbre :as log]))
(def debug? ^boolean js/goog.DEBUG)
(def splash-screen (-> rn .-NativeModules .-SplashScreen))
(defonce set-navigation-default-options
(.setDefaultOptions Navigation (clj->js {:layout {:orientation "portrait"}})))
;; REGISTER COMPONENT (LAZY)
(defn reg-comp [key]
(log/debug "reg-comp" key)
(if-let [comp (get views/components (keyword key))]
(.registerComponent Navigation key (fn [] (views/component comp)))
(let [screen (views/screen key)]
(.registerComponent Navigation key (fn [] (gestureHandlerRootHOC screen)) (fn [] screen)))))
(defonce rset-lazy-reg
(.setLazyComponentRegistrator Navigation reg-comp))
(defn dismiss-all-modals []
(log/debug "dissmiss-all-modals")
(when @state/curr-modal
(reset! state/curr-modal false)
(reset! state/dissmissing true)
(doseq [modal @state/modals]
(.dismissModal Navigation (name modal)))
(reset! state/modals [])))
;; PUSH SCREEN
(defn navigate [comp]
(log/debug "NAVIGATE" comp)
(let [{:keys [options]} (get views/screens comp)]
(.push Navigation
(name @state/root-comp-id)
(clj->js {:component {:id comp
:name comp
:options (merge options
(roots/status-bar-options)
(roots/merge-top-bar (roots/topbar-options) options))}}))
;;if we push the screen from modal, we want to dismiss all modals
(dismiss-all-modals)))
;; OPEN MODAL
(defn update-modal-topbar-options [options]
(log/debug "update-modal-topbar-options" options)
(merge options
(roots/merge-top-bar {:elevation 0
:noBorder true
:title {:color quo.colors/black}
:background {:color quo.colors/white}
:leftButtonColor quo.colors/black
:leftButtons {:id "dismiss-modal"
:icon (icons/icon-source :main-icons/close)}}
options)))
(defn open-modal [comp]
(log/debug "open-modal" comp)
(let [{:keys [options]} (get views/screens comp)]
(if @state/dissmissing
(reset! state/dissmissing comp)
(do
(reset! state/curr-modal true)
(swap! state/modals conj comp)
(.showModal Navigation
(clj->js {:stack {:children
[{:component
{:name comp
:id comp
:options (update-modal-topbar-options
(merge (roots/status-bar-options)
(roots/default-root)
options))}}]}}))))))
(re-frame/reg-fx :open-modal-fx open-modal)
;; DISSMISS MODAL
(defn dissmissModal []
(log/debug "dissmissModal")
(reset! state/dissmissing true)
(.dismissModal Navigation (name (last @state/modals))))
(defonce register-nav-button-reg
(.registerNavigationButtonPressedListener
(.events Navigation)
(fn [^js evn]
(let [id (.-buttonId evn)]
(if (= "dismiss-modal" id)
(do
(when-let [event (get-in views/screens [(last @state/modals) :on-dissmiss])]
(re-frame/dispatch event))
(dissmissModal))
(when-let [handler (get-in views/screens [(keyword id) :right-handler])]
(handler)))))))
(defn set-view-id [view-id]
(log/debug "set-view-id" view-id)
(when-let [{:keys [on-focus]} (get views/screens view-id)]
(re-frame/dispatch [:set-view-id view-id])
(re-frame/dispatch [:screens/on-will-focus view-id])
(when on-focus
(re-frame/dispatch on-focus))))
(defonce register-modal-reg
(.registerModalDismissedListener
(.events Navigation)
(fn [_]
(if (> (count @state/modals) 1)
(let [new-modals (butlast @state/modals)]
(reset! state/modals (vec new-modals))
(set-view-id (last new-modals)))
(do
(reset! state/modals [])
(reset! state/curr-modal false)
(set-view-id @state/pushed-screen-id)))
(let [comp @state/dissmissing]
(reset! state/dissmissing false)
(when (keyword? comp)
(open-modal comp))))))
;; SCREEN DID APPEAR
(defonce screen-appear-reg
(.registerComponentDidAppearListener
(.events Navigation)
(fn [^js evn]
(let [view-id (keyword (.-componentName evn))]
(log/debug "screen-appear-reg" view-id)
(when (get views/screens view-id)
(when (and (not= view-id :bottom-sheet)
(not= view-id :popover)
(not= view-id :visibility-status-popover))
(set-view-id view-id)
(when-not @state/curr-modal
(reset! state/pushed-screen-id view-id))))))))
;; SCREEN DID DISAPPEAR
(defonce screen-disappear-reg
(.registerComponentDidDisappearListener
(.events Navigation)
(fn [^js evn]
(let [view-id (keyword (.-componentName evn))]
(when-not (#{"popover" "bottom-sheet" "signing-sheet" "visibility-status-popover" "wallet-connect-sheet" "wallet-connect-success-sheet" "wallet-connect-app-management-sheet"}
(.-componentName evn))
(re-frame/dispatch [::view-disappeared view-id])
(doseq [[_ {:keys [ref value]}] @quo.text-input/text-input-refs]
(.setNativeProps ^js ref (clj->js {:text value})))
(doseq [[^js text-input default-value] @react/text-input-refs]
(.setNativeProps text-input (clj->js {:text default-value}))))))))
;; SET ROOT
(re-frame/reg-fx
:init-root-fx
(fn [new-root-id]
(log/debug :init-root-fx new-root-id)
(reset! state/root-comp-id new-root-id)
(reset! state/root-id @state/root-comp-id)
(.setRoot Navigation (clj->js (get (roots/roots) new-root-id)))))
(re-frame/reg-fx
:init-root-with-component-fx
(fn [[new-root-id new-root-comp-id]]
(log/debug :init-root-with-component-fx new-root-id new-root-comp-id)
(reset! state/root-comp-id new-root-comp-id)
(reset! state/root-id @state/root-comp-id)
(.setRoot Navigation (clj->js (get (roots/roots) new-root-id)))))
(fx/defn set-multiaccount-root
{:events [::set-multiaccount-root]}
[{:keys [db]}]
(log/debug :set-multiaccounts-root)
(let [key-uid (get-in db [:multiaccounts/login :key-uid])
keycard-account? (boolean (get-in db [:multiaccounts/multiaccounts
key-uid
:keycard-pairing]))]
{:init-root-fx (if keycard-account? :multiaccounts-keycard :multiaccounts)}))
(defonce rset-app-launched
(.registerAppLaunchedListener (.events Navigation)
(fn []
(reset! state/curr-modal false)
(reset! state/dissmissing false)
(if (or (= @state/root-id :multiaccounts)
(= @state/root-id :multiaccounts-keycard))
(re-frame/dispatch-sync [::set-multiaccount-root])
(when @state/root-id
(reset! state/root-comp-id @state/root-id)
(.setRoot Navigation (clj->js (get (roots/roots) @state/root-id)))
(re-frame/dispatch [::login-core/check-last-chat])))
(.hide ^js splash-screen))))
(defn get-screen-component [comp]
(log/debug :get-screen-component comp)
(let [{:keys [options]} (get views/screens comp)]
{:component {:id comp
:name comp
:options (merge options
(roots/status-bar-options)
(roots/merge-top-bar (roots/topbar-options) options))}}))
;; SET STACK ROOT
(re-frame/reg-fx
:set-stack-root-fx
(fn [[stack comp]]
(log/debug :set-stack-root-fx stack comp)
(.setStackRoot Navigation
(name stack)
(clj->js (if (vector? comp)
(mapv get-screen-component comp)
(get-screen-component comp))))))
;; BOTTOM TABS
(def tab-root-ids {0 :chat-stack
1 :browser-stack
2 :wallet-stack
3 :status-stack
4 :profile-stack})
(def tab-key-idx {:chat 0
:browser 1
:wallet 2
:status 3
:profile 4})
(re-frame/reg-fx
:change-tab-fx
(fn [tab]
(log/debug :change-tab-fx)
(reset! state/root-comp-id (get tab-root-ids (get tab-key-idx tab)))
(.mergeOptions Navigation "tabs-stack" (clj->js {:bottomTabs {:currentTabIndex (get tab-key-idx tab)}}))
;;when we change tab we want to dismiss all modals
(dismiss-all-modals)))
;issue on ios https://github.com/wix/react-native-navigation/issues/7146
(re-frame/reg-fx
:change-tab-count-fx
(fn [[tab cnt]]
(log/debug :change-tab-count-fx tab cnt)
(.mergeOptions Navigation
(name (get tab-root-ids (get tab-key-idx tab)))
(clj->js {:bottomTab (cond
(or (pos? cnt) (pos? (:other cnt)))
(if (and (= :chat tab) platform/ios?)
{:dotIndicator {:visible true}}
{:badge (str (or (:other cnt) cnt)) :dotIndicator {:visible false}})
(pos? (:public cnt))
(if platform/ios?
{:dotIndicator {:visible true}}
{:badge nil :dotIndicator {:visible true}})
:else
(if (and (= :chat tab) platform/ios?)
{:dotIndicator {:visible false}}
{:dotIndicator {:visible false} :badge ""}))}))))
(re-frame/reg-fx
:pop-to-root-tab-fx
(fn [comp]
(log/debug :pop-to-root-tab-fx comp)
(dismiss-all-modals)
(.popToRoot Navigation (name comp))))
(defonce register-bottom-tab-reg
(.registerBottomTabSelectedListener
(.events Navigation)
(fn [^js evn]
(let [selected-tab-index (.-selectedTabIndex evn)
comp (get tab-root-ids selected-tab-index)
tab-key (get (clojure.set/map-invert tab-key-idx) selected-tab-index)]
(re-frame/dispatch [:set :current-tab tab-key])
(when (= @state/root-comp-id comp)
(when (= :chat tab-key)
(re-frame/dispatch [:close-chat]))
(when platform/android?
(.popToRoot Navigation (name comp))))
(reset! state/root-comp-id comp)))))
;; OVERLAY (Popover and bottom sheets)
(defn dissmiss-overlay [comp]
(.catch (.dismissOverlay Navigation comp) #()))
(defn show-overlay [comp]
(dissmiss-overlay comp)
(.showOverlay Navigation
(clj->js
{:component {:name comp
:id comp
:options (merge (cond-> (roots/status-bar-options)
(and platform/android? (not (quo.colors/dark?)))
(assoc-in [:statusBar :backgroundColor] "#99999A"))
{:layout {:componentBackgroundColor (if platform/android?
(:backdrop @quo.colors/theme)
"transparent")}
:overlay {:interceptTouchOutside true}})}})))
;; POPOVER
(defonce popover-reg
(.registerComponent Navigation
"popover"
(fn [] (gestureHandlerRootHOC views/popover-comp))
(fn [] views/popover-comp)))
(re-frame/reg-fx :show-popover (fn [] (show-overlay "popover")))
(re-frame/reg-fx :hide-popover (fn [] (dissmiss-overlay "popover")))
;; VISIBILITY STATUS POPOVER
(defonce visibility-status-popover-reg
(.registerComponent Navigation
"visibility-status-popover"
(fn [] (gestureHandlerRootHOC views/visibility-status-popover-comp))
(fn [] views/visibility-status-popover-comp)))
(re-frame/reg-fx :show-visibility-status-popover
(fn [] (show-overlay "visibility-status-popover")))
(re-frame/reg-fx :hide-visibility-status-popover
(fn [] (dissmiss-overlay "visibility-status-popover")))
;; BOTTOM SHEETS
(defonce bottom-sheet-reg
(.registerComponent Navigation
"bottom-sheet"
(fn [] (gestureHandlerRootHOC views/sheet-comp))
(fn [] views/sheet-comp)))
(re-frame/reg-fx :show-bottom-sheet (fn [] (show-overlay "bottom-sheet")))
(re-frame/reg-fx :hide-bottom-sheet (fn [] (dissmiss-overlay "bottom-sheet")))
;; WALLET CONNECT
(defonce wallet-connect-sheet-reg
(.registerComponent Navigation
"wallet-connect-sheet"
(fn [] (gestureHandlerRootHOC views/wallet-connect-comp))
(fn [] views/wallet-connect-comp)))
(defonce wallet-connect-success-sheet-reg
(.registerComponent Navigation
"wallet-connect-success-sheet"
(fn [] (gestureHandlerRootHOC views/wallet-connect-success-comp))
(fn [] views/wallet-connect-success-comp)))
(defonce wallet-connect-app-management-sheet-reg
(.registerComponent Navigation
"wallet-connect-app-management-sheet"
(fn [] (gestureHandlerRootHOC views/wallet-connect-app-management-comp))
(fn [] views/wallet-connect-app-management-comp)))
(re-frame/reg-fx :show-wallet-connect-sheet (fn [] (show-overlay "wallet-connect-sheet")))
(re-frame/reg-fx :hide-wallet-connect-sheet (fn [] (dissmiss-overlay "wallet-connect-sheet")))
(re-frame/reg-fx :show-wallet-connect-success-sheet (fn [] (show-overlay "wallet-connect-success-sheet")))
(re-frame/reg-fx :hide-wallet-connect-success-sheet (fn [] (dissmiss-overlay "wallet-connect-success-sheet")))
(re-frame/reg-fx :show-wallet-connect-app-management-sheet (fn [] (show-overlay "wallet-connect-app-management-sheet")))
(re-frame/reg-fx :hide-wallet-connect-app-management-sheet (fn [] (dissmiss-overlay "wallet-connect-app-management-sheet")))
;; SIGNING
(defonce signing-sheet-reg
(.registerComponent Navigation
"signing-sheet"
(fn [] (gestureHandlerRootHOC views/signing-comp))
(fn [] views/signing-comp)))
(re-frame/reg-fx :show-signing-sheet (fn [] (show-overlay "signing-sheet")))
(re-frame/reg-fx :hide-signing-sheet (fn [] (dissmiss-overlay "signing-sheet")))
;; Select account
;; TODO why is this not a regular bottom sheet ?
(defonce select-acc-sheet-reg
(.registerComponent Navigation
"select-acc-sheet"
(fn [] (gestureHandlerRootHOC views/select-acc-comp))
(fn [] views/select-acc-comp)))
(re-frame/reg-fx :show-select-acc-sheet (fn [] (show-overlay "select-acc-sheet")))
(re-frame/reg-fx :hide-select-acc-sheet (fn [] (dissmiss-overlay "select-acc-sheet")))
;; NAVIGATION
(re-frame/reg-fx
:navigate-to-fx
(fn [key]
(log/debug :navigate-to-fx key)
(navigate key)))
(re-frame/reg-fx
:navigate-back-fx
(fn []
(log/debug :navigate-back-fx)
(if @state/curr-modal
(dissmissModal)
(.pop Navigation (name @state/root-comp-id)))))
(re-frame/reg-fx
:navigate-replace-fx
(fn [view-id]
(log/debug :navigate-replace-fx view-id)
(.pop Navigation (name @state/root-comp-id))
(navigate view-id)))
(def community-screens '(:community-management
:community-members
:community-requests-to-join
:create-community-channel
:community-emoji-thumbnail-picker
:create-community-category
:community-edit-chats
:community-edit
:community-reorder-categories))
;; change view-id if it is still same after component is disappeared
;; https://github.com/wix/react-native-navigation/issues/5744#issuecomment-563226820
(fx/defn view-disappeared
{:events [::view-disappeared]}
[{:keys [db]} view-id]
(when (= view-id (:view-id db))
{:db (assoc db :view-id (cond
(= view-id :community-emoji-thumbnail-picker)
:create-community-channel
(some #(= view-id %) community-screens)
:community
:else
:home))
:dispatch-n (enc/conj-when []
(and (= view-id :chat) [:chat.ui/sync-all-deleted-for-me-messages]))}))

View File

@ -1,193 +0,0 @@
(ns status-im.navigation.roots
(:require [quo.design-system.colors :as colors]
[status-im.utils.platform :as platform]
[status-im.ui.components.icons.icons :as icons]
[status-im.ui.screens.views :as views]
[status-im.navigation2.roots :as nav2-roots]))
(defn status-bar-options []
(if platform/android?
{:navigationBar {:backgroundColor colors/white}
:statusBar {:backgroundColor colors/white
:style (if (colors/dark?) :light :dark)}}
{:statusBar {:style (if (colors/dark?) :light :dark)}}))
(defn topbar-options []
{:noBorder true
:scrollEdgeAppearance {:active false
:noBorder true}
:elevation 0
:title {:color colors/black}
:rightButtonColor colors/black
:background {:color colors/white}
:backButton {:icon (icons/icon-source :main-icons/arrow-left)
:color colors/black}})
(defn bottom-tab-general [icon accessibility]
(merge
{:testID accessibility
:accessibilityLabel accessibility
:fontSize 11
:icon (icons/icon-source icon)
:badgeColor colors/blue
:dotIndicator {:color colors/blue :visible false :size 10}
:iconColor colors/gray :selectedIconColor colors/blue
:textColor colors/gray :selectedTextColor colors/blue}
(when platform/android?
{:badge ""})))
(defn default-root []
{:layout {:componentBackgroundColor colors/white
:orientation "portrait"
:backgroundColor colors/white}})
(defn merge-top-bar [root-options options]
(let [options (:topBar options)]
{:topBar
(merge root-options
options
(when (or (:title root-options) (:title options))
{:title (merge (:title root-options) (:title options))})
(when (or (:background root-options) (:background options))
{:background (merge (:background root-options) (:background options))})
(when (or (:backButton root-options) (:backButton options))
{:backButton (merge (:backButton root-options) (:backButton options))})
(when (or (:leftButtons root-options) (:leftButtons options))
{:leftButtons (merge (:leftButtons root-options) (:leftButtons options))})
(when (or (:rightButtons root-options) (:rightButtons options))
{:rightButtons (merge (:rightButtons root-options) (:rightButtons options))}))}))
(defn get-screen-options [screen]
(merge (get-in views/screens [screen :options])
(status-bar-options)
(merge-top-bar (topbar-options)
(get-in views/screens [screen :options]))))
;;TODO problem here is that we have two places for screens, here and in screens ns, and we have handler in navigate
(defn roots []
;;TABS
(merge
{:chat-stack
{:root
{:bottomTabs
{:id :tabs-stack
:options (merge (default-root)
{:bottomTabs {:titleDisplayMode :alwaysHide
:tabsAttachMode :onSwitchToTab
:backgroundColor colors/white}})
:children [;CHAT STACK
{:stack {:id :chat-stack
:children [{:component {:name :home
:id :home
:options (merge (status-bar-options)
{:topBar (assoc (topbar-options) :visible false)})}}]
:options {:bottomTab (bottom-tab-general :main-icons/message :home-tab-button)}}}
;BROWSER STACK
{:stack {:id :browser-stack
:children [{:component {:name :empty-tab
:id :empty-tab
:options (merge (status-bar-options)
{:topBar (assoc (topbar-options) :visible false)})}}]
:options {:bottomTab (bottom-tab-general :main-icons/browser :dapp-tab-button)}}}
;WALLET STACK
{:stack {:id :wallet-stack
:children [{:component {:name :wallet
:id :wallet
:options (merge (status-bar-options)
{:topBar (assoc (topbar-options) :visible false)})}}]
:options {:bottomTab (bottom-tab-general :main-icons/wallet :wallet-tab-button)}}}
;STATUS STACK
{:stack {:id :status-stack
:children [{:component {:name :status
:id :status
:options (merge (status-bar-options)
{:topBar (assoc (topbar-options) :visible false)})}}]
:options {:bottomTab (bottom-tab-general :main-icons/status :status-tab-button)}}}
;PROFILE STACK
{:stack {:id :profile-stack
:children [{:component {:name :my-profile
:id :my-profile
:options (merge (status-bar-options)
{:topBar (assoc (topbar-options) :visible false)})}}]
:options {:bottomTab (bottom-tab-general :main-icons/user-profile :profile-tab-button)}}}]}}}
;;INTRO (onboarding carousel)
:intro
{:root {:stack {:children [{:component {:name :intro
:id :intro
:options (status-bar-options)}}]
:options (merge (default-root)
(status-bar-options)
{:topBar (assoc (topbar-options) :visible false)})}}}
;; ONBOARDING
:onboarding
{:root {:stack {:id :onboarding
:children [{:component {:name :get-your-keys
:id :get-your-keys
:options (status-bar-options)}}]
:options (merge (default-root)
(status-bar-options)
{:topBar (assoc (topbar-options) :elevation 0 :noBorder true :animate false)})}}}
;;PROGRESS
:progress
{:root {:stack {:children [{:component {:name :progress
:id :progress
:options (status-bar-options)}}]
:options (merge (default-root)
{:topBar (assoc (topbar-options) :visible false)})}}}
;;LOGIN
:multiaccounts
{:root {:stack {:id :multiaccounts-stack
:children [{:component {:name :multiaccounts
:id :multiaccounts
:options (get-screen-options :multiaccounts)}}
{:component {:name :login
:id :login
:options (get-screen-options :login)}}]
:options (merge (default-root)
(status-bar-options)
{:topBar (topbar-options)})}}}
:multiaccounts-keycard
{:root {:stack {:id :multiaccounts-stack
:children [{:component {:name :multiaccounts
:id :multiaccounts
:options (get-screen-options :multiaccounts)}}
{:component {:name :keycard-login-pin
:id :keycard-login-pin
:options (get-screen-options :keycard-login-pin)}}]
:options (merge (default-root)
(status-bar-options)
{:topBar (topbar-options)})}}}
;;WELCOME
:welcome
{:root {:stack {:children [{:component {:name :welcome
:id :welcome
:options (status-bar-options)}}]
:options (merge (default-root)
(status-bar-options)
{:topBar (assoc (topbar-options) :visible false)})}}}
;;NOTIFICATIONS
:onboarding-notification
{:root {:stack {:children [{:component {:name :onboarding-notification
:id :onboarding-notification
:options (status-bar-options)}}]
:options (merge (default-root)
(status-bar-options)
{:topBar (assoc (topbar-options) :visible false)})}}}
;; TERMS OF SERVICE
:tos
{:root {:stack {:children [{:component {:name :force-accept-tos
:id :force-accept-tos
:options (get-screen-options :force-accept-tos)}}]
:options (merge (default-root)
(status-bar-options)
{:topBar (assoc (topbar-options) :visible false)})}}}}
(nav2-roots/roots)))

View File

@ -1,60 +0,0 @@
(ns status-im.navigation2
(:require [status-im.utils.fx :as fx]
[status-im.reloader :as reloader]
[status-im.utils.datetime :as datetime]))
(def parent-stack (atom :shell-stack))
(fx/defn reload-new-ui
{:events [:reload-new-ui]}
[_]
(reloader/reload)
{:new-ui/reset-bottom-tabs nil
:dispatch [:init-root :shell-stack]})
(fx/defn init-root-nav2
{:events [:init-root-nav2]}
[_ root-id]
{:init-root-fx-nav2 root-id})
(fx/defn open-modal-nav2
{:events [:open-modal-nav2]}
[_ modal]
{:open-modal-fx-nav2 modal})
(fx/defn close-modal-nav2
{:events [:close-modal-nav2]}
[_ modal]
{:close-modal-fx-nav2 modal})
(defn navigate-from-shell-stack [go-to-view-id id db]
(reset! parent-stack go-to-view-id)
{:navigate-to-fx-nav2 [go-to-view-id id]
:db (assoc-in db [:navigation2/navigation2-stacks id] {:type go-to-view-id
:id id
:clock (datetime/timestamp)})})
(defn navigate-from-switcher [go-to-view-id id db from-home?]
(reset! parent-stack go-to-view-id)
{:navigate-from-switcher-fx [go-to-view-id id from-home?]
:db (assoc-in db [:navigation2/navigation2-stacks id] {:type go-to-view-id
:id id
:clock (datetime/timestamp)})})
(fx/defn navigate-to-nav2
{:events [:navigate-to-nav2]}
[{:keys [db]} go-to-view-id id _ from-switcher?]
(let [view-id (:view-id db)
from-home? (= view-id :chat-stack)]
(if from-switcher?
(navigate-from-switcher go-to-view-id id db from-home?)
(if from-home?
(navigate-from-shell-stack go-to-view-id id db)
;; TODO(parvesh) - new stacks created from other screens should be stacked on current stack, instead of creating new entry
(navigate-from-shell-stack go-to-view-id id db)))))
(fx/defn change-root-status-bar-style
{:events [:change-root-status-bar-style]}
[_ style]
{:change-root-status-bar-style-fx style})

View File

@ -1,85 +0,0 @@
(ns status-im.navigation2.core
(:require [re-frame.core :as re-frame]
[quo2.foundations.colors :as colors]
[status-im.ui.screens.views :as views]
[status-im.navigation2.roots :as roots]
[status-im.utils.platform :as platform]
[status-im.navigation.roots :as nav-roots]
[status-im.navigation2.utils :as nav2-utils]
["react-native-navigation" :refer (Navigation)]))
(def tab-key-idx {:home 0
:communities 1
:wallet 2
:browser 3})
(defn change-root-status-bar-style [style]
(.mergeOptions Navigation
"shell-stack"
(clj->js {:statusBar {:style style}})))
;; TODO (parvesh) - improve open-modal and close-modal
(defn open-modal [comp]
(.showModal Navigation
(clj->js {:stack {:children
[{:component
{:name comp
:id comp
:options {:topBar {:visible false}}}}]}})))
(defn close-modal [_])
(defn close-all-modals []
(.dismissAllModals Navigation))
(defn get-id [comp id]
(str comp "-" id))
(defn get-options [show-topbar? options]
(merge options
(roots/status-bar-options)
(when platform/android?
{:navigationBar {:backgroundColor (colors/theme-colors colors/white colors/neutral-90)}})
(if show-topbar?
(nav-roots/merge-top-bar (nav-roots/topbar-options) options)
{:topBar {:visible false}})))
(defn change-stack-root [[comp _]]
(let [{:keys [options]} (get views/screens comp)]
(.setStackRoot Navigation
(name comp)
(clj->js {:stack {:id comp
:children [{:component {:id comp
:name comp
:options (get-options false options)}}]}}))))
(defn navigate [[comp _]]
(let [{:keys [options]} (get views/screens comp)]
(reset! nav2-utils/container-stack-view-id comp)
(.push Navigation
"shell-stack"
(clj->js {:stack {:id comp
:children [{:component {:id comp
:name comp
:options (get-options false options)}}]}}))))
(defn navigate-from-switcher [[comp id from-home?]]
(if from-home?
(navigate [comp id])
(change-stack-root [comp id])))
(re-frame/reg-fx
:init-root-fx-nav2
(fn [new-root-id]
(reset! nav2-utils/container-stack-view-id new-root-id)
(.setRoot Navigation (clj->js (get (roots/roots) new-root-id)))))
(re-frame/reg-fx :open-modal-fx-nav2 open-modal)
(re-frame/reg-fx :close-modal-fx-nav2 close-modal)
(re-frame/reg-fx :navigate-to-fx-nav2 navigate)
(re-frame/reg-fx :navigate-from-switcher-fx navigate-from-switcher)
(re-frame/reg-fx :change-root-status-bar-style-fx change-root-status-bar-style)

View File

@ -1,20 +0,0 @@
(ns status-im.navigation2.roots
(:require [quo2.foundations.colors :as colors]
[status-im.utils.platform :as platform]))
(defn status-bar-options []
(if platform/android?
{:navigationBar {:backgroundColor colors/neutral-100}
:statusBar {:backgroundColor :transparent
:style :light
:drawBehind true}}
{:statusBar {:style :light}}))
(defn roots []
{:shell-stack
{:root
{:stack {:id :shell-stack
:children [{:component {:name :chat-stack
:id :chat-stack
:options (merge (status-bar-options)
{:topBar {:visible false}})}}]}}}})

View File

@ -1,22 +0,0 @@
(ns status-im.navigation2.screens
(:require [status-im.ui2.screens.chat.view :as chat]
[status-im.switcher.shell-stack :as shell-stack]
[status-im.ui2.screens.communities.discover-communities :as discover-communities]))
;; We have to use the home screen name :chat-stack for now, for compatibility with navigation.cljs
(def screens [{:name :chat-stack ;; TODO(parvesh) - rename to shell-stack
:insets {:top false}
:component shell-stack/shell-stack}
{:name :discover-communities
;;TODO animated-header scroll behaviours
:options {:topBar {:visible false}}
:component discover-communities/communities}])
;; These screens will overwrite navigation/screens.cljs screens on enabling new UI toggle
(def screen-overwrites
[{:name :chat
:options {:topBar {:visible false}}
:component chat/chat}])

View File

@ -1,3 +0,0 @@
(ns status-im.navigation2.utils)
(defonce container-stack-view-id (atom nil))

View File

@ -5,7 +5,7 @@
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.i18n.i18n :as i18n]
[status-im.node.core :as node]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[status-im.utils.http :as http]
[status-im.utils.types :as types]))

View File

@ -51,7 +51,7 @@
(js->clj % :keywordize-keys true)]))))
(re-frame/reg-fx
::listen-to-network-info
:network/listen-to-network-info
(fn []
(add-net-info-listener)))

View File

@ -2,7 +2,7 @@
(:require [re-frame.core :as re-frame]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.i18n.i18n :as i18n]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.config :as config]
[status-im.utils.fx :as fx]
[status-im.utils.platform :as utils.platform]

View File

@ -3,7 +3,7 @@
[status-im.i18n.i18n :as i18n]
[status-im.chat.models :as chat]
[status-im.router.core :as router]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.utils :as utils]
[status-im.ethereum.core :as ethereum]
[status-im.add-new.db :as new-chat.db]

View File

@ -1,6 +1,5 @@
(ns status-im.router.core
(:require [bidi.bidi :as bidi]
[cljs.spec.alpha :as spec]
[clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.add-new.db :as public-chat.db]
@ -65,7 +64,7 @@
(defn match-contact-async
[chain {:keys [user-id ens-name]} callback]
(let [valid-key (and (spec/valid? :global/public-key user-id)
(let [valid-key (and (utils.db/valid-public-key? user-id)
(not= user-id ens/default-key))]
(cond
valid-key
@ -200,7 +199,7 @@
(= handler :group-chat)
(cb (match-group-chat chats query-params))
(spec/valid? :global/public-key uri)
(utils.db/valid-public-key? uri)
(match-contact-async chain {:user-id uri} cb)
(= handler :community-requests)

View File

@ -1,6 +1,6 @@
(ns status-im.search.core-test
(:require [cljs.test :refer-macros [deftest testing is]]
[status-im.subs.search :as search.subs]))
[status-im2.subs.search :as search.subs]))
(defn extract-chat-attributes [chat]
(let [{:keys [name alias tags]} (val chat)]

View File

@ -3,7 +3,7 @@
[re-frame.core :as re-frame]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[status-im.utils.utils :as utils]
[status-im.utils.config :as config]

View File

@ -1,25 +1,9 @@
(ns status-im.ui.components.tabbar.core
(:require [re-frame.core :as re-frame]
[status-im.utils.platform :as platform]))
(:require [status-im.utils.platform :as platform]))
(defn get-height []
(if platform/android?
56
(if platform/iphone-x?
84
50)))
(defn chat-tab []
(let [count-subscription @(re-frame/subscribe [:chats/unread-messages-number])]
(re-frame/dispatch [:change-tab-count :chat count-subscription])
nil))
(defn profile-tab []
(let [count-subscription @(re-frame/subscribe [:get-profile-unread-messages-number])]
(re-frame/dispatch [:change-tab-count :profile count-subscription])
nil))
(defn tabs-counts-subscriptions []
[:<>
[chat-tab]
[profile-tab]])
50)))

View File

@ -36,7 +36,7 @@
[status-im.utils.utils :as utils]
[status-im.ui.screens.chat.sheets :as sheets]
[status-im.utils.debounce :as debounce]
[status-im.navigation.state :as navigation.state]
[status-im2.navigation.state :as navigation.state]
[status-im.react-native.resources :as resources]))
(defn invitation-requests [chat-id admins]

View File

@ -1,6 +1,5 @@
(ns status-im.ui.screens.group.views
(:require [cljs.spec.alpha :as spec]
[clojure.string :as string]
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[reagent.core :as reagent]
[status-im.constants :as constants]
@ -100,7 +99,7 @@
(views/defview new-group []
(views/letsubs [contacts [:selected-group-contacts]
group-name [:new-chat-name]]
(let [group-name-empty? (not (spec/valid? :global/not-empty-string group-name))]
(let [group-name-empty? (not (and (string? group-name) (not-empty group-name)))]
[react/keyboard-avoiding-view {:style styles/group-container
:ignore-offset true}
[react/view {:flex 1}

View File

@ -21,7 +21,6 @@
[status-im.ui.components.topbar :as topbar]
[status-im.ui.components.plus-button :as components.plus-button]
[status-im.ui.screens.chat.sheets :as sheets]
[status-im.ui.components.tabbar.core :as tabbar]
[status-im.ui.components.invite.views :as invite]
[status-im.utils.config :as config]
[quo2.components.markdown.text :as quo2.text]
@ -340,8 +339,7 @@
:margin-bottom 8}
[quo2.text/text {:size :heading-1 :weight :semi-bold} (i18n/label :t/messages)]
[plus-button]]
[chats-list]
[tabbar/tabs-counts-subscriptions]])
[chats-list]])
(defn home-old []
[react/keyboard-avoiding-view {:style {:flex 1}
@ -352,5 +350,4 @@
[connectivity/connectivity-button]
[notifications-button-old]]}]
[chats-list-old]
[plus-button-old]
[tabbar/tabs-counts-subscriptions]])
[plus-button-old]])

View File

@ -9,8 +9,7 @@
[status-im.ui.components.react :as react]
[status-im.ui.screens.keycard.pin.styles :as styles]
[status-im.ui.components.checkbox.view :as checkbox]
[status-im.utils.platform :as platform]
[status-im.utils.utils :as utils]))
[status-im.utils.platform :as platform]))
(def default-pin-retries-number 3)
(def default-puk-retries-number 5)
@ -164,7 +163,6 @@
(case new-status
:error (when (or (nil? previous-status)
(= :verifying previous-status))
(utils/vibrate)
(reset! !error? true)
(animate-info-in error-y-translation
error-opacity

View File

@ -20,7 +20,7 @@
[status-im.ui.screens.keycard.frozen-card.view :as frozen-card.view]
[status-im.multiaccounts.create.core :as multiaccounts.create]
[status-im.bottom-sheet.core :as bottom-sheet]
[status-im.navigation :as navigation])
[status-im2.navigation.events :as navigation])
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
;; NOTE(Ferossgp): Seems like it should be in popover

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,6 @@
[status-im.utils.utils :as utils]
[status-im.ui.components.topbar :as topbar]
[status-im.ui.components.plus-button :as components.plus-button]
[status-im.ui.components.tabbar.core :as tabbar]
[status-im.ui.components.invite.views :as invite]
[status-im.utils.handlers :refer [<sub >evt]]
[status-im.utils.config :as config]
@ -377,6 +376,5 @@
:margin-bottom 20}
[quo2.text/text {:size :heading-1 :weight :semi-bold} (i18n/label :t/messages)]
[plus-button]]
[chats-list]
[tabbar/tabs-counts-subscriptions]])])
[chats-list]])])

View File

@ -439,7 +439,7 @@
(when pinned (pin-message message))
(re-frame/dispatch
[:chat.ui/delete-message-for-me message
config/delete-message-for-me-undo-time-limit-ms]))
constants/delete-message-for-me-undo-time-limit-ms]))
:label (i18n/label :t/delete-for-me)
:icon :i/delete
:id :delete-for-me}]
@ -590,7 +590,7 @@
[{:type :danger
:on-press #(re-frame/dispatch
[:chat.ui/delete-message-for-me message
config/delete-message-for-me-undo-time-limit-ms])
constants/delete-message-for-me-undo-time-limit-ms])
:label (i18n/label :t/delete-for-me)
:icon :i/delete-context20
:id :delete-for-me}]
@ -627,7 +627,7 @@
{:type :danger
:on-press #(re-frame/dispatch
[:chat.ui/delete-message-for-me message
config/delete-message-for-me-undo-time-limit-ms])
constants/delete-message-for-me-undo-time-limit-ms])
:label (i18n/label :t/delete-for-me)
:icon :i/delete-context20
:id :delete-for-me}

View File

@ -8,7 +8,7 @@
[quo2.components.buttons.button :as quo2.button]
[quo2.foundations.colors :as colors]
[status-im.ui.components.react :as react]
[status-im.navigation.state :as navigation.state]
[status-im2.navigation.state :as navigation.state]
[status-im.ui2.screens.chat.messages.view :as messages]
[status-im.utils.handlers :refer [<sub >evt]]
[status-im.ui.components.icons.icons :as icons]

View File

@ -3,7 +3,8 @@
[clojure.string :as string]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.ens :as ens]))
;;TODO (14/11/22 flexsurfer) this namespace has been moved to the status-im2 namespace, we keep this only for old (status 1.0) code,
;; can be removed with old code later
(def config
(memoize
(fn []
@ -15,9 +16,6 @@
(defn enabled? [v] (= "1" v))
;; NOTE(oskarth): Feature flag deprecation lifecycles. We want to make sure
;; flags stay up to date and are removed once behavior introduced is stable.
(goog-define POKT_TOKEN "3ef2018191814b7e1009b8d9")
(goog-define OPENSEA_API_KEY "")
@ -151,5 +149,3 @@
;; TODO: Remove this (highly) temporary flag once the new Activity Center is
;; usable enough to replace the old one **in the new UI**.
(def new-activity-center-enabled? false)
(def delete-message-for-me-undo-time-limit-ms 4000)

View File

@ -1,5 +1,4 @@
(ns status-im.utils.core
(:require [clojure.string :as string]))
(ns status-im.utils.core)
(defn truncate-str-memo
"Given string and max threshold, trims the string to threshold length with `...`
@ -20,12 +19,6 @@
(def truncate-str (memoize truncate-str-memo))
(defn clean-text [s]
(-> s
(string/replace #"\n" "")
(string/replace #"\r" "")
(string/trim)))
(defn first-index
"Returns first index in coll where predicate on coll element is truthy"
[pred coll]
@ -35,31 +28,6 @@
idx)))
first))
(defn hash-tag? [s]
(= \# (first s)))
(defn update-if-present
"Like regular `clojure.core/update` but returns original map if update key is not present"
[m k f & args]
(if (contains? m k)
(apply update m k f args)
m))
(defn map-values
"Efficiently apply function to all map values"
[f m]
(into {}
(map (fn [[k v]]
[k (f v)]))
m))
(defn deep-merge
"Recursively merge maps"
[& maps]
(if (every? map? maps)
(apply merge-with deep-merge maps)
(last maps)))
(defn index-by
"Given a collection and a unique key function, returns a map that indexes the collection.
Similar to group-by except that the map values are single objects (depends on key uniqueness)."

View File

@ -1,9 +1,4 @@
(ns status-im.utils.db
(:require [cljs.spec.alpha :as spec]))
(ns status-im.utils.db)
(defn valid-public-key? [s]
(boolean (re-matches #"0x04[0-9a-f]{128}" s)))
(spec/def :global/not-empty-string (spec/and string? not-empty))
(spec/def :global/public-key (spec/and :global/not-empty-string valid-public-key?))
(and (string? s) (not-empty s) (boolean (re-matches #"0x04[0-9a-f]{128}" s))))

View File

@ -2,13 +2,10 @@
(:require [re-frame.core :as re-frame]
[status-im.ui.components.react :as react]))
(declare window)
(defn add-event-listener []
(.addEventListener ^js react/dimensions
"change"
#(do
(re-frame/dispatch [:update-window-dimensions %]))))
#(re-frame/dispatch-sync [:update-window-dimensions %])))
(defn window
([]

View File

@ -1,5 +1,5 @@
(ns status-im.utils.logging.core
(:require ["react-native-mail" :default react-native-mail]
(:require [react-native.mail :as react-native-mail]
[clojure.string :as string]
[goog.string :as gstring]
[re-frame.core :as re-frame]
@ -9,54 +9,22 @@
[status-im.transport.utils :as transport.utils]
[status-im.ui.components.react :as react]
[status-im.utils.build :as build]
[status-im.utils.config :as config]
[status-im.utils.datetime :as datetime]
[status-im.utils.fx :as fx]
[status-im.utils.platform :as platform]
[status-im.utils.types :as types]
[taoensso.timbre :as log]))
[status-im2.setup.log :as log]))
(def report-email "error-reports@status.im")
(def max-log-entries 1000)
(def logs-queue (atom #queue[]))
(defn add-log-entry [entry]
(swap! logs-queue conj entry)
(when (>= (count @logs-queue) max-log-entries)
(swap! logs-queue pop)))
(defn init-logs [level]
(when-not (string/blank? level)
(log/set-level! (-> level
string/lower-case
keyword))
(log/merge-config!
{:output-fn (fn [& data]
(let [res (apply log/default-output-fn data)]
(add-log-entry res)
res))})))
(defn get-js-logs []
(string/join "\n" @logs-queue))
(re-frame/reg-fx
:logs/archive-logs
(fn [[db-json callback-handler]]
(status/send-logs
db-json
(get-js-logs)
(string/join "\n" (log/get-logs-queue))
#(re-frame/dispatch [callback-handler %]))))
(re-frame/reg-fx
:logs/set-level
(fn [level]
(init-logs level)))
(fx/defn set-log-level
[{:keys [db]} log-level]
(let [log-level (or log-level config/log-level)]
{:db (assoc-in db [:multiaccount :log-level] log-level)
:logs/set-level log-level}))
(defn email-body
"logs attached"
[{:keys [:web3-node-version :mailserver/current-id
@ -188,9 +156,8 @@
(re-frame/reg-fx
:email/send
;; https://github.com/chirag04/react-native-mail#example
(fn [[opts callback]]
(.mail react-native-mail (clj->js opts) callback)))
(react-native-mail/mail (clj->js opts) callback)))
(re-frame/reg-fx
::share-archive

View File

@ -1,75 +0,0 @@
(ns status-im.utils.number
(:require [goog.string :as gstring]
[goog.string.format]))
(defn naive-round
"Quickly and naively round number `n` up to `decimal-places`.
Example usage: use it to avoid re-renders caused by floating-point number
changes in Reagent atoms. Such numbers can be rounded up to a certain number
of `decimal-places` in order to avoid re-rendering due to tiny fractional
changes.
Don't use this function for arbitrary-precision arithmetic."
[n decimal-places]
(let [scale (Math/pow 10 decimal-places)]
(/ (Math/round (* n scale))
scale)))
(defn- caught-invalid-number []
(throw (js/Error "Invalid Number")))
(defn- with-precision [precision input-number]
(gstring/format (str "%." precision "f") input-number))
(defn- is-bad-number [number-string]
(nil? (re-find #"^\d+(\.\d{1,9})?$" number-string)))
(defn- with-precision-division [numerator-num denominator-num precision]
(->> (/ numerator-num denominator-num)
(with-precision precision)))
(defn- number->formatted-number [number-string precision]
(let [parsed-number (js/parseInt number-string 10)
numeric-value (if (or (neg? number-string)
(is-bad-number (str number-string)))
(caught-invalid-number)
parsed-number)
million 1000000
billion 1000000000
>=-and-< #(and
(>= %1 %2)
(< %1 %3))
unit (cond
(>=-and-< parsed-number billion js/Number.MAX_SAFE_INTEGER) "b"
(>=-and-< parsed-number million billion) "m"
:else
"k")
denominator (cond
(= unit "m") million
(= unit "b") billion
:else 1000)]
(if (js/isNaN numeric-value)
(caught-invalid-number)
(if (>= numeric-value 1000)
(str (with-precision-division numeric-value denominator precision)
unit)
(str numeric-value)))))
(defn format-number
"Returns the thousands in a number in kilo format
Arguments:
number-string (or string int) The input of value of the number
Examples:
[1000 0] -> 1k
[1001 0] -> 1k
[10000 0] -> 10k
[5000 0] -> 5k
[5000 0] -> 5k
[5000000 0] -> 5m
[5000 0] -> 5k"
[number-string precision]
(number->formatted-number number-string precision))

View File

@ -1,27 +0,0 @@
(ns status-im.utils.number-test
(:require [cljs.test :refer-macros [deftest testing are]]
[status-im.utils.number :as number]))
(deftest format-number-test
(testing "Positive cases"
(are [input-number precision expected] (= (number/format-number input-number precision) expected)
"100" 0 "100"
"1000" 0 "1k"
"10000" 0 "10k"
"11000" 1 "11.0k"
"11000" 0 "11k"
"11010" 3 "11.010k"
"5200000" 3 "5.200m"
"1000000000" 0 "1b"
"1110000000" 2 "1.11b"
"9000000" 0 "9m"))
(testing "Negative cases"
(are [input-number precision] (thrown-with-msg? js/Error #"Invalid Number" (number/format-number input-number precision))
js/undefined 0
nil 0
"-1" 0
"" 0
js/NaN 0
"1e3" 0
"10,2" 0
"6hello" 0)))

View File

@ -1,16 +0,0 @@
(ns status-im.utils.theme
(:require ["react-native" :refer (Appearance)]
[oops.core :refer [ocall]]))
(def initial-mode (atom (ocall Appearance "getColorScheme")))
;; Note - don't use value returned by change listener
;; https://github.com/facebook/react-native/issues/28525
(defn add-mode-change-listener [callback]
(ocall Appearance "addChangeListener" #(let [mode (ocall Appearance "getColorScheme")]
(when-not (= mode @initial-mode)
(reset! initial-mode mode)
(callback (keyword mode))))))
(defn is-dark-mode []
(= @initial-mode "dark"))

View File

@ -10,7 +10,7 @@
[status-im.ethereum.core :as ethereum]
[status-im.ui.components.react :as react]
[status-im.add-new.db :as new-chat.db]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[taoensso.timbre :as log]
[status-im.wallet.choose-recipient.core :as choose-recipient]

View File

@ -2,12 +2,14 @@
(:require [clojure.string :as string]
[goog.string :as gstring]
[status-im.i18n.i18n :as i18n]
[re-frame.core :as re-frame]
[status-im.ethereum.eip55 :as eip55]
[status-im.ethereum.core :as ethereum]
["react-native" :as react-native]
["react-native-background-timer" :default background-timer]))
["react-native-background-timer" :default background-timer]
[re-frame.core :as re-frame]))
;;TODO (14/11/22 flexsurfer) .-Alert usage code has been moved to the status-im2 namespace, we keep this only for old (status 1.0) code,
;; can be removed with old code later
(defn show-popup
([title content]
(show-popup title content nil))
@ -23,14 +25,6 @@
(when on-dismiss
(clj->js {:cancelable false})))))
(defn vibrate []
#_(.vibrate (.-Vibration react-native)))
(re-frame/reg-fx
:utils/show-popup
(fn [{:keys [title content on-dismiss]}]
(show-popup title content on-dismiss)))
(defn show-confirmation
[{:keys [title content confirm-button-text on-accept on-cancel cancel-button-text
extra-options]}]
@ -51,17 +45,6 @@
(or extra-options nil)))
#js {:cancelable false}))
(re-frame/reg-fx
:utils/show-confirmation
(fn [{:keys [title content confirm-button-text on-accept on-cancel cancel-button-text extra-options]}]
(show-confirmation {:title title
:content content
:confirm-button-text confirm-button-text
:cancel-button-text cancel-button-text
:on-accept on-accept
:on-cancel on-cancel
:extra-options extra-options})))
(defn show-question
([title content on-accept]
(show-question title content on-accept nil))
@ -77,6 +60,36 @@
:onPress on-accept
:accessibility-label :yes-button})))))
;;TODO (14/11/22 flexsurfer) background-timer usage code has been moved to the status-im2 namespace, we keep this only for old (status 1.0) code,
;; can be removed with old code later
(defn set-timeout [cb ms]
(.setTimeout background-timer cb ms))
(defn clear-timeout [id]
(.clearTimeout background-timer id))
(defn set-interval [cb ms]
(.setInterval background-timer cb ms))
(defn clear-interval [id]
(.clearInterval background-timer id))
(re-frame/reg-fx
:utils/dispatch-later
(fn [params]
(doseq [{:keys [ms dispatch]} params]
(when (and ms dispatch)
(set-timeout #(re-frame/dispatch dispatch) ms)))))
(re-frame/reg-fx
::clear-timeouts
(fn [ids]
(doseq [id ids]
(when id
(clear-timeout id)))))
;;TODO (14/11/22 flexsurfer) haven't moved yet
(defn get-shortened-address
"Takes first and last 4 digits from address including leading 0x
and adds unicode ellipsis in between"
@ -88,36 +101,6 @@
(when address
(get-shortened-address (eip55/address->checksum (ethereum/normalized-hex address)))))
;; background-timer
(defn set-timeout [cb ms]
(.setTimeout background-timer cb ms))
;; same as re-frame dispatch-later but using background timer for long
;; running timeouts
(re-frame/reg-fx
:utils/dispatch-later
(fn [params]
(doseq [{:keys [ms dispatch]} params]
(when (and ms dispatch)
(set-timeout #(re-frame/dispatch dispatch) ms)))))
(defn clear-timeout [id]
(.clearTimeout background-timer id))
(re-frame/reg-fx
::clear-timeouts
(fn [ids]
(doseq [id ids]
(when id
(clear-timeout id)))))
(defn set-interval [cb ms]
(.setInterval background-timer cb ms))
(defn clear-interval [id]
(.clearInterval background-timer id))
(defn format-decimals [amount places]
(let [decimal-part (get (string/split (str amount) ".") 1)]
(if (> (count decimal-part) places)

View File

@ -9,38 +9,12 @@
(is (= (u/truncate-str "Long string" 11) "Long string")) ; threshold is the same as string length
(is (= (u/truncate-str "Long string" 20) "Long string"))) ; threshold is more then string length
(deftest clean-text-test
(is (= (u/clean-text "Hello! \n\r") "Hello!")
(= (u/clean-text "Hello!") "Hello!")))
(deftest first-index-test
(is (= 2 (u/first-index (partial = :test)
'(:a :b :test :c :test))))
(is (= nil (u/first-index (partial = :test)
'(:a :b :c)))))
(deftest hash-tag?-test
(is (u/hash-tag? "#clojure"))
(is (not (u/hash-tag? "clojure")))
(is (not (u/hash-tag? "clo#jure")))
(is (not (u/hash-tag? "clojure#"))))
(deftest update-if-present-test
(is (= {:a 1} (u/update-if-present {:a 0} :a inc)))
(is (= {:a 2} (u/update-if-present {:a 0} :a + 2)))
(is (= {:a 0} (u/update-if-present {:a 0} :b inc))))
(deftest map-values-test
(is (= {} (u/map-values inc {})))
(is (= {:a 1} (u/map-values inc {:a 0})))
(is (= {:a 1 :b 2} (u/map-values inc {:a 0 :b 1}))))
(deftest deep-merge-test
(is (= {} (u/deep-merge {} {})))
(is (= {:a 1 :b 2} (u/deep-merge {:a 1} {:b 2})))
(is (= {:a {:b 1 :c 2}} (u/deep-merge {:a {:b 1 :c 1}} {:a {:c 2}})))
(is (= {:a {:b {:c 2}} :d 1} (u/deep-merge {:a {:b {:c 1}} :d 1} {:a {:b {:c 2}}}))))
(deftest format-decimals-test
(is (= "1" (uu/format-decimals 1 5)))
(is (= "1.1" (uu/format-decimals 1.1 5)))

View File

@ -4,7 +4,7 @@
[status-im.i18n.i18n :as i18n]
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.node.core :as node]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]))
(fx/defn switch-waku-bloom-filter-mode

View File

@ -10,7 +10,7 @@
[status-im.native-module.core :as status]
[quo.design-system.colors :as colors]
[status-im.ui.components.list-selection :as list-selection]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.fx :as fx]
[status-im.utils.types :as types]
[status-im.wallet.core :as wallet]

View File

@ -6,7 +6,7 @@
[status-im.ethereum.eip681 :as eip681]
[status-im.ethereum.ens :as ens]
[status-im.i18n.i18n :as i18n]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.qr-scanner.core :as qr-scaner]
[status-im.router.core :as router]
[status-im.utils.fx :as fx]

View File

@ -8,7 +8,7 @@
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.ethereum.tokens :as tokens]
[status-im.i18n.i18n :as i18n]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.utils.core :as utils.core]
[status-im.utils.fx :as fx]
[status-im.utils.money :as money]

View File

@ -8,7 +8,7 @@
[status-im.ui.components.react :as react]
[status-im.utils.fx :as fx]
[status-im.wallet.core :as wallet]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.wallet.prices :as prices]))
(re-frame/reg-fx

View File

@ -10,7 +10,7 @@
[status-im.ethereum.eip55 :as eip55]
[status-im.i18n.i18n :as i18n]
[status-im.ethereum.stateofus :as stateofus]
[status-im.navigation :as navigation]
[status-im2.navigation.events :as navigation]
[status-im.ethereum.json-rpc :as json-rpc]))
;;NOTE we want to handle only last resolve

View File

@ -1,7 +1,7 @@
(ns status-im.wallet.swap.core
(:require [status-im.utils.fx :as fx]
[re-frame.db :as re-frame.db]
[status-im.navigation :as navigation]))
[status-im2.navigation.events :as navigation]))
(fx/defn open-asset-selector-modal
"source? true signinfies we are selecting the source asset. false implies selection of sink asset"

View File

@ -0,0 +1,68 @@
(ns status-im2.common.alert.events
(:require [re-frame.core :as re-frame]
[react-native.core :as rn]
[i18n.i18n :as i18n]))
(defn show-popup
([title content]
(show-popup title content nil))
([title content on-dismiss]
(rn/alert
title
content
(vector (merge {:text "OK"
:style "cancel"
:accessibility-label :cancel-button}
(when on-dismiss {:onPress on-dismiss})))
(when on-dismiss
{:cancelable false}))))
(re-frame/reg-fx
:utils/show-popup
(fn [{:keys [title content on-dismiss]}]
(show-popup title content on-dismiss)))
(defn show-confirmation
[{:keys [title content confirm-button-text on-accept on-cancel cancel-button-text
extra-options]}]
(rn/alert
title
content
;; Styles are only relevant on iOS. On Android first button is 'neutral' and second is 'positive'
(concat
(vector (merge {:text (or cancel-button-text (i18n/label :t/cancel))
:style "cancel"
:accessibility-label :cancel-button}
(when on-cancel {:onPress on-cancel}))
{:text (or confirm-button-text (i18n/label :t/ok))
:onPress on-accept
:style "default"
:accessibility-label :confirm-button})
(or extra-options nil))
{:cancelable false}))
(re-frame/reg-fx
:utils/show-confirmation
(fn [{:keys [title content confirm-button-text on-accept on-cancel cancel-button-text extra-options]}]
(show-confirmation {:title title
:content content
:confirm-button-text confirm-button-text
:cancel-button-text cancel-button-text
:on-accept on-accept
:on-cancel on-cancel
:extra-options extra-options})))
(defn show-question
([title content on-accept]
(show-question title content on-accept nil))
([title content on-accept on-cancel]
(rn/alert
title
content
(vector (merge {:text (i18n/label :t/no)
:accessibility-label :no-button}
(when on-cancel {:onPress on-cancel}))
{:text (i18n/label :t/yes)
:onPress on-accept
:accessibility-label :yes-button})
nil)))

View File

@ -0,0 +1,15 @@
(ns status-im2.common.theme.core
(:require [react-native.core :as rn]))
(def initial-mode (atom (rn/get-color-scheme)))
;; Note - don't use value returned by change listener
;; https://github.com/facebook/react-native/issues/28525
(defn add-mode-change-listener [callback]
(rn/appearance-add-change-listener #(let [mode (rn/get-color-scheme)]
(when-not (= mode @initial-mode)
(reset! initial-mode mode)
(callback (keyword mode))))))
(defn dark-mode? []
(= @initial-mode "dark"))

View File

@ -0,0 +1,17 @@
(ns status-im2.common.timer.events
(:require [re-frame.core :as re-frame]
[react-native.background-timer :as background-timer]))
(re-frame/reg-fx
:background-timer/dispatch-later
(fn [params]
(doseq [{:keys [ms dispatch]} params]
(when (and ms dispatch)
(background-timer/set-timeout #(re-frame/dispatch dispatch) ms)))))
(re-frame/reg-fx
:background-timer/clear-timeouts
(fn [ids]
(doseq [id ids]
(when id
(background-timer/clear-timeout id)))))

Some files were not shown because too many files have changed in this diff Show More