-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
99 additions
and
175 deletions.
There are no files selected for viewing
29 changes: 14 additions & 15 deletions
29
src/status_im2/common/floating_button_page/floating_container/style.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,18 +1,17 @@ | ||
(ns status-im2.common.floating-button-page.floating-container.style | ||
(:require [react-native.platform :as platform])) | ||
(:require [react-native.safe-area :as safe-area])) | ||
|
||
(def container | ||
{:width "100%" | ||
:margin-top :auto | ||
:align-self :flex-end}) | ||
(defn content-container | ||
[blur? keyboard-shown?] | ||
(let [margin-bottom (if keyboard-shown? 0 (safe-area/get-bottom))] | ||
(cond-> {:margin-top :auto | ||
:overflow :hidden | ||
:margin-bottom margin-bottom | ||
:padding-vertical 12 | ||
:padding-horizontal 20} | ||
blur? (dissoc :padding-vertical :padding-horizontal)))) | ||
|
||
(def view-container | ||
(assoc container | ||
:padding-left 20 | ||
:padding-right 20 | ||
:padding-top 12 | ||
:padding-bottom 12)) | ||
|
||
(def blur-container | ||
(merge container | ||
(when platform/android? {:margin-left 20}))) | ||
(def blur-inner-container | ||
{:background-color :transparent ; required, otherwise blur-view will shrink | ||
:padding-vertical 12 | ||
:padding-horizontal 20}) |
84 changes: 17 additions & 67 deletions
84
src/status_im2/common/floating_button_page/floating_container/view.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,75 +1,25 @@ | ||
(ns status-im2.common.floating-button-page.floating-container.view | ||
(:require [quo.foundations.colors :as colors] | ||
[quo.theme :as quo.theme] | ||
(:require [quo.theme :as quo.theme] | ||
[react-native.blur :as blur] | ||
[react-native.core :as rn] | ||
[react-native.platform :as platform] | ||
[react-native.reanimated :as reanimated] | ||
[react-native.safe-area :as safe-area] | ||
[status-im2.common.floating-button-page.floating-container.style :as style])) | ||
|
||
(def duration 100) | ||
|
||
(defn blur-container-props | ||
[theme] | ||
{:blur-amount 12 | ||
:blur-radius 25 | ||
:blur-type (quo.theme/theme-value :light :dark theme) | ||
:style (when platform/ios? | ||
{:width "100%" | ||
:padding-horizontal 20 | ||
:padding-vertical 12}) | ||
:background-color (colors/theme-colors colors/white-70-blur colors/neutral-80-opa-1-blur theme)}) | ||
|
||
(defn- blur-container | ||
[props & children] | ||
[rn/view | ||
(merge props | ||
{:width "100%" | ||
:overflow :hidden} | ||
(when platform/android? | ||
{:padding-horizontal 20 | ||
:padding-vertical 12})) | ||
(into [blur/view (blur-container-props (:theme props))] children)]) | ||
[child theme] | ||
[blur/view | ||
{:blur-amount 12 | ||
:blur-radius 12 | ||
:blur-type (quo.theme/theme-value :light :dark theme)} | ||
[rn/view {:style style/blur-inner-container} | ||
child]]) | ||
|
||
" | ||
- on-layout : will trigger to dynamically get the height of the container to screen using it. | ||
- show-background? : blurred container that is activated when this component is on top of the page content. | ||
- keyboard-shown? : keyboard is visible on the current page. | ||
" | ||
(defn get-margin-bottom | ||
[show-background? keyboard-will-show?] | ||
(if platform/android? | ||
0 | ||
(cond keyboard-will-show? (safe-area/get-top) | ||
(and show-background? keyboard-will-show?) (safe-area/get-bottom) | ||
:else (safe-area/get-bottom)))) | ||
|
||
(defn f-view | ||
[{:keys [on-layout show-background? keyboard-will-show?]} | ||
children] | ||
(let [theme (quo.theme/use-theme-value) | ||
container-view (if show-background? blur-container rn/view) | ||
inline-container-style (if show-background? style/blur-container style/view-container) | ||
margin-bottom (reanimated/use-shared-value (get-margin-bottom show-background? | ||
keyboard-will-show?))] | ||
(rn/use-effect #(reanimated/animate-shared-value-with-timing | ||
margin-bottom | ||
(get-margin-bottom show-background? keyboard-will-show?) | ||
duration | ||
:easing4) | ||
[keyboard-will-show?]) | ||
[reanimated/view | ||
{:style (reanimated/apply-animations-to-style | ||
{:margin-bottom margin-bottom} | ||
{:margin-top :auto})} | ||
[container-view | ||
{:on-layout on-layout | ||
:theme theme | ||
:style | ||
(merge inline-container-style)} | ||
children]])) | ||
(defn view-internal | ||
[{:keys [theme on-layout keyboard-shown? blur?]} child] | ||
[rn/view | ||
{:style (style/content-container blur? keyboard-shown?) | ||
:on-layout on-layout} | ||
(if blur? | ||
[blur-container child theme] | ||
child)]) | ||
|
||
(defn view | ||
[props children] | ||
[:f> f-view props children]) | ||
(def view (quo.theme/with-theme view-internal)) |
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