Skip to content

Commit

Permalink
[#19351] fix: reviewer feedbacks, use animated style js
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen-ghafouri committed Apr 3, 2024
1 parent 0587196 commit 6a7783d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 59 deletions.
19 changes: 0 additions & 19 deletions src/js/worklets/header.js

This file was deleted.

13 changes: 13 additions & 0 deletions src/js/worklets/profile_header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useAnimatedStyle, withTiming } from 'react-native-reanimated';

export function profileHeaderAnimation(scrollY, threshold, topBarHeight) {
return useAnimatedStyle(() => {
const opacity = scrollY.value < threshold ? withTiming(0) : withTiming(1);
const translateY = scrollY.value < threshold ? withTiming(topBarHeight) : withTiming(0);

return {
opacity: opacity,
transform: [{ translateY: translateY }],
};
});
}
13 changes: 1 addition & 12 deletions src/quo/components/navigation/page_nav/style.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns quo.components.navigation.page-nav.style
(:require
[quo.foundations.colors :as colors]
[react-native.reanimated :as reanimated]))
[quo.foundations.colors :as colors]))

(defn container
[margin-top]
Expand All @@ -22,16 +21,6 @@
:justify-content (if centered? :center :flex-start)
:opacity center-opacity})

(defn center-content-container-animation
[{:keys [centered? center-opacity has-animations? translate-animation opacity-animation]}]
(if has-animations?
(reanimated/apply-animations-to-style
{:transform [{:translate-y translate-animation}]
:opacity opacity-animation}
(center-content-container centered? center-opacity))
(center-content-container centered? center-opacity)))


(def right-actions-container
{:flex-direction :row})

Expand Down
19 changes: 7 additions & 12 deletions src/quo/components/navigation/page_nav/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[quo.theme :as theme]
[react-native.core :as rn]
[react-native.reanimated :as reanimated]
[utils.worklets.header :as header-worklet]))
[utils.worklets.profile-header :as header-worklet]))

(def ^:private button-type
{:white :grey
Expand Down Expand Up @@ -93,18 +93,13 @@

(defn- title-center
[{:keys [centered? title center-opacity scroll-y]}]
(let [translate-animation (when scroll-y
(header-worklet/header-content-position scroll-y
threshold
page-nav-height))
opacity-animation (when scroll-y
(header-worklet/header-content-opacity scroll-y threshold))]
(let [animated-style (when scroll-y
(header-worklet/profile-header-animation scroll-y
threshold
page-nav-height))]
[reanimated/view
{:style (style/center-content-container-animation {:has-animations? (some? scroll-y)
:centered? centered?
:center-opacity center-opacity
:translate-animation translate-animation
:opacity-animation opacity-animation})}
{:style [(style/center-content-container centered? center-opacity)
animated-style]}
[text/text
{:weight :medium
:size :paragraph-1
Expand Down
16 changes: 0 additions & 16 deletions src/utils/worklets/header.cljs

This file was deleted.

10 changes: 10 additions & 0 deletions src/utils/worklets/profile_header.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(ns utils.worklets.profile-header)

(def ^:private worklets (js/require "../src/js/worklets/profile_header.js"))

(defn profile-header-animation
[scroll-y threshold top-bar-height]
(.profileHeaderAnimation ^js worklets
scroll-y
threshold
top-bar-height))

0 comments on commit 6a7783d

Please sign in to comment.