Utils.swift 632 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // Utils.swift
  3. // Logseq
  4. //
  5. // Created by leizhe on 2022/5/23.
  6. //
  7. import Foundation
  8. import Capacitor
  9. @objc(Utils)
  10. public class Utils: CAPPlugin {
  11. @objc func isZoomed(_ call: CAPPluginCall) {
  12. var isZoomed: Bool {
  13. UIScreen.main.scale < UIScreen.main.nativeScale
  14. }
  15. call.resolve(["isZoomed": isZoomed])
  16. }
  17. @objc func getDocumentRoot(_ call: CAPPluginCall) {
  18. let doc = FileManager.default.urls(
  19. for: .documentDirectory,
  20. in: .userDomainMask).first
  21. if doc != nil {
  22. call.resolve(["documentRoot": doc!.path])
  23. } else {
  24. call.resolve(["documentRoot": ""])
  25. }
  26. }
  27. }