@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.
Files changed (413) hide show
  1. package/README.md +7 -5
  2. package/dist/native/avatar-image.d.ts +4 -0
  3. package/dist/native/avatar-image.d.ts.map +1 -0
  4. package/dist/native/avatar-image.js +12 -0
  5. package/dist/native/avatar-image.js.map +1 -0
  6. package/dist/native/avatar-label.android.d.ts +9 -0
  7. package/dist/native/avatar-label.android.d.ts.map +1 -0
  8. package/dist/native/avatar-label.android.js +9 -0
  9. package/dist/native/avatar-label.android.js.map +1 -0
  10. package/dist/native/avatar-label.d.ts +2 -0
  11. package/dist/native/avatar-label.d.ts.map +1 -0
  12. package/dist/native/avatar-label.js +2 -0
  13. package/dist/native/avatar-label.js.map +1 -0
  14. package/dist/native/box.ios.d.ts +4 -0
  15. package/dist/native/box.ios.d.ts.map +1 -1
  16. package/dist/native/box.ios.js +29 -1
  17. package/dist/native/box.ios.js.map +1 -1
  18. package/dist/native/button.ios.d.ts +13 -1
  19. package/dist/native/button.ios.d.ts.map +1 -1
  20. package/dist/native/button.ios.js +29 -1
  21. package/dist/native/button.ios.js.map +1 -1
  22. package/dist/native/checkbox.android.d.ts +7 -0
  23. package/dist/native/checkbox.android.d.ts.map +1 -0
  24. package/dist/native/checkbox.android.js +26 -0
  25. package/dist/native/checkbox.android.js.map +1 -0
  26. package/dist/native/checkbox.d.ts +7 -0
  27. package/dist/native/checkbox.d.ts.map +1 -0
  28. package/dist/native/checkbox.js +7 -0
  29. package/dist/native/checkbox.js.map +1 -0
  30. package/dist/native/composed-button.android.d.ts +4 -0
  31. package/dist/native/composed-button.android.d.ts.map +1 -0
  32. package/dist/native/composed-button.android.js +53 -0
  33. package/dist/native/composed-button.android.js.map +1 -0
  34. package/dist/native/composed-button.d.ts +3 -0
  35. package/dist/native/composed-button.d.ts.map +1 -0
  36. package/dist/native/composed-button.js +4 -0
  37. package/dist/native/composed-button.js.map +1 -0
  38. package/dist/native/dialog.android.d.ts +12 -0
  39. package/dist/native/dialog.android.d.ts.map +1 -0
  40. package/dist/native/dialog.android.js +46 -0
  41. package/dist/native/dialog.android.js.map +1 -0
  42. package/dist/native/dialog.d.ts +12 -0
  43. package/dist/native/dialog.d.ts.map +1 -0
  44. package/dist/native/dialog.ios.d.ts +12 -0
  45. package/dist/native/dialog.ios.d.ts.map +1 -0
  46. package/dist/native/dialog.ios.js +13 -0
  47. package/dist/native/dialog.ios.js.map +1 -0
  48. package/dist/native/dialog.js +4 -0
  49. package/dist/native/dialog.js.map +1 -0
  50. package/dist/native/dynamic-type.d.ts +15 -0
  51. package/dist/native/dynamic-type.d.ts.map +1 -0
  52. package/dist/native/dynamic-type.js +47 -0
  53. package/dist/native/dynamic-type.js.map +1 -0
  54. package/dist/native/flex-layout.ios.d.ts +10 -0
  55. package/dist/native/flex-layout.ios.d.ts.map +1 -1
  56. package/dist/native/flex-layout.ios.js +85 -0
  57. package/dist/native/flex-layout.ios.js.map +1 -1
  58. package/dist/native/input-action.d.ts +5 -0
  59. package/dist/native/input-action.d.ts.map +1 -0
  60. package/dist/native/input-action.js +13 -0
  61. package/dist/native/input-action.js.map +1 -0
  62. package/dist/native/keyboard-dismiss.android.d.ts +8 -0
  63. package/dist/native/keyboard-dismiss.android.d.ts.map +1 -0
  64. package/dist/native/keyboard-dismiss.android.js +9 -0
  65. package/dist/native/keyboard-dismiss.android.js.map +1 -0
  66. package/dist/native/keyboard-dismiss.d.ts +10 -0
  67. package/dist/native/keyboard-dismiss.d.ts.map +1 -0
  68. package/dist/native/keyboard-dismiss.ios.d.ts +8 -0
  69. package/dist/native/keyboard-dismiss.ios.d.ts.map +1 -0
  70. package/dist/native/keyboard-dismiss.ios.js +91 -0
  71. package/dist/native/keyboard-dismiss.ios.js.map +1 -0
  72. package/dist/native/keyboard-dismiss.js +6 -0
  73. package/dist/native/keyboard-dismiss.js.map +1 -0
  74. package/dist/native/label.android.d.ts +12 -0
  75. package/dist/native/label.android.d.ts.map +1 -0
  76. package/dist/native/label.android.js +19 -0
  77. package/dist/native/label.android.js.map +1 -0
  78. package/dist/native/label.ios.d.ts +14 -1
  79. package/dist/native/label.ios.d.ts.map +1 -1
  80. package/dist/native/label.ios.js +37 -1
  81. package/dist/native/label.ios.js.map +1 -1
  82. package/dist/native/measure-memo.d.ts +37 -0
  83. package/dist/native/measure-memo.d.ts.map +1 -0
  84. package/dist/native/measure-memo.js +82 -0
  85. package/dist/native/measure-memo.js.map +1 -0
  86. package/dist/native/motion-surface.d.ts +9 -0
  87. package/dist/native/motion-surface.d.ts.map +1 -0
  88. package/dist/native/motion-surface.js +119 -0
  89. package/dist/native/motion-surface.js.map +1 -0
  90. package/dist/native/press.d.ts +5 -2
  91. package/dist/native/press.d.ts.map +1 -1
  92. package/dist/native/press.js +52 -8
  93. package/dist/native/press.js.map +1 -1
  94. package/dist/native/progress.d.ts +7 -0
  95. package/dist/native/progress.d.ts.map +1 -0
  96. package/dist/native/progress.js +77 -0
  97. package/dist/native/progress.js.map +1 -0
  98. package/dist/native/screen.android.d.ts +6 -0
  99. package/dist/native/screen.android.d.ts.map +1 -0
  100. package/dist/native/screen.android.js +8 -0
  101. package/dist/native/screen.android.js.map +1 -0
  102. package/dist/native/screen.d.ts +2 -0
  103. package/dist/native/screen.d.ts.map +1 -0
  104. package/dist/native/screen.js +3 -0
  105. package/dist/native/screen.js.map +1 -0
  106. package/dist/native/scroll-motion.d.ts +11 -0
  107. package/dist/native/scroll-motion.d.ts.map +1 -0
  108. package/dist/native/scroll-motion.js +94 -0
  109. package/dist/native/scroll-motion.js.map +1 -0
  110. package/dist/native/segmented.d.ts +14 -0
  111. package/dist/native/segmented.d.ts.map +1 -0
  112. package/dist/native/segmented.js +86 -0
  113. package/dist/native/segmented.js.map +1 -0
  114. package/dist/native/sheet.android.d.ts +18 -0
  115. package/dist/native/sheet.android.d.ts.map +1 -0
  116. package/dist/native/sheet.android.js +16 -0
  117. package/dist/native/sheet.android.js.map +1 -0
  118. package/dist/native/sheet.d.ts +21 -0
  119. package/dist/native/sheet.d.ts.map +1 -0
  120. package/dist/native/sheet.ios.d.ts +19 -0
  121. package/dist/native/sheet.ios.d.ts.map +1 -0
  122. package/dist/native/sheet.ios.js +41 -0
  123. package/dist/native/sheet.ios.js.map +1 -0
  124. package/dist/native/sheet.js +17 -0
  125. package/dist/native/sheet.js.map +1 -0
  126. package/dist/native/tabs.android.d.ts +3 -0
  127. package/dist/native/tabs.android.d.ts.map +1 -0
  128. package/dist/native/tabs.android.js +29 -0
  129. package/dist/native/tabs.android.js.map +1 -0
  130. package/dist/native/tabs.d.ts +3 -0
  131. package/dist/native/tabs.d.ts.map +1 -0
  132. package/dist/native/tabs.js +4 -0
  133. package/dist/native/tabs.js.map +1 -0
  134. package/dist/native/text-field.android.d.ts +1 -0
  135. package/dist/native/text-field.android.d.ts.map +1 -1
  136. package/dist/native/text-field.android.js +13 -0
  137. package/dist/native/text-field.android.js.map +1 -1
  138. package/dist/native/text-field.ios.d.ts +9 -0
  139. package/dist/native/text-field.ios.d.ts.map +1 -0
  140. package/dist/native/text-field.ios.js +52 -0
  141. package/dist/native/text-field.ios.js.map +1 -0
  142. package/dist/native/text-view.ios.d.ts +7 -0
  143. package/dist/native/text-view.ios.d.ts.map +1 -0
  144. package/dist/native/text-view.ios.js +10 -0
  145. package/dist/native/text-view.ios.js.map +1 -0
  146. package/dist/native/toast.android.d.ts +4 -0
  147. package/dist/native/toast.android.d.ts.map +1 -0
  148. package/dist/native/toast.android.js +10 -0
  149. package/dist/native/toast.android.js.map +1 -0
  150. package/dist/native/toast.d.ts +4 -0
  151. package/dist/native/toast.d.ts.map +1 -0
  152. package/dist/native/toast.ios.d.ts +4 -0
  153. package/dist/native/toast.ios.d.ts.map +1 -0
  154. package/dist/native/toast.ios.js +8 -0
  155. package/dist/native/toast.ios.js.map +1 -0
  156. package/dist/native/toast.js +5 -0
  157. package/dist/native/toast.js.map +1 -0
  158. package/dist/vue/components/ChoiceControl.d.ts +101 -0
  159. package/dist/vue/components/ChoiceControl.d.ts.map +1 -0
  160. package/dist/vue/components/ChoiceControl.js +196 -0
  161. package/dist/vue/components/ChoiceControl.js.map +1 -0
  162. package/dist/vue/components/MAccordion.d.ts +109 -0
  163. package/dist/vue/components/MAccordion.d.ts.map +1 -0
  164. package/dist/vue/components/MAccordion.js +83 -0
  165. package/dist/vue/components/MAccordion.js.map +1 -0
  166. package/dist/vue/components/MAlert.d.ts +99 -0
  167. package/dist/vue/components/MAlert.d.ts.map +1 -0
  168. package/dist/vue/components/MAlert.js +126 -0
  169. package/dist/vue/components/MAlert.js.map +1 -0
  170. package/dist/vue/components/MAvatar.d.ts +74 -0
  171. package/dist/vue/components/MAvatar.d.ts.map +1 -0
  172. package/dist/vue/components/MAvatar.js +86 -0
  173. package/dist/vue/components/MAvatar.js.map +1 -0
  174. package/dist/vue/components/MBadge.d.ts +64 -0
  175. package/dist/vue/components/MBadge.d.ts.map +1 -0
  176. package/dist/vue/components/MBadge.js +30 -0
  177. package/dist/vue/components/MBadge.js.map +1 -0
  178. package/dist/vue/components/MButton.d.ts +57 -5
  179. package/dist/vue/components/MButton.d.ts.map +1 -1
  180. package/dist/vue/components/MButton.js +129 -11
  181. package/dist/vue/components/MButton.js.map +1 -1
  182. package/dist/vue/components/MCard.d.ts +23 -5
  183. package/dist/vue/components/MCard.d.ts.map +1 -1
  184. package/dist/vue/components/MCard.js +14 -4
  185. package/dist/vue/components/MCard.js.map +1 -1
  186. package/dist/vue/components/MCheckbox.d.ts +93 -0
  187. package/dist/vue/components/MCheckbox.d.ts.map +1 -0
  188. package/dist/vue/components/MCheckbox.js +26 -0
  189. package/dist/vue/components/MCheckbox.js.map +1 -0
  190. package/dist/vue/components/MChip.d.ts +107 -0
  191. package/dist/vue/components/MChip.d.ts.map +1 -0
  192. package/dist/vue/components/MChip.js +120 -0
  193. package/dist/vue/components/MChip.js.map +1 -0
  194. package/dist/vue/components/MDialog.d.ts +95 -0
  195. package/dist/vue/components/MDialog.d.ts.map +1 -0
  196. package/dist/vue/components/MDialog.js +245 -0
  197. package/dist/vue/components/MDialog.js.map +1 -0
  198. package/dist/vue/components/MEmptyState.d.ts +107 -0
  199. package/dist/vue/components/MEmptyState.d.ts.map +1 -0
  200. package/dist/vue/components/MEmptyState.js +79 -0
  201. package/dist/vue/components/MEmptyState.js.map +1 -0
  202. package/dist/vue/components/MInput.d.ts +62 -7
  203. package/dist/vue/components/MInput.d.ts.map +1 -1
  204. package/dist/vue/components/MInput.js +88 -14
  205. package/dist/vue/components/MInput.js.map +1 -1
  206. package/dist/vue/components/MListItem.d.ts +92 -0
  207. package/dist/vue/components/MListItem.d.ts.map +1 -0
  208. package/dist/vue/components/MListItem.js +53 -0
  209. package/dist/vue/components/MListItem.js.map +1 -0
  210. package/dist/vue/components/MProgress.d.ts +112 -0
  211. package/dist/vue/components/MProgress.d.ts.map +1 -0
  212. package/dist/vue/components/MProgress.js +75 -0
  213. package/dist/vue/components/MProgress.js.map +1 -0
  214. package/dist/vue/components/MRadioGroup.d.ts +93 -0
  215. package/dist/vue/components/MRadioGroup.d.ts.map +1 -0
  216. package/dist/vue/components/MRadioGroup.js +57 -0
  217. package/dist/vue/components/MRadioGroup.js.map +1 -0
  218. package/dist/vue/components/MReveal.d.ts.map +1 -1
  219. package/dist/vue/components/MReveal.js +5 -7
  220. package/dist/vue/components/MReveal.js.map +1 -1
  221. package/dist/vue/components/MScreen.d.ts +18 -0
  222. package/dist/vue/components/MScreen.d.ts.map +1 -1
  223. package/dist/vue/components/MScreen.js +68 -5
  224. package/dist/vue/components/MScreen.js.map +1 -1
  225. package/dist/vue/components/MSegmentedControl.d.ts +85 -0
  226. package/dist/vue/components/MSegmentedControl.d.ts.map +1 -0
  227. package/dist/vue/components/MSegmentedControl.js +172 -0
  228. package/dist/vue/components/MSegmentedControl.js.map +1 -0
  229. package/dist/vue/components/MSelect.d.ts +130 -0
  230. package/dist/vue/components/MSelect.d.ts.map +1 -0
  231. package/dist/vue/components/MSelect.js +158 -0
  232. package/dist/vue/components/MSelect.js.map +1 -0
  233. package/dist/vue/components/MSeparator.d.ts +54 -0
  234. package/dist/vue/components/MSeparator.d.ts.map +1 -0
  235. package/dist/vue/components/MSeparator.js +36 -0
  236. package/dist/vue/components/MSeparator.js.map +1 -0
  237. package/dist/vue/components/MSheet.d.ts +101 -0
  238. package/dist/vue/components/MSheet.d.ts.map +1 -0
  239. package/dist/vue/components/MSheet.js +313 -0
  240. package/dist/vue/components/MSheet.js.map +1 -0
  241. package/dist/vue/components/MSkeleton.d.ts +70 -0
  242. package/dist/vue/components/MSkeleton.d.ts.map +1 -0
  243. package/dist/vue/components/MSkeleton.js +87 -0
  244. package/dist/vue/components/MSkeleton.js.map +1 -0
  245. package/dist/vue/components/MSlider.d.ts +1 -1
  246. package/dist/vue/components/MSlider.d.ts.map +1 -1
  247. package/dist/vue/components/MSlider.js +2 -1
  248. package/dist/vue/components/MSlider.js.map +1 -1
  249. package/dist/vue/components/MSwitch.d.ts +79 -0
  250. package/dist/vue/components/MSwitch.d.ts.map +1 -0
  251. package/dist/vue/components/MSwitch.js +163 -0
  252. package/dist/vue/components/MSwitch.js.map +1 -0
  253. package/dist/vue/components/MTabs.d.ts +91 -0
  254. package/dist/vue/components/MTabs.d.ts.map +1 -0
  255. package/dist/vue/components/MTabs.js +245 -0
  256. package/dist/vue/components/MTabs.js.map +1 -0
  257. package/dist/vue/components/MText.d.ts +16 -7
  258. package/dist/vue/components/MText.d.ts.map +1 -1
  259. package/dist/vue/components/MText.js +43 -17
  260. package/dist/vue/components/MText.js.map +1 -1
  261. package/dist/vue/components/MToast.d.ts +23 -0
  262. package/dist/vue/components/MToast.d.ts.map +1 -0
  263. package/dist/vue/components/MToast.js +242 -0
  264. package/dist/vue/components/MToast.js.map +1 -0
  265. package/dist/vue/index.d.ts +31 -4
  266. package/dist/vue/index.d.ts.map +1 -1
  267. package/dist/vue/index.js +48 -4
  268. package/dist/vue/index.js.map +1 -1
  269. package/dist/vue/layers.d.ts +19 -0
  270. package/dist/vue/layers.d.ts.map +1 -0
  271. package/dist/vue/layers.js +26 -0
  272. package/dist/vue/layers.js.map +1 -0
  273. package/dist/vue/native-view.d.ts +6 -0
  274. package/dist/vue/native-view.d.ts.map +1 -0
  275. package/dist/vue/native-view.js +5 -0
  276. package/dist/vue/native-view.js.map +1 -0
  277. package/dist/vue/props.d.ts +12 -11
  278. package/dist/vue/props.d.ts.map +1 -1
  279. package/dist/vue/props.js +25 -10
  280. package/dist/vue/props.js.map +1 -1
  281. package/dist/vue/reveal-motion.d.ts +13 -0
  282. package/dist/vue/reveal-motion.d.ts.map +1 -0
  283. package/dist/vue/reveal-motion.js +55 -0
  284. package/dist/vue/reveal-motion.js.map +1 -0
  285. package/dist/vue/system-back.d.ts +11 -0
  286. package/dist/vue/system-back.d.ts.map +1 -0
  287. package/dist/vue/system-back.js +2 -0
  288. package/dist/vue/system-back.js.map +1 -0
  289. package/dist/vue/use-motion-surface.d.ts +8 -0
  290. package/dist/vue/use-motion-surface.d.ts.map +1 -0
  291. package/dist/vue/use-motion-surface.js +75 -0
  292. package/dist/vue/use-motion-surface.js.map +1 -0
  293. package/dist/vue/use-press.d.ts +1 -1
  294. package/dist/vue/use-press.d.ts.map +1 -1
  295. package/dist/vue/use-press.js +12 -4
  296. package/dist/vue/use-press.js.map +1 -1
  297. package/dist/vue/use-scroll-motion.d.ts +7 -0
  298. package/dist/vue/use-scroll-motion.d.ts.map +1 -0
  299. package/dist/vue/use-scroll-motion.js +30 -0
  300. package/dist/vue/use-scroll-motion.js.map +1 -0
  301. package/package.json +3 -3
  302. package/platforms/android/java/com/mavis/ui/Box.java +38 -3
  303. package/platforms/android/java/com/mavis/ui/ContentWidth.java +77 -0
  304. package/platforms/android/java/com/mavis/ui/FlexLayout.java +80 -4
  305. package/platforms/android/java/com/mavis/ui/MeasureMemo.java +145 -0
  306. package/platforms/android/java/com/mavis/ui/Screen.java +108 -0
  307. package/src/native/avatar-image.ts +9 -0
  308. package/src/native/avatar-label.android.ts +14 -0
  309. package/src/native/avatar-label.ts +1 -0
  310. package/src/native/box.ios.ts +48 -1
  311. package/src/native/button.ios.ts +53 -1
  312. package/src/native/checkbox.android.ts +35 -0
  313. package/src/native/checkbox.ts +9 -0
  314. package/src/native/composed-button.android.ts +74 -0
  315. package/src/native/composed-button.ts +9 -0
  316. package/src/native/dialog.android.ts +56 -0
  317. package/src/native/dialog.ios.ts +23 -0
  318. package/src/native/dialog.ts +10 -0
  319. package/src/native/dynamic-type.ts +71 -0
  320. package/src/native/flex-layout.ios.ts +113 -0
  321. package/src/native/input-action.ts +15 -0
  322. package/src/native/keyboard-dismiss.android.ts +17 -0
  323. package/src/native/keyboard-dismiss.ios.ts +124 -0
  324. package/src/native/keyboard-dismiss.ts +14 -0
  325. package/src/native/label.android.ts +27 -0
  326. package/src/native/label.ios.ts +54 -1
  327. package/src/native/measure-memo.ts +116 -0
  328. package/src/native/motion-surface.ts +137 -0
  329. package/src/native/press.ts +52 -10
  330. package/src/native/progress.ts +78 -0
  331. package/src/native/screen.android.ts +12 -0
  332. package/src/native/screen.ts +2 -0
  333. package/src/native/scroll-motion.ts +101 -0
  334. package/src/native/segmented.ts +95 -0
  335. package/src/native/sheet.android.ts +24 -0
  336. package/src/native/sheet.ios.ts +52 -0
  337. package/src/native/sheet.ts +26 -0
  338. package/src/native/tabs.android.ts +58 -0
  339. package/src/native/tabs.ts +8 -0
  340. package/src/native/text-field.android.ts +19 -0
  341. package/src/native/text-field.ios.ts +53 -0
  342. package/src/native/text-view.ios.ts +10 -0
  343. package/src/native/toast.android.ts +9 -0
  344. package/src/native/toast.ios.ts +13 -0
  345. package/src/native/toast.ts +6 -0
  346. package/src/vue/components/ChoiceControl.ts +238 -0
  347. package/src/vue/components/MAccordion.ts +123 -0
  348. package/src/vue/components/MAlert.ts +156 -0
  349. package/src/vue/components/MAvatar.ts +103 -0
  350. package/src/vue/components/MBadge.ts +34 -0
  351. package/src/vue/components/MButton.ts +176 -9
  352. package/src/vue/components/MCard.ts +23 -3
  353. package/src/vue/components/MCheckbox.ts +25 -0
  354. package/src/vue/components/MChip.ts +134 -0
  355. package/src/vue/components/MDialog.ts +312 -0
  356. package/src/vue/components/MEmptyState.ts +96 -0
  357. package/src/vue/components/MInput.ts +96 -12
  358. package/src/vue/components/MListItem.ts +66 -0
  359. package/src/vue/components/MProgress.ts +94 -0
  360. package/src/vue/components/MRadioGroup.ts +64 -0
  361. package/src/vue/components/MReveal.ts +6 -7
  362. package/src/vue/components/MScreen.ts +93 -5
  363. package/src/vue/components/MSegmentedControl.ts +214 -0
  364. package/src/vue/components/MSelect.ts +185 -0
  365. package/src/vue/components/MSeparator.ts +40 -0
  366. package/src/vue/components/MSheet.ts +375 -0
  367. package/src/vue/components/MSkeleton.ts +100 -0
  368. package/src/vue/components/MSlider.ts +7 -1
  369. package/src/vue/components/MSwitch.ts +187 -0
  370. package/src/vue/components/MTabs.ts +302 -0
  371. package/src/vue/components/MText.ts +37 -6
  372. package/src/vue/components/MToast.ts +289 -0
  373. package/src/vue/index.ts +90 -4
  374. package/src/vue/layers.ts +48 -0
  375. package/src/vue/native-view.ts +6 -0
  376. package/src/vue/props.ts +37 -12
  377. package/src/vue/reveal-motion.ts +61 -0
  378. package/src/vue/system-back.ts +12 -0
  379. package/src/vue/use-motion-surface.ts +77 -0
  380. package/src/vue/use-press.ts +12 -4
  381. package/src/vue/use-scroll-motion.ts +31 -0
  382. package/dist/native/input-description.android.d.ts +0 -4
  383. package/dist/native/input-description.android.d.ts.map +0 -1
  384. package/dist/native/input-description.android.js +0 -18
  385. package/dist/native/input-description.android.js.map +0 -1
  386. package/dist/theme/resolve.d.ts +0 -3
  387. package/dist/theme/resolve.d.ts.map +0 -1
  388. package/dist/theme/resolve.js +0 -8
  389. package/dist/theme/resolve.js.map +0 -1
  390. package/dist/theme/themes.d.ts +0 -6
  391. package/dist/theme/themes.d.ts.map +0 -1
  392. package/dist/theme/themes.js +0 -83
  393. package/dist/theme/themes.js.map +0 -1
  394. package/dist/theme/types.d.ts +0 -50
  395. package/dist/theme/types.d.ts.map +0 -1
  396. package/dist/theme/types.js +0 -2
  397. package/dist/theme/types.js.map +0 -1
  398. package/dist/vue/global-components.d.ts +0 -21
  399. package/dist/vue/global-components.d.ts.map +0 -1
  400. package/dist/vue/global-components.js +0 -2
  401. package/dist/vue/global-components.js.map +0 -1
  402. package/dist/vue/layout-context.d.ts +0 -5
  403. package/dist/vue/layout-context.d.ts.map +0 -1
  404. package/dist/vue/layout-context.js +0 -7
  405. package/dist/vue/layout-context.js.map +0 -1
  406. package/dist/vue/text-content.d.ts +0 -4
  407. package/dist/vue/text-content.d.ts.map +0 -1
  408. package/dist/vue/text-content.js +0 -17
  409. package/dist/vue/text-content.js.map +0 -1
  410. package/dist/vue/theme.d.ts +0 -177
  411. package/dist/vue/theme.d.ts.map +0 -1
  412. package/dist/vue/theme.js +0 -17
  413. package/dist/vue/theme.js.map +0 -1
