[#16066] bottom sheet height (#16285)

This commit is contained in:
Ulises Manuel Cárdenas 2023-06-19 07:22:45 -06:00 committed by GitHub
parent 2b465cb980
commit 428616332b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 27 deletions

View File

@ -26,15 +26,17 @@
:style {:color (colors/theme-colors colors/neutral-100 :style {:color (colors/theme-colors colors/neutral-100
colors/white colors/white
(when shell? :dark))} (when shell? :dark))}
:weight :semi-bold} title] :weight :semi-bold}
title]
[rn/view {:style style/content :accessibility-label :documentation-drawer-content} [rn/view {:style style/content :accessibility-label :documentation-drawer-content}
content] content]
(when show-button? (when show-button?
[button/button [button/button
(merge {:size 24 (cond-> {:size 24
:type (if shell? :blur-bg-outline :outline) :type (if shell? :blur-bg-outline :outline)
:on-press on-press-button :on-press on-press-button
:accessibility-label :documentation-drawer-button :accessibility-label :documentation-drawer-button
:after button-icon} :after button-icon}
(when shell? {:override-theme :dark})) button-label])]]) shell? (assoc :override-theme :dark))
button-label])]])

View File

@ -16,7 +16,8 @@
(defn sheet (defn sheet
[{:keys [top bottom]} window-height override-theme padding-bottom-override shell?] [{:keys [top bottom]} window-height override-theme padding-bottom-override shell?]
{:position :absolute {:position :absolute
:max-height (- window-height top 20) :max-height (cond-> window-height
platform/ios? (- top))
:z-index 1 :z-index 1
:bottom 0 :bottom 0
:left 0 :left 0

View File

@ -1,14 +1,14 @@
(ns status-im2.common.bottom-sheet.view (ns status-im2.common.bottom-sheet.view
(:require [utils.re-frame :as rf] (:require [oops.core :as oops]
[react-native.core :as rn]
[quo2.foundations.colors :as colors] [quo2.foundations.colors :as colors]
[react-native.reanimated :as reanimated]
[status-im2.common.bottom-sheet.style :as style]
[react-native.gesture :as gesture]
[oops.core :as oops]
[react-native.hooks :as hooks]
[react-native.blur :as blur] [react-native.blur :as blur]
[reagent.core :as reagent])) [react-native.core :as rn]
[react-native.gesture :as gesture]
[react-native.hooks :as hooks]
[react-native.reanimated :as reanimated]
[reagent.core :as reagent]
[status-im2.common.bottom-sheet.style :as style]
[utils.re-frame :as rf]))
(def duration 450) (def duration 450)
(def timing-options #js {:duration duration}) (def timing-options #js {:duration duration})
@ -62,12 +62,15 @@
translate-y (reanimated/use-shared-value window-height) translate-y (reanimated/use-shared-value window-height)
sheet-gesture (get-sheet-gesture translate-y bg-opacity window-height on-close)] sheet-gesture (get-sheet-gesture translate-y bg-opacity window-height on-close)]
(rn/use-effect (rn/use-effect
#(if hide? (hide translate-y bg-opacity window-height on-close) (show translate-y bg-opacity)) #(if hide?
(hide translate-y bg-opacity window-height on-close)
(show translate-y bg-opacity))
[hide?]) [hide?])
(hooks/use-back-handler #(do (when (fn? on-close) (hooks/use-back-handler (fn []
(on-close)) (when (fn? on-close)
(rf/dispatch [:hide-bottom-sheet]) (on-close))
true)) (rf/dispatch [:hide-bottom-sheet])
true))
[rn/view {:style {:flex 1}} [rn/view {:style {:flex 1}}
;; backdrop ;; backdrop
[rn/touchable-without-feedback {:on-press #(rf/dispatch [:hide-bottom-sheet])} [rn/touchable-without-feedback {:on-press #(rf/dispatch [:hide-bottom-sheet])}
@ -86,8 +89,8 @@
padding-bottom-override padding-bottom-override
shell?)) shell?))
:on-layout #(reset! sheet-height (oops/oget % "nativeEvent" "layout" "height"))} :on-layout #(reset! sheet-height (oops/oget % "nativeEvent" "layout" "height"))}
(when shell? [blur/ios-view {:style style/shell-bg}]) (when shell?
[blur/ios-view {:style style/shell-bg}])
(when selected-item (when selected-item
[rn/view [rn/view
[rn/view {:style (style/selected-item override-theme window-height @sheet-height insets)} [rn/view {:style (style/selected-item override-theme window-height @sheet-height insets)}

View File

@ -33,7 +33,9 @@
(defn show-new-account-options (defn show-new-account-options
[] []
(rf/dispatch [:show-bottom-sheet {:content new-account-options}])) (rf/dispatch [:show-bottom-sheet
{:content new-account-options
:shell? true}]))
(defn delete-profile-confirmation (defn delete-profile-confirmation
[key-uid context] [key-uid context]

View File

@ -82,9 +82,7 @@
{:style {:position :relative :flex 1} {:style {:position :relative :flex 1}
:keyboard-vertical-offset (- (max 20 (:bottom insets)))} :keyboard-vertical-offset (- (max 20 (:bottom insets)))}
(when sheet (when sheet
[:f> [:f> bottom-sheet/f-view {:insets insets :hide? hide?}
bottom-sheet/f-view
{:insets insets :hide? hide?}
sheet])]])))) sheet])]]))))
(def toasts (reagent/reactify-component toasts/toasts)) (def toasts (reagent/reactify-component toasts/toasts))