enhance(mobile): make input into viewport when initial editing

pull/3547/head
charlie 2021-12-22 17:12:54 +08:00
parent 6b45277229
commit a72de57627
4 changed files with 16 additions and 7 deletions

View File

@ -162,7 +162,6 @@
(remove #(= (:url %) config/local-repo)))
electron-mac? (and util/mac? (util/electron?))
vw-state (state/sub :ui/visual-viewport-state)
vw-pending? (state/sub :ui/visual-viewport-pending?)
show-open-folder? (and (or (nfs/supported?)
(mobile-util/is-native-platform?))
(empty? repos)
@ -172,8 +171,7 @@
[:div.cp__header#head
{:class (util/classnames [{:electron-mac electron-mac?
:native-ios (mobile-util/native-ios?)
:native-android (mobile-util/native-android?)
:is-vw-pending (boolean vw-pending?)}])
:native-android (mobile-util/native-android?)}])
:on-double-click (fn [^js e]
(when-let [target (.-target e)]
(when (and (util/electron?)

View File

@ -23,7 +23,7 @@
(.focus element)
(when (or (mobile-util/is-native-platform?)
(util/mobile?))
(js/setTimeout #(util/make-el-into-viewport element 60) 80))))
(js/setTimeout #(util/make-el-into-viewport element 60) 64))))
state)
(defn did-remount!

View File

@ -221,6 +221,15 @@
(reset! st/*inited? true)
(st/consume-pending-shortcuts!)))
(defmethod handle :mobile/keyboard-will-show [[_]]
(when (state/get-left-sidebar-open?)
(state/set-left-sidebar-open! false)))
(defmethod handle :mobile/keyboard-did-show [[_]]
(when-let [input (state/get-input)]
(js/setTimeout #(util/make-el-into-viewport input 60) 64)))
(defn run!
[]
(let [chan (state/get-events-chan)]

View File

@ -34,7 +34,9 @@
(when (mobile-util/native-ios?)
(let [path (fs/iOS-ensure-documents!)]
(println "iOS container path: " path))
;; keyboard watcher
;; Keyboard watcher
(.addListener Keyboard "keyboardWillShow"
#(when (state/get-left-sidebar-open?)
(state/set-left-sidebar-open! false)))))
#(state/pub-event! [:mobile/keyboard-will-show]))
(.addListener Keyboard "keyboardDidShow"
#(state/pub-event! [:mobile/keyboard-did-show]))))