Compare commits

..
17 changed files with 2657 additions and 4929 deletions
+3 -6
View File
@@ -1,9 +1,6 @@
module.exports = {
presets: [
"@babel/preset-env"
// 'module:metro-react-native-babel-preset'
],
/*plugins: ['react-native-reanimated/plugin', '@babel/plugin-transform-named-capturing-groups-regex'],
presets: ['module:metro-react-native-babel-preset'],
plugins: ['react-native-reanimated/plugin', '@babel/plugin-transform-named-capturing-groups-regex'],
env: {
test: {
presets: [
@@ -18,5 +15,5 @@ module.exports = {
],
],
},
},*/
},
};
-1
View File
@@ -78,7 +78,6 @@
"@babel/helper-builder-react-jsx": "^7.20.0",
"@babel/plugin-transform-block-scoping": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/preset-es2015": "^7.0.0-beta.53",
"@babel/preset-react": "^7.18.6",
"@babel/register": "7.0.0",
"@jest/globals": "^25.1.0",
-1
View File
@@ -46,7 +46,6 @@
;; To match the folder created by Nix build of JSBundle.
:output-dir "result"
:init-fn status-im.core/init
:build-hooks [(status-im.setup.build-hooks.worklets/transform-output)]
;; 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!`.
+1 -4
View File
@@ -20,8 +20,7 @@
LinearTransition
enableLayoutAnimations
useAnimatedScrollHandler
runOnJS)
:as reanimated*]
runOnJS)]
["react-native-redash" :refer (withPause)]
[react-native.flat-list :as rn-flat-list]
[react-native.utils :as rn.utils]
@@ -108,8 +107,6 @@
(when (and anim (some? v))
(set! (.-value anim) v)))
(def interpolate* reanimated*/interpolate)
(defn interpolate
([shared-value input-range output-range]
(interpolate shared-value input-range output-range nil))
+24 -57
View File
@@ -1,36 +1,31 @@
(ns ^:workletize status-im.common.scalable-avatar.view
(ns status-im.common.scalable-avatar.view
(:require [quo.core :as quo]
[react-native.reanimated :as reanimated]
;;[status-im.common.scalable-avatar.style :as style]
[status-im.contexts.profile.settings.header.style :as style]))
[status-im.common.scalable-avatar.style :as style]))
(def scroll-animation-input-range [0 50])
(def header-extrapolation-option
{:extrapolateLeft "clamp"
:extrapolateRight "clamp"})
(defn f-avatar
[{:keys [scroll-y full-name online? profile-picture customization-color]}]
(let [avatar-total-size 88
border-height 4
translation-to-bottom (fn [scale inverse-scale]
(js* "'worklet'")
(let [current-avatar-size (* avatar-total-size (- 1 scale))
current-center (/ current-avatar-size 2)]
(* current-center inverse-scale)))
transform (reanimated/use-animated-style
(fn []
(js* "'worklet'")
(let [scale (reanimated/interpolate*
(.-value scroll-y)
#js [0 48]
#js [1 0.4]
"clamp")
inverse-scale (/ 1 scale)
translation (translation-to-bottom scale inverse-scale)
bottom (* border-height inverse-scale (- 1 scale))]
#js
{:transform #js
[#js {:scale scale}
#js {:translateX (- translation)}
#js {:translateY (- translation bottom)}]})))
theme (quo.theme/get-theme)]
[reanimated/view {:style [transform (style/avatar-container theme)]}
[{:keys [scroll-y full-name online? profile-picture customization-color border-color]}]
(let [image-scale-animation (reanimated/interpolate scroll-y
scroll-animation-input-range
[1 0.4]
header-extrapolation-option)
image-top-margin-animation (reanimated/interpolate scroll-y
scroll-animation-input-range
[0 20]
header-extrapolation-option)
image-side-margin-animation (reanimated/interpolate scroll-y
scroll-animation-input-range
[-4 -20]
header-extrapolation-option)]
[reanimated/view
{:style (style/wrapper {:scale image-scale-animation
:margin-top image-top-margin-animation
:margin image-side-margin-animation
:border-color border-color})}
[quo/user-avatar
{:full-name full-name
:online? online?
@@ -40,34 +35,6 @@
:customization-color customization-color
:size :big}]]))
#_(defn f-avatar
[{:keys [scroll-y full-name online? profile-picture customization-color border-color]}]
(let [image-scale-animation (reanimated/interpolate scroll-y
scroll-animation-input-range
[1 0.4]
header-extrapolation-option)
image-top-margin-animation (reanimated/interpolate scroll-y
scroll-animation-input-range
[0 20]
header-extrapolation-option)
image-side-margin-animation (reanimated/interpolate scroll-y
scroll-animation-input-range
[-4 -20]
header-extrapolation-option)]
[reanimated/view
{:style (style/wrapper {:scale image-scale-animation
:margin-top image-top-margin-animation
:margin image-side-margin-animation
:border-color border-color})}
[quo/user-avatar
{:full-name full-name
:online? online?
:profile-picture profile-picture
:status-indicator? true
:ring? true
:customization-color customization-color
:size :big}]]))
(defn view
[props]
[:f> f-avatar props])
@@ -293,7 +293,7 @@
(defn community-fetched
[{:keys [db]} [community-id community]]
(when community
{:db (update db :communities/fetching-community dissoc community-id)
{:db (update db :communities/fetching-communities dissoc community-id)
:fx [[:dispatch [:communities/handle-community community]]
[:dispatch [:communities/update-last-opened-at community-id]]
[:dispatch
@@ -304,14 +304,14 @@
(defn community-failed-to-fetch
[{:keys [db]} [community-id]]
{:db (update db :communities/fetching-community dissoc community-id)})
{:db (update db :communities/fetching-communities dissoc community-id)})
(rf/reg-event-fx :chat.ui/community-failed-to-fetch community-failed-to-fetch)
(defn fetch-community
[{:keys [db]} [{:keys [community-id update-last-opened-at?]}]]
(when (and community-id (not (get-in db [:communities/fetching-community community-id])))
{:db (assoc-in db [:communities/fetching-community community-id] true)
(when (and community-id (not (get-in db [:communities/fetching-communities community-id])))
{:db (assoc-in db [:communities/fetching-communities community-id] true)
:json-rpc/call [{:method "wakuext_fetchCommunity"
:params [{:CommunityKey community-id
:TryDatabase true
@@ -398,7 +398,7 @@
:community-id community-id})}})
(rf/reg-event-fx :communities/navigate-to-community-overview
(fn [cofx [deserialized-key]]
(fn [{:keys [db] :as cofx} [deserialized-key]]
(if (string/starts-with? deserialized-key constants/serialization-key)
(navigate-to-serialized-community cofx deserialized-key)
(rf/merge
@@ -407,7 +407,9 @@
[:communities/fetch-community
{:community-id deserialized-key
:update-last-opened-at? true}]]
[:dispatch [:navigate-to :community-overview deserialized-key]]]}
[:dispatch [:navigate-to :community-overview deserialized-key]]
(when (get-in db [:communities deserialized-key :joined])
[:dispatch [:activity-center.notifications/dismiss-community-overview deserialized-key]])]}
(navigation/pop-to-root :shell-stack)))))
(rf/reg-event-fx :communities/navigate-to-community-chat
@@ -104,7 +104,7 @@
(testing "with community id"
(testing "update fetching indicator in db"
(is (match?
{:db {:communities/fetching-community {community-id true}}}
{:db {:communities/fetching-communities {community-id true}}}
(events/fetch-community {} [{:community-id community-id}]))))
(testing "call the fetch community rpc method with correct community id"
(is (match?
@@ -124,21 +124,21 @@
(testing "remove community id from fetching indicator in db"
(is (match?
nil
(get-in (events/community-failed-to-fetch {:db {:communities/fetching-community
(get-in (events/community-failed-to-fetch {:db {:communities/fetching-communities
{community-id true}}}
[community-id])
[:db :communities/fetching-community community-id]))))))
[:db :communities/fetching-communities community-id]))))))
(deftest community-fetched
(with-redefs [link-preview.events/community-link (fn [id] (str "community-link+" id))]
(testing "given a community"
(let [cofx {:db {:communities/fetching-community {community-id true}}}
(let [cofx {:db {:communities/fetching-communities {community-id true}}}
arg [community-id {:id community-id}]]
(testing "remove community id from fetching indicator in db"
(is (match?
nil
(get-in (events/community-fetched cofx arg)
[:db :communities/fetching-community community-id]))))
[:db :communities/fetching-communities community-id]))))
(testing "dispatch fxs"
(is (match?
{:fx [[:dispatch [:communities/handle-community {:id community-id}]]
@@ -148,7 +148,7 @@
{:id community-id}]]]}
(events/community-fetched cofx arg))))))
(testing "given a joined community"
(let [cofx {:db {:communities/fetching-community {community-id true}}}
(let [cofx {:db {:communities/fetching-communities {community-id true}}}
arg [community-id {:id community-id :joined true}]]
(testing "dispatch fxs, do not spectate community"
(is (match?
@@ -159,7 +159,7 @@
{:id community-id}]]]}
(events/community-fetched cofx arg))))))
(testing "given a token-gated community"
(let [cofx {:db {:communities/fetching-community {community-id true}}}
(let [cofx {:db {:communities/fetching-communities {community-id true}}}
arg [community-id {:id community-id :tokenPermissions [1]}]]
(testing "dispatch fxs, do not spectate community"
(is (match?
@@ -21,6 +21,13 @@
:align-items :center
:margin-top 20})
(def fetching-placeholder
{:align-items :center
:justify-content :center
:flex 1})
(def fetching-text {:color :red})
(def blur-channel-header
{:position :absolute
:top 100
@@ -7,6 +7,7 @@
[react-native.core :as rn]
[reagent.core :as reagent]
[status-im.common.home.actions.view :as actions]
[status-im.common.not-implemented :as not-implemented]
[status-im.common.scroll-page.style :as scroll-page.style]
[status-im.common.scroll-page.view :as scroll-page]
[status-im.config :as config]
@@ -177,7 +178,6 @@
:icon-left (if can-request-access? :i/unlocked :i/locked)}
(i18n/label :t/join-open-community)]])))
(defn- join-community
[{:keys [id joined permissions role-permissions? can-join?] :as community}]
(let [pending? (rf/sub [:communities/my-pending-request-to-join id])
@@ -366,14 +366,28 @@
;; might have been removed.
on-first-channel-height-changed}]]))))
(defn- community-fetching-placeholder
[id]
(let [fetching? (rf/sub [:communities/fetching-community id])]
[rn/view
{:style style/fetching-placeholder
:accessibility-label (if fetching?
:fetching-community-overview
:failed-to-fetch-community-overview)}
[not-implemented/not-implemented
[rn/text
{:style style/fetching-text}
(if fetching?
"Fetching community..."
"Failed to fetch community")]]]))
(defn- community-card-page-view
[id]
(let [{:keys [id joined name images]
(let [{:keys [joined name images]
:as community} (rf/sub [:communities/community id])]
(when community
(when joined
(rf/dispatch [:activity-center.notifications/dismiss-community-overview id]))
[community-scroll-page id joined name images])))
(if community
[community-scroll-page id joined name images]
[community-fetching-placeholder id])))
(defn view
[id]
@@ -203,7 +203,6 @@
(rf/merge
cofx
{:db (assoc-in db [:profile/login :password] password)}
(navigation/init-root :progress)
(biometrics-login))))
(rf/reg-event-fx
@@ -1,4 +1,4 @@
(ns ^:workletize status-im.contexts.profile.settings.header.header-shape
(ns status-im.contexts.profile.settings.header.header-shape
(:require [quo.foundations.colors :as colors]
[react-native.core :as rn]
[react-native.reanimated :as reanimated]
@@ -21,17 +21,13 @@
(defn f-view
[{:keys [scroll-y customization-color theme]}]
(let [background-color (colors/resolve-color customization-color theme 40)
opacity (reanimated/use-animated-style
(fn []
(js* "'worklet'")
#js
{:opacity (reanimated/interpolate* (.-value scroll-y)
#js [0 45 50]
#js [1 1 0])}))]
(let [background-color (colors/resolve-color customization-color theme 40)
opacity-animation (reanimated/interpolate scroll-y
[0 45 50]
[1 1 0])]
[:<>
[rn/view {:style (style/header-middle-shape background-color)}]
[reanimated/view {:style [opacity style/radius-container]}
[reanimated/view {:style (style/radius-container opacity-animation)}
[left-radius background-color]
[right-radius background-color]]]))
@@ -27,13 +27,19 @@
:height 48
:flex-grow 1})
(def radius-container
{:flex-direction :row
(defn radius-container
[opacity-animation]
{:opacity opacity-animation
:flex-direction :row
:justify-content :space-between})
(defn avatar-container
[theme]
{:align-items :flex-start
:border-width 4
:border-color (colors/theme-colors colors/border-avatar-light colors/neutral-80-opa-80 theme)
:border-radius 44})
[theme scale-animation top-margin-animation side-margin-animation]
[{:transform [{:scale scale-animation}]
:margin-top top-margin-animation
:margin-left side-margin-animation
:margin-bottom side-margin-animation}
{:align-items :flex-start
:border-width 4
:border-color (colors/theme-colors colors/border-avatar-light colors/neutral-80-opa-80 theme)
:border-radius 100}])
@@ -1,74 +0,0 @@
(ns status-im.setup.build-hooks.worklets
(:require [clojure.set]
[clojure.java.io :as io]
[cljs.build.api :as b])
(:import (java.io BufferedReader InputStreamReader PrintWriter)
(javax.script ScriptEngineManager)))
(def engine
(doto (.getEngineByName (ScriptEngineManager.) "nashorn")
(.eval (io/reader (io/file "babel.min.js")))))
(defn- update-js-output
[build-state code-processed]
(reduce-kv (fn [prev-build-state ns-key new-code]
(assoc-in prev-build-state [:output ns-key :js] new-code))
build-state
code-processed))
(defn- gen-workletized-code!
[code-seq store-atom]
(doall
(pmap (fn [[[_ filepath :as ns-key] js-code]]
(println "Workletizing:" filepath) ;; TODO: debug remove
(def js-code* js-code)
(try
(let [command "node workletize-code.js"
process (.exec (Runtime/getRuntime) command)
output-stream (.getOutputStream process)
writer (PrintWriter. output-stream)
reader (BufferedReader. (InputStreamReader. (.getInputStream process)))]
(.println writer js-code)
(.flush writer)
(.close writer)
(let [output (apply str (interleave (line-seq reader) (repeat "\n")))
_exit-code (.waitFor process)]
(swap! store-atom assoc ns-key output)))
(catch Exception e
(println (str "Exception while workletizing: " filepath "\n")
(.getMessage e)))))
code-seq)))
(defn- get-js-code-with-ns
[build-state-output file-path]
(let [ns-key [:shadow.build.classpath/resource file-path]
js-code (get-in build-state-output [ns-key :js])]
[ns-key js-code]))
(defn- get-files-to-workletize
[{:keys [shadow.build/build-info compiler-env] :as _build-state}]
(let [files-compiled (->> build-info
:compiled
(map second)
(set))
namespaces-metadata (->> compiler-env
:cljs.analyzer/namespaces
vals
(map :meta))
files-marked (->> namespaces-metadata
(filter :workletize)
(map :file)
(set))]
(clojure.set/intersection files-compiled files-marked)))
(defn transform-output
{:shadow.build/stage :compile-finish}
[{:keys [output] :as build-state}]
(let [files-to-workletize (get-files-to-workletize build-state)
js-code-with-ns (map #(get-js-code-with-ns output %) files-to-workletize)
code-processed-store (atom {})]
(gen-workletized-code! js-code-with-ns code-processed-store)
(update-js-output build-state @code-processed-store)))
+1 -1
View File
@@ -9,7 +9,7 @@
(re-frame/reg-sub
:communities/fetching-community
:<- [:communities/fetching-community]
:<- [:communities/fetching-communities]
(fn [info [_ id]]
(get info id)))
+1 -1
View File
@@ -143,7 +143,7 @@
(reg-root-key-sub :communities/create-channel :communities/create-channel)
(reg-root-key-sub :communities/requests-to-join :communities/requests-to-join)
(reg-root-key-sub :communities/community-id-input :communities/community-id-input)
(reg-root-key-sub :communities/fetching-community :communities/fetching-community)
(reg-root-key-sub :communities/fetching-communities :communities/fetching-communities)
(reg-root-key-sub :communities/my-pending-requests-to-join :communities/my-pending-requests-to-join)
(reg-root-key-sub :communities/collapsed-categories :communities/collapsed-categories)
(reg-root-key-sub :communities/selected-tab :communities/selected-tab)
File diff suppressed because one or more lines are too long
+2566 -4719
View File
File diff suppressed because it is too large Load Diff