fix keyboard and haptics

This commit is contained in:
2023-06-01 23:17:41 +02:00
parent a66b838f46
commit c984cc7a7b
10 changed files with 41 additions and 7 deletions

View File

@@ -2,7 +2,6 @@
import { Capacitor } from '@capacitor/core'
import { Dialog } from '@capacitor/dialog'
import type { ConfirmOptions } from '@capacitor/dialog'
import { Haptics, ImpactStyle } from '@capacitor/haptics'
const props = defineProps<{
note: Note
@@ -44,7 +43,6 @@ const emit = defineEmits<{
const openModal = async (open: () => void, modal: ModalOptions) => {
if (['android', 'ios'].includes(Capacitor.getPlatform())) {
const { value: confirmed } = await Dialog.confirm(modal.confirmOptions)
await Haptics.impact({ style: ImpactStyle.Light });
if (confirmed) emit('execute', modal.key)
} else {
open()

View File

@@ -8,6 +8,7 @@ import { defaultNotes } from '@/utils/defaultNotes'
import { mdToHtml } from '@/utils/markdown'
import { getAllMatches } from '@/utils/helpers'
import { preferredNotesSource } from '@/composables/useSettings'
import { Haptics, ImpactStyle } from '@capacitor/haptics'
export const notesSources = computed(() => ({
local: true,
@@ -89,7 +90,7 @@ export const notes = computed<Note[]>(() => {
})
watch(notes, () => {
if (notes.value.length > 0 && !activeNote.value && activeViewMode.value.name === 'Note')
setActiveNote(rootNote.value?.id)
setActiveNote(rootNote.value?.id, false)
})
const activeNoteId = ref<string>()
@@ -99,10 +100,11 @@ watch(activeNote, () => {
useTitle(`${activeNote.value.title} | Contexted`)
}
})
export const setActiveNote = (noteId: string | undefined) => {
export const setActiveNote = (noteId: string | undefined, haptic: boolean = true) => {
if (noteId) {
activeNoteId.value = noteId
activeViewMode.value = viewModes.find((mode) => mode.name === 'Note') || viewModes[0]
if (haptic) Haptics.impact({ style: ImpactStyle.Light })
}
}
@@ -118,7 +120,7 @@ export const setRootNote = (noteId: string) => {
}
const note = { ...baseNotes.value[noteId], isRoot: true }
updateNote(noteId, note)
setActiveNote(noteId)
setActiveNote(noteId, false)
}
export const insertDefaultNotes = (defaultNotes: BaseNote[]) => {
@@ -268,5 +270,5 @@ export const getNotes = async () => {
}
baseNotes.value = parseBaseNotes(notes)
if (!rootNote.value) insertDefaultNotes(defaultNotes)
setActiveNote(rootNote.value?.id)
setActiveNote(rootNote.value?.id, false)
}

View File

@@ -5,8 +5,10 @@ import App from './App.vue'
import { usePreferredDark, useFavicon } from '@vueuse/core'
import { initializeFirebase } from '@/composables/useFirebase'
import { StatusBar, Style } from '@capacitor/status-bar'
import { Keyboard } from '@capacitor/keyboard'
StatusBar.setStyle({ style: Style.Dark })
Keyboard.setAccessoryBarVisible({ isVisible: true })
initializeFirebase()