-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#17986] refactor: apply header animation on scroll list
- Loading branch information
1 parent
34e472f
commit 13b8e73
Showing
6 changed files
with
140 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/status_im2/contexts/profile/settings/header/avatar.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
(ns status-im2.contexts.profile.settings.header.avatar | ||
(:require [quo.core :as quo] | ||
[quo.theme :as quo.theme] | ||
[react-native.reanimated :as reanimated] | ||
[status-im2.contexts.profile.settings.header.style :as style])) | ||
|
||
(defonce ^:const 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 [image-scale-animation (reanimated/interpolate scroll-y | ||
scroll-animation-input-range | ||
[1 0.5] | ||
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 | ||
[0 -20] | ||
header-extrapolation-option) | ||
theme (quo.theme/get-theme)] | ||
[reanimated/view | ||
{:style (style/avatar-container theme | ||
image-scale-animation | ||
image-top-margin-animation | ||
image-side-margin-animation)} | ||
[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]) |
37 changes: 24 additions & 13 deletions
37
src/status_im2/contexts/profile/settings/header/header_shape.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
(ns status-im2.contexts.profile.settings.header.header-shape | ||
(:require [quo.foundations.colors :as colors] | ||
[react-native.core :as rn] | ||
[react-native.reanimated :as reanimated] | ||
[react-native.svg :as svg] | ||
[status-im2.contexts.profile.settings.header.style :as style])) | ||
|
||
(defn left-shape | ||
(defonce ^:const scroll-animation-input-range [0 45 50]) | ||
|
||
(defn left-radius | ||
[background-color] | ||
[svg/svg {:width "109" :height "68" :viewBox "0 0 109 68" :fill "none"} | ||
[svg/svg {:width "20" :height "20" :viewBox "0 0 20 20" :fill "none"} | ||
[svg/path | ||
{:d | ||
"M0 0H109V48H103.821C101.8 25.574 82.9522 8 60 8C36.9215 8 17.993 25.768 16.1475 48.3707C6.94517 50.1664 0 58.2721 0 68V0Z" | ||
{:d "M20 0C7 2 0 10 0 20V0H15Z" | ||
:fill background-color}]]) | ||
|
||
(defn right-shape | ||
(defn right-radius | ||
[background-color] | ||
[svg/svg {:width "25" :height "68" :viewBox "0 0 25 68" :fill "none"} | ||
[svg/svg {:width "20" :height "21" :viewBox "0 0 20 21" :fill "none"} | ||
[svg/path | ||
{:d "M0.000610352 0H24.5005V68L24.5003 68C24.5003 56.9543 15.546 48 4.50031 48H0.000610352V0Z" | ||
{:d "M20 20V0H0C11 0 20 9 20 20Z" | ||
:fill background-color}]]) | ||
|
||
(defn view | ||
[customization-color theme] | ||
(let [background-color (colors/resolve-color customization-color theme 40)] | ||
[rn/view {:style style/header-shape-container} | ||
[left-shape background-color] | ||
|
||
(defn f-view | ||
[{:keys [scroll-y customization-color theme]}] | ||
(let [background-color (colors/resolve-color customization-color theme 40) | ||
opacity-animation (reanimated/interpolate scroll-y | ||
scroll-animation-input-range | ||
[1 1 0])] | ||
[rn/view | ||
[rn/view {:style (style/header-middle-shape background-color)}] | ||
[right-shape background-color]])) | ||
[reanimated/view {:style (style/radius-container opacity-animation)} | ||
[left-radius background-color] | ||
[right-radius background-color]]])) | ||
|
||
(defn view | ||
[props] | ||
[:f> f-view props]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters