-
Notifications
You must be signed in to change notification settings - Fork 987
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# This is a combination of 7 commits.
# This is the 1st commit message: updates status-im/status-go@1d9d734...fc03393 # This is the commit message #2: updates # This is the commit message #3: test # This is the commit message #4: updates # This is the commit message #5: feat: animated-header-list status-im/status-go@1d9d734...fc03393 # This is the commit message #6: lint # This is the commit message #7: refactor
- Loading branch information
Showing
6 changed files
with
251 additions
and
2 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
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,71 @@ | ||
(ns status-im2.common.animated-header-list.style | ||
(:require [quo2.foundations.colors :as colors] | ||
[react-native.reanimated :as reanimated])) | ||
|
||
(defn container-view | ||
[view-height theme-color] | ||
{:position :absolute | ||
:top 0 | ||
:left 0 | ||
:right 0 | ||
;; height must be set, otherwise list will not scroll | ||
:height view-height}) | ||
|
||
(defn button-container | ||
[position] | ||
(merge | ||
{:width 32 | ||
:height 32 | ||
:border-radius 10 | ||
:justify-content :center | ||
:align-items :center | ||
:background-color (colors/theme-colors colors/white-opa-40 colors/neutral-80-opa-40) | ||
:position :absolute | ||
:top 56 | ||
:z-index 3} | ||
position)) | ||
|
||
(defn blur-view | ||
[animation] | ||
(reanimated/apply-animations-to-style | ||
{:transform [{:translateY animation}]} | ||
{:position :absolute | ||
:top 0 | ||
:left 0 | ||
:right 0 | ||
:height 100 | ||
:z-index 2})) | ||
|
||
(defn entity-picture | ||
[animation] | ||
(reanimated/apply-animations-to-style | ||
{:transform [{:scale animation}]} | ||
{:width 80 | ||
:height 80 | ||
:border-radius 40 | ||
:position :absolute | ||
:bottom 0 | ||
:left 20 | ||
:justify-content :center | ||
:align-items :center | ||
:background-color (colors/theme-colors colors/white colors/neutral-95) | ||
:overflow :hidden})) | ||
|
||
(def header-bottom-part | ||
{:position :absolute | ||
:bottom 0 | ||
:height 44 | ||
:left 0 | ||
:right 0 | ||
:background-color (colors/theme-colors colors/white colors/neutral-95) | ||
:border-top-right-radius 16 | ||
:border-top-left-radius 16}) | ||
|
||
(defn title-comp | ||
[animation] | ||
(reanimated/apply-animations-to-style | ||
{:opacity animation} | ||
{:position :absolute | ||
:top 56 | ||
:left 64 | ||
:z-index 3})) |
69 changes: 69 additions & 0 deletions
69
src/status_im2/common/animated_header_list/test_screen.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,69 @@ | ||
(ns status-im2.common.animated-header-list.test-screen | ||
(:require | ||
[quo2.core :as quo] | ||
[quo2.foundations.colors :as colors] | ||
[react-native.core :as rn] | ||
[react-native.fast-image :as fast-image] | ||
[status-im2.common.animated-header-list.view :as animated-header-list])) | ||
|
||
;; THIS IS A TEMPORARY SCREEN. WILL REMOVE AFTER QA TESTING. | ||
|
||
(def data [0 1 2 3 4 5 6 7 8 9 10]) | ||
|
||
(defn child | ||
[] | ||
[rn/view | ||
{:style {:height 100 | ||
:background-color colors/primary-50-opa-40 | ||
:margin 10 | ||
:justify-content :center | ||
:padding-left 10}} | ||
[rn/text "This is some message!!!!!"]]) | ||
|
||
|
||
(defn main-comp | ||
[] | ||
[rn/flat-list | ||
{:data data | ||
:render-fn child | ||
:key-fn (fn [item] (str item))}]) | ||
|
||
(defn display-picture-comp | ||
[] | ||
[fast-image/fast-image | ||
{:style {:width 72 | ||
:height 72 | ||
:border-radius 72} | ||
:source {:uri | ||
"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"}}]) | ||
|
||
(defn title-comp | ||
[] | ||
[rn/view | ||
{:style {:flex-direction :row | ||
:justify-content :center | ||
:align-items :center}} | ||
[fast-image/fast-image | ||
{:source {:uri | ||
"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"} | ||
:style {:width 32 | ||
:height 32 | ||
:border-radius 16 | ||
:margin-right 8}}] | ||
[quo/text {:weight :semi-bold} "Alecia Keys"]]) | ||
|
||
(def theme-color (colors/theme-alpha "#5BCC95" 0.2 0.2)) | ||
|
||
(def parameters | ||
{:theme-color theme-color | ||
:cover-uri | ||
"https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/kitten-playing-with-toy-mouse-royalty-free-image-590055188-1542816918.jpg?crop=1.00xw:0.758xh;0,0.132xh&resize=480:*" | ||
:display-picture-comp display-picture-comp | ||
:title-comp title-comp | ||
:main-comp main-comp}) | ||
|
||
(defn test-screen | ||
[] | ||
[animated-header-list/animated-header-list parameters]) | ||
|
||
|
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,97 @@ | ||
(ns status-im2.common.animated-header-list.view | ||
(:require | ||
[quo2.core :as quo] | ||
[react-native.core :as rn] | ||
[react-native.platform :as platform] | ||
[react-native.reanimated :as reanimated] | ||
[react-native.safe-area :as safe-area] | ||
[reagent.core :as reagent] | ||
[quo2.foundations.colors :as colors] | ||
[status-im.ui.components.fast-image :as fast-image] | ||
[status-im2.common.animated-header-list.style :as style] | ||
[oops.core :as oops] | ||
[utils.re-frame :as rf])) | ||
|
||
(def header-height 192) | ||
|
||
(def threshold (/ header-height 2)) | ||
|
||
(defn scroll-handler | ||
[event initial-y scroll-y opacity-value] | ||
(let [current-y (- (oops/oget event "nativeEvent.contentOffset.y") initial-y)] | ||
(reanimated/set-shared-value scroll-y current-y) | ||
(reanimated/set-shared-value opacity-value | ||
(reanimated/with-timing (if (> current-y threshold) 1 0))))) | ||
|
||
(defn header | ||
[{:keys [theme-color display-picture-comp cover-uri]} top-inset scroll-y] | ||
(let [input-range [0 threshold] | ||
output-range [1 0.4] | ||
scale-animation (reanimated/interpolate scroll-y | ||
input-range | ||
output-range | ||
{:extrapolateLeft "clamp" | ||
:extrapolateRight "clamp"})] | ||
[rn/view | ||
{:style {:height header-height | ||
:background-color (or theme-color (colors/theme-colors colors/white colors/neutral-95)) | ||
:margin-top (when platform/ios? (- top-inset))}} | ||
(when cover-uri | ||
[fast-image/fast-image | ||
{:style {:width "100%" | ||
:height "100%"} | ||
:source {:uri cover-uri}}]) | ||
[rn/view {:style style/header-bottom-part}] | ||
[reanimated/view {:style (style/entity-picture scale-animation)} | ||
[display-picture-comp]]])) | ||
|
||
(defn animated-header-list | ||
[{:keys [title-comp theme-color main-comp] :as parameters}] | ||
[safe-area/consumer | ||
(fn [insets] | ||
(let [window-height (:height (rn/get-window)) | ||
status-bar-height (rn/status-bar-height) | ||
bottom-inset (:bottom insets) | ||
;; view height calculation is different because window height is different on iOS and Android: | ||
;; https://i.stack.imgur.com/LSyW5.png | ||
view-height (if platform/ios? | ||
(- window-height bottom-inset) | ||
(+ window-height status-bar-height)) | ||
input-range [0 threshold] | ||
output-range [-100 0] | ||
initial-y (if platform/ios? (- (:top insets)) 0)] | ||
[:f> | ||
(fn [] | ||
(let [scroll-y (reanimated/use-shared-value initial-y) | ||
translate-animation (reanimated/interpolate scroll-y | ||
input-range | ||
output-range | ||
{:extrapolateLeft "clamp" | ||
:extrapolateRight "clamp"}) | ||
opacity-value (reanimated/use-shared-value 0)] | ||
[rn/view {:style (style/container-view view-height theme-color)} | ||
[rn/touchable-opacity | ||
{:active-opacity 1 | ||
:on-press #(rf/dispatch [:navigate-back]) | ||
:style (style/button-container {:left 20})} | ||
[quo/icon :i/arrow-left {:size 20 :color (colors/theme-colors colors/black colors/white)}]] | ||
[rn/touchable-opacity | ||
{:active-opacity 1 | ||
:style (style/button-container {:right 20})} | ||
[quo/icon :i/options {:size 20 :color (colors/theme-colors colors/black colors/white)}]] | ||
[reanimated/view {:style (style/title-comp opacity-value)} | ||
[title-comp]] | ||
[reanimated/blur-view | ||
{:blurAmount 32 | ||
:blurType :light | ||
:overlayColor (if platform/ios? colors/white-opa-70 :transparent) | ||
:style (style/blur-view translate-animation)}] | ||
[reanimated/flat-list | ||
{:data [nil] | ||
:render-fn main-comp | ||
:key-fn (fn [i] (str i)) | ||
:header (reagent/as-element (header parameters (:top insets) scroll-y)) | ||
:scroll-event-throttle 8 | ||
:on-scroll (fn [event] (scroll-handler event initial-y scroll-y opacity-value))}]]))]))]) | ||
|
||
|
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