Skip to content

Commit

Permalink
enhance(iOS): disable webview resize
Browse files Browse the repository at this point in the history
  • Loading branch information
llcc committed May 5, 2022
1 parent 8162394 commit 0cb6751
Show file tree
Hide file tree
Showing 32 changed files with 192 additions and 208 deletions.
3 changes: 3 additions & 0 deletions android/app/src/main/assets/capacitor.config.json
Expand Up @@ -10,6 +10,9 @@
"androidScaleType": "CENTER_CROP",
"splashImmersive": false,
"backgroundColor": "#002b36"
},
"Keyboard": {
"resize": "none"
}
},
"ios": {
Expand Down
4 changes: 4 additions & 0 deletions capacitor.config.ts
Expand Up @@ -13,6 +13,10 @@ const config: CapacitorConfig = {
splashImmersive: false,
backgroundColor: "#002b36"
},

Keyboard: {
resize: "none"
}
},
ios: {
scheme: "Logseq"
Expand Down
3 changes: 3 additions & 0 deletions ios/App/App/capacitor.config.json
Expand Up @@ -10,6 +10,9 @@
"androidScaleType": "CENTER_CROP",
"splashImmersive": false,
"backgroundColor": "#002b36"
},
"Keyboard": {
"resize": "none"
}
},
"ios": {
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/components/block.cljs
Expand Up @@ -259,7 +259,7 @@
(let [src (::src state)
granted? (state/sub [:nfs/user-granted? (state/get-current-repo)])
href (config/get-local-asset-absolute-path href)]
(when (or granted? (util/electron?) (mobile-util/is-native-platform?))
(when (or granted? (util/electron?) (mobile-util/native-platform?))
(p/then (editor-handler/make-asset-url href) #(reset! src %)))

(when @src
Expand Down Expand Up @@ -1467,7 +1467,7 @@
"hide-inner-bullet"))}
[:span.bullet {:blockid (str uuid)}]]]]
(cond
(and (or (mobile-util/is-native-platform?)
(and (or (mobile-util/native-platform?)
(:ui/show-empty-bullets? (state/get-config)))
(not doc-mode?))
bullet
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/components/header.cljs
Expand Up @@ -228,7 +228,7 @@
show-open-folder? (and (nfs/supported?)
(or (empty? repos)
(nil? (state/sub :git/current-repo)))
(not (mobile-util/is-native-platform?))
(not (mobile-util/native-platform?))
(not config/publishing?))]
[:div.cp__header#head
{:class (util/classnames [{:electron-mac electron-mac?
Expand Down Expand Up @@ -271,7 +271,7 @@
(mobile-util/native-ios?))
(back-and-forward))

(when-not (mobile-util/is-native-platform?)
(when-not (mobile-util/native-platform?)
(new-block-mode))

(when show-open-folder?
Expand Down
4 changes: 3 additions & 1 deletion src/main/frontend/components/header.css
Expand Up @@ -221,7 +221,9 @@ html.is-native-iphone-without-notch,
html.is-native-ipad {

#main-container {
padding-top: 0px;
padding-top: 0px;
display: flex;
flex-direction: column;
}

#main-content-container {
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/components/onboarding/setups.cljs
Expand Up @@ -71,10 +71,10 @@
[:section.a
[:strong "Let’s get you set up."]
[:small (str "Where on your " DEVICE " do you want to save your work?")
(when (mobile-util/is-native-platform?)
(when (mobile-util/native-platform?)
(mobile-intro))]

(if (or (nfs/supported?) (mobile-util/is-native-platform?))
(if (or (nfs/supported?) (mobile-util/native-platform?))
[:div.choose.flex.flex-col.items-center
{:on-click #(page-handler/ls-dir-files!
(fn []
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/components/page.cljs
Expand Up @@ -350,7 +350,7 @@
[:div.relative
(when (and (not sidebar?) (not block?))
[:div.flex.flex-row.space-between
(when (or (mobile-util/is-native-platform?) (util/mobile?))
(when (or (mobile-util/native-platform?) (util/mobile?))
[:div.flex.flex-row.pr-2
{:style {:margin-left -15}
:on-mouse-over (fn [e]
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/components/page_menu.cljs
Expand Up @@ -84,7 +84,7 @@
(page-handler/unfavorite-page! page-original-name)
(page-handler/favorite-page! page-original-name)))}}

(when-not (mobile-util/is-native-platform?)
(when-not (mobile-util/native-platform?)
{:title (t :page/presentation-mode)
:options {:on-click (fn []
(state/sidebar-add-block!
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/components/repo.cljs
Expand Up @@ -42,7 +42,7 @@
[:div.pl-1.content.mt-3
[:div.flex.flex-row.my-4
(when (or (nfs-handler/supported?)
(mobile-util/is-native-platform?))
(mobile-util/native-platform?))
[:div.mr-8
(ui/button
(t :open-a-directory)
Expand Down Expand Up @@ -95,7 +95,7 @@
(when (and nfs-repo?
(not= current-repo config/local-repo)
(or (nfs-handler/supported?)
(mobile-util/is-native-platform?)))
(mobile-util/native-platform?)))
{:title (t :sync-from-local-files)
:hover-detail (t :sync-from-local-files-detail)
:options {:on-click
Expand Down
12 changes: 6 additions & 6 deletions src/main/frontend/components/settings.cljs
Expand Up @@ -131,7 +131,7 @@
:href href
:on-click on-click))]
(when-not (or (util/mobile?)
(mobile-util/is-native-platform?))
(mobile-util/native-platform?))
[:div.text-sm desc])]])


Expand Down Expand Up @@ -161,7 +161,7 @@
(ui/toggle show-brackets?
config-handler/toggle-ui-show-brackets!
true)]]
(when (not (or (util/mobile?) (mobile-util/is-native-platform?)))
(when (not (or (util/mobile?) (mobile-util/native-platform?)))
[:div {:style {:text-align "right"}}
(ui/render-keyboard-shortcut (shortcut-helper/gen-shortcut-seq :ui/toggle-brackets))])])

Expand Down Expand Up @@ -559,9 +559,9 @@
(show-brackets-row t show-brackets?)
(when (util/electron?) (switch-spell-check-row t))
(outdenting-row t logical-outdenting?)
(when-not (or (util/mobile?) (mobile-util/is-native-platform?))
(when-not (or (util/mobile?) (mobile-util/native-platform?))
(shortcut-tooltip-row t enable-shortcut-tooltip?))
(when-not (or (util/mobile?) (mobile-util/is-native-platform?))
(when-not (or (util/mobile?) (mobile-util/native-platform?))
(tooltip-row t enable-tooltip?))
(timetracking-row t enable-timetracking?)
(journal-row t enable-journals?)
Expand Down Expand Up @@ -610,7 +610,7 @@
[:div.panel-wrap.is-advanced
(when (and util/mac? (util/electron?)) (app-auto-update-row t))
(usage-diagnostics-row t instrument-disabled?)
(when-not (mobile-util/is-native-platform?) (developer-mode-row t developer-mode?))
(when-not (mobile-util/native-platform?) (developer-mode-row t developer-mode?))
(when (util/electron?) (plugin-system-switcher-row))
(when (util/electron?) (https-user-agent-row https-agent-opts))
(clear-cache-row t)
Expand Down Expand Up @@ -648,7 +648,7 @@
(for [[label text icon]
[[:general (t :settings-page/tab-general) (ui/icon "adjustments" {:style {:font-size 20}})]
[:editor (t :settings-page/tab-editor) (ui/icon "writing" {:style {:font-size 20}})]
(when-not (mobile-util/is-native-platform?)
(when-not (mobile-util/native-platform?)
[:git (t :settings-page/tab-version-control) (ui/icon "history" {:style {:font-size 20}})])
[:advanced (t :settings-page/tab-advanced) (ui/icon "bulb" {:style {:font-size 20}})]
(when plugins-of-settings
Expand Down
32 changes: 18 additions & 14 deletions src/main/frontend/components/sidebar.cljs
@@ -1,40 +1,44 @@
(ns frontend.components.sidebar
(:require [cljs-drag-n-drop.core :as dnd]
[clojure.string :as string]
[frontend.commands :as commands]
[frontend.components.command-palette :as command-palette]
[frontend.components.header :as header]
[frontend.components.journal :as journal]
[frontend.components.onboarding :as onboarding]
[frontend.components.plugins :as plugins]
[frontend.components.repo :as repo]
[frontend.components.right-sidebar :as right-sidebar]
[frontend.components.select :as select]
[frontend.components.svg :as svg]
[frontend.components.theme :as theme]
[frontend.components.widgets :as widgets]
[frontend.components.plugins :as plugins]
[frontend.components.select :as select]
[frontend.config :as config]
[frontend.context.i18n :refer [t]]
[frontend.db :as db]
[frontend.db.model :as db-model]
[frontend.components.svg :as svg]
[frontend.db-mixins :as db-mixins]
[frontend.db.model :as db-model]
[frontend.extensions.pdf.assets :as pdf-assets]
[frontend.extensions.srs :as srs]
[frontend.handler.config :as config-handler]
[frontend.handler.editor :as editor-handler]
[frontend.handler.route :as route-handler]
[frontend.handler.history :as history]
[frontend.handler.mobile.swipe :as swipe]
[frontend.handler.page :as page-handler]
[frontend.handler.route :as route-handler]
[frontend.handler.user :as user-handler]
[frontend.mixins :as mixins]
[frontend.mobile.camera :as mobile-camera]
[frontend.mobile.footer :as footer]
[frontend.mobile.util :as mobile-util]
[frontend.modules.shortcut.data-helper :as shortcut-dh]
[frontend.state :as state]
[frontend.ui :as ui]
[frontend.util :as util]
[reitit.frontend.easy :as rfe]
[goog.dom :as gdom]
[goog.object :as gobj]
[rum.core :as rum]
[frontend.extensions.srs :as srs]
[frontend.extensions.pdf.assets :as pdf-assets]
[frontend.mobile.util :as mobile-util]
[frontend.handler.mobile.swipe :as swipe]
[frontend.components.onboarding :as onboarding]
[frontend.mobile.footer :as footer]))
[reitit.frontend.easy :as rfe]
[rum.core :as rum]))

(rum/defc nav-content-item
[name {:keys [class]} child]
Expand Down Expand Up @@ -524,7 +528,7 @@
:db-restoring? db-restoring?
:main-content main-content})

(when (and (mobile-util/is-native-platform?)
(when (and (mobile-util/native-platform?)
current-repo
(not (state/sub :modal/show?)))
(footer/footer))]
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/components/widgets.cljs
Expand Up @@ -12,8 +12,8 @@
[]
[:div.flex.flex-col
[:h1.title (t :on-boarding/add-graph)]
(let [nfs-supported? (or (nfs/supported?) (mobile-util/is-native-platform?))]
(if (mobile-util/is-native-platform?)
(let [nfs-supported? (or (nfs/supported?) (mobile-util/native-platform?))]
(if (mobile-util/native-platform?)
[:div.text-sm
(ui/button "Open a local directory"
:on-click #(page-handler/ls-dir-files! shortcut/refresh!))
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/config.cljs
Expand Up @@ -321,7 +321,7 @@
(and (util/electron?) (local-db? repo-url))
(get-local-dir repo-url)

(and (mobile-util/is-native-platform?) (local-db? repo-url))
(and (mobile-util/native-platform?) (local-db? repo-url))
(let [dir (get-local-dir repo-url)]
(if (string/starts-with? dir "file:")
dir
Expand All @@ -334,7 +334,7 @@

(defn get-repo-path
[repo-url path]
(if (and (or (util/electron?) (mobile-util/is-native-platform?))
(if (and (or (util/electron?) (mobile-util/native-platform?))
(local-db? repo-url))
path
(util/node-path.join (get-repo-dir repo-url) path)))
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/db/conn.cljs
Expand Up @@ -22,7 +22,7 @@
(defn get-repo-name
[repo]
(cond
(mobile-util/is-native-platform?)
(mobile-util/native-platform?)
(text/get-graph-name-from-path repo)

(config/local-db? repo)
Expand All @@ -35,7 +35,7 @@
"repo-path: output of `get-repo-name`"
[repo-path]
(if (or (util/electron?)
(mobile-util/is-native-platform?))
(mobile-util/native-platform?))
(text/get-file-basename repo-path)
repo-path))

Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/extensions/excalidraw.cljs
Expand Up @@ -149,5 +149,5 @@
(when-not (and (config/local-db? repo)
(not granted?)
(not (util/electron?))
(not (mobile-util/is-native-platform?)))
(not (mobile-util/native-platform?)))
(draw-container option))))
2 changes: 1 addition & 1 deletion src/main/frontend/extensions/video/youtube.cljs
Expand Up @@ -109,7 +109,7 @@
(defn gen-youtube-ts-macro []
(if-let [player (get-player (state/get-input))]
(util/format "{{youtube-timestamp %s}}" (Math/floor (.getCurrentTime ^js player)))
(when (mobile-util/is-native-platform?)
(when (mobile-util/native-platform?)
(notification/show!
"Please embed a YouTube video at first, then use this icon.
Remember: You can paste a raw YouTube url as embedded video on mobile."
Expand Down
10 changes: 5 additions & 5 deletions src/main/frontend/fs.cljs
Expand Up @@ -31,7 +31,7 @@
(and (util/electron?) (not bfs-local?))
node-record

(mobile-util/is-native-platform?)
(mobile-util/native-platform?)
mobile-record

(local-db? dir)
Expand Down Expand Up @@ -105,7 +105,7 @@

:else
(let [[old-path new-path]
(map #(if (or (util/electron?) (mobile-util/is-native-platform?))
(map #(if (or (util/electron?) (mobile-util/native-platform?))
%
(str (config/get-repo-dir repo) "/" %))
[old-path new-path])]
Expand All @@ -121,7 +121,7 @@
(util/electron?)
node-record

(mobile-util/is-native-platform?)
(mobile-util/native-platform?)
mobile-record

:else
Expand All @@ -132,7 +132,7 @@
(let [record (get-record)]
(p/let [result (protocol/open-dir record ok-handler)]
(if (or (util/electron?)
(mobile-util/is-native-platform?))
(mobile-util/native-platform?))
(let [[dir & paths] (bean/->clj result)]
[(:path dir) paths])
result))))
Expand All @@ -141,7 +141,7 @@
[path-or-handle ok-handler]
(let [record (get-record)
electron? (util/electron?)
mobile? (mobile-util/is-native-platform?)]
mobile? (mobile-util/native-platform?)]
(p/let [result (protocol/get-files record path-or-handle ok-handler)]
(if (or electron? mobile?)
(let [result (bean/->clj result)]
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/handler.cljs
Expand Up @@ -92,7 +92,7 @@
(and (not (seq (db/get-files config/local-repo)))
;; Not native local directory
(not (some config/local-db? (map :url repos)))
(not (mobile-util/is-native-platform?)))
(not (mobile-util/native-platform?)))
;; will execute `(state/set-db-restoring! false)` inside
(repo-handler/setup-local-repo-if-not-exists!)

Expand Down Expand Up @@ -191,7 +191,7 @@
(p/let [repos (get-repos)]
(state/set-repos! repos)
(restore-and-setup! repos db-schema)
(when (mobile-util/is-native-platform?)
(when (mobile-util/native-platform?)
(p/do! (mobile-util/hide-splash))))

(reset! db/*sync-search-indice-f search/sync-search-indice!)
Expand Down

0 comments on commit 0cb6751

Please sign in to comment.