|
@@ -1,9 +1,14 @@
|
|
|
(ns mobile.components.popup
|
|
(ns mobile.components.popup
|
|
|
"Mobile popup"
|
|
"Mobile popup"
|
|
|
(:require [dommy.core :as dom]
|
|
(:require [dommy.core :as dom]
|
|
|
|
|
+ [frontend.db :as db]
|
|
|
|
|
+ [frontend.handler.editor :as editor-handler]
|
|
|
[frontend.state :as state]
|
|
[frontend.state :as state]
|
|
|
|
|
+ [logseq.common.config :as common-config]
|
|
|
|
|
+ [logseq.db :as ldb]
|
|
|
[logseq.shui.popup.core :as shui-popup]
|
|
[logseq.shui.popup.core :as shui-popup]
|
|
|
[logseq.shui.ui :as shui]
|
|
[logseq.shui.ui :as shui]
|
|
|
|
|
+ [mobile.components.ui :as mobile-ui]
|
|
|
[mobile.init :as init]
|
|
[mobile.init :as init]
|
|
|
[mobile.ionic :as ion]
|
|
[mobile.ionic :as ion]
|
|
|
[mobile.state :as mobile-state]
|
|
[mobile.state :as mobile-state]
|
|
@@ -11,7 +16,7 @@
|
|
|
|
|
|
|
|
(defonce *last-popup-modal? (atom nil))
|
|
(defonce *last-popup-modal? (atom nil))
|
|
|
|
|
|
|
|
-(defn warp-calc-commands-popup-side
|
|
|
|
|
|
|
+(defn wrap-calc-commands-popup-side
|
|
|
[pos opts]
|
|
[pos opts]
|
|
|
(let [[side mh] (let [[_x y _ height] pos
|
|
(let [[side mh] (let [[_x y _ height] pos
|
|
|
vh js/window.innerHeight
|
|
vh js/window.innerHeight
|
|
@@ -29,7 +34,7 @@
|
|
|
[event content-fn {:keys [id dropdown-menu?] :as opts}]
|
|
[event content-fn {:keys [id dropdown-menu?] :as opts}]
|
|
|
(cond
|
|
(cond
|
|
|
(and (keyword? id) (= "editor.commands" (namespace id)))
|
|
(and (keyword? id) (= "editor.commands" (namespace id)))
|
|
|
- (let [opts (warp-calc-commands-popup-side event opts)
|
|
|
|
|
|
|
+ (let [opts (wrap-calc-commands-popup-side event opts)
|
|
|
side (some-> opts :content-props :side)
|
|
side (some-> opts :content-props :side)
|
|
|
max-h (some-> opts :max-popup-height (js/parseInt) (- 48))
|
|
max-h (some-> opts :max-popup-height (js/parseInt) (- 48))
|
|
|
_ (when max-h (js/document.documentElement.style.setProperty
|
|
_ (when max-h (js/document.documentElement.style.setProperty
|
|
@@ -65,13 +70,30 @@
|
|
|
(set! shui/popup-show! popup-show!)
|
|
(set! shui/popup-show! popup-show!)
|
|
|
(set! shui/popup-hide! popup-hide!)
|
|
(set! shui/popup-hide! popup-hide!)
|
|
|
|
|
|
|
|
|
|
+(rum/defc inner-content <
|
|
|
|
|
+ {:will-unmount (fn [state]
|
|
|
|
|
+ (state/clear-edit!)
|
|
|
|
|
+ (init/keyboard-hide)
|
|
|
|
|
+ state)}
|
|
|
|
|
+ [content-fn]
|
|
|
|
|
+ (content-fn))
|
|
|
|
|
+
|
|
|
(rum/defc popup < rum/reactive
|
|
(rum/defc popup < rum/reactive
|
|
|
[]
|
|
[]
|
|
|
(let [{:keys [open? content-fn opts]} (rum/react mobile-state/*popup-data)
|
|
(let [{:keys [open? content-fn opts]} (rum/react mobile-state/*popup-data)
|
|
|
initial-breakpoint (if (= (:id opts) :ls-quick-add) 1 0.75)]
|
|
initial-breakpoint (if (= (:id opts) :ls-quick-add) 1 0.75)]
|
|
|
(when open?
|
|
(when open?
|
|
|
- (state/clear-edit!)
|
|
|
|
|
- (init/keyboard-hide))
|
|
|
|
|
|
|
+ (if (= :ls-quick-add (:id opts))
|
|
|
|
|
+ (when-let [add-page (ldb/get-built-in-page (db/get-db) common-config/quick-add-page-name)]
|
|
|
|
|
+ (when (:block/_parent add-page)
|
|
|
|
|
+ (js/setTimeout
|
|
|
|
|
+ (fn []
|
|
|
|
|
+ (let [block (last (ldb/sort-by-order (:block/_parent add-page)))]
|
|
|
|
|
+ (editor-handler/edit-block! block :max {:container-id :unknown-container})))
|
|
|
|
|
+ 500)))
|
|
|
|
|
+ (do
|
|
|
|
|
+ (state/clear-edit!)
|
|
|
|
|
+ (init/keyboard-hide))))
|
|
|
(ion/modal
|
|
(ion/modal
|
|
|
(merge
|
|
(merge
|
|
|
{:isOpen (boolean open?)
|
|
{:isOpen (boolean open?)
|
|
@@ -86,4 +108,5 @@
|
|
|
(when-let [title (:title opts)]
|
|
(when-let [title (:title opts)]
|
|
|
[:h2.py-2.opacity-40 title])
|
|
[:h2.py-2.opacity-40 title])
|
|
|
(when content-fn
|
|
(when content-fn
|
|
|
- (content-fn))]))))
|
|
|
|
|
|
|
+ (mobile-ui/classic-app-container-wrap
|
|
|
|
|
+ (inner-content content-fn)))]))))
|