Pārlūkot izejas kodu

feat(gesture): add haptics impact on action

llcc 3 gadi atpakaļ
vecāks
revīzija
312f6b968f

+ 2 - 0
android/app/capacitor.build.gradle

@@ -11,7 +11,9 @@ apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
 dependencies {
     implementation project(':capacitor-app')
     implementation project(':capacitor-camera')
+    implementation project(':capacitor-clipboard')
     implementation project(':capacitor-filesystem')
+    implementation project(':capacitor-haptics')
     implementation project(':capacitor-keyboard')
     implementation project(':capacitor-splash-screen')
     implementation project(':capacitor-status-bar')

+ 8 - 0
android/app/src/main/assets/capacitor.plugins.json

@@ -7,10 +7,18 @@
 		"pkg": "@capacitor/camera",
 		"classpath": "com.capacitorjs.plugins.camera.CameraPlugin"
 	},
+	{
+		"pkg": "@capacitor/clipboard",
+		"classpath": "com.capacitorjs.plugins.clipboard.ClipboardPlugin"
+	},
 	{
 		"pkg": "@capacitor/filesystem",
 		"classpath": "com.capacitorjs.plugins.filesystem.FilesystemPlugin"
 	},
+	{
+		"pkg": "@capacitor/haptics",
+		"classpath": "com.capacitorjs.plugins.haptics.HapticsPlugin"
+	},
 	{
 		"pkg": "@capacitor/keyboard",
 		"classpath": "com.capacitorjs.plugins.keyboard.KeyboardPlugin"

+ 6 - 0
android/capacitor.settings.gradle

@@ -8,9 +8,15 @@ project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/
 include ':capacitor-camera'
 project(':capacitor-camera').projectDir = new File('../node_modules/@capacitor/camera/android')
 
+include ':capacitor-clipboard'
+project(':capacitor-clipboard').projectDir = new File('../node_modules/@capacitor/clipboard/android')
+
 include ':capacitor-filesystem'
 project(':capacitor-filesystem').projectDir = new File('../node_modules/@capacitor/filesystem/android')
 
+include ':capacitor-haptics'
+project(':capacitor-haptics').projectDir = new File('../node_modules/@capacitor/haptics/android')
+
 include ':capacitor-keyboard'
 project(':capacitor-keyboard').projectDir = new File('../node_modules/@capacitor/keyboard/android')
 

+ 1 - 0
ios/App/Podfile

@@ -13,6 +13,7 @@ def capacitor_pods
   pod 'CapacitorCamera', :path => '../../node_modules/@capacitor/camera'
   pod 'CapacitorClipboard', :path => '../../node_modules/@capacitor/clipboard'
   pod 'CapacitorFilesystem', :path => '../../node_modules/@capacitor/filesystem'
+  pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'
   pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'
   pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
   pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'

+ 1 - 0
package.json

@@ -69,6 +69,7 @@
         "@capacitor/clipboard": "^1.0.8",
         "@capacitor/core": "3.2.2",
         "@capacitor/filesystem": "1.0.6",
+        "@capacitor/haptics": "^1.1.4",
         "@capacitor/ios": "3.2.2",
         "@capacitor/keyboard": "^1.2.0",
         "@capacitor/splash-screen": "1.1.3",

+ 7 - 3
src/main/frontend/components/block.cljs

@@ -41,6 +41,7 @@
             [frontend.handler.repeated :as repeated]
             [frontend.handler.route :as route-handler]
             [frontend.handler.ui :as ui-handler]
+            [frontend.mobile.haptics :as haptics]
             [frontend.mobile.util :as mobile-util]
             [frontend.modules.outliner.tree :as tree]
             [frontend.search :as search]
@@ -1943,7 +1944,9 @@
                           util/safe-parse-int)
                   0)
               50)
-          (block-handler/indent-outdent-block! block :right)
+          (haptics/with-haptics-impact
+            (block-handler/indent-outdent-block! block :right)
+            :light)
 
           (>= (or (some-> (.. right-menu -style -width)
                           (string/replace "px" "")
@@ -1951,8 +1954,9 @@
                   0)
               50)
           ;; (editor-handler/delete-block-aux! block true)
-          ;; (block-handler/indent-outdent-block! block :left)
-          (action-sheet/show-actions)
+          (haptics/with-haptics-impact
+            (block-handler/indent-outdent-block! block :left)
+            :light)
 
           :else
           nil)

+ 15 - 0
src/main/frontend/mobile/haptics.cljs

@@ -0,0 +1,15 @@
+(ns frontend.mobile.haptics
+  (:require
+   ["@capacitor/haptics" :refer [Haptics ImpactStyle]]
+   [promesa.core :as p]))
+
+(defn with-haptics-impact
+  [fn impact-style]
+  (let [style (cond
+                (= impact-style :light)
+                {:style (.-Light ImpactStyle)}
+
+                (= impact-style :medium)
+                {:style (.-Medium ImpactStyle)})]
+    (p/do! (.impact Haptics (clj->js style))
+           fn)))