From 248996ce6f617f6006547c30be05f94cfa875b6d Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Tue, 16 Jan 2024 19:01:07 +0530 Subject: [PATCH] Organize composer worklets (#18528) --- src/js/worklets/chat/messages.js | 92 ---------- src/js/worklets/chat/messenger/composer.js | 26 +++ .../worklets/chat/{ => messenger}/lightbox.js | 0 src/js/worklets/chat/messenger/messages.js | 14 ++ src/js/worklets/chat/messenger/navigation.js | 40 +++++ src/js/worklets/chat/messenger/placeholder.js | 15 ++ src/mocks/js_dependencies.cljs | 161 +++++++++--------- .../chat/messenger/composer/sub_view.cljs | 2 +- .../chat/messenger/lightbox/utils.cljs | 2 +- .../chat/messenger/messages/list/view.cljs | 2 +- .../messenger/messages/navigation/view.cljs | 2 +- .../chat/messenger/placeholder/view.cljs | 2 +- src/utils/worklets/chat/messages.cljs | 51 ------ .../worklets/chat/messenger/composer.cljs | 15 ++ .../chat/{ => messenger}/lightbox.cljs | 4 +- .../worklets/chat/messenger/messages.cljs | 7 + .../worklets/chat/messenger/navigation.cljs | 23 +++ .../worklets/chat/messenger/placeholder.cljs | 11 ++ 18 files changed, 242 insertions(+), 227 deletions(-) delete mode 100644 src/js/worklets/chat/messages.js create mode 100644 src/js/worklets/chat/messenger/composer.js rename src/js/worklets/chat/{ => messenger}/lightbox.js (100%) create mode 100644 src/js/worklets/chat/messenger/messages.js create mode 100644 src/js/worklets/chat/messenger/navigation.js create mode 100644 src/js/worklets/chat/messenger/placeholder.js delete mode 100644 src/utils/worklets/chat/messages.cljs create mode 100644 src/utils/worklets/chat/messenger/composer.cljs rename src/utils/worklets/chat/{ => messenger}/lightbox.cljs (66%) create mode 100644 src/utils/worklets/chat/messenger/messages.cljs create mode 100644 src/utils/worklets/chat/messenger/navigation.cljs create mode 100644 src/utils/worklets/chat/messenger/placeholder.cljs diff --git a/src/js/worklets/chat/messages.js b/src/js/worklets/chat/messages.js deleted file mode 100644 index 4babcd3885..0000000000 --- a/src/js/worklets/chat/messages.js +++ /dev/null @@ -1,92 +0,0 @@ -import { useDerivedValue, withTiming, interpolate, useAnimatedScrollHandler, runOnJS } from 'react-native-reanimated'; - -export function navigationHeaderOpacity(distanceFromListTop, isAllLoaded, isCalculationsComplete, startPosition) { - return useDerivedValue(function () { - 'worklet'; - const isCalculationsCompleteValue = isCalculationsComplete.value; - if (distanceFromListTop.value < startPosition && isAllLoaded.value) { - return isCalculationsCompleteValue ? withTiming(0) : 0; - } else { - return isCalculationsCompleteValue ? withTiming(1) : 1; - } - }); -} - -export function navigationHeaderPosition(distanceFromListTop, isAllLoaded, topBarHeight, startPosition) { - return useDerivedValue(function () { - 'worklet'; - return distanceFromListTop.value < startPosition && isAllLoaded.value ? withTiming(topBarHeight) : withTiming(0); - }); -} - -export function interpolateNavigationViewOpacity(props) { - return useDerivedValue(function () { - 'worklet'; - const { - 'all-loaded?': isAllLoaded, - 'end-position': endPosition, - 'start-position': startPosition, - 'distance-from-list-top': distanceFromListTop, - } = props; - if (isAllLoaded.value) { - return interpolate(distanceFromListTop.value, [startPosition, endPosition], [0, 1], { - extrapolateLeft: 'clamp', - extrapolateRight: 'clamp', - }); - } else { - return 1; - } - }); -} - -export function messagesListOnScroll(distanceFromListTop, chatListScrollY, callback) { - return function (event) { - 'worklet'; - const currentY = event.contentOffset.y; - const layoutHeight = event.layoutMeasurement.height; - const contentSizeY = event.contentSize.height - layoutHeight; - const newDistance = contentSizeY - currentY; - distanceFromListTop.value = newDistance; - chatListScrollY.value = currentY; - runOnJS(callback)(layoutHeight, newDistance); - }; -} - -export function placeholderOpacity(isCalculationsComplete) { - return useDerivedValue(function () { - 'worklet'; - return isCalculationsComplete.value ? 0 : 1; - }); -} - -export function placeholderZIndex(isCalculationsComplete) { - return useDerivedValue(function () { - 'worklet'; - return isCalculationsComplete.value ? 0 : 2; - }); -} - -export function scrollDownButtonOpacity(chatListScrollY, isComposerFocused, windowHeight) { - return useDerivedValue(function () { - 'worklet'; - if (isComposerFocused.value) { - return 0; - } else { - return chatListScrollY.value > windowHeight * 0.75 ? 1 : 0; - } - }); -} - -export function jumpToButtonOpacity(scrollDownButtonOpacity, isComposerFocused) { - return useDerivedValue(function () { - 'worklet'; - return withTiming(scrollDownButtonOpacity.value == 1 || isComposerFocused.value ? 0 : 1); - }); -} - -export function jumpToButtonPosition(scrollDownButtonOpacity, isComposerFocused) { - return useDerivedValue(function () { - 'worklet'; - return withTiming(scrollDownButtonOpacity.value == 1 || isComposerFocused.value ? 35 : 0); - }); -} diff --git a/src/js/worklets/chat/messenger/composer.js b/src/js/worklets/chat/messenger/composer.js new file mode 100644 index 0000000000..7600d7a1c8 --- /dev/null +++ b/src/js/worklets/chat/messenger/composer.js @@ -0,0 +1,26 @@ +import { useDerivedValue, withTiming } from 'react-native-reanimated'; + +export function scrollDownButtonOpacity(chatListScrollY, isComposerFocused, windowHeight) { + return useDerivedValue(function () { + 'worklet'; + if (isComposerFocused.value) { + return 0; + } else { + return chatListScrollY.value > windowHeight * 0.75 ? 1 : 0; + } + }); +} + +export function jumpToButtonOpacity(scrollDownButtonOpacity, isComposerFocused) { + return useDerivedValue(function () { + 'worklet'; + return withTiming(scrollDownButtonOpacity.value == 1 || isComposerFocused.value ? 0 : 1); + }); +} + +export function jumpToButtonPosition(scrollDownButtonOpacity, isComposerFocused) { + return useDerivedValue(function () { + 'worklet'; + return withTiming(scrollDownButtonOpacity.value == 1 || isComposerFocused.value ? 35 : 0); + }); +} diff --git a/src/js/worklets/chat/lightbox.js b/src/js/worklets/chat/messenger/lightbox.js similarity index 100% rename from src/js/worklets/chat/lightbox.js rename to src/js/worklets/chat/messenger/lightbox.js diff --git a/src/js/worklets/chat/messenger/messages.js b/src/js/worklets/chat/messenger/messages.js new file mode 100644 index 0000000000..5aa0cb5ed8 --- /dev/null +++ b/src/js/worklets/chat/messenger/messages.js @@ -0,0 +1,14 @@ +import { withTiming, runOnJS } from 'react-native-reanimated'; + +export function messagesListOnScroll(distanceFromListTop, chatListScrollY, callback) { + return function (event) { + 'worklet'; + const currentY = event.contentOffset.y; + const layoutHeight = event.layoutMeasurement.height; + const contentSizeY = event.contentSize.height - layoutHeight; + const newDistance = contentSizeY - currentY; + distanceFromListTop.value = newDistance; + chatListScrollY.value = currentY; + runOnJS(callback)(layoutHeight, newDistance); + }; +} diff --git a/src/js/worklets/chat/messenger/navigation.js b/src/js/worklets/chat/messenger/navigation.js new file mode 100644 index 0000000000..8df1ced52e --- /dev/null +++ b/src/js/worklets/chat/messenger/navigation.js @@ -0,0 +1,40 @@ +import { useDerivedValue, withTiming, interpolate } from 'react-native-reanimated'; + +export function navigationHeaderOpacity(distanceFromListTop, isAllLoaded, isCalculationsComplete, startPosition) { + return useDerivedValue(function () { + 'worklet'; + const isCalculationsCompleteValue = isCalculationsComplete.value; + if (distanceFromListTop.value < startPosition && isAllLoaded.value) { + return isCalculationsCompleteValue ? withTiming(0) : 0; + } else { + return isCalculationsCompleteValue ? withTiming(1) : 1; + } + }); +} + +export function navigationHeaderPosition(distanceFromListTop, isAllLoaded, topBarHeight, startPosition) { + return useDerivedValue(function () { + 'worklet'; + return distanceFromListTop.value < startPosition && isAllLoaded.value ? withTiming(topBarHeight) : withTiming(0); + }); +} + +export function interpolateNavigationViewOpacity(props) { + return useDerivedValue(function () { + 'worklet'; + const { + 'all-loaded?': isAllLoaded, + 'end-position': endPosition, + 'start-position': startPosition, + 'distance-from-list-top': distanceFromListTop, + } = props; + if (isAllLoaded.value) { + return interpolate(distanceFromListTop.value, [startPosition, endPosition], [0, 1], { + extrapolateLeft: 'clamp', + extrapolateRight: 'clamp', + }); + } else { + return 1; + } + }); +} diff --git a/src/js/worklets/chat/messenger/placeholder.js b/src/js/worklets/chat/messenger/placeholder.js new file mode 100644 index 0000000000..281bddcc29 --- /dev/null +++ b/src/js/worklets/chat/messenger/placeholder.js @@ -0,0 +1,15 @@ +import { useDerivedValue } from 'react-native-reanimated'; + +export function placeholderOpacity(isCalculationsComplete) { + return useDerivedValue(function () { + 'worklet'; + return isCalculationsComplete.value ? 0 : 1; + }); +} + +export function placeholderZIndex(isCalculationsComplete) { + return useDerivedValue(function () { + 'worklet'; + return isCalculationsComplete.value ? 0 : 2; + }); +} diff --git a/src/mocks/js_dependencies.cljs b/src/mocks/js_dependencies.cljs index 27d3b41f6d..56d7ae397b 100644 --- a/src/mocks/js_dependencies.cljs +++ b/src/mocks/js_dependencies.cljs @@ -377,81 +377,88 @@ (defn mock [module] (case module - "react-native-languages" react-native-languages - "react-native-background-timer" background-timer - "react-native-image-crop-picker" image-crop-picker - "react-native-gesture-handler" react-native-gesture-handler - "react-native-static-safe-area-insets" react-native-static-safe-area-insets - "react-native-config" config - "react-native-iphone-x-helper" (clj->js {:getStatusBarHeight (fn []) - :getBottomSpace (fn [])}) - "react-native-screens" (clj->js {}) - "react-native-reanimated" react-native-reanimated - "react-native-redash" react-native-redash - "react-native-fetch-polyfill" fetch - "react-native-status-keycard" status-keycard - "react-native-keychain" keychain - "react-native-touch-id" touchid - "@react-native-community/netinfo" net-info - "react-native-dialogs" dialogs - "react-native" react-native - "react-native-fs" fs - "react-native-mail" react-native-mail - "react-native-image-resizer" image-resizer - "react-native-haptic-feedback" react-native-haptic-feedback - "react-native-device-info" react-native-device-info - "react-native-push-notification" react-native-push-notification - "react-native-linear-gradient" react-native-gradien - "@react-native-community/masked-view" masked-view - "react-native-blob-util" react-native-blob-util - "react-native-navigation" react-native-navigation - "@react-native-community/push-notification-ios" push-notification-ios - "@react-native-community/blur" react-native-blur - "@react-native-camera-roll/camera-roll" react-native-camera-roll - "react-native-camera-kit" react-native-camera-kit - "react-native-permissions" react-native-permissions - "rn-emoji-keyboard" rn-emoji-keyboard - "react-native-hole-view" react-native-hole-view - "react-native-draggable-flatlist" react-native-draggable-flatlist - "react-native-webview" react-native-webview - "@react-native-community/audio-toolkit" react-native-audio-toolkit - "react-native-image-viewing" react-native-image-viewing - "react-native-share" react-native-share - "@react-native-async-storage/async-storage" async-storage - "react-native-svg" react-native-svg - "react-native-transparent-video" react-native-transparent-video - "react-native-orientation-locker" react-native-orientation-locker - "react-native-gifted-charts" react-native-gifted-charts - "../resources/data/emojis/en.json" (js/JSON.parse (slurp - "./resources/data/emojis/en.json")) - "../src/js/worklets/core.js" worklet-factory - "../src/js/worklets/shell/bottom_tabs.js" #js {} - "../src/js/worklets/shell/home_stack.js" #js {} - "../src/js/worklets/shell/floating_screen.js" #js {} - "../src/js/worklets/bottom_sheet.js" #js {} - "../src/js/worklets/record_audio.js" #js {} - "../src/js/worklets/scroll_view.js" #js {} - "../src/js/worklets/onboarding_carousel.js" #js {} - "../src/js/worklets/chat/lightbox.js" #js {} - "../src/js/worklets/chat/messages.js" #js {} - "../src/js/worklets/parallax.js" #js {} - "../src/js/worklets/identifiers_highlighting.js" #js {} - "./fleets.js" default-fleets - "../translations/ar.json" (js/JSON.parse (slurp "./translations/ar.json")) - "../translations/de.json" (js/JSON.parse (slurp "./translations/de.json")) - "../translations/en.json" (js/JSON.parse (slurp "./translations/en.json")) - "../translations/es.json" (js/JSON.parse (slurp "./translations/es.json")) - "../translations/es_419.json" (js/JSON.parse (slurp "./translations/es_419.json")) - "../translations/fil.json" (js/JSON.parse (slurp "./translations/fil.json")) - "../translations/fr.json" (js/JSON.parse (slurp "./translations/fr.json")) - "../translations/id.json" (js/JSON.parse (slurp "./translations/id.json")) - "../translations/it.json" (js/JSON.parse (slurp "./translations/it.json")) - "../translations/ko.json" (js/JSON.parse (slurp "./translations/ko.json")) - "../translations/pt_BR.json" (js/JSON.parse (slurp "./translations/pt_BR.json")) - "../translations/ru.json" (js/JSON.parse (slurp "./translations/ru.json")) - "../translations/tr.json" (js/JSON.parse (slurp "./translations/tr.json")) - "../translations/zh.json" (js/JSON.parse (slurp "./translations/zh.json")) - "../translations/zh_hant.json" (js/JSON.parse (slurp - "./translations/zh_hant.json")) - "../translations/zh_TW.json" (js/JSON.parse (slurp "./translations/zh_TW.json")) + "react-native-languages" react-native-languages + "react-native-background-timer" background-timer + "react-native-image-crop-picker" image-crop-picker + "react-native-gesture-handler" react-native-gesture-handler + "react-native-static-safe-area-insets" react-native-static-safe-area-insets + "react-native-config" config + "react-native-iphone-x-helper" (clj->js {:getStatusBarHeight (fn []) + :getBottomSpace (fn [])}) + "react-native-screens" (clj->js {}) + "react-native-reanimated" react-native-reanimated + "react-native-redash" react-native-redash + "react-native-fetch-polyfill" fetch + "react-native-status-keycard" status-keycard + "react-native-keychain" keychain + "react-native-touch-id" touchid + "@react-native-community/netinfo" net-info + "react-native-dialogs" dialogs + "react-native" react-native + "react-native-fs" fs + "react-native-mail" react-native-mail + "react-native-image-resizer" image-resizer + "react-native-haptic-feedback" react-native-haptic-feedback + "react-native-device-info" react-native-device-info + "react-native-push-notification" react-native-push-notification + "react-native-linear-gradient" react-native-gradien + "@react-native-community/masked-view" masked-view + "react-native-blob-util" react-native-blob-util + "react-native-navigation" react-native-navigation + "@react-native-community/push-notification-ios" push-notification-ios + "@react-native-community/blur" react-native-blur + "@react-native-camera-roll/camera-roll" react-native-camera-roll + "react-native-camera-kit" react-native-camera-kit + "react-native-permissions" react-native-permissions + "rn-emoji-keyboard" rn-emoji-keyboard + "react-native-hole-view" react-native-hole-view + "react-native-draggable-flatlist" react-native-draggable-flatlist + "react-native-webview" react-native-webview + "@react-native-community/audio-toolkit" react-native-audio-toolkit + "react-native-image-viewing" react-native-image-viewing + "react-native-share" react-native-share + "@react-native-async-storage/async-storage" async-storage + "react-native-svg" react-native-svg + "react-native-transparent-video" react-native-transparent-video + "react-native-orientation-locker" react-native-orientation-locker + "react-native-gifted-charts" react-native-gifted-charts + "../resources/data/emojis/en.json" (js/JSON.parse + (slurp + "./resources/data/emojis/en.json")) + "../src/js/worklets/core.js" worklet-factory + "../src/js/worklets/shell/bottom_tabs.js" #js {} + "../src/js/worklets/shell/home_stack.js" #js {} + "../src/js/worklets/shell/floating_screen.js" #js {} + "../src/js/worklets/bottom_sheet.js" #js {} + "../src/js/worklets/record_audio.js" #js {} + "../src/js/worklets/scroll_view.js" #js {} + "../src/js/worklets/onboarding_carousel.js" #js {} + "../src/js/worklets/chat/messenger/lightbox.js" #js {} + "../src/js/worklets/chat/messenger/messages.js" #js {} + "../src/js/worklets/chat/messenger/navigation.js" #js {} + "../src/js/worklets/chat/messenger/composer.js" #js {} + "../src/js/worklets/chat/messenger/placeholder.js" #js {} + "../src/js/worklets/parallax.js" #js {} + "../src/js/worklets/identifiers_highlighting.js" #js {} + "./fleets.js" default-fleets + "../translations/ar.json" (js/JSON.parse (slurp "./translations/ar.json")) + "../translations/de.json" (js/JSON.parse (slurp "./translations/de.json")) + "../translations/en.json" (js/JSON.parse (slurp "./translations/en.json")) + "../translations/es.json" (js/JSON.parse (slurp "./translations/es.json")) + "../translations/es_419.json" (js/JSON.parse (slurp + "./translations/es_419.json")) + "../translations/fil.json" (js/JSON.parse (slurp "./translations/fil.json")) + "../translations/fr.json" (js/JSON.parse (slurp "./translations/fr.json")) + "../translations/id.json" (js/JSON.parse (slurp "./translations/id.json")) + "../translations/it.json" (js/JSON.parse (slurp "./translations/it.json")) + "../translations/ko.json" (js/JSON.parse (slurp "./translations/ko.json")) + "../translations/pt_BR.json" (js/JSON.parse (slurp + "./translations/pt_BR.json")) + "../translations/ru.json" (js/JSON.parse (slurp "./translations/ru.json")) + "../translations/tr.json" (js/JSON.parse (slurp "./translations/tr.json")) + "../translations/zh.json" (js/JSON.parse (slurp "./translations/zh.json")) + "../translations/zh_hant.json" (js/JSON.parse (slurp + "./translations/zh_hant.json")) + "../translations/zh_TW.json" (js/JSON.parse (slurp + "./translations/zh_TW.json")) nil)) diff --git a/src/status_im/contexts/chat/messenger/composer/sub_view.cljs b/src/status_im/contexts/chat/messenger/composer/sub_view.cljs index f698fe42d5..6d2ae2491c 100644 --- a/src/status_im/contexts/chat/messenger/composer/sub_view.cljs +++ b/src/status_im/contexts/chat/messenger/composer/sub_view.cljs @@ -7,7 +7,7 @@ [status-im.contexts.chat.messenger.composer.style :as style] [utils.i18n :as i18n] [utils.re-frame :as rf] - [utils.worklets.chat.messages :as worklets])) + [utils.worklets.chat.messenger.composer :as worklets])) (defn bar [theme] diff --git a/src/status_im/contexts/chat/messenger/lightbox/utils.cljs b/src/status_im/contexts/chat/messenger/lightbox/utils.cljs index 7040330b5b..93c23eeb36 100644 --- a/src/status_im/contexts/chat/messenger/lightbox/utils.cljs +++ b/src/status_im/contexts/chat/messenger/lightbox/utils.cljs @@ -13,7 +13,7 @@ [status-im.contexts.chat.messenger.lightbox.constants :as constants] [status-im.contexts.chat.messenger.lightbox.top-view :as top-view] [utils.re-frame :as rf] - [utils.worklets.chat.lightbox :as worklet])) + [utils.worklets.chat.messenger.lightbox :as worklet])) (defn clear-timers [timers] diff --git a/src/status_im/contexts/chat/messenger/messages/list/view.cljs b/src/status_im/contexts/chat/messenger/messages/list/view.cljs index 8f51077c0d..58b674322c 100644 --- a/src/status_im/contexts/chat/messenger/messages/list/view.cljs +++ b/src/status_im/contexts/chat/messenger/messages/list/view.cljs @@ -21,7 +21,7 @@ [status-im.contexts.shell.jump-to.constants :as jump-to.constants] [utils.i18n :as i18n] [utils.re-frame :as rf] - [utils.worklets.chat.messages :as worklets])) + [utils.worklets.chat.messenger.messages :as worklets])) (defonce ^:const loading-indicator-extra-spacing 250) (defonce ^:const loading-indicator-page-loading-height 100) diff --git a/src/status_im/contexts/chat/messenger/messages/navigation/view.cljs b/src/status_im/contexts/chat/messenger/messages/navigation/view.cljs index e4a72a2c6b..dc4ce18287 100644 --- a/src/status_im/contexts/chat/messenger/messages/navigation/view.cljs +++ b/src/status_im/contexts/chat/messenger/messages/navigation/view.cljs @@ -15,7 +15,7 @@ [status-im.contexts.chat.messenger.messages.pin.banner.view :as pin.banner] [utils.i18n :as i18n] [utils.re-frame :as rf] - [utils.worklets.chat.messages :as worklets])) + [utils.worklets.chat.messenger.navigation :as worklets])) (defn f-header-content-container [{:keys [chat distance-from-list-top all-loaded? calculations-complete?]}] diff --git a/src/status_im/contexts/chat/messenger/placeholder/view.cljs b/src/status_im/contexts/chat/messenger/placeholder/view.cljs index 48ea4a38c6..9a6c6420b3 100644 --- a/src/status_im/contexts/chat/messenger/placeholder/view.cljs +++ b/src/status_im/contexts/chat/messenger/placeholder/view.cljs @@ -5,7 +5,7 @@ [react-native.reanimated :as reanimated] [react-native.safe-area :as safe-area] [status-im.contexts.chat.messenger.placeholder.style :as style] - [utils.worklets.chat.messages :as worklets])) + [utils.worklets.chat.messenger.placeholder :as worklets])) (defn- loading-skeleton [] diff --git a/src/utils/worklets/chat/messages.cljs b/src/utils/worklets/chat/messages.cljs deleted file mode 100644 index 88a6291cd0..0000000000 --- a/src/utils/worklets/chat/messages.cljs +++ /dev/null @@ -1,51 +0,0 @@ -(ns utils.worklets.chat.messages) - -(def ^:private messages-worklets (js/require "../src/js/worklets/chat/messages.js")) - -;;;; Navigtion -(defn navigation-header-opacity - [distance-from-list-top all-loaded? calculations-complete? start-position] - (.navigationHeaderOpacity ^js messages-worklets - distance-from-list-top - all-loaded? - calculations-complete? - start-position)) - -(defn navigation-header-position - [distance-from-list-top all-loaded? top-bar-height start-position] - (.navigationHeaderPosition ^js messages-worklets - distance-from-list-top - all-loaded? - top-bar-height - start-position)) - -(defn interpolate-navigation-view-opacity - [props] - (.interpolateNavigationViewOpacity ^js messages-worklets (clj->js props))) - -;;;; Messages List -(defn messages-list-on-scroll - [distance-from-list-top chat-list-scroll-y callback] - (.messagesListOnScroll ^js messages-worklets distance-from-list-top chat-list-scroll-y callback)) - -;;;; Placeholder -(defn placeholder-opacity - [calculations-complete?] - (.placeholderOpacity ^js messages-worklets calculations-complete?)) - -(defn placeholder-z-index - [calculations-complete?] - (.placeholderZIndex ^js messages-worklets calculations-complete?)) - -;;;; Common -(defn scroll-down-button-opacity - [chat-list-scroll-y composer-focused? window-height] - (.scrollDownButtonOpacity ^js messages-worklets chat-list-scroll-y composer-focused? window-height)) - -(defn jump-to-button-opacity - [scroll-down-button-opacity-sv composer-focused?] - (.jumpToButtonOpacity ^js messages-worklets scroll-down-button-opacity-sv composer-focused?)) - -(defn jump-to-button-position - [scroll-down-button-opacity-sv composer-focused?] - (.jumpToButtonPosition ^js messages-worklets scroll-down-button-opacity-sv composer-focused?)) diff --git a/src/utils/worklets/chat/messenger/composer.cljs b/src/utils/worklets/chat/messenger/composer.cljs new file mode 100644 index 0000000000..91b1282ed8 --- /dev/null +++ b/src/utils/worklets/chat/messenger/composer.cljs @@ -0,0 +1,15 @@ +(ns utils.worklets.chat.messenger.composer) + +(def ^:private worklets (js/require "../src/js/worklets/chat/messenger/composer.js")) + +(defn scroll-down-button-opacity + [chat-list-scroll-y composer-focused? window-height] + (.scrollDownButtonOpacity ^js worklets chat-list-scroll-y composer-focused? window-height)) + +(defn jump-to-button-opacity + [scroll-down-button-opacity-sv composer-focused?] + (.jumpToButtonOpacity ^js worklets scroll-down-button-opacity-sv composer-focused?)) + +(defn jump-to-button-position + [scroll-down-button-opacity-sv composer-focused?] + (.jumpToButtonPosition ^js worklets scroll-down-button-opacity-sv composer-focused?)) diff --git a/src/utils/worklets/chat/lightbox.cljs b/src/utils/worklets/chat/messenger/lightbox.cljs similarity index 66% rename from src/utils/worklets/chat/lightbox.cljs rename to src/utils/worklets/chat/messenger/lightbox.cljs index be20d0d59a..b3c4a1f755 100644 --- a/src/utils/worklets/chat/lightbox.cljs +++ b/src/utils/worklets/chat/messenger/lightbox.cljs @@ -1,6 +1,6 @@ -(ns utils.worklets.chat.lightbox) +(ns utils.worklets.chat.messenger.lightbox) -(def ^:private layout-worklets (js/require "../src/js/worklets/chat/lightbox.js")) +(def ^:private layout-worklets (js/require "../src/js/worklets/chat/messenger/lightbox.js")) (defn info-layout [input top?] diff --git a/src/utils/worklets/chat/messenger/messages.cljs b/src/utils/worklets/chat/messenger/messages.cljs new file mode 100644 index 0000000000..a9b26b1528 --- /dev/null +++ b/src/utils/worklets/chat/messenger/messages.cljs @@ -0,0 +1,7 @@ +(ns utils.worklets.chat.messenger.messages) + +(def ^:private worklets (js/require "../src/js/worklets/chat/messenger/messages.js")) + +(defn messages-list-on-scroll + [distance-from-list-top chat-list-scroll-y callback] + (.messagesListOnScroll ^js worklets distance-from-list-top chat-list-scroll-y callback)) diff --git a/src/utils/worklets/chat/messenger/navigation.cljs b/src/utils/worklets/chat/messenger/navigation.cljs new file mode 100644 index 0000000000..d78b5014ee --- /dev/null +++ b/src/utils/worklets/chat/messenger/navigation.cljs @@ -0,0 +1,23 @@ +(ns utils.worklets.chat.messenger.navigation) + +(def ^:private worklets (js/require "../src/js/worklets/chat/messenger/navigation.js")) + +(defn navigation-header-opacity + [distance-from-list-top all-loaded? calculations-complete? start-position] + (.navigationHeaderOpacity ^js worklets + distance-from-list-top + all-loaded? + calculations-complete? + start-position)) + +(defn navigation-header-position + [distance-from-list-top all-loaded? top-bar-height start-position] + (.navigationHeaderPosition ^js worklets + distance-from-list-top + all-loaded? + top-bar-height + start-position)) + +(defn interpolate-navigation-view-opacity + [props] + (.interpolateNavigationViewOpacity ^js worklets (clj->js props))) diff --git a/src/utils/worklets/chat/messenger/placeholder.cljs b/src/utils/worklets/chat/messenger/placeholder.cljs new file mode 100644 index 0000000000..0640be76fb --- /dev/null +++ b/src/utils/worklets/chat/messenger/placeholder.cljs @@ -0,0 +1,11 @@ +(ns utils.worklets.chat.messenger.placeholder) + +(def ^:private worklets (js/require "../src/js/worklets/chat/messenger/placeholder.js")) + +(defn placeholder-opacity + [calculations-complete?] + (.placeholderOpacity ^js worklets calculations-complete?)) + +(defn placeholder-z-index + [calculations-complete?] + (.placeholderZIndex ^js worklets calculations-complete?))