This commit is contained in:
parent
1047190d69
commit
ca35de2f72
|
@ -39,9 +39,11 @@
|
||||||
:bottom 0})
|
:bottom 0})
|
||||||
|
|
||||||
(defn selected-item
|
(defn selected-item
|
||||||
[override-theme]
|
[override-theme window-height sheet-height {:keys [top]}]
|
||||||
{:position :absolute
|
{:position :absolute
|
||||||
:bottom 10
|
:bottom 10
|
||||||
|
:max-height (- window-height sheet-height top)
|
||||||
|
:overflow :hidden
|
||||||
:left 0
|
:left 0
|
||||||
:right 0
|
:right 0
|
||||||
:border-radius 12
|
:border-radius 12
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
[react-native.gesture :as gesture]
|
[react-native.gesture :as gesture]
|
||||||
[oops.core :as oops]
|
[oops.core :as oops]
|
||||||
[react-native.hooks :as hooks]
|
[react-native.hooks :as hooks]
|
||||||
[react-native.blur :as blur]))
|
[react-native.blur :as blur]
|
||||||
|
[reagent.core :as reagent]))
|
||||||
|
|
||||||
(def duration 450)
|
(def duration 450)
|
||||||
(def timing-options #js {:duration duration})
|
(def timing-options #js {:duration duration})
|
||||||
|
@ -51,44 +52,48 @@
|
||||||
(show translate-y bg-opacity)
|
(show translate-y bg-opacity)
|
||||||
(hide translate-y bg-opacity window-height on-close))))))
|
(hide translate-y bg-opacity window-height on-close))))))
|
||||||
|
|
||||||
(defn view
|
(defn f-view
|
||||||
[{:keys [hide? insets]}
|
[_ _]
|
||||||
{:keys [content override-theme selected-item padding-bottom-override on-close shell?]}]
|
(let [sheet-height (reagent/atom 0)]
|
||||||
(let [{window-height :height} (rn/get-window)
|
(fn [{:keys [hide? insets]}
|
||||||
bg-opacity (reanimated/use-shared-value 0)
|
{:keys [content override-theme selected-item padding-bottom-override on-close shell?]}]
|
||||||
translate-y (reanimated/use-shared-value window-height)
|
(let [{window-height :height} (rn/get-window)
|
||||||
sheet-gesture (get-sheet-gesture translate-y bg-opacity window-height on-close)]
|
bg-opacity (reanimated/use-shared-value 0)
|
||||||
(rn/use-effect
|
translate-y (reanimated/use-shared-value window-height)
|
||||||
#(if hide? (hide translate-y bg-opacity window-height on-close) (show translate-y bg-opacity))
|
sheet-gesture (get-sheet-gesture translate-y bg-opacity window-height on-close)]
|
||||||
[hide?])
|
(rn/use-effect
|
||||||
(hooks/use-back-handler #(do (when (fn? on-close)
|
#(if hide? (hide translate-y bg-opacity window-height on-close) (show translate-y bg-opacity))
|
||||||
(on-close))
|
[hide?])
|
||||||
(rf/dispatch [:hide-bottom-sheet])
|
(hooks/use-back-handler #(do (when (fn? on-close)
|
||||||
true))
|
(on-close))
|
||||||
[rn/view {:flex 1}
|
(rf/dispatch [:hide-bottom-sheet])
|
||||||
;; backdrop
|
true))
|
||||||
[rn/touchable-without-feedback {:on-press #(rf/dispatch [:hide-bottom-sheet])}
|
[rn/view {:style {:flex 1}}
|
||||||
[reanimated/view
|
;; backdrop
|
||||||
{:style (reanimated/apply-animations-to-style
|
[rn/touchable-without-feedback {:on-press #(rf/dispatch [:hide-bottom-sheet])}
|
||||||
{:opacity bg-opacity}
|
[reanimated/view
|
||||||
{:flex 1 :background-color colors/neutral-100-opa-70})}]]
|
{:style (reanimated/apply-animations-to-style
|
||||||
;; sheet
|
{:opacity bg-opacity}
|
||||||
[gesture/gesture-detector {:gesture sheet-gesture}
|
{:flex 1 :background-color colors/neutral-100-opa-70})}]]
|
||||||
[reanimated/view
|
;; sheet
|
||||||
{:style (reanimated/apply-animations-to-style
|
[gesture/gesture-detector {:gesture sheet-gesture}
|
||||||
{:transform [{:translateY translate-y}]}
|
[reanimated/view
|
||||||
(styles/sheet insets window-height override-theme padding-bottom-override shell?))}
|
{:style (reanimated/apply-animations-to-style
|
||||||
|
{:transform [{:translateY translate-y}]}
|
||||||
|
(styles/sheet insets
|
||||||
|
window-height
|
||||||
|
override-theme
|
||||||
|
padding-bottom-override
|
||||||
|
shell?))
|
||||||
|
:on-layout #(reset! sheet-height (oops/oget % "nativeEvent" "layout" "height"))}
|
||||||
|
(when shell? [blur/ios-view {:style styles/shell-bg}])
|
||||||
|
|
||||||
(when shell?
|
(when selected-item
|
||||||
[blur/ios-view
|
[rn/view
|
||||||
{:style styles/shell-bg}])
|
[rn/view {:style (styles/selected-item override-theme window-height @sheet-height insets)}
|
||||||
|
[selected-item]]])
|
||||||
|
|
||||||
(when selected-item
|
;; handle
|
||||||
[rn/view
|
[rn/view {:style (styles/handle override-theme)}]
|
||||||
[rn/view {:style (styles/selected-item override-theme)}
|
;; content
|
||||||
[selected-item]]])
|
[content]]]]))))
|
||||||
|
|
||||||
;; handle
|
|
||||||
[rn/view {:style (styles/handle override-theme)}]
|
|
||||||
;; content
|
|
||||||
[content]]]]))
|
|
||||||
|
|
|
@ -74,11 +74,7 @@
|
||||||
constants/content-type-contact-request [not-implemented/not-implemented
|
constants/content-type-contact-request [not-implemented/not-implemented
|
||||||
[old-message/system-contact-request message-data]])))
|
[old-message/system-contact-request message-data]])))
|
||||||
|
|
||||||
(defn on-long-press
|
(declare on-long-press)
|
||||||
[message-data context]
|
|
||||||
(rf/dispatch [:dismiss-keyboard])
|
|
||||||
(rf/dispatch [:show-bottom-sheet
|
|
||||||
{:content (drawers/reactions-and-actions message-data context)}]))
|
|
||||||
|
|
||||||
(defn user-message-content
|
(defn user-message-content
|
||||||
[]
|
[]
|
||||||
|
@ -94,7 +90,9 @@
|
||||||
outgoing (if (= content-type constants/content-type-album)
|
outgoing (if (= content-type constants/content-type-album)
|
||||||
(:outgoing first-image)
|
(:outgoing first-image)
|
||||||
outgoing)
|
outgoing)
|
||||||
context (assoc context :on-long-press #(on-long-press message-data context))
|
context (assoc context
|
||||||
|
:on-long-press
|
||||||
|
#(on-long-press message-data context keyboard-shown?))
|
||||||
response-to (:response-to content)
|
response-to (:response-to content)
|
||||||
height (rf/sub [:dimensions/window-height])]
|
height (rf/sub [:dimensions/window-height])]
|
||||||
[rn/touchable-highlight
|
[rn/touchable-highlight
|
||||||
|
@ -113,7 +111,7 @@
|
||||||
(reset! show-delivery-state? true)
|
(reset! show-delivery-state? true)
|
||||||
(js/setTimeout #(reset! show-delivery-state? false)
|
(js/setTimeout #(reset! show-delivery-state? false)
|
||||||
delivery-state-showing-time-ms))))
|
delivery-state-showing-time-ms))))
|
||||||
:on-long-press #(on-long-press message-data context)}
|
:on-long-press #(on-long-press message-data context keyboard-shown?)}
|
||||||
[rn/view {:style {:padding-vertical 8}}
|
[rn/view {:style {:padding-vertical 8}}
|
||||||
(when (and (seq response-to) quoted-message)
|
(when (and (seq response-to) quoted-message)
|
||||||
[reply/quoted-message quoted-message])
|
[reply/quoted-message quoted-message])
|
||||||
|
@ -152,6 +150,15 @@
|
||||||
(when @show-delivery-state?
|
(when @show-delivery-state?
|
||||||
[status/status outgoing-status])])]]]))))
|
[status/status outgoing-status])])]]]))))
|
||||||
|
|
||||||
|
(defn on-long-press
|
||||||
|
[message-data context keyboard-shown]
|
||||||
|
(rf/dispatch [:dismiss-keyboard])
|
||||||
|
(rf/dispatch [:show-bottom-sheet
|
||||||
|
{:content (drawers/reactions-and-actions message-data context)
|
||||||
|
:selected-item (fn []
|
||||||
|
[rn/view {:pointer-events :none}
|
||||||
|
[user-message-content message-data context keyboard-shown true]])}]))
|
||||||
|
|
||||||
(defn message-with-reactions
|
(defn message-with-reactions
|
||||||
[{:keys [pinned-by mentioned in-pinned-view? content-type last-in-group?] :as message-data}
|
[{:keys [pinned-by mentioned in-pinned-view? content-type last-in-group?] :as message-data}
|
||||||
context
|
context
|
||||||
|
@ -168,4 +175,5 @@
|
||||||
[system-message-content message-data]
|
[system-message-content message-data]
|
||||||
[user-message-content message-data context keyboard-shown false])
|
[user-message-content message-data context keyboard-shown false])
|
||||||
[reactions/message-reactions-row message-data
|
[reactions/message-reactions-row message-data
|
||||||
[user-message-content message-data context keyboard-shown true]]])
|
[rn/view {:pointer-events :none}
|
||||||
|
[user-message-content message-data context keyboard-shown true]]]])
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
:keyboard-vertical-offset (- (max 20 (:bottom insets)))}
|
:keyboard-vertical-offset (- (max 20 (:bottom insets)))}
|
||||||
(when sheet
|
(when sheet
|
||||||
[:f>
|
[:f>
|
||||||
bottom-sheet/view
|
bottom-sheet/f-view
|
||||||
{:insets insets :hide? hide?}
|
{:insets insets :hide? hide?}
|
||||||
sheet])]]))))
|
sheet])]]))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue