-
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.
chore: add floating button page component
- Loading branch information
Showing
19 changed files
with
459 additions
and
34 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
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
32 changes: 32 additions & 0 deletions
32
src/status_im2/common/floating_button_page/component_spec.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,32 @@ | ||
(ns status-im2.common.floating-button-page.component-spec | ||
(:require [quo.core :as quo] | ||
[status-im2.common.floating-button-page.view :as floating-button-page] | ||
[test-helpers.component :as h])) | ||
|
||
(h/describe "floating button page" | ||
(h/test "renders with a header and standard button" | ||
(h/render [floating-button-page/view | ||
{:header [quo/page-nav | ||
{:type :title-description | ||
:title "floating button page" | ||
:description "press right icon to swap button type" | ||
:text-align :left | ||
:background :blur | ||
:icon-name :i/close}] | ||
:footer [quo/button {} "continue"]}]) | ||
(h/is-truthy (h/get-by-text "continue")) | ||
(h/is-truthy (h/get-by-text "floating button page"))) | ||
|
||
(h/test "renders with a header and a slide button" | ||
(h/render [floating-button-page/view | ||
{:header [quo/page-nav | ||
{:type :title-description | ||
:title "floating button page" | ||
:description "press right icon to swap button type" | ||
:text-align :left | ||
:background :blur | ||
:icon-name :i/close}] | ||
:footer [quo/slide-button | ||
{:track-text "We gotta slide" | ||
:track-icon :face-id}]}]) | ||
(h/is-truthy (h/get-by-text "We gotta slide")))) |
18 changes: 18 additions & 0 deletions
18
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(ns status-im2.common.floating-button-page.floating-container.style | ||
(:require [react-native.platform :as platform])) | ||
|
||
(def container | ||
{:width "100%" | ||
:margin-top :auto | ||
:align-self :flex-end}) | ||
|
||
(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}))) |
75 changes: 75 additions & 0 deletions
75
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
(ns status-im2.common.floating-button-page.floating-container.view | ||
(:require [quo.foundations.colors :as colors] | ||
[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)]) | ||
|
||
" | ||
- 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 | ||
[props children] | ||
[:f> f-view props children]) |
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,15 @@ | ||
(ns status-im2.common.floating-button-page.style) | ||
|
||
(def page-container | ||
{:position :absolute | ||
:top 0 | ||
:bottom 0 | ||
:left 0 | ||
:right 0}) | ||
|
||
(def keyboard-avoiding-view | ||
{:position :absolute | ||
:top 0 | ||
:bottom 0 | ||
:left 0 | ||
:right 0}) |
Oops, something went wrong.