@@ -2,23 +2,99 @@ package com.mavis.ui;
2
2
 
3
3
  import android.content.Context;
4
4
  import android.view.View;
5
+ import android.view.View.MeasureSpec;
5
6
  import org.nativescript.widgets.FlexboxLayout;
6
7
 
7
8
  /** Keeps the cross-axis measurement in sync with the final width of flexible children. */
8
- public class FlexLayout extends FlexboxLayout {
9
+ public class FlexLayout extends FlexboxLayout implements MeasureMemo.Owner {
10
+ private final MeasureMemo memo = new MeasureMemo();
11
+
9
12
  public FlexLayout(Context context) {
10
13
  super(context);
11
14
  }
12
15
 
16
+ @Override
17
+ public int memoWidthSpec() {
18
+ return memo.receivedWidthSpec();
19
+ }
20
+
21
+ @Override
22
+ public int memoHeightSpec() {
23
+ return memo.receivedHeightSpec();
24
+ }
25
+
26
+ // Android's view constructors already request layout, before this field exists.
27
+ @Override
28
+ public void requestLayout() {
29
+ if (memo != null) memo.invalidate();
30
+ super.requestLayout();
31
+ }
32
+
33
+ @Override
34
+ public void forceLayout() {
35
+ if (memo != null) memo.invalidate();
36
+ super.forceLayout();
37
+ }
38
+
13
39
  @Override
14
40
  protected void onMeasure(int widthSpec, int heightSpec) {
41
+ memo.receive(widthSpec, heightSpec);
42
+ if (memo.restore(this, widthSpec, heightSpec)) {
43
+ setMeasuredDimension(memo.widthAndState(), memo.heightAndState());
44
+ return;
45
+ }
46
+ boolean column = getFlexDirection() == FLEX_DIRECTION_COLUMN
47
+ || getFlexDirection() == FLEX_DIRECTION_COLUMN_REVERSE;
48
+ try (ContentWidth widths = ContentWidth.resolve(this, widthSpec, column)) {
49
+ measureContent(widthSpec, heightSpec);
50
+ }
51
+ memo.record(this, widthSpec, heightSpec, contentExceeds(widthSpec, heightSpec));
52
+ }
53
+
54
+ // Core measures a looser request without shrinking, so the children's sizes tell whether the
55
+ // content wanted more room than the request allowed. Wrapping lines are not summed here.
56
+ private boolean contentExceeds(int widthSpec, int heightSpec) {
57
+ if (getFlexWrap() != FLEX_WRAP_NOWRAP) {
58
+ return MeasureSpec.getMode(widthSpec) == MeasureSpec.AT_MOST
59
+ || MeasureSpec.getMode(heightSpec) == MeasureSpec.AT_MOST;
60
+ }
61
+ boolean horizontal = getFlexDirection() == FLEX_DIRECTION_ROW
62
+ || getFlexDirection() == FLEX_DIRECTION_ROW_REVERSE;
63
+ int main = 0;
64
+ int cross = 0;
65
+ int visible = 0;
66
+ for (int i = 0, count = getChildCount(); i < count; i++) {
67
+ View child = getChildAt(i);
68
+ if (child.getVisibility() == View.GONE) continue;
69
+ LayoutParams params = (LayoutParams) child.getLayoutParams();
70
+ int width = child.getMeasuredWidth() + params.leftMargin + params.rightMargin;
71
+ int height = child.getMeasuredHeight() + params.topMargin + params.bottomMargin;
72
+ main += horizontal ? width : height;
73
+ cross = Math.max(cross, horizontal ? height : width);
74
+ visible++;
75
+ }
76
+ main += (horizontal ? getColumnGap() : getRowGap()) * Math.max(0, visible - 1);
77
+ int contentWidth = (horizontal ? main : cross) + getPaddingLeft() + getPaddingRight();
78
+ int contentHeight = (horizontal ? cross : main) + getPaddingTop() + getPaddingBottom();
79
+ return exceeds(widthSpec, contentWidth) || exceeds(heightSpec, contentHeight);
80
+ }
81
+
82
+ private static boolean exceeds(int spec, int size) {
83
+ return MeasureSpec.getMode(spec) == MeasureSpec.AT_MOST && MeasureSpec.getSize(spec) < size;
84
+ }
85
+
86
+ private void measureContent(int widthSpec, int heightSpec) {
15
87
  boolean horizontal = getFlexDirection() == FLEX_DIRECTION_ROW
16
88
  || getFlexDirection() == FLEX_DIRECTION_ROW_REVERSE;
17
89
 
18
90
  int count = getChildCount();
19
91
  // Core restores percentage LayoutParams after layout. Android's measure cache can then
20
- // return a result from an earlier pass with different resolved LayoutParams.
21
- for (int i = 0; i < count; i++) getChildAt(i).forceLayout();
92
+ // return a result from an earlier pass with different resolved LayoutParams. Mavis
93
+ // layouts key their own memo on the specs, so only other views need the forced pass.
94
+ for (int i = 0; i < count; i++) {
95
+ View child = getChildAt(i);
96
+ if (!(child instanceof MeasureMemo.Owner)) child.forceLayout();
97
+ }
22
98
  super.onMeasure(widthSpec, heightSpec);
23
99
 
24
100
  int[] widths = new int[count];
@@ -40,7 +116,7 @@ public class FlexLayout extends FlexboxLayout {
40
116
  params.flexGrow = 0;
41
117
  params.flexShrink = 0;
42
118
  }
43
- child.forceLayout();
119
+ if (!(child instanceof MeasureMemo.Owner)) child.forceLayout();
44
120
  }
45
121
  try {
46
122
  // Core's growth pass fixes the old height even when the new width unwraps text.
@@ -0,0 +1,145 @@
1
+ package com.mavis.ui;
2
+
3
+ import android.view.View;
4
+ import android.view.View.MeasureSpec;
5
+ import android.view.ViewGroup;
6
+ import org.nativescript.widgets.CommonLayoutParams;
7
+
8
+ /**
9
+ * Remembers the last measurement of a layout while nothing in its subtree asked for layout.
10
+ *
11
+ * Android measures every view again whenever its parent asks while a layout request is pending,
12
+ * and flex containers ask several times per pass, so nested containers measure their leaves an
13
+ * exponential number of times. The memo answers a repeated request from the recorded result and
14
+ * measures again only the children that no longer hold that result.
15
+ */
16
+ final class MeasureMemo {
17
+ /** Layouts that own a memo report the specs their latest measurement received. */
18
+ interface Owner {
19
+ int memoWidthSpec();
20
+
21
+ int memoHeightSpec();
22
+ }
23
+
24
+ private boolean valid;
25
+ private boolean percentChildren;
26
+ private boolean clamped;
27
+ private int widthSpec;
28
+ private int heightSpec;
29
+ private int widthAndState;
30
+ private int heightAndState;
31
+ private int receivedWidthSpec;
32
+ private int receivedHeightSpec;
33
+ private int[] childWidthSpecs = new int[0];
34
+ private int[] childHeightSpecs = new int[0];
35
+ private int[] childWidths = new int[0];
36
+ private int[] childHeights = new int[0];
37
+
38
+ void invalidate() {
39
+ valid = false;
40
+ }
41
+
42
+ int receivedWidthSpec() {
43
+ return receivedWidthSpec;
44
+ }
45
+
46
+ int receivedHeightSpec() {
47
+ return receivedHeightSpec;
48
+ }
49
+
50
+ /** Records the specs of the measurement that is starting, memoized or not. */
51
+ void receive(int widthSpec, int heightSpec) {
52
+ receivedWidthSpec = widthSpec;
53
+ receivedHeightSpec = heightSpec;
54
+ }
55
+
56
+ /** True when the recorded measurement answers these specs; children that changed are measured again. */
57
+ boolean restore(ViewGroup owner, int widthSpec, int heightSpec) {
58
+ if (!valid) return false;
59
+ if (!matches(widthSpec, this.widthSpec, widthAndState)) return false;
60
+ if (!matches(heightSpec, this.heightSpec, heightAndState)) return false;
61
+ int count = owner.getChildCount();
62
+ if (count != childWidthSpecs.length) {
63
+ valid = false;
64
+ return false;
65
+ }
66
+ for (int i = 0; i < count; i++) {
67
+ View child = owner.getChildAt(i);
68
+ if (child.getVisibility() == View.GONE) continue;
69
+ // A child still holding the recorded result was measured by this record's pass.
70
+ if (child.getMeasuredWidthAndState() == childWidths[i]
71
+ && child.getMeasuredHeightAndState() == childHeights[i]) continue;
72
+ child.measure(childWidthSpecs[i], childHeightSpecs[i]);
73
+ }
74
+ return true;
75
+ }
76
+
77
+ int widthAndState() {
78
+ return widthAndState;
79
+ }
80
+
81
+ int heightAndState() {
82
+ return heightAndState;
83
+ }
84
+
85
+ /**
86
+ * Stores the measurement that just completed with the result and specs every child last
87
+ * received. A clamped looser request is never reused for an exact size, which would shrink
88
+ * the children; Android keeps the too-small state only for widths.
89
+ */
90
+ void record(ViewGroup owner, int widthSpec, int heightSpec, boolean clamped) {
91
+ this.widthSpec = widthSpec;
92
+ this.heightSpec = heightSpec;
93
+ this.clamped = clamped;
94
+ widthAndState = owner.getMeasuredWidthAndState();
95
+ heightAndState = owner.getMeasuredHeightAndState();
96
+ int count = owner.getChildCount();
97
+ if (childWidthSpecs.length != count) {
98
+ childWidthSpecs = new int[count];
99
+ childHeightSpecs = new int[count];
100
+ childWidths = new int[count];
101
+ childHeights = new int[count];
102
+ }
103
+ percentChildren = false;
104
+ for (int i = 0; i < count; i++) {
105
+ View child = owner.getChildAt(i);
106
+ ViewGroup.LayoutParams params = child.getLayoutParams();
107
+ if (params instanceof CommonLayoutParams) {
108
+ CommonLayoutParams common = (CommonLayoutParams) params;
109
+ if (common.widthPercent > 0 || common.heightPercent > 0) percentChildren = true;
110
+ }
111
+ childWidths[i] = child.getMeasuredWidthAndState();
112
+ childHeights[i] = child.getMeasuredHeightAndState();
113
+ if (child instanceof Owner) {
114
+ childWidthSpecs[i] = ((Owner) child).memoWidthSpec();
115
+ childHeightSpecs[i] = ((Owner) child).memoHeightSpec();
116
+ } else {
117
+ childWidthSpecs[i] = MeasureSpec.makeMeasureSpec(child.getMeasuredWidth(), MeasureSpec.EXACTLY);
118
+ childHeightSpecs[i] = MeasureSpec.makeMeasureSpec(child.getMeasuredHeight(), MeasureSpec.EXACTLY);
119
+ }
120
+ }
121
+ valid = true;
122
+ }
123
+
124
+ /** Whether a looser request on either axis returned its whole limit; for layouts that cannot tell. */
125
+ static boolean filledLimit(int widthSpec, int heightSpec, int widthAndState, int heightAndState) {
126
+ return filled(widthSpec, widthAndState) || filled(heightSpec, heightAndState);
127
+ }
128
+
129
+ private static boolean filled(int spec, int sizeAndState) {
130
+ return MeasureSpec.getMode(spec) == MeasureSpec.AT_MOST
131
+ && (sizeAndState & View.MEASURED_SIZE_MASK) >= MeasureSpec.getSize(spec);
132
+ }
133
+
134
+ // An exact request for the size a looser request produced is the same measurement, unless a
135
+ // child resolves a percentage against the request itself or the looser request clamped content
136
+ // that wanted more room: an exact size would then shrink the children instead.
137
+ private boolean matches(int spec, int recordedSpec, int recordedSizeAndState) {
138
+ if (spec == recordedSpec) return true;
139
+ if (percentChildren || clamped) return false;
140
+ if (MeasureSpec.getMode(spec) != MeasureSpec.EXACTLY) return false;
141
+ if (MeasureSpec.getMode(recordedSpec) == MeasureSpec.EXACTLY) return false;
142
+ if ((recordedSizeAndState & View.MEASURED_STATE_TOO_SMALL) != 0) return false;
143
+ return MeasureSpec.getSize(spec) == (recordedSizeAndState & View.MEASURED_SIZE_MASK);
144
+ }
145
+ }
@@ -0,0 +1,108 @@
1
+ package com.mavis.ui;
2
+
3
+ import android.content.Context;
4
+ import android.view.MotionEvent;
5
+ import android.view.View;
6
+ import android.view.ViewConfiguration;
7
+ import android.view.ViewGroup;
8
+ import android.view.inputmethod.InputMethodManager;
9
+ import android.widget.EditText;
10
+ import org.nativescript.widgets.GridLayout;
11
+
12
+ /** The page container: puts the soft keyboard away on a tap outside the editor or on a drag. */
13
+ public class Screen extends GridLayout {
14
+ private final int slop;
15
+ private boolean dismissOnTap;
16
+ private boolean dismissOnDrag;
17
+ private boolean tracking;
18
+ private View editing;
19
+ private float downX;
20
+ private float downY;
21
+
22
+ public Screen(Context context) {
23
+ super(context);
24
+ slop = ViewConfiguration.get(context).getScaledTouchSlop();
25
+ }
26
+
27
+ public void setKeyboardDismissal(boolean onTap, boolean onDrag) {
28
+ dismissOnTap = onTap;
29
+ dismissOnDrag = onDrag;
30
+ if (!onTap && !onDrag) tracking = false;
31
+ }
32
+
33
+ // Every touch of the page passes here, so a tap on a button or a drag that the scroll view
34
+ // takes over still counts. The event itself is never consumed. Clicks run from the queue
35
+ // after the up event, so the tap waits its turn: a control that focused another editor
36
+ // meanwhile keeps that focus.
37
+ @Override
38
+ public boolean dispatchTouchEvent(MotionEvent event) {
39
+ switch (event.getActionMasked()) {
40
+ case MotionEvent.ACTION_DOWN:
41
+ downX = event.getRawX();
42
+ downY = event.getRawY();
43
+ editing = findFocus();
44
+ tracking = (dismissOnTap || dismissOnDrag)
45
+ && editing instanceof EditText
46
+ && !touchesEditor(this, downX, downY);
47
+ break;
48
+ case MotionEvent.ACTION_MOVE:
49
+ // Like the interactive mode on iOS, only a drag towards the keyboard puts it
50
+ // away; dragging the other way still scrolls the form while typing.
51
+ if (tracking && dismissOnDrag && event.getRawY() - downY > slop) {
52
+ tracking = false;
53
+ dismiss();
54
+ } else if (tracking && moved(event)) {
55
+ tracking = false;
56
+ }
57
+ break;
58
+ case MotionEvent.ACTION_UP:
59
+ if (tracking && dismissOnTap && !moved(event)) {
60
+ final View before = editing;
61
+ post(() -> {
62
+ if (findFocus() == before) dismiss();
63
+ });
64
+ }
65
+ tracking = false;
66
+ break;
67
+ case MotionEvent.ACTION_CANCEL:
68
+ tracking = false;
69
+ break;
70
+ default:
71
+ break;
72
+ }
73
+ return super.dispatchTouchEvent(event);
74
+ }
75
+
76
+ private boolean moved(MotionEvent event) {
77
+ return Math.abs(event.getRawX() - downX) > slop || Math.abs(event.getRawY() - downY) > slop;
78
+ }
79
+
80
+ // A touch that starts on any editor keeps the keyboard: it focuses that editor or edits it.
81
+ private static boolean touchesEditor(View view, float x, float y) {
82
+ if (view.getVisibility() != View.VISIBLE) return false;
83
+ if (view instanceof EditText) {
84
+ int[] origin = new int[2];
85
+ view.getLocationOnScreen(origin);
86
+ return x >= origin[0] && x <= origin[0] + view.getWidth()
87
+ && y >= origin[1] && y <= origin[1] + view.getHeight();
88
+ }
89
+ if (view instanceof ViewGroup) {
90
+ ViewGroup group = (ViewGroup) view;
91
+ for (int i = 0, count = group.getChildCount(); i < count; i++) {
92
+ if (touchesEditor(group.getChildAt(i), x, y)) return true;
93
+ }
94
+ }
95
+ return false;
96
+ }
97
+
98
+ // Clearing the focus makes Core report blur and hide the keyboard; hiding it here as well
99
+ // covers editors that are not Core views.
100
+ private void dismiss() {
101
+ View focused = findFocus();
102
+ if (!(focused instanceof EditText)) return;
103
+ InputMethodManager manager =
104
+ (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
105
+ if (manager != null) manager.hideSoftInputFromWindow(focused.getWindowToken(), 0);
106
+ focused.clearFocus();
107
+ }
108
+ }
@@ -0,0 +1,9 @@
1
+ import { ImageSource, Utils } from '@nativescript/core'
2
+
3
+ /** Use Core decoding without leaving rejected local-image promises unhandled. */
4
+ export function loadAvatarImage(src: string): Promise<ImageSource | null> {
5
+ if (Utils.isDataURI(src)) return ImageSource.fromBase64(src.slice(src.indexOf(',') + 1))
6
+ if (src.startsWith('res://')) return ImageSource.fromResource(src.slice(6))
7
+ if (Utils.isFileOrResourcePath(src)) return ImageSource.fromFile(src)
8
+ return ImageSource.fromUrl(src)
9
+ }
@@ -0,0 +1,14 @@
1
+ import { Label, Utils } from '@nativescript/core'
2
+ import { fontSizeProperty } from '@nativescript/core/ui/styling/style-properties'
3
+
4
+ declare const android: { util: { TypedValue: { COMPLEX_UNIT_PX: number } } }
5
+
6
+ /** Initials are a fixed visual mark; the adjacent name remains scalable text. */
7
+ export class MavisAvatarLabel extends Label {
8
+ [fontSizeProperty.setNative](value: number | { nativeSize: number }) {
9
+ this.nativeTextViewProtected.setTextSize(
10
+ android.util.TypedValue.COMPLEX_UNIT_PX,
11
+ typeof value === 'number' ? Utils.layout.toDevicePixels(value) : value.nativeSize,
12
+ )
13
+ }
14
+ }
@@ -0,0 +1 @@
1
+ export { MavisLabel as MavisAvatarLabel } from './label'
@@ -1,14 +1,61 @@
1
1
  import { GridLayout, Utils } from '@nativescript/core'
2
+ import {
3
+ filledLimit,
4
+ layoutChildren,
5
+ recordMeasurement,
6
+ reuseMeasurement,
7
+ type MeasureRecord,
8
+ } from './measure-memo'
2
9
 
3
10
  const { layout } = Utils
4
11
 
5
12
  /** An auto-height Box takes its content height when the parent only limits the available space. */
6
13
  export class MavisBox extends GridLayout {
14
+ measureRecord?: MeasureRecord
15
+
16
+ measure(widthSpec: number, heightSpec: number) {
17
+ if (reuseMeasurement(this, widthSpec, heightSpec)) return
18
+ super.measure(widthSpec, heightSpec)
19
+ const measured = this as unknown as { _measuredWidth: number; _measuredHeight: number }
20
+ recordMeasurement(
21
+ this,
22
+ widthSpec,
23
+ heightSpec,
24
+ layoutChildren(this),
25
+ filledLimit(widthSpec, heightSpec, measured._measuredWidth, measured._measuredHeight),
26
+ )
27
+ }
28
+
29
+ requestLayout() {
30
+ this.measureRecord = undefined
31
+ super.requestLayout()
32
+ }
33
+
7
34
  onMeasure(widthSpec: number, heightSpec: number) {
8
35
  const relaxed =
9
36
  this.effectiveHeight < 0 && layout.getMeasureSpecMode(heightSpec) === layout.AT_MOST
10
37
  ? layout.makeMeasureSpec(0, layout.UNSPECIFIED)
11
38
  : heightSpec
12
- super.onMeasure(widthSpec, relaxed)
39
+ // Grid calculates cell sizes from the arguments, but View.measureChild resolves a
40
+ // percentage from the parent's stored spec. Supply the content width for that lookup.
41
+ const measurement = this as unknown as { _currentWidthMeasureSpec: number }
42
+ const original = measurement._currentWidthMeasureSpec
43
+ const contentWidth = Math.max(
44
+ 0,
45
+ layout.getMeasureSpecSize(widthSpec) -
46
+ this.effectivePaddingLeft -
47
+ this.effectivePaddingRight -
48
+ this.effectiveBorderLeftWidth -
49
+ this.effectiveBorderRightWidth,
50
+ )
51
+ measurement._currentWidthMeasureSpec = layout.makeMeasureSpec(
52
+ contentWidth,
53
+ layout.getMeasureSpecMode(widthSpec),
54
+ )
55
+ try {
56
+ super.onMeasure(widthSpec, relaxed)
57
+ } finally {
58
+ measurement._currentWidthMeasureSpec = original
59
+ }
13
60
  }
14
61
  }
@@ -1,6 +1,58 @@
1
- import { Button } from '@nativescript/core'
1
+ import { Button, Font, type Span } from '@nativescript/core'
2
+ import { fontScaleInternalProperty } from '@nativescript/core/ui/styling/style-properties'
3
+ import { recordMeasurement, reuseMeasurement, type MeasureRecord } from './measure-memo'
4
+ import { applyDynamicType, dynamicTypeScale } from './dynamic-type'
5
+
6
+ interface SpanDetails {
7
+ iosFont: unknown
8
+ baselineOffset: number
9
+ }
10
+ interface FormattedText {
11
+ createMutableStringDetails(span: Span, text: string, index?: number): SpanDetails
12
+ getBaselineOffset(font: unknown, align: unknown): number
13
+ }
14
+ const formatted = Button.prototype as unknown as FormattedText
2
15
 
3
16
  export class MavisButton extends Button {
17
+ measureRecord?: MeasureRecord;
18
+
19
+ [fontScaleInternalProperty.setNative]() {
20
+ applyDynamicType(this)
21
+ }
22
+
23
+ // Icon buttons render their label as spans, which Core scales with its own table too.
24
+ createMutableStringDetails(span: Span, text: string, index?: number) {
25
+ const details = formatted.createMutableStringDetails.call(this, span, text, index)
26
+ const { style } = span
27
+ const size = style.fontSize ?? this.style.fontSize
28
+ const font = new Font(
29
+ style.fontFamily,
30
+ style.fontSize,
31
+ style.fontStyle,
32
+ style.fontWeight,
33
+ dynamicTypeScale(this, size),
34
+ style.fontVariationSettings,
35
+ )
36
+ details.iosFont = font.getUIFont(this.nativeTextViewProtected.font)
37
+ details.baselineOffset = formatted.getBaselineOffset.call(
38
+ this,
39
+ details.iosFont,
40
+ style.verticalAlignment,
41
+ )
42
+ return details
43
+ }
44
+
45
+ measure(widthSpec: number, heightSpec: number) {
46
+ if (reuseMeasurement(this, widthSpec, heightSpec)) return
47
+ super.measure(widthSpec, heightSpec)
48
+ recordMeasurement(this, widthSpec, heightSpec)
49
+ }
50
+
51
+ requestLayout() {
52
+ this.measureRecord = undefined
53
+ super.requestLayout()
54
+ }
55
+
4
56
  onMeasure(widthSpec: number, heightSpec: number) {
5
57
  const button = this.ios
6
58
  // UIButton updates titleLabel during its layout pass. Wrapped measurement needs the
@@ -0,0 +1,35 @@
1
+ import type { View } from '@nativescript/core'
2
+ import { SDK_VERSION } from '@nativescript/core/utils/constants'
3
+
4
+ declare const android: {
5
+ view: {
6
+ View: {
7
+ OnFocusChangeListener: new (listener: {
8
+ onFocusChange(view: unknown, focused: boolean): void
9
+ }) => object
10
+ }
11
+ }
12
+ }
13
+
14
+ export function mixedValue(indeterminate: boolean, label: string) {
15
+ return indeterminate && SDK_VERSION < 30 ? label : ''
16
+ }
17
+
18
+ export function observeCheckbox(view: View, focus: (focused: boolean) => void) {
19
+ const button = view.android
20
+ const listener = new android.view.View.OnFocusChangeListener({
21
+ onFocusChange: (_view: unknown, focused: boolean) => focus(focused),
22
+ })
23
+ button.setOnFocusChangeListener(listener)
24
+ focus(button.hasFocus())
25
+ return {
26
+ setMixed(label: string | undefined) {
27
+ if (SDK_VERSION >= 30) button.setStateDescription(label ?? null)
28
+ },
29
+ dispose() {
30
+ if (button.getOnFocusChangeListener() === listener) button.setOnFocusChangeListener(null)
31
+ if (SDK_VERSION >= 30) button.setStateDescription(null)
32
+ focus(false)
33
+ },
34
+ }
35
+ }
@@ -0,0 +1,9 @@
1
+ import type { View } from '@nativescript/core'
2
+
3
+ export function mixedValue(indeterminate: boolean, label: string) {
4
+ return indeterminate ? label : ''
5
+ }
6
+
7
+ export function observeCheckbox(_view: View, _focus: (focused: boolean) => void) {
8
+ return { setMixed(_label: string | undefined) {}, dispose() {} }
9
+ }
@@ -0,0 +1,74 @@
1
+ import type { View } from '@nativescript/core'
2
+
3
+ declare const android: {
4
+ view: {
5
+ View: {
6
+ OnKeyListener: new (listener: {
7
+ onKey(
8
+ view: unknown,
9
+ key: number,
10
+ event: {
11
+ getAction(): number
12
+ getRepeatCount(): number
13
+ isCanceled(): boolean
14
+ },
15
+ ): boolean
16
+ }) => unknown
17
+ OnFocusChangeListener: new (listener: {
18
+ onFocusChange(view: unknown, focused: boolean): void
19
+ }) => unknown
20
+ }
21
+ }
22
+ }
23
+
24
+ /** A composed surface keeps a single Android keyboard/accessibility action. */
25
+ export function observeComposedButton(
26
+ view: View,
27
+ focus: (focused: boolean) => void,
28
+ activate: () => void,
29
+ press: (pressed: boolean) => void,
30
+ ) {
31
+ const button = view.android
32
+ let down = false
33
+ const cancel = () => {
34
+ if (down) press(false)
35
+ down = false
36
+ }
37
+ const keys = new android.view.View.OnKeyListener({
38
+ onKey(_view, key, event) {
39
+ if (![23, 62, 66].includes(key)) return false
40
+ if (!view.isEnabled) {
41
+ cancel()
42
+ return false
43
+ }
44
+ if (event.getAction() === 0) {
45
+ if (!event.getRepeatCount()) {
46
+ down = true
47
+ press(true)
48
+ }
49
+ } else if (event.getAction() === 1 && down) {
50
+ const accepted = !event.isCanceled()
51
+ cancel()
52
+ if (accepted) activate()
53
+ }
54
+ return true
55
+ },
56
+ })
57
+ const focused = new android.view.View.OnFocusChangeListener({
58
+ onFocusChange(_view, value) {
59
+ focus(value)
60
+ if (!value) cancel()
61
+ },
62
+ })
63
+ view.on('isEnabledChange', cancel)
64
+ button.setDescendantFocusability(393216) // FOCUS_BLOCK_DESCENDANTS
65
+ button.setFocusable(true)
66
+ button.setOnKeyListener(keys)
67
+ button.setOnFocusChangeListener(focused)
68
+ return () => {
69
+ cancel()
70
+ view.off('isEnabledChange', cancel)
71
+ button.setOnKeyListener(null)
72
+ if (button.getOnFocusChangeListener() === focused) button.setOnFocusChangeListener(null)
73
+ }
74
+ }
@@ -0,0 +1,9 @@
1
+ import type { View } from '@nativescript/core'
2
+ export function observeComposedButton(
3
+ _view: View,
4
+ _focus: (focused: boolean) => void,
5
+ _activate: () => void,
6
+ _press: (pressed: boolean) => void,
7
+ ) {
8
+ return () => {}
9
+ }