@getcortexlabs/mavis 0.1.0-alpha.2 → 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/dist/native/avatar-image.d.ts +4 -0
- package/dist/native/avatar-image.d.ts.map +1 -0
- package/dist/native/avatar-image.js +12 -0
- package/dist/native/avatar-image.js.map +1 -0
- package/dist/native/avatar-label.android.d.ts +9 -0
- package/dist/native/avatar-label.android.d.ts.map +1 -0
- package/dist/native/avatar-label.android.js +9 -0
- package/dist/native/avatar-label.android.js.map +1 -0
- package/dist/native/avatar-label.d.ts +2 -0
- package/dist/native/avatar-label.d.ts.map +1 -0
- package/dist/native/avatar-label.js +2 -0
- package/dist/native/avatar-label.js.map +1 -0
- package/dist/native/box.ios.d.ts +4 -0
- package/dist/native/box.ios.d.ts.map +1 -1
- package/dist/native/box.ios.js +29 -1
- package/dist/native/box.ios.js.map +1 -1
- package/dist/native/button.ios.d.ts +13 -1
- package/dist/native/button.ios.d.ts.map +1 -1
- package/dist/native/button.ios.js +29 -1
- package/dist/native/button.ios.js.map +1 -1
- package/dist/native/checkbox.android.d.ts +7 -0
- package/dist/native/checkbox.android.d.ts.map +1 -0
- package/dist/native/checkbox.android.js +26 -0
- package/dist/native/checkbox.android.js.map +1 -0
- package/dist/native/checkbox.d.ts +7 -0
- package/dist/native/checkbox.d.ts.map +1 -0
- package/dist/native/checkbox.js +7 -0
- package/dist/native/checkbox.js.map +1 -0
- package/dist/native/composed-button.android.d.ts +4 -0
- package/dist/native/composed-button.android.d.ts.map +1 -0
- package/dist/native/composed-button.android.js +53 -0
- package/dist/native/composed-button.android.js.map +1 -0
- package/dist/native/composed-button.d.ts +3 -0
- package/dist/native/composed-button.d.ts.map +1 -0
- package/dist/native/composed-button.js +4 -0
- package/dist/native/composed-button.js.map +1 -0
- package/dist/native/dialog.android.d.ts +12 -0
- package/dist/native/dialog.android.d.ts.map +1 -0
- package/dist/native/dialog.android.js +46 -0
- package/dist/native/dialog.android.js.map +1 -0
- package/dist/native/dialog.d.ts +12 -0
- package/dist/native/dialog.d.ts.map +1 -0
- package/dist/native/dialog.ios.d.ts +12 -0
- package/dist/native/dialog.ios.d.ts.map +1 -0
- package/dist/native/dialog.ios.js +13 -0
- package/dist/native/dialog.ios.js.map +1 -0
- package/dist/native/dialog.js +4 -0
- package/dist/native/dialog.js.map +1 -0
- package/dist/native/dynamic-type.d.ts +15 -0
- package/dist/native/dynamic-type.d.ts.map +1 -0
- package/dist/native/dynamic-type.js +47 -0
- package/dist/native/dynamic-type.js.map +1 -0
- package/dist/native/flex-layout.ios.d.ts +10 -0
- package/dist/native/flex-layout.ios.d.ts.map +1 -1
- package/dist/native/flex-layout.ios.js +85 -0
- package/dist/native/flex-layout.ios.js.map +1 -1
- package/dist/native/input-action.d.ts +5 -0
- package/dist/native/input-action.d.ts.map +1 -0
- package/dist/native/input-action.js +13 -0
- package/dist/native/input-action.js.map +1 -0
- package/dist/native/keyboard-dismiss.android.d.ts +8 -0
- package/dist/native/keyboard-dismiss.android.d.ts.map +1 -0
- package/dist/native/keyboard-dismiss.android.js +9 -0
- package/dist/native/keyboard-dismiss.android.js.map +1 -0
- package/dist/native/keyboard-dismiss.d.ts +10 -0
- package/dist/native/keyboard-dismiss.d.ts.map +1 -0
- package/dist/native/keyboard-dismiss.ios.d.ts +8 -0
- package/dist/native/keyboard-dismiss.ios.d.ts.map +1 -0
- package/dist/native/keyboard-dismiss.ios.js +91 -0
- package/dist/native/keyboard-dismiss.ios.js.map +1 -0
- package/dist/native/keyboard-dismiss.js +6 -0
- package/dist/native/keyboard-dismiss.js.map +1 -0
- package/dist/native/label.android.d.ts +12 -0
- package/dist/native/label.android.d.ts.map +1 -0
- package/dist/native/label.android.js +19 -0
- package/dist/native/label.android.js.map +1 -0
- package/dist/native/label.ios.d.ts +14 -1
- package/dist/native/label.ios.d.ts.map +1 -1
- package/dist/native/label.ios.js +37 -1
- package/dist/native/label.ios.js.map +1 -1
- package/dist/native/measure-memo.d.ts +37 -0
- package/dist/native/measure-memo.d.ts.map +1 -0
- package/dist/native/measure-memo.js +82 -0
- package/dist/native/measure-memo.js.map +1 -0
- package/dist/native/motion-surface.d.ts +9 -0
- package/dist/native/motion-surface.d.ts.map +1 -0
- package/dist/native/motion-surface.js +119 -0
- package/dist/native/motion-surface.js.map +1 -0
- package/dist/native/press.d.ts +5 -2
- package/dist/native/press.d.ts.map +1 -1
- package/dist/native/press.js +52 -8
- package/dist/native/press.js.map +1 -1
- package/dist/native/progress.d.ts +7 -0
- package/dist/native/progress.d.ts.map +1 -0
- package/dist/native/progress.js +77 -0
- package/dist/native/progress.js.map +1 -0
- package/dist/native/screen.android.d.ts +6 -0
- package/dist/native/screen.android.d.ts.map +1 -0
- package/dist/native/screen.android.js +8 -0
- package/dist/native/screen.android.js.map +1 -0
- package/dist/native/screen.d.ts +2 -0
- package/dist/native/screen.d.ts.map +1 -0
- package/dist/native/screen.js +3 -0
- package/dist/native/screen.js.map +1 -0
- package/dist/native/scroll-motion.d.ts +11 -0
- package/dist/native/scroll-motion.d.ts.map +1 -0
- package/dist/native/scroll-motion.js +94 -0
- package/dist/native/scroll-motion.js.map +1 -0
- package/dist/native/segmented.d.ts +14 -0
- package/dist/native/segmented.d.ts.map +1 -0
- package/dist/native/segmented.js +86 -0
- package/dist/native/segmented.js.map +1 -0
- package/dist/native/sheet.android.d.ts +18 -0
- package/dist/native/sheet.android.d.ts.map +1 -0
- package/dist/native/sheet.android.js +16 -0
- package/dist/native/sheet.android.js.map +1 -0
- package/dist/native/sheet.d.ts +21 -0
- package/dist/native/sheet.d.ts.map +1 -0
- package/dist/native/sheet.ios.d.ts +19 -0
- package/dist/native/sheet.ios.d.ts.map +1 -0
- package/dist/native/sheet.ios.js +41 -0
- package/dist/native/sheet.ios.js.map +1 -0
- package/dist/native/sheet.js +17 -0
- package/dist/native/sheet.js.map +1 -0
- package/dist/native/tabs.android.d.ts +3 -0
- package/dist/native/tabs.android.d.ts.map +1 -0
- package/dist/native/tabs.android.js +29 -0
- package/dist/native/tabs.android.js.map +1 -0
- package/dist/native/tabs.d.ts +3 -0
- package/dist/native/tabs.d.ts.map +1 -0
- package/dist/native/tabs.js +4 -0
- package/dist/native/tabs.js.map +1 -0
- package/dist/native/text-field.android.d.ts +1 -0
- package/dist/native/text-field.android.d.ts.map +1 -1
- package/dist/native/text-field.android.js +13 -0
- package/dist/native/text-field.android.js.map +1 -1
- package/dist/native/text-field.ios.d.ts +9 -0
- package/dist/native/text-field.ios.d.ts.map +1 -0
- package/dist/native/text-field.ios.js +52 -0
- package/dist/native/text-field.ios.js.map +1 -0
- package/dist/native/text-view.ios.d.ts +7 -0
- package/dist/native/text-view.ios.d.ts.map +1 -0
- package/dist/native/text-view.ios.js +10 -0
- package/dist/native/text-view.ios.js.map +1 -0
- package/dist/native/toast.android.d.ts +4 -0
- package/dist/native/toast.android.d.ts.map +1 -0
- package/dist/native/toast.android.js +10 -0
- package/dist/native/toast.android.js.map +1 -0
- package/dist/native/toast.d.ts +4 -0
- package/dist/native/toast.d.ts.map +1 -0
- package/dist/native/toast.ios.d.ts +4 -0
- package/dist/native/toast.ios.d.ts.map +1 -0
- package/dist/native/toast.ios.js +8 -0
- package/dist/native/toast.ios.js.map +1 -0
- package/dist/native/toast.js +5 -0
- package/dist/native/toast.js.map +1 -0
- package/dist/vue/components/ChoiceControl.d.ts +101 -0
- package/dist/vue/components/ChoiceControl.d.ts.map +1 -0
- package/dist/vue/components/ChoiceControl.js +196 -0
- package/dist/vue/components/ChoiceControl.js.map +1 -0
- package/dist/vue/components/MAccordion.d.ts +109 -0
- package/dist/vue/components/MAccordion.d.ts.map +1 -0
- package/dist/vue/components/MAccordion.js +83 -0
- package/dist/vue/components/MAccordion.js.map +1 -0
- package/dist/vue/components/MAlert.d.ts +99 -0
- package/dist/vue/components/MAlert.d.ts.map +1 -0
- package/dist/vue/components/MAlert.js +126 -0
- package/dist/vue/components/MAlert.js.map +1 -0
- package/dist/vue/components/MAvatar.d.ts +74 -0
- package/dist/vue/components/MAvatar.d.ts.map +1 -0
- package/dist/vue/components/MAvatar.js +86 -0
- package/dist/vue/components/MAvatar.js.map +1 -0
- package/dist/vue/components/MBadge.d.ts +64 -0
- package/dist/vue/components/MBadge.d.ts.map +1 -0
- package/dist/vue/components/MBadge.js +30 -0
- package/dist/vue/components/MBadge.js.map +1 -0
- package/dist/vue/components/MButton.d.ts +57 -5
- package/dist/vue/components/MButton.d.ts.map +1 -1
- package/dist/vue/components/MButton.js +129 -11
- package/dist/vue/components/MButton.js.map +1 -1
- package/dist/vue/components/MCard.d.ts +23 -5
- package/dist/vue/components/MCard.d.ts.map +1 -1
- package/dist/vue/components/MCard.js +14 -4
- package/dist/vue/components/MCard.js.map +1 -1
- package/dist/vue/components/MCheckbox.d.ts +93 -0
- package/dist/vue/components/MCheckbox.d.ts.map +1 -0
- package/dist/vue/components/MCheckbox.js +26 -0
- package/dist/vue/components/MCheckbox.js.map +1 -0
- package/dist/vue/components/MChip.d.ts +107 -0
- package/dist/vue/components/MChip.d.ts.map +1 -0
- package/dist/vue/components/MChip.js +120 -0
- package/dist/vue/components/MChip.js.map +1 -0
- package/dist/vue/components/MDialog.d.ts +95 -0
- package/dist/vue/components/MDialog.d.ts.map +1 -0
- package/dist/vue/components/MDialog.js +245 -0
- package/dist/vue/components/MDialog.js.map +1 -0
- package/dist/vue/components/MEmptyState.d.ts +107 -0
- package/dist/vue/components/MEmptyState.d.ts.map +1 -0
- package/dist/vue/components/MEmptyState.js +79 -0
- package/dist/vue/components/MEmptyState.js.map +1 -0
- package/dist/vue/components/MInput.d.ts +62 -7
- package/dist/vue/components/MInput.d.ts.map +1 -1
- package/dist/vue/components/MInput.js +88 -14
- package/dist/vue/components/MInput.js.map +1 -1
- package/dist/vue/components/MListItem.d.ts +92 -0
- package/dist/vue/components/MListItem.d.ts.map +1 -0
- package/dist/vue/components/MListItem.js +53 -0
- package/dist/vue/components/MListItem.js.map +1 -0
- package/dist/vue/components/MProgress.d.ts +112 -0
- package/dist/vue/components/MProgress.d.ts.map +1 -0
- package/dist/vue/components/MProgress.js +75 -0
- package/dist/vue/components/MProgress.js.map +1 -0
- package/dist/vue/components/MRadioGroup.d.ts +93 -0
- package/dist/vue/components/MRadioGroup.d.ts.map +1 -0
- package/dist/vue/components/MRadioGroup.js +57 -0
- package/dist/vue/components/MRadioGroup.js.map +1 -0
- package/dist/vue/components/MReveal.d.ts.map +1 -1
- package/dist/vue/components/MReveal.js +5 -7
- package/dist/vue/components/MReveal.js.map +1 -1
- package/dist/vue/components/MScreen.d.ts +18 -0
- package/dist/vue/components/MScreen.d.ts.map +1 -1
- package/dist/vue/components/MScreen.js +68 -5
- package/dist/vue/components/MScreen.js.map +1 -1
- package/dist/vue/components/MSegmentedControl.d.ts +85 -0
- package/dist/vue/components/MSegmentedControl.d.ts.map +1 -0
- package/dist/vue/components/MSegmentedControl.js +172 -0
- package/dist/vue/components/MSegmentedControl.js.map +1 -0
- package/dist/vue/components/MSelect.d.ts +130 -0
- package/dist/vue/components/MSelect.d.ts.map +1 -0
- package/dist/vue/components/MSelect.js +158 -0
- package/dist/vue/components/MSelect.js.map +1 -0
- package/dist/vue/components/MSeparator.d.ts +54 -0
- package/dist/vue/components/MSeparator.d.ts.map +1 -0
- package/dist/vue/components/MSeparator.js +36 -0
- package/dist/vue/components/MSeparator.js.map +1 -0
- package/dist/vue/components/MSheet.d.ts +101 -0
- package/dist/vue/components/MSheet.d.ts.map +1 -0
- package/dist/vue/components/MSheet.js +313 -0
- package/dist/vue/components/MSheet.js.map +1 -0
- package/dist/vue/components/MSkeleton.d.ts +70 -0
- package/dist/vue/components/MSkeleton.d.ts.map +1 -0
- package/dist/vue/components/MSkeleton.js +87 -0
- package/dist/vue/components/MSkeleton.js.map +1 -0
- package/dist/vue/components/MSlider.d.ts +1 -1
- package/dist/vue/components/MSlider.d.ts.map +1 -1
- package/dist/vue/components/MSlider.js +2 -1
- package/dist/vue/components/MSlider.js.map +1 -1
- package/dist/vue/components/MSwitch.d.ts +79 -0
- package/dist/vue/components/MSwitch.d.ts.map +1 -0
- package/dist/vue/components/MSwitch.js +163 -0
- package/dist/vue/components/MSwitch.js.map +1 -0
- package/dist/vue/components/MTabs.d.ts +91 -0
- package/dist/vue/components/MTabs.d.ts.map +1 -0
- package/dist/vue/components/MTabs.js +245 -0
- package/dist/vue/components/MTabs.js.map +1 -0
- package/dist/vue/components/MText.d.ts +16 -7
- package/dist/vue/components/MText.d.ts.map +1 -1
- package/dist/vue/components/MText.js +43 -17
- package/dist/vue/components/MText.js.map +1 -1
- package/dist/vue/components/MToast.d.ts +23 -0
- package/dist/vue/components/MToast.d.ts.map +1 -0
- package/dist/vue/components/MToast.js +242 -0
- package/dist/vue/components/MToast.js.map +1 -0
- package/dist/vue/index.d.ts +31 -4
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +48 -4
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/layers.d.ts +19 -0
- package/dist/vue/layers.d.ts.map +1 -0
- package/dist/vue/layers.js +26 -0
- package/dist/vue/layers.js.map +1 -0
- package/dist/vue/native-view.d.ts +6 -0
- package/dist/vue/native-view.d.ts.map +1 -0
- package/dist/vue/native-view.js +5 -0
- package/dist/vue/native-view.js.map +1 -0
- package/dist/vue/props.d.ts +12 -11
- package/dist/vue/props.d.ts.map +1 -1
- package/dist/vue/props.js +25 -10
- package/dist/vue/props.js.map +1 -1
- package/dist/vue/reveal-motion.d.ts +13 -0
- package/dist/vue/reveal-motion.d.ts.map +1 -0
- package/dist/vue/reveal-motion.js +55 -0
- package/dist/vue/reveal-motion.js.map +1 -0
- package/dist/vue/system-back.d.ts +11 -0
- package/dist/vue/system-back.d.ts.map +1 -0
- package/dist/vue/system-back.js +2 -0
- package/dist/vue/system-back.js.map +1 -0
- package/dist/vue/use-motion-surface.d.ts +8 -0
- package/dist/vue/use-motion-surface.d.ts.map +1 -0
- package/dist/vue/use-motion-surface.js +75 -0
- package/dist/vue/use-motion-surface.js.map +1 -0
- package/dist/vue/use-press.d.ts +1 -1
- package/dist/vue/use-press.d.ts.map +1 -1
- package/dist/vue/use-press.js +12 -4
- package/dist/vue/use-press.js.map +1 -1
- package/dist/vue/use-scroll-motion.d.ts +7 -0
- package/dist/vue/use-scroll-motion.d.ts.map +1 -0
- package/dist/vue/use-scroll-motion.js +30 -0
- package/dist/vue/use-scroll-motion.js.map +1 -0
- package/package.json +3 -3
- package/platforms/android/java/com/mavis/ui/Box.java +38 -3
- package/platforms/android/java/com/mavis/ui/ContentWidth.java +77 -0
- package/platforms/android/java/com/mavis/ui/FlexLayout.java +80 -4
- package/platforms/android/java/com/mavis/ui/MeasureMemo.java +145 -0
- package/platforms/android/java/com/mavis/ui/Screen.java +108 -0
- package/src/native/avatar-image.ts +9 -0
- package/src/native/avatar-label.android.ts +14 -0
- package/src/native/avatar-label.ts +1 -0
- package/src/native/box.ios.ts +48 -1
- package/src/native/button.ios.ts +53 -1
- package/src/native/checkbox.android.ts +35 -0
- package/src/native/checkbox.ts +9 -0
- package/src/native/composed-button.android.ts +74 -0
- package/src/native/composed-button.ts +9 -0
- package/src/native/dialog.android.ts +56 -0
- package/src/native/dialog.ios.ts +23 -0
- package/src/native/dialog.ts +10 -0
- package/src/native/dynamic-type.ts +71 -0
- package/src/native/flex-layout.ios.ts +113 -0
- package/src/native/input-action.ts +15 -0
- package/src/native/keyboard-dismiss.android.ts +17 -0
- package/src/native/keyboard-dismiss.ios.ts +124 -0
- package/src/native/keyboard-dismiss.ts +14 -0
- package/src/native/label.android.ts +27 -0
- package/src/native/label.ios.ts +54 -1
- package/src/native/measure-memo.ts +116 -0
- package/src/native/motion-surface.ts +137 -0
- package/src/native/press.ts +52 -10
- package/src/native/progress.ts +78 -0
- package/src/native/screen.android.ts +12 -0
- package/src/native/screen.ts +2 -0
- package/src/native/scroll-motion.ts +101 -0
- package/src/native/segmented.ts +95 -0
- package/src/native/sheet.android.ts +24 -0
- package/src/native/sheet.ios.ts +52 -0
- package/src/native/sheet.ts +26 -0
- package/src/native/tabs.android.ts +58 -0
- package/src/native/tabs.ts +8 -0
- package/src/native/text-field.android.ts +19 -0
- package/src/native/text-field.ios.ts +53 -0
- package/src/native/text-view.ios.ts +10 -0
- package/src/native/toast.android.ts +9 -0
- package/src/native/toast.ios.ts +13 -0
- package/src/native/toast.ts +6 -0
- package/src/vue/components/ChoiceControl.ts +238 -0
- package/src/vue/components/MAccordion.ts +123 -0
- package/src/vue/components/MAlert.ts +156 -0
- package/src/vue/components/MAvatar.ts +103 -0
- package/src/vue/components/MBadge.ts +34 -0
- package/src/vue/components/MButton.ts +176 -9
- package/src/vue/components/MCard.ts +23 -3
- package/src/vue/components/MCheckbox.ts +25 -0
- package/src/vue/components/MChip.ts +134 -0
- package/src/vue/components/MDialog.ts +312 -0
- package/src/vue/components/MEmptyState.ts +96 -0
- package/src/vue/components/MInput.ts +96 -12
- package/src/vue/components/MListItem.ts +66 -0
- package/src/vue/components/MProgress.ts +94 -0
- package/src/vue/components/MRadioGroup.ts +64 -0
- package/src/vue/components/MReveal.ts +6 -7
- package/src/vue/components/MScreen.ts +93 -5
- package/src/vue/components/MSegmentedControl.ts +214 -0
- package/src/vue/components/MSelect.ts +185 -0
- package/src/vue/components/MSeparator.ts +40 -0
- package/src/vue/components/MSheet.ts +375 -0
- package/src/vue/components/MSkeleton.ts +100 -0
- package/src/vue/components/MSlider.ts +7 -1
- package/src/vue/components/MSwitch.ts +187 -0
- package/src/vue/components/MTabs.ts +302 -0
- package/src/vue/components/MText.ts +37 -6
- package/src/vue/components/MToast.ts +289 -0
- package/src/vue/index.ts +90 -4
- package/src/vue/layers.ts +48 -0
- package/src/vue/native-view.ts +6 -0
- package/src/vue/props.ts +37 -12
- package/src/vue/reveal-motion.ts +61 -0
- package/src/vue/system-back.ts +12 -0
- package/src/vue/use-motion-surface.ts +77 -0
- package/src/vue/use-press.ts +12 -4
- package/src/vue/use-scroll-motion.ts +31 -0
- package/dist/native/input-description.android.d.ts +0 -4
- package/dist/native/input-description.android.d.ts.map +0 -1
- package/dist/native/input-description.android.js +0 -18
- package/dist/native/input-description.android.js.map +0 -1
- package/dist/theme/resolve.d.ts +0 -3
- package/dist/theme/resolve.d.ts.map +0 -1
- package/dist/theme/resolve.js +0 -8
- package/dist/theme/resolve.js.map +0 -1
- package/dist/theme/themes.d.ts +0 -6
- package/dist/theme/themes.d.ts.map +0 -1
- package/dist/theme/themes.js +0 -83
- package/dist/theme/themes.js.map +0 -1
- package/dist/theme/types.d.ts +0 -50
- package/dist/theme/types.d.ts.map +0 -1
- package/dist/theme/types.js +0 -2
- package/dist/theme/types.js.map +0 -1
- package/dist/vue/global-components.d.ts +0 -21
- package/dist/vue/global-components.d.ts.map +0 -1
- package/dist/vue/global-components.js +0 -2
- package/dist/vue/global-components.js.map +0 -1
- package/dist/vue/layout-context.d.ts +0 -5
- package/dist/vue/layout-context.d.ts.map +0 -1
- package/dist/vue/layout-context.js +0 -7
- package/dist/vue/layout-context.js.map +0 -1
- package/dist/vue/text-content.d.ts +0 -4
- package/dist/vue/text-content.d.ts.map +0 -1
- package/dist/vue/text-content.js +0 -17
- package/dist/vue/text-content.js.map +0 -1
- package/dist/vue/theme.d.ts +0 -177
- package/dist/vue/theme.d.ts.map +0 -1
- package/dist/vue/theme.js +0 -17
- package/dist/vue/theme.js.map +0 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { nativeScrollMotion } from './scroll-motion.js'
|
|
2
|
+
import type { View, EventData, TouchGestureEventData } from '@nativescript/core'
|
|
3
|
+
import {
|
|
4
|
+
bind,
|
|
5
|
+
motionValue,
|
|
6
|
+
springValue,
|
|
7
|
+
set,
|
|
8
|
+
stop,
|
|
9
|
+
drag,
|
|
10
|
+
type DerivedValue,
|
|
11
|
+
} from '@rafaelaugusto/jolt'
|
|
12
|
+
import type {
|
|
13
|
+
MotionSurfaceAdapter,
|
|
14
|
+
MotionValueAdapter,
|
|
15
|
+
} from '@getcortexlabs/mavis-core/experimental'
|
|
16
|
+
|
|
17
|
+
export function nativeContinuousSurface(target: View, enabled: () => boolean) {
|
|
18
|
+
const sources = new WeakMap<object, DerivedValue>()
|
|
19
|
+
const refreshes = new Set<() => void>()
|
|
20
|
+
const scrolls = new Set<ReturnType<typeof nativeScrollMotion>>()
|
|
21
|
+
const interrupt = (properties: readonly string[]) => {
|
|
22
|
+
for (const scroll of scrolls) scroll.interrupt(properties)
|
|
23
|
+
}
|
|
24
|
+
let suppressUntil = 0
|
|
25
|
+
const adapter: Pick<
|
|
26
|
+
MotionSurfaceAdapter,
|
|
27
|
+
'motionValue' | 'springValue' | 'bind' | 'drag' | 'map' | 'refresh' | 'scrollLinked'
|
|
28
|
+
> = {
|
|
29
|
+
scrollLinked(source, frames, options) {
|
|
30
|
+
interrupt(Object.keys(frames))
|
|
31
|
+
const scroll = nativeScrollMotion(source, target, frames, options)
|
|
32
|
+
scrolls.add(scroll)
|
|
33
|
+
return {
|
|
34
|
+
get execution() {
|
|
35
|
+
return scroll.execution
|
|
36
|
+
},
|
|
37
|
+
refresh: () => scroll.refresh(),
|
|
38
|
+
dispose() {
|
|
39
|
+
scrolls.delete(scroll)
|
|
40
|
+
scroll.dispose()
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
// Native views keep their fractional pivot through layout; no surface recreation.
|
|
45
|
+
refresh: () => target.requestLayout(),
|
|
46
|
+
map(source, input, output, options) {
|
|
47
|
+
const mapped = sources.get(source)!.to(input, output, options)
|
|
48
|
+
const value = { get: () => mapped.get(), dispose() {} }
|
|
49
|
+
sources.set(value, mapped)
|
|
50
|
+
return value
|
|
51
|
+
},
|
|
52
|
+
motionValue(initial) {
|
|
53
|
+
const source = motionValue(initial)
|
|
54
|
+
const value: MotionValueAdapter = {
|
|
55
|
+
get: () => source.get(),
|
|
56
|
+
set: (value) => set(source, value),
|
|
57
|
+
dispose: () => stop(source),
|
|
58
|
+
}
|
|
59
|
+
sources.set(value, source)
|
|
60
|
+
return value
|
|
61
|
+
},
|
|
62
|
+
springValue(input, options) {
|
|
63
|
+
const spring = springValue(sources.get(input)!, options)
|
|
64
|
+
const value = {
|
|
65
|
+
get: () => spring.get(),
|
|
66
|
+
getVelocity: () => spring.getVelocity(),
|
|
67
|
+
get moving() {
|
|
68
|
+
return spring.moving
|
|
69
|
+
},
|
|
70
|
+
get paused() {
|
|
71
|
+
return spring.paused
|
|
72
|
+
},
|
|
73
|
+
pause: () => spring.pause(),
|
|
74
|
+
resume: () => spring.play(),
|
|
75
|
+
dispose: () => spring.dispose(),
|
|
76
|
+
}
|
|
77
|
+
sources.set(value, spring)
|
|
78
|
+
return value
|
|
79
|
+
},
|
|
80
|
+
bind(values) {
|
|
81
|
+
interrupt(Object.keys(values))
|
|
82
|
+
const dispose = bind(
|
|
83
|
+
target,
|
|
84
|
+
Object.fromEntries(
|
|
85
|
+
Object.entries(values).map(([key, value]) => [key, sources.get(value)!]),
|
|
86
|
+
),
|
|
87
|
+
)
|
|
88
|
+
return { dispose }
|
|
89
|
+
},
|
|
90
|
+
drag(options) {
|
|
91
|
+
let paused = false
|
|
92
|
+
const gesture = drag(target, {
|
|
93
|
+
...options,
|
|
94
|
+
onMove: () => {
|
|
95
|
+
suppressUntil = Date.now() + 500
|
|
96
|
+
},
|
|
97
|
+
onRelease: () => {
|
|
98
|
+
suppressUntil = Date.now() + 500
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
const refresh = () => (paused || !enabled() ? gesture.pause() : gesture.play())
|
|
102
|
+
refreshes.add(refresh)
|
|
103
|
+
refresh()
|
|
104
|
+
const touch = (event: EventData) => {
|
|
105
|
+
if ((event as TouchGestureEventData).action === 'down') suppressUntil = 0
|
|
106
|
+
}
|
|
107
|
+
target.on('touch', touch)
|
|
108
|
+
return {
|
|
109
|
+
get dragging() {
|
|
110
|
+
return gesture.dragging
|
|
111
|
+
},
|
|
112
|
+
pause() {
|
|
113
|
+
paused = true
|
|
114
|
+
refresh()
|
|
115
|
+
},
|
|
116
|
+
resume() {
|
|
117
|
+
paused = false
|
|
118
|
+
refresh()
|
|
119
|
+
},
|
|
120
|
+
cancel: () => gesture.cancel(),
|
|
121
|
+
dispose() {
|
|
122
|
+
refreshes.delete(refresh)
|
|
123
|
+
target.off('touch', touch)
|
|
124
|
+
gesture.dispose()
|
|
125
|
+
},
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
adapter,
|
|
131
|
+
interrupt,
|
|
132
|
+
refresh() {
|
|
133
|
+
for (const refresh of refreshes) refresh()
|
|
134
|
+
},
|
|
135
|
+
allowsActivation: () => Date.now() >= suppressUntil,
|
|
136
|
+
}
|
|
137
|
+
}
|
package/src/native/press.ts
CHANGED
|
@@ -1,13 +1,55 @@
|
|
|
1
|
-
import type { View } from '@nativescript/core'
|
|
2
|
-
import {
|
|
1
|
+
import type { EventData, TouchGestureEventData, View } from '@nativescript/core'
|
|
2
|
+
import { animate, stop, onReducedMotion } from '@rafaelaugusto/jolt'
|
|
3
|
+
import { pressMotion } from '@getcortexlabs/mavis-core'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
let nextLayer = 0
|
|
6
|
+
|
|
7
|
+
/** Press multiplies the app's scale; releasing it removes only that contribution. */
|
|
8
|
+
export function attachPressFeedback(view: View, scale: number) {
|
|
9
|
+
let motion = pressMotion(scale)
|
|
10
|
+
// Each attachment owns its channel, including after a theme change or reload.
|
|
11
|
+
const layer = `mavis-press-${++nextLayer}`
|
|
12
|
+
let pressed = false
|
|
13
|
+
let used = false
|
|
14
|
+
let disposed = false
|
|
15
|
+
|
|
16
|
+
const onTouch = (event: EventData) => {
|
|
17
|
+
if (disposed) return
|
|
18
|
+
const { action } = event as TouchGestureEventData
|
|
19
|
+
if (action === 'down' && !pressed && view.isEnabled !== false) {
|
|
20
|
+
pressed = true
|
|
21
|
+
used = true
|
|
22
|
+
animate(view, motion.pressed[0], { ...motion.pressed[1], layer })
|
|
23
|
+
} else if ((action === 'up' || action === 'cancel') && pressed) {
|
|
24
|
+
pressed = false
|
|
25
|
+
animate(view, motion.released[0], { ...motion.released[1], layer })
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const remove = () => {
|
|
29
|
+
if (disposed) return
|
|
30
|
+
disposed = true
|
|
31
|
+
offPreference()
|
|
32
|
+
view.off('touch', onTouch)
|
|
33
|
+
view.off('unloaded', remove)
|
|
34
|
+
// A finished press can still hold its multiplier. stop(layer) also removes that rest.
|
|
35
|
+
if (used) {
|
|
36
|
+
stop(view, ['scale'], { layer })
|
|
37
|
+
}
|
|
12
38
|
}
|
|
39
|
+
const offPreference = onReducedMotion((reduced) => {
|
|
40
|
+
if (reduced && used && !disposed) {
|
|
41
|
+
animate(view, motion[pressed ? 'pressed' : 'released'][0], { duration: 0, layer })
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
view.on('touch', onTouch)
|
|
45
|
+
view.on('unloaded', remove)
|
|
46
|
+
return Object.assign(remove, {
|
|
47
|
+
press(pressed: boolean) {
|
|
48
|
+
onTouch({ action: pressed ? 'down' : 'cancel' } as TouchGestureEventData)
|
|
49
|
+
},
|
|
50
|
+
update(scale: number) {
|
|
51
|
+
motion = pressMotion(scale)
|
|
52
|
+
if (pressed && !disposed) animate(view, motion.pressed[0], { ...motion.pressed[1], layer })
|
|
53
|
+
},
|
|
54
|
+
})
|
|
13
55
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Application, type View } from '@nativescript/core'
|
|
2
|
+
import { animate, set, onReducedMotion, reducedMotion } from '@rafaelaugusto/jolt'
|
|
3
|
+
import { progressMotion } from '@getcortexlabs/mavis-core'
|
|
4
|
+
|
|
5
|
+
/** The fill is private to Progress; only its translation is animated. */
|
|
6
|
+
export function attachProgressMotion(track: View, fill: View, indeterminate: boolean) {
|
|
7
|
+
let motion: ReturnType<typeof animate> | undefined
|
|
8
|
+
let pending: ReturnType<typeof setTimeout> | undefined
|
|
9
|
+
let suspended = Application.suspended
|
|
10
|
+
let disposed = false
|
|
11
|
+
let previous = ''
|
|
12
|
+
|
|
13
|
+
function stop() {
|
|
14
|
+
motion?.stop()
|
|
15
|
+
motion = undefined
|
|
16
|
+
}
|
|
17
|
+
function apply() {
|
|
18
|
+
pending = undefined
|
|
19
|
+
if (disposed) return
|
|
20
|
+
const measured = track.getActualSize().width
|
|
21
|
+
const width = Number.isFinite(measured) ? measured : 0
|
|
22
|
+
const reduced = reducedMotion()
|
|
23
|
+
const key = `${indeterminate}/${width}/${reduced}/${suspended}`
|
|
24
|
+
if (key === previous) return
|
|
25
|
+
previous = key
|
|
26
|
+
stop()
|
|
27
|
+
const travel = Math.max(0, width * (1 - progressMotion.segment))
|
|
28
|
+
set(fill, { x: indeterminate && reduced ? travel / 2 : 0 })
|
|
29
|
+
if (indeterminate && !reduced && !suspended && width > 0) {
|
|
30
|
+
motion = animate(
|
|
31
|
+
fill,
|
|
32
|
+
{ x: [0, travel, 0] },
|
|
33
|
+
{
|
|
34
|
+
duration: progressMotion.duration,
|
|
35
|
+
ease: 'easeInOut',
|
|
36
|
+
repeat: Infinity,
|
|
37
|
+
},
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function schedule() {
|
|
42
|
+
if (disposed) return
|
|
43
|
+
clearTimeout(pending)
|
|
44
|
+
// Native styles finish syncing after loaded and after a mode change.
|
|
45
|
+
pending = setTimeout(apply, 0)
|
|
46
|
+
}
|
|
47
|
+
function suspend() {
|
|
48
|
+
suspended = true
|
|
49
|
+
clearTimeout(pending)
|
|
50
|
+
apply()
|
|
51
|
+
}
|
|
52
|
+
function resume() {
|
|
53
|
+
suspended = false
|
|
54
|
+
schedule()
|
|
55
|
+
}
|
|
56
|
+
const offMotion = onReducedMotion(schedule)
|
|
57
|
+
track.on('layoutChanged', schedule)
|
|
58
|
+
Application.on(Application.suspendEvent, suspend)
|
|
59
|
+
Application.on(Application.resumeEvent, resume)
|
|
60
|
+
schedule()
|
|
61
|
+
return {
|
|
62
|
+
update(value: boolean) {
|
|
63
|
+
indeterminate = value
|
|
64
|
+
schedule()
|
|
65
|
+
},
|
|
66
|
+
dispose() {
|
|
67
|
+
if (disposed) return
|
|
68
|
+
disposed = true
|
|
69
|
+
clearTimeout(pending)
|
|
70
|
+
stop()
|
|
71
|
+
set(fill, { x: 0 })
|
|
72
|
+
offMotion()
|
|
73
|
+
track.off('layoutChanged', schedule)
|
|
74
|
+
Application.off(Application.suspendEvent, suspend)
|
|
75
|
+
Application.off(Application.resumeEvent, resume)
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GridLayout } from '@nativescript/core'
|
|
2
|
+
|
|
3
|
+
declare const com: {
|
|
4
|
+
mavis: { ui: { Screen: new (context: unknown) => object } }
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** The page container sees every touch of the page and can put the keyboard away. */
|
|
8
|
+
export class MavisScreen extends GridLayout {
|
|
9
|
+
createNativeView() {
|
|
10
|
+
return new com.mavis.ui.Screen(this._context)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { EventData, ScrollView, View } from '@nativescript/core'
|
|
2
|
+
import { bind, scrollValue, onReducedMotion, reducedMotion } from '@rafaelaugusto/jolt'
|
|
3
|
+
import {
|
|
4
|
+
bindMotionScrollSource,
|
|
5
|
+
type MotionScrollAdapter,
|
|
6
|
+
type MotionScrollSource,
|
|
7
|
+
type MotionScrollFrames,
|
|
8
|
+
type MotionScrollOptions,
|
|
9
|
+
} from '@getcortexlabs/mavis-core/experimental'
|
|
10
|
+
|
|
11
|
+
const sources = new WeakMap<MotionScrollAdapter, ScrollView>()
|
|
12
|
+
export function attachNativeScrollSource(reference: MotionScrollSource, source: ScrollView) {
|
|
13
|
+
const adapter: MotionScrollAdapter = { kind: 'native' }
|
|
14
|
+
sources.set(adapter, source)
|
|
15
|
+
const unbind = bindMotionScrollSource(reference, adapter)
|
|
16
|
+
return () => {
|
|
17
|
+
unbind()
|
|
18
|
+
sources.delete(adapter)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Jolt owns numeric mappings and the application channels; Mavis resolves Screen/layout. */
|
|
23
|
+
export function nativeScrollMotion(
|
|
24
|
+
adapter: MotionScrollAdapter,
|
|
25
|
+
target: View,
|
|
26
|
+
frames: MotionScrollFrames,
|
|
27
|
+
options: MotionScrollOptions,
|
|
28
|
+
) {
|
|
29
|
+
const source = sources.get(adapter)
|
|
30
|
+
if (!source) throw new TypeError('Use a scrolling MScreen in this renderer.')
|
|
31
|
+
const offset = scrollValue(source)
|
|
32
|
+
const active = new Map<string, readonly number[]>()
|
|
33
|
+
for (const [key, values] of Object.entries(frames)) {
|
|
34
|
+
if (key === 'scale') {
|
|
35
|
+
if (!frames.scaleX) active.set('scaleX', values)
|
|
36
|
+
if (!frames.scaleY) active.set('scaleY', values)
|
|
37
|
+
} else active.set(key, values)
|
|
38
|
+
}
|
|
39
|
+
const bindings = new Map<string, () => void>()
|
|
40
|
+
let disposed = false
|
|
41
|
+
let maximum = -1
|
|
42
|
+
let content: View | undefined
|
|
43
|
+
const apply = () => {
|
|
44
|
+
if (disposed) return
|
|
45
|
+
const bounded = offset.to([0, Math.max(1, maximum)], [0, Math.max(0, maximum)])
|
|
46
|
+
for (const [key, output] of active) {
|
|
47
|
+
bindings.get(key)?.()
|
|
48
|
+
const input = output.map(
|
|
49
|
+
(_, index) =>
|
|
50
|
+
options.range[0] + (index * (options.range[1] - options.range[0])) / (output.length - 1),
|
|
51
|
+
)
|
|
52
|
+
const values =
|
|
53
|
+
reducedMotion() && key !== 'opacity' ? output.map(() => output.at(-1)!) : output
|
|
54
|
+
bindings.set(key, bind(target, { [key]: bounded.to(input, values) }))
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const refresh = () => {
|
|
58
|
+
if (disposed) return
|
|
59
|
+
const next = Math.max(0, source.scrollableHeight)
|
|
60
|
+
const changed = maximum !== next
|
|
61
|
+
maximum = next
|
|
62
|
+
if (content !== source.content) {
|
|
63
|
+
content?.off('layoutChanged', layout)
|
|
64
|
+
content = source.content
|
|
65
|
+
content?.on('layoutChanged', layout)
|
|
66
|
+
}
|
|
67
|
+
if (changed) apply()
|
|
68
|
+
// Re-read the actual bounded offset without a Vue update or an additional clock.
|
|
69
|
+
offset.ref(null)
|
|
70
|
+
offset.ref(source)
|
|
71
|
+
}
|
|
72
|
+
const layout = (_event: EventData) => refresh()
|
|
73
|
+
source.on('layoutChanged', layout)
|
|
74
|
+
const offReduced = onReducedMotion(apply)
|
|
75
|
+
refresh()
|
|
76
|
+
return {
|
|
77
|
+
get execution() {
|
|
78
|
+
return disposed || !active.size ? ('released' as const) : ('native' as const)
|
|
79
|
+
},
|
|
80
|
+
refresh,
|
|
81
|
+
interrupt(properties: readonly string[]) {
|
|
82
|
+
for (const property of properties)
|
|
83
|
+
for (const key of property === 'scale' ? ['scaleX', 'scaleY'] : [property]) {
|
|
84
|
+
active.delete(key)
|
|
85
|
+
bindings.get(key)?.()
|
|
86
|
+
bindings.delete(key)
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
dispose() {
|
|
90
|
+
if (disposed) return
|
|
91
|
+
disposed = true
|
|
92
|
+
source.off('layoutChanged', layout)
|
|
93
|
+
content?.off('layoutChanged', layout)
|
|
94
|
+
offReduced()
|
|
95
|
+
for (const release of bindings.values()) release()
|
|
96
|
+
bindings.clear()
|
|
97
|
+
active.clear()
|
|
98
|
+
offset.dispose()
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Application, type View } from '@nativescript/core'
|
|
2
|
+
import { animate, set, onReducedMotion, reducedMotion } from '@rafaelaugusto/jolt'
|
|
3
|
+
import { segmentedMotion } from '@getcortexlabs/mavis-core'
|
|
4
|
+
|
|
5
|
+
interface SegmentBounds {
|
|
6
|
+
key: string
|
|
7
|
+
x: number
|
|
8
|
+
width: number
|
|
9
|
+
height: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The marker belongs to the control; application transforms are never animated. */
|
|
13
|
+
export function attachSegmentedIndicator(indicator: View, read: () => SegmentBounds | undefined) {
|
|
14
|
+
let motion: ReturnType<typeof animate> | undefined
|
|
15
|
+
let pending: ReturnType<typeof setTimeout> | undefined
|
|
16
|
+
let previous: SegmentBounds | undefined
|
|
17
|
+
let animateNext = false
|
|
18
|
+
let suspended = Application.suspended
|
|
19
|
+
let disposed = false
|
|
20
|
+
function stop() {
|
|
21
|
+
motion?.stop()
|
|
22
|
+
motion = undefined
|
|
23
|
+
}
|
|
24
|
+
function apply() {
|
|
25
|
+
pending = undefined
|
|
26
|
+
if (disposed) return
|
|
27
|
+
const next = read()
|
|
28
|
+
if (
|
|
29
|
+
!next ||
|
|
30
|
+
![next.x, next.width, next.height].every(Number.isFinite) ||
|
|
31
|
+
next.width <= 0 ||
|
|
32
|
+
next.height <= 0
|
|
33
|
+
) {
|
|
34
|
+
stop()
|
|
35
|
+
indicator.opacity = 0
|
|
36
|
+
previous = undefined
|
|
37
|
+
animateNext = false
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
const changed =
|
|
41
|
+
!previous ||
|
|
42
|
+
next.x !== previous.x ||
|
|
43
|
+
next.width !== previous.width ||
|
|
44
|
+
next.height !== previous.height
|
|
45
|
+
if (changed || suspended || reducedMotion()) {
|
|
46
|
+
stop()
|
|
47
|
+
indicator.width = next.width
|
|
48
|
+
indicator.height = next.height
|
|
49
|
+
indicator.opacity = 1
|
|
50
|
+
if (previous && previous.key !== next.key && animateNext && !suspended && !reducedMotion())
|
|
51
|
+
motion = animate(
|
|
52
|
+
indicator,
|
|
53
|
+
{ x: next.x },
|
|
54
|
+
{ duration: segmentedMotion.duration, ease: segmentedMotion.ease },
|
|
55
|
+
)
|
|
56
|
+
else set(indicator, { x: next.x })
|
|
57
|
+
}
|
|
58
|
+
previous = next
|
|
59
|
+
animateNext = false
|
|
60
|
+
}
|
|
61
|
+
function update(animated = false) {
|
|
62
|
+
if (disposed) return
|
|
63
|
+
animateNext ||= animated
|
|
64
|
+
if (pending === undefined) pending = setTimeout(apply, 0)
|
|
65
|
+
}
|
|
66
|
+
function suspend() {
|
|
67
|
+
suspended = true
|
|
68
|
+
clearTimeout(pending)
|
|
69
|
+
apply()
|
|
70
|
+
}
|
|
71
|
+
function resume() {
|
|
72
|
+
suspended = false
|
|
73
|
+
update()
|
|
74
|
+
}
|
|
75
|
+
const offMotion = onReducedMotion(() => {
|
|
76
|
+
stop()
|
|
77
|
+
previous = undefined
|
|
78
|
+
update()
|
|
79
|
+
})
|
|
80
|
+
Application.on(Application.suspendEvent, suspend)
|
|
81
|
+
Application.on(Application.resumeEvent, resume)
|
|
82
|
+
update()
|
|
83
|
+
return {
|
|
84
|
+
update,
|
|
85
|
+
dispose() {
|
|
86
|
+
if (disposed) return
|
|
87
|
+
disposed = true
|
|
88
|
+
clearTimeout(pending)
|
|
89
|
+
stop()
|
|
90
|
+
offMotion()
|
|
91
|
+
Application.off(Application.suspendEvent, suspend)
|
|
92
|
+
Application.off(Application.resumeEvent, resume)
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Application, type View } from '@nativescript/core'
|
|
2
|
+
|
|
3
|
+
export interface BackPress {
|
|
4
|
+
cancel: boolean
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function watchBack(handler: (event: BackPress) => void): () => void {
|
|
8
|
+
const event = Application.android.activityBackPressedEvent
|
|
9
|
+
Application.android.on(event, handler)
|
|
10
|
+
return () => Application.android.off(event, handler)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function setModal(_panel: View, _modal: boolean) {}
|
|
14
|
+
|
|
15
|
+
/** The Android window keeps the page inside the system bars, so the host needs no insets. */
|
|
16
|
+
export function safeAreaOf(_host: View): { readonly top: number; readonly bottom: number } {
|
|
17
|
+
return { top: 0, bottom: 0 }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function expandLayerHost(_host: View) {}
|
|
21
|
+
|
|
22
|
+
export function contentInsets(_host: View): { left: number; right: number; bottom: number } {
|
|
23
|
+
return { left: 0, right: 0, bottom: 0 }
|
|
24
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { View } from '@nativescript/core'
|
|
2
|
+
|
|
3
|
+
export interface BackPress {
|
|
4
|
+
cancel: boolean
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function watchBack(_handler: (event: BackPress) => void): () => void {
|
|
8
|
+
return () => {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function setModal(panel: View, modal: boolean) {
|
|
12
|
+
const native = panel.ios as { accessibilityViewIsModal: boolean } | undefined
|
|
13
|
+
if (native) native.accessibilityViewIsModal = modal
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface Insets {
|
|
17
|
+
top: number
|
|
18
|
+
right: number
|
|
19
|
+
bottom: number
|
|
20
|
+
left: number
|
|
21
|
+
}
|
|
22
|
+
const windowInsets = (view: View): Insets | undefined =>
|
|
23
|
+
(view.page?.ios as { view?: { safeAreaInsets?: Insets } } | undefined)?.view?.safeAreaInsets
|
|
24
|
+
|
|
25
|
+
/** The page lays its content inside the safe area; the host grows back over it with negative margins. */
|
|
26
|
+
export function expandLayerHost(host: View) {
|
|
27
|
+
const insets = windowInsets(host)
|
|
28
|
+
if (!insets) return
|
|
29
|
+
if (host.marginTop !== -insets.top) host.marginTop = -insets.top
|
|
30
|
+
if (host.marginRight !== -insets.right) host.marginRight = -insets.right
|
|
31
|
+
if (host.marginBottom !== -insets.bottom) host.marginBottom = -insets.bottom
|
|
32
|
+
if (host.marginLeft !== -insets.left) host.marginLeft = -insets.left
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Keeps the panel below the status bar; the panel itself pads its content above the home indicator. */
|
|
36
|
+
export function safeAreaOf(host: View): { readonly top: number; readonly bottom: number } {
|
|
37
|
+
return {
|
|
38
|
+
get top() {
|
|
39
|
+
return windowInsets(host)?.top ?? 0
|
|
40
|
+
},
|
|
41
|
+
bottom: 0,
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function contentInsets(host: View): { left: number; right: number; bottom: number } {
|
|
46
|
+
const insets = windowInsets(host)
|
|
47
|
+
return {
|
|
48
|
+
left: insets?.left ?? 0,
|
|
49
|
+
right: insets?.right ?? 0,
|
|
50
|
+
bottom: insets?.bottom ?? 0,
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { View } from '@nativescript/core'
|
|
2
|
+
|
|
3
|
+
export interface BackPress {
|
|
4
|
+
cancel: boolean
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// NativeScript resolves the platform implementation before loading this module.
|
|
8
|
+
/** Android reports the back press before the sheet handles it; other platforms have none. */
|
|
9
|
+
export function watchBack(_handler: (event: BackPress) => void): () => void {
|
|
10
|
+
return () => {}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** iOS keeps VoiceOver inside a modal view; Android hides the covered content instead. */
|
|
14
|
+
export function setModal(_panel: View, _modal: boolean) {}
|
|
15
|
+
|
|
16
|
+
/** Safe-area insets around the sheet host, in DIPs; only iOS reports them. */
|
|
17
|
+
export function safeAreaOf(_host: View): { readonly top: number; readonly bottom: number } {
|
|
18
|
+
return { top: 0, bottom: 0 }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Lets the layer host cover the whole window; only iOS insets it by default. */
|
|
22
|
+
export function expandLayerHost(_host: View) {}
|
|
23
|
+
|
|
24
|
+
export function contentInsets(_host: View): { left: number; right: number; bottom: number } {
|
|
25
|
+
return { left: 0, right: 0, bottom: 0 }
|
|
26
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { View } from '@nativescript/core'
|
|
2
|
+
|
|
3
|
+
declare const android: {
|
|
4
|
+
view: {
|
|
5
|
+
View: {
|
|
6
|
+
OnFocusChangeListener: new (listener: {
|
|
7
|
+
onFocusChange(view: unknown, focused: boolean): void
|
|
8
|
+
}) => unknown
|
|
9
|
+
OnKeyListener: new (listener: {
|
|
10
|
+
onKey(
|
|
11
|
+
view: unknown,
|
|
12
|
+
key: number,
|
|
13
|
+
event: {
|
|
14
|
+
getAction(): number
|
|
15
|
+
isAltPressed(): boolean
|
|
16
|
+
isCtrlPressed(): boolean
|
|
17
|
+
isMetaPressed(): boolean
|
|
18
|
+
},
|
|
19
|
+
): boolean
|
|
20
|
+
}) => unknown
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function observeTab(
|
|
26
|
+
view: View,
|
|
27
|
+
focus: (focused: boolean) => void,
|
|
28
|
+
navigate: (key: string) => void,
|
|
29
|
+
) {
|
|
30
|
+
const button = view.android
|
|
31
|
+
const focused = new android.view.View.OnFocusChangeListener({
|
|
32
|
+
onFocusChange: (_view, value) => focus(value),
|
|
33
|
+
})
|
|
34
|
+
const keys = new android.view.View.OnKeyListener({
|
|
35
|
+
onKey(_view, key, event) {
|
|
36
|
+
if (
|
|
37
|
+
event.getAction() !== 0 ||
|
|
38
|
+
event.isAltPressed() ||
|
|
39
|
+
event.isCtrlPressed() ||
|
|
40
|
+
event.isMetaPressed()
|
|
41
|
+
)
|
|
42
|
+
return false
|
|
43
|
+
const name = (
|
|
44
|
+
{ 21: 'ArrowLeft', 22: 'ArrowRight', 122: 'Home', 123: 'End' } as Record<number, string>
|
|
45
|
+
)[key]
|
|
46
|
+
if (!name) return false
|
|
47
|
+
navigate(name)
|
|
48
|
+
return true
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
button.setOnFocusChangeListener(focused)
|
|
52
|
+
button.setOnKeyListener(keys)
|
|
53
|
+
// Preserve Android's default touch focus: forcing it would consume the first tap.
|
|
54
|
+
return () => {
|
|
55
|
+
if (button.getOnFocusChangeListener() === focused) button.setOnFocusChangeListener(null)
|
|
56
|
+
button.setOnKeyListener(null)
|
|
57
|
+
}
|
|
58
|
+
}
|