Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#16446] Communities banner animation #16567

Merged
merged 11 commits into from
Jul 28, 2023
34 changes: 15 additions & 19 deletions src/quo2/components/community/banner/style.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
(:require [quo2.foundations.colors :as colors]))

(defn community-card
[radius]
{:shadow-offset {:width 0
:height 2}
:shadow-radius radius
:shadow-opacity 1
:shadow-color colors/shadow
:elevation 1
:border-radius radius
:justify-content :space-between
:background-color (colors/theme-colors
colors/white
colors/neutral-90)})
[theme]
{:shadow-offset {:width 0 :height 2}
:shadow-radius 16
:shadow-opacity 1
:shadow-color colors/shadow
:elevation 1
:border-radius 16
:justify-content :space-between
:background-color (colors/theme-colors colors/white colors/neutral-90 theme)
:flex-direction :row
:margin-horizontal 20
:margin-top 8
:margin-bottom 8
ulisesmac marked this conversation as resolved.
Show resolved Hide resolved
:height 56
:padding-right 12})

(def banner-content
{:flex 1
Expand All @@ -25,13 +28,6 @@
{:flex 1
:padding-horizontal 12})

(def banner-card
{:flex-direction :row
:margin-horizontal 20
:margin-vertical 8
:height 56
:padding-right 12})

(def discover-illustration
ulisesmac marked this conversation as resolved.
Show resolved Hide resolved
{:position :absolute
:top -4
Expand Down
28 changes: 11 additions & 17 deletions src/quo2/components/community/banner/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
(:require [quo2.components.community.banner.style :as style]
[quo2.components.markdown.text :as text]
[quo2.foundations.colors :as colors]
[quo2.theme :as theme]
[react-native.core :as rn]))

(defn- card-title-and-description
[title description]
[rn/view
{:style style/banner-content}
[rn/view
{:style style/banner-title}
[title description theme]
[rn/view {:style style/banner-content}
[rn/view {:style style/banner-title}
[text/text
{:accessibility-label :community-name-text
:ellipsize-mode :tail
Expand All @@ -21,26 +20,21 @@
{:accessibility-label :community-name-text
:ellipsize-mode :tail
:number-of-lines 1
:color (colors/theme-colors
colors/neutral-50
colors/neutral-40)
:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)
:weight :regular
:size :paragraph-2}
description]]])

(defn view
[{:keys [title description on-press accessibility-label banner]}]
(defn view-internal
[{:keys [title description on-press accessibility-label banner style theme]}]
[rn/touchable-without-feedback
{:on-press on-press
:accessibility-label accessibility-label}
[rn/view
(merge (style/community-card 16)
{:background-color (colors/theme-colors
colors/white
colors/neutral-90)}
style/banner-card)
[card-title-and-description title description]
[rn/view {:style (merge (style/community-card theme) style)}
[card-title-and-description title description theme]
[rn/image
{:style style/discover-illustration
:source banner
:accessibility-label :discover-communities-illustration}]]])

(def view (theme/with-theme view-internal))
2 changes: 1 addition & 1 deletion src/quo2/components/tabs/tabs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[react-native.masked-view :as masked-view]
[reagent.core :as reagent]
[utils.collection :as utils.collection]
[utils.number :as utils.number]
[utils.number]
[react-native.gesture :as gesture]))

(def default-tab-size 32)
Expand Down
2 changes: 1 addition & 1 deletion src/status_im2/contexts/chat/composer/effects.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[status-im2.contexts.chat.composer.constants :as constants]
[status-im2.contexts.chat.composer.keyboard :as kb]
[status-im2.contexts.chat.composer.utils :as utils]
[utils.number :as utils.number]
[utils.number]
[utils.re-frame :as rf]))

(defn reenter-screen-effect
Expand Down
5 changes: 3 additions & 2 deletions src/status_im2/contexts/chat/composer/gesture.cljs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(ns status-im2.contexts.chat.composer.gesture
(:require
[oops.core :as oops]
[react-native.gesture :as gesture]
[react-native.reanimated :as reanimated]
[oops.core :as oops]
[status-im2.contexts.chat.composer.constants :as constants]
[status-im2.contexts.chat.composer.utils :as utils]
[utils.number]
[utils.re-frame :as rf]))

(defn set-opacity
Expand Down Expand Up @@ -83,7 +84,7 @@
(let [translation (oops/oget event "translationY")
min-height (utils/get-min-height lines images link-previews?)
new-height (- (reanimated/get-shared-value saved-height) translation)
bounded-height (utils/bounded-val new-height min-height max-height)]
bounded-height (utils.number/value-in-range new-height min-height max-height)]
(when keyboard-shown
(if (>= new-height min-height)
(do ; expand sheet
Expand Down
5 changes: 4 additions & 1 deletion src/status_im2/contexts/chat/composer/handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[status-im2.contexts.chat.composer.selection :as selection]
[status-im2.contexts.chat.composer.utils :as utils]
[utils.debounce :as debounce]
[utils.number]
[utils.re-frame :as rf]))

(defn focus
Expand Down Expand Up @@ -82,7 +83,9 @@
content-size (if (or (= lines 1) (empty? @text-value))
constants/input-height
(if (= lines 2) constants/multiline-minimized-height content-size))
new-height (utils/bounded-val content-size constants/input-height max-height)
new-height (utils.number/value-in-range content-size
constants/input-height
max-height)
bottom-content-height (utils/calc-bottom-content-height images link-previews?)
new-height (min (+ new-height bottom-content-height) max-height)]
(reset! content-height content-size)
Expand Down
5 changes: 3 additions & 2 deletions src/status_im2/contexts/chat/composer/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[reagent.core :as reagent]
[status-im2.contexts.chat.composer.constants :as constants]
[status-im2.contexts.chat.composer.selection :as selection]
[utils.number]
[utils.re-frame :as rf]))

(defn bounded-val
Expand Down Expand Up @@ -142,7 +143,7 @@
base (+ base (- curr-height constants/input-height))
base (+ base (calc-top-content-height reply edit))
view-height (- window-height keyboard-height (:top insets))
container-height (bounded-val
container-height (utils.number/value-in-range
(* (/ constants/mentions-max-height 4) size)
(/ constants/mentions-max-height 4)
constants/mentions-max-height)]
Expand Down Expand Up @@ -228,7 +229,7 @@
:saved-height (reanimated/use-shared-value
initial-height)
:last-height (reanimated/use-shared-value
(bounded-val
(utils.number/value-in-range
(+ @content-height bottom-content-height)
constants/input-height
max-height))
Expand Down
54 changes: 43 additions & 11 deletions src/status_im2/contexts/communities/home/style.cljs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
(ns status-im2.contexts.communities.home.style
(:require [quo2.foundations.colors :as colors]
[react-native.platform :as platform]))
[react-native.platform :as platform]
[react-native.safe-area :as safe-area]
[react-native.reanimated :as reanimated]))

(def header-height 245)

(def tabs
{:padding-horizontal 20
:padding-top 16
:padding-top 8
ulisesmac marked this conversation as resolved.
Show resolved Hide resolved
:padding-bottom 12})

(def blur
Expand All @@ -17,8 +19,8 @@
:bottom 0})

(defn empty-state-container
[top]
{:margin-top (+ header-height top)
[]
{:margin-top (+ header-height (safe-area/get-top))
:margin-bottom 44
:flex 1
:justify-content :center})
Expand All @@ -29,16 +31,46 @@
:background-color colors/danger-50})

(defn header-spacing
[top]
{:height (+ header-height top)})
[]
{:height (+ header-height (safe-area/get-top))})

(defn blur-container
[top]
{:overflow (if platform/ios? :visible :hidden)
(defn blur-banner-layer
[animated-translation-y]
(let [fixed-height (+ (safe-area/get-top) 244)]
(reanimated/apply-animations-to-style
{:transform [{:translate-y animated-translation-y}]}
{:overflow (if platform/ios? :visible :hidden)
:z-index 1
:position :absolute
:top 0
:right 0
:left 0
:height fixed-height})))

(defn hiding-banner-layer
[]
{:z-index 2
:position :absolute
:z-index 1
:top 0
:right 0
:left 0
:padding-top top})
:padding-top (safe-area/get-top)})

(defn tabs-banner-layer
[animated-translation-y]
(let [top-offset (+ (safe-area/get-top) 192)]
(reanimated/apply-animations-to-style
{:transform [{:translate-y animated-translation-y}]}
{:z-index 3
:position :absolute
:top top-offset
:right 0
:left 0})))

(def animated-card-container {:overflow :hidden})

(defn animated-card
[opacity translate-y]
(reanimated/apply-animations-to-style {:opacity opacity
:transform [{:translate-y translate-y}]}
{}))
Loading