@adminide-stack/clock-tik-mobile 0.0.0-stage → 12.0.37-alpha.0

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 (376) hide show
  1. package/.claude-flow/data/pending-insights.jsonl +43 -0
  2. package/.claude-flow/sessions/session-1794323376548.json +14 -0
  3. package/CHANGELOG.md +31 -0
  4. package/jest.config.cjs +22 -0
  5. package/lib/assets/home/loop-day.jpg +0 -0
  6. package/lib/assets/home/loop-day.mp4 +0 -0
  7. package/lib/assets/home/loop-time-back.jpg +0 -0
  8. package/lib/assets/home/loop-time-back.mp4 +0 -0
  9. package/lib/assets/home/loop-where.jpg +0 -0
  10. package/lib/assets/home/loop-where.mp4 +0 -0
  11. package/lib/assets/home/reel-gym.jpg +0 -0
  12. package/lib/assets/home/reel-gym.mp4 +0 -0
  13. package/lib/assets/home/reel-internet.jpg +0 -0
  14. package/lib/assets/home/reel-internet.mp4 +0 -0
  15. package/lib/assets/icon.png +0 -0
  16. package/lib/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
  17. package/lib/assets/lottie/lucy-mark-calendar.json +1827 -0
  18. package/lib/assets/lottie/lucy-mark-call.json +1470 -0
  19. package/lib/assets/lottie/lucy-mark-connect.json +2552 -0
  20. package/lib/assets/lottie/lucy-mark-details.json +1735 -0
  21. package/lib/assets/lottie/lucy-mark-email.json +1363 -0
  22. package/lib/assets/lottie/lucy-mark-message.json +1154 -0
  23. package/lib/assets/lottie/lucy-mark-search.json +1067 -0
  24. package/lib/assets/lottie/lucy-mark-think.json +1253 -0
  25. package/lib/assets/lottie/lucy-mark-write.json +1532 -0
  26. package/lib/assets/lottie/time-back.json +16458 -0
  27. package/lib/assets/lottie/where-lucy-works-chat.json +6170 -0
  28. package/lib/assets/lottie/where-lucy-works-cloud.json +10066 -0
  29. package/lib/assets/lottie/where-lucy-works-mine-none.json +2478 -0
  30. package/lib/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
  31. package/lib/assets/lottie/where-lucy-works-mine-online.json +7881 -0
  32. package/lib/assets/sounds/hours-back.m4a +0 -0
  33. package/lib/assets/sounds/meet-lucy.m4a +0 -0
  34. package/lib/assets/sounds/power-on.m4a +0 -0
  35. package/lib/assets/sounds/wind-back.m4a +0 -0
  36. package/lib/assets/sounds/youre-in.m4a +0 -0
  37. package/lib/chat/agent.js +358 -0
  38. package/lib/chat/agent.js.map +1 -0
  39. package/lib/chat/appFront.js +32 -0
  40. package/lib/chat/appFront.js.map +1 -0
  41. package/lib/chat/auth.js +370 -0
  42. package/lib/chat/auth.js.map +1 -0
  43. package/lib/chat/chores.js +360 -0
  44. package/lib/chat/chores.js.map +1 -0
  45. package/lib/chat/connectors.js +42 -0
  46. package/lib/chat/connectors.js.map +1 -0
  47. package/lib/chat/jobs.js +223 -0
  48. package/lib/chat/jobs.js.map +1 -0
  49. package/lib/chat/lucyMotion.js +6 -0
  50. package/lib/chat/lucyMotion.js.map +1 -0
  51. package/lib/chat/protocol.js +111 -0
  52. package/lib/chat/protocol.js.map +1 -0
  53. package/lib/chat/results.js +133 -0
  54. package/lib/chat/results.js.map +1 -0
  55. package/lib/chat/store.js +81 -0
  56. package/lib/chat/store.js.map +1 -0
  57. package/lib/chat/useDictation.js +168 -0
  58. package/lib/chat/useDictation.js.map +1 -0
  59. package/lib/chat/useLucyChat.js +451 -0
  60. package/lib/chat/useLucyChat.js.map +1 -0
  61. package/lib/chat/useMyComputer.js +32 -0
  62. package/lib/chat/useMyComputer.js.map +1 -0
  63. package/lib/chat/whereLucyWorks.js +52 -0
  64. package/lib/chat/whereLucyWorks.js.map +1 -0
  65. package/lib/chat/workspace.js +124 -0
  66. package/lib/chat/workspace.js.map +1 -0
  67. package/lib/components/AreaShot.js +289 -0
  68. package/lib/components/AreaShot.js.map +1 -0
  69. package/lib/components/Backdrops.js +262 -0
  70. package/lib/components/Backdrops.js.map +1 -0
  71. package/lib/components/BottomSheet.js +61 -0
  72. package/lib/components/BottomSheet.js.map +1 -0
  73. package/lib/components/ChatSheets.js +429 -0
  74. package/lib/components/ChatSheets.js.map +1 -0
  75. package/lib/components/ConnectorLogo.js +91 -0
  76. package/lib/components/ConnectorLogo.js.map +1 -0
  77. package/lib/components/CustomDrawer.js +534 -0
  78. package/lib/components/CustomDrawer.js.map +1 -0
  79. package/lib/components/IdeasPane.js +394 -0
  80. package/lib/components/IdeasPane.js.map +1 -0
  81. package/lib/components/ImessageSheet.js +261 -0
  82. package/lib/components/ImessageSheet.js.map +1 -0
  83. package/lib/components/KeyboardAvoider.js +29 -0
  84. package/lib/components/KeyboardAvoider.js.map +1 -0
  85. package/lib/components/Logo.js +81 -0
  86. package/lib/components/Logo.js.map +1 -0
  87. package/lib/components/LucyWorking.js +67 -0
  88. package/lib/components/LucyWorking.js.map +1 -0
  89. package/lib/components/Markdown.js +260 -0
  90. package/lib/components/Markdown.js.map +1 -0
  91. package/lib/components/Media.js +93 -0
  92. package/lib/components/Media.js.map +1 -0
  93. package/lib/components/MessagesAppIcon.js +23 -0
  94. package/lib/components/MessagesAppIcon.js.map +1 -0
  95. package/lib/components/MicButton.js +71 -0
  96. package/lib/components/MicButton.js.map +1 -0
  97. package/lib/components/ResultCards.js +974 -0
  98. package/lib/components/ResultCards.js.map +1 -0
  99. package/lib/components/SignInPrompt.js +148 -0
  100. package/lib/components/SignInPrompt.js.map +1 -0
  101. package/lib/components/SignedOut.js +38 -0
  102. package/lib/components/SignedOut.js.map +1 -0
  103. package/lib/components/TalkToLucyHero.js +487 -0
  104. package/lib/components/TalkToLucyHero.js.map +1 -0
  105. package/lib/components/TalkToLucySheet.js +182 -0
  106. package/lib/components/TalkToLucySheet.js.map +1 -0
  107. package/lib/components/WhereLucyWorks.js +277 -0
  108. package/lib/components/WhereLucyWorks.js.map +1 -0
  109. package/lib/components/WorkspaceSection.js +271 -0
  110. package/lib/components/WorkspaceSection.js.map +1 -0
  111. package/lib/components/YantraMark.js +13 -0
  112. package/lib/components/YantraMark.js.map +1 -0
  113. package/lib/components/drawerHeader.js +38 -0
  114. package/lib/components/drawerHeader.js.map +1 -0
  115. package/lib/components/lottieInstalled.js +6 -0
  116. package/lib/components/lottieInstalled.js.map +1 -0
  117. package/lib/components/ui.js +550 -0
  118. package/lib/components/ui.js.map +1 -0
  119. package/lib/components/useSignOut.js +7 -0
  120. package/lib/components/useSignOut.js.map +1 -0
  121. package/lib/components/viewport.js +121 -0
  122. package/lib/components/viewport.js.map +1 -0
  123. package/lib/components/voiceDial.js +10 -0
  124. package/lib/components/voiceDial.js.map +1 -0
  125. package/lib/compute.js +157 -0
  126. package/lib/compute.js.map +1 -0
  127. package/lib/config/env-config.js +21 -0
  128. package/lib/config/env-config.js.map +1 -0
  129. package/lib/config/routes.js +15 -0
  130. package/lib/config/routes.js.map +1 -0
  131. package/lib/content.js +25 -0
  132. package/lib/content.js.map +1 -0
  133. package/lib/hooks/keyboardCover.js +39 -0
  134. package/lib/hooks/keyboardCover.js.map +1 -0
  135. package/lib/hooks/useKeyboard.js +121 -0
  136. package/lib/hooks/useKeyboard.js.map +1 -0
  137. package/lib/hooks/useReducedMotion.js +13 -0
  138. package/lib/hooks/useReducedMotion.js.map +1 -0
  139. package/lib/imessage/openMessages.js +25 -0
  140. package/lib/imessage/openMessages.js.map +1 -0
  141. package/lib/imessage/platform.js +12 -0
  142. package/lib/imessage/platform.js.map +1 -0
  143. package/lib/imessage/textLink.js +262 -0
  144. package/lib/imessage/textLink.js.map +1 -0
  145. package/lib/index.js +1 -0
  146. package/lib/index.js.map +1 -0
  147. package/lib/live/card.js +28 -0
  148. package/lib/live/card.js.map +1 -0
  149. package/lib/live/liveActivity.js +144 -0
  150. package/lib/live/liveActivity.js.map +1 -0
  151. package/lib/module.js +3 -0
  152. package/lib/module.js.map +1 -0
  153. package/lib/offer/BlackFridayOffer.js +378 -0
  154. package/lib/offer/BlackFridayOffer.js.map +1 -0
  155. package/lib/offer/blackFriday.js +78 -0
  156. package/lib/offer/blackFriday.js.map +1 -0
  157. package/lib/offer/parts.js +624 -0
  158. package/lib/offer/parts.js.map +1 -0
  159. package/lib/offer/state.js +63 -0
  160. package/lib/offer/state.js.map +1 -0
  161. package/lib/push/push.js +142 -0
  162. package/lib/push/push.js.map +1 -0
  163. package/lib/push/usePushNotifications.js +39 -0
  164. package/lib/push/usePushNotifications.js.map +1 -0
  165. package/lib/routes.json +175 -0
  166. package/lib/screens/Account/index.js +209 -0
  167. package/lib/screens/Account/index.js.map +1 -0
  168. package/lib/screens/Chat/index.js +710 -0
  169. package/lib/screens/Chat/index.js.map +1 -0
  170. package/lib/screens/Chores/index.js +18 -0
  171. package/lib/screens/Chores/index.js.map +1 -0
  172. package/lib/screens/Connectors/index.js +17 -0
  173. package/lib/screens/Connectors/index.js.map +1 -0
  174. package/lib/screens/History/index.js +380 -0
  175. package/lib/screens/History/index.js.map +1 -0
  176. package/lib/screens/Home/index.js +2711 -0
  177. package/lib/screens/Home/index.js.map +1 -0
  178. package/lib/screens/Home/media.js +25 -0
  179. package/lib/screens/Home/media.js.map +1 -0
  180. package/lib/screens/Welcome/index.js +1066 -0
  181. package/lib/screens/Welcome/index.js.map +1 -0
  182. package/lib/talk/talkToLucy.js +139 -0
  183. package/lib/talk/talkToLucy.js.map +1 -0
  184. package/lib/theme/colors.js +29 -0
  185. package/lib/theme/colors.js.map +1 -0
  186. package/lib/theme/fonts.js +17 -0
  187. package/lib/theme/fonts.js.map +1 -0
  188. package/lib/theme/muse.js +134 -0
  189. package/lib/theme/muse.js.map +1 -0
  190. package/lib/utils/links.js +54 -0
  191. package/lib/utils/links.js.map +1 -0
  192. package/lib/utils/yantraLinks.js +68 -0
  193. package/lib/utils/yantraLinks.js.map +1 -0
  194. package/lib/welcome/flow.js +375 -0
  195. package/lib/welcome/flow.js.map +1 -0
  196. package/lib/welcome/haptics.js +125 -0
  197. package/lib/welcome/haptics.js.map +1 -0
  198. package/lib/welcome/parts.js +1996 -0
  199. package/lib/welcome/parts.js.map +1 -0
  200. package/lib/welcome/powerOn.js +29 -0
  201. package/lib/welcome/powerOn.js.map +1 -0
  202. package/lib/welcome/seen.js +41 -0
  203. package/lib/welcome/seen.js.map +1 -0
  204. package/lib/welcome/sound.js +110 -0
  205. package/lib/welcome/sound.js.map +1 -0
  206. package/package.json +66 -5
  207. package/rollup.config.mjs +42 -0
  208. package/src/.claude-flow/data/pending-insights.jsonl +19 -0
  209. package/src/.claude-flow/sessions/session-1795013028422.json +14 -0
  210. package/src/__tests__/auth.test.ts +94 -0
  211. package/src/__tests__/blackFriday.test.ts +75 -0
  212. package/src/__tests__/cardTokens.test.ts +77 -0
  213. package/src/__tests__/chores.test.ts +179 -0
  214. package/src/__tests__/choresList.test.ts +100 -0
  215. package/src/__tests__/content.test.ts +54 -0
  216. package/src/__tests__/dictation.test.ts +186 -0
  217. package/src/__tests__/haptics.test.ts +202 -0
  218. package/src/__tests__/jobs.test.ts +130 -0
  219. package/src/__tests__/keyboardCover.test.ts +84 -0
  220. package/src/__tests__/liveCard.test.ts +39 -0
  221. package/src/__tests__/lockedPhone.test.ts +355 -0
  222. package/src/__tests__/lucyMotion.test.ts +34 -0
  223. package/src/__tests__/platform.test.ts +32 -0
  224. package/src/__tests__/powerOn.test.ts +62 -0
  225. package/src/__tests__/protocol.test.ts +125 -0
  226. package/src/__tests__/push.test.ts +111 -0
  227. package/src/__tests__/results.test.ts +256 -0
  228. package/src/__tests__/sound.test.ts +248 -0
  229. package/src/__tests__/talkToLucy.test.ts +205 -0
  230. package/src/__tests__/textLink.test.ts +91 -0
  231. package/src/__tests__/voiceDial.test.ts +53 -0
  232. package/src/__tests__/welcomeFlow.test.ts +157 -0
  233. package/src/__tests__/whereLucyWorks.test.ts +81 -0
  234. package/src/__tests__/yantraLinks.test.ts +96 -0
  235. package/src/assets/home/loop-day.jpg +0 -0
  236. package/src/assets/home/loop-day.mp4 +0 -0
  237. package/src/assets/home/loop-time-back.jpg +0 -0
  238. package/src/assets/home/loop-time-back.mp4 +0 -0
  239. package/src/assets/home/loop-where.jpg +0 -0
  240. package/src/assets/home/loop-where.mp4 +0 -0
  241. package/src/assets/home/reel-gym.jpg +0 -0
  242. package/src/assets/home/reel-gym.mp4 +0 -0
  243. package/src/assets/home/reel-internet.jpg +0 -0
  244. package/src/assets/home/reel-internet.mp4 +0 -0
  245. package/src/assets/icon.png +0 -0
  246. package/src/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
  247. package/src/assets/lottie/lucy-mark-calendar.json +1827 -0
  248. package/src/assets/lottie/lucy-mark-call.json +1470 -0
  249. package/src/assets/lottie/lucy-mark-connect.json +2552 -0
  250. package/src/assets/lottie/lucy-mark-details.json +1735 -0
  251. package/src/assets/lottie/lucy-mark-email.json +1363 -0
  252. package/src/assets/lottie/lucy-mark-message.json +1154 -0
  253. package/src/assets/lottie/lucy-mark-search.json +1067 -0
  254. package/src/assets/lottie/lucy-mark-think.json +1253 -0
  255. package/src/assets/lottie/lucy-mark-write.json +1532 -0
  256. package/src/assets/lottie/time-back.json +16458 -0
  257. package/src/assets/lottie/where-lucy-works-chat.json +6170 -0
  258. package/src/assets/lottie/where-lucy-works-cloud.json +10066 -0
  259. package/src/assets/lottie/where-lucy-works-mine-none.json +2478 -0
  260. package/src/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
  261. package/src/assets/lottie/where-lucy-works-mine-online.json +7881 -0
  262. package/src/assets/sounds/hours-back.m4a +0 -0
  263. package/src/assets/sounds/meet-lucy.m4a +0 -0
  264. package/src/assets/sounds/power-on.m4a +0 -0
  265. package/src/assets/sounds/wind-back.m4a +0 -0
  266. package/src/assets/sounds/youre-in.m4a +0 -0
  267. package/src/chat/.claude-flow/data/pending-insights.jsonl +1 -0
  268. package/src/chat/agent.ts +376 -0
  269. package/src/chat/appFront.ts +39 -0
  270. package/src/chat/auth.ts +433 -0
  271. package/src/chat/chores.ts +394 -0
  272. package/src/chat/connectors.ts +65 -0
  273. package/src/chat/jobs.ts +228 -0
  274. package/src/chat/lucyMotion.ts +33 -0
  275. package/src/chat/protocol.ts +192 -0
  276. package/src/chat/results.ts +224 -0
  277. package/src/chat/store.ts +87 -0
  278. package/src/chat/useDictation.ts +201 -0
  279. package/src/chat/useLucyChat.ts +458 -0
  280. package/src/chat/useMyComputer.ts +41 -0
  281. package/src/chat/whereLucyWorks.ts +97 -0
  282. package/src/chat/workspace.ts +127 -0
  283. package/src/components/.claude-flow/data/pending-insights.jsonl +3 -0
  284. package/src/components/AreaShot.tsx +239 -0
  285. package/src/components/Backdrops.tsx +323 -0
  286. package/src/components/BottomSheet.tsx +96 -0
  287. package/src/components/ChatSheets.tsx +565 -0
  288. package/src/components/ConnectorLogo.tsx +116 -0
  289. package/src/components/CustomDrawer.tsx +526 -0
  290. package/src/components/IdeasPane.tsx +318 -0
  291. package/src/components/ImessageSheet.tsx +280 -0
  292. package/src/components/KeyboardAvoider.tsx +45 -0
  293. package/src/components/Logo.tsx +97 -0
  294. package/src/components/LucyWorking.tsx +122 -0
  295. package/src/components/Markdown.tsx +219 -0
  296. package/src/components/Media.tsx +173 -0
  297. package/src/components/MessagesAppIcon.tsx +51 -0
  298. package/src/components/MicButton.tsx +92 -0
  299. package/src/components/ResultCards.tsx +1067 -0
  300. package/src/components/SignInPrompt.tsx +182 -0
  301. package/src/components/SignedOut.tsx +47 -0
  302. package/src/components/TalkToLucyHero.tsx +540 -0
  303. package/src/components/TalkToLucySheet.tsx +208 -0
  304. package/src/components/VoiceOrb.tsx +364 -0
  305. package/src/components/WhereLucyWorks.tsx +261 -0
  306. package/src/components/WorkspaceSection.tsx +307 -0
  307. package/src/components/YantraMark.tsx +30 -0
  308. package/src/components/drawerHeader.tsx +46 -0
  309. package/src/components/kit.tsx +309 -0
  310. package/src/components/lottieInstalled.ts +7 -0
  311. package/src/components/ui.tsx +700 -0
  312. package/src/components/useSignOut.ts +21 -0
  313. package/src/components/viewport.tsx +166 -0
  314. package/src/components/voiceDial.ts +45 -0
  315. package/src/compute.ts +168 -0
  316. package/src/config/env-config.ts +37 -0
  317. package/src/config/routes.ts +28 -0
  318. package/src/content.ts +217 -0
  319. package/src/hooks/keyboardCover.ts +70 -0
  320. package/src/hooks/useKeyboard.ts +135 -0
  321. package/src/hooks/useReducedMotion.ts +19 -0
  322. package/src/imessage/openMessages.ts +53 -0
  323. package/src/imessage/platform.ts +32 -0
  324. package/src/imessage/textLink.ts +307 -0
  325. package/src/index.ts +24 -0
  326. package/src/live/card.ts +62 -0
  327. package/src/live/liveActivity.ts +192 -0
  328. package/src/module.ts +8 -0
  329. package/src/offer/BlackFridayOffer.tsx +394 -0
  330. package/src/offer/blackFriday.ts +109 -0
  331. package/src/offer/parts.tsx +650 -0
  332. package/src/offer/state.ts +78 -0
  333. package/src/push/push.ts +171 -0
  334. package/src/push/usePushNotifications.ts +47 -0
  335. package/src/screens/Account/index.tsx +310 -0
  336. package/src/screens/Chat/.claude-flow/data/pending-insights.jsonl +4 -0
  337. package/src/screens/Chat/index.tsx +891 -0
  338. package/src/screens/Chores/index.tsx +35 -0
  339. package/src/screens/Connectors/index.tsx +35 -0
  340. package/src/screens/History/index.tsx +346 -0
  341. package/src/screens/Home/index.tsx +2773 -0
  342. package/src/screens/Home/media.ts +31 -0
  343. package/src/screens/Welcome/index.tsx +1182 -0
  344. package/src/talk/talkToLucy.ts +187 -0
  345. package/src/theme/colors.ts +38 -0
  346. package/src/theme/fonts.ts +30 -0
  347. package/src/theme/muse.ts +86 -0
  348. package/src/utils/links.ts +84 -0
  349. package/src/utils/yantraLinks.ts +94 -0
  350. package/src/welcome/flow.ts +418 -0
  351. package/src/welcome/haptics.ts +179 -0
  352. package/src/welcome/parts.tsx +2160 -0
  353. package/src/welcome/powerOn.ts +84 -0
  354. package/src/welcome/seen.ts +68 -0
  355. package/src/welcome/sound.ts +173 -0
  356. package/tools/lottie/chat.motion +0 -0
  357. package/tools/lottie/cloud.motion +0 -0
  358. package/tools/lottie/generate.mjs +1209 -0
  359. package/tools/lottie/inter-glyphs.json +4416 -0
  360. package/tools/lottie/lucy-mark-calendar.motion +0 -0
  361. package/tools/lottie/lucy-mark-call.motion +0 -0
  362. package/tools/lottie/lucy-mark-connect.motion +0 -0
  363. package/tools/lottie/lucy-mark-details.motion +0 -0
  364. package/tools/lottie/lucy-mark-email.motion +0 -0
  365. package/tools/lottie/lucy-mark-message.motion +0 -0
  366. package/tools/lottie/lucy-mark-search.motion +0 -0
  367. package/tools/lottie/lucy-mark-think.motion +0 -0
  368. package/tools/lottie/lucy-mark-write.motion +0 -0
  369. package/tools/lottie/mark.json +1 -0
  370. package/tools/lottie/mine-none.motion +0 -0
  371. package/tools/lottie/mine-offline.motion +0 -0
  372. package/tools/lottie/mine-online.motion +0 -0
  373. package/tools/lottie/time-back.mjs +604 -0
  374. package/tools/sounds/render.mjs +730 -0
  375. package/tsconfig.json +17 -0
  376. package/README.md +0 -3
@@ -0,0 +1,526 @@
1
+ /**
2
+ * The app's drawer: Clockbook on top (back to Home), who you are (Account), Lucy's time back this month as the web's
3
+ * dark card (opens her chores), New chat, the places (Home, Chat with Lucy, Lucy's chores, Connectors), and Text Lucy
4
+ * (the iMessage sheet). At the foot, For business (out to Yantra),
5
+ * Sign out and the version; signed out, Sign in. A signed-out person is asked to sign in before anything of Lucy's.
6
+ * Auth is @adminide-stack/user-auth0-mobile's (its Login / SignUp / Logout routes), the session read with
7
+ * @adminide-stack/user-auth0-client's useIsUserAuthenticated.
8
+ * Wired in by portable-devices/mobile config.json `mobileConfig.customDrawerPath`.
9
+ */
10
+ import React, { useEffect, useMemo, useState } from 'react';
11
+ import { Image, Pressable, StyleSheet, Text, View } from 'react-native';
12
+ import { DrawerContentScrollView } from '@react-navigation/drawer';
13
+ import { Ionicons } from '@expo/vector-icons';
14
+ import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
15
+ import { AuthMobileNavigationRoutesEnum, useIsUserAuthenticated } from '@adminide-stack/user-auth0-client';
16
+ import { Mark } from './Logo';
17
+ import type { IconName } from './ui';
18
+ import { useChoreCount } from './ChatSheets';
19
+ import { MESSAGES_APP } from '../imessage/platform';
20
+ import { ImessageSheet } from './ImessageSheet';
21
+ import { useSignInGate } from './SignInPrompt';
22
+ import { useSignOut } from './useSignOut';
23
+ import { CLOCKBOOK_ROUTES } from '../config/routes';
24
+ import { cachedChores, fetchChores, onChoresChanged, type ChoreList } from '../chat/chores';
25
+ import { yantraAppUrl } from '../utils/links';
26
+ import { openYantraUrl } from '../utils/yantraLinks';
27
+ import { ui } from '../theme/muse';
28
+
29
+ function readAppVersion(): string {
30
+ try {
31
+ // eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
32
+ const Constants = require('expo-constants').default as {
33
+ expoConfig?: { version?: string };
34
+ nativeApplicationVersion?: string | null;
35
+ };
36
+ const version = Constants?.expoConfig?.version || Constants?.nativeApplicationVersion;
37
+ if (typeof version === 'string' && version.trim()) return version.trim();
38
+ } catch {
39
+ // expo-constants unavailable in this bundle
40
+ }
41
+ return '1.0.0';
42
+ }
43
+
44
+ interface Person {
45
+ name?: string;
46
+ given_name?: string;
47
+ nickname?: string;
48
+ email?: string;
49
+ picture?: string;
50
+ }
51
+
52
+ function displayName(p: Person): string {
53
+ return p.name?.trim() || p.given_name?.trim() || p.nickname?.trim() || p.email?.trim() || 'Your account';
54
+ }
55
+
56
+ function Avatar({ person, size }: { person: Person; size: number }) {
57
+ const round = { width: size, height: size, borderRadius: size / 2 };
58
+ if (person.picture)
59
+ return <Image source={{ uri: person.picture }} style={round} accessibilityIgnoresInvertColors />;
60
+ return (
61
+ <View style={[round, styles.avatarFallback]}>
62
+ <Text style={[styles.avatarText, { fontSize: size * 0.44 }]}>
63
+ {displayName(person).charAt(0).toUpperCase()}
64
+ </Text>
65
+ </View>
66
+ );
67
+ }
68
+
69
+ /**
70
+ * What one finished chore gives back, on average: the web's 38 minutes a day comes from about one chore a day, so 40
71
+ * minutes a chore, rounded. An estimate, as the web's own figure is.
72
+ */
73
+ const MINUTES_PER_CHORE = 40;
74
+
75
+ /** The chores Lucy finished this calendar month (each counted once, however many turns it took), read as time back. */
76
+ function timeBackThisMonth(list: ChoreList | null, now = Date.now()): { chores: number; minutes: number } {
77
+ const start = new Date(now);
78
+ start.setDate(1);
79
+ start.setHours(0, 0, 0, 0);
80
+ const done = (list?.all ?? list?.done ?? []).filter(
81
+ (c) => c.status === 'done' && (c.endedAt ?? c.startedAt) >= start.getTime(),
82
+ );
83
+ const chores = new Set(done.map((c) => c.id)).size;
84
+ return { chores, minutes: chores * MINUTES_PER_CHORE };
85
+ }
86
+
87
+ /** Lucy's chores, read once the drawer mounts and again when one starts or ends here. */
88
+ function useChoreList(enabled: boolean): ChoreList | null {
89
+ const [list, setList] = useState<ChoreList | null>(cachedChores);
90
+ useEffect(() => {
91
+ if (!enabled) return undefined;
92
+ const read = () =>
93
+ fetchChores()
94
+ .then(setList)
95
+ .catch(() => undefined);
96
+ read();
97
+ return onChoresChanged(read);
98
+ }, [enabled]);
99
+ return enabled ? list : null;
100
+ }
101
+
102
+ /** "4h 50m" as the card sets it: the numbers large, the units small. */
103
+ function Duration({ minutes }: { minutes: number }) {
104
+ const h = Math.floor(minutes / 60);
105
+ const m = minutes % 60;
106
+ return (
107
+ <Text style={styles.big} accessibilityLabel={h ? `${h} hours ${m} minutes` : `${m} minutes`}>
108
+ {h ? (
109
+ <>
110
+ {h}
111
+ <Text style={styles.unit}>h </Text>
112
+ </>
113
+ ) : null}
114
+ {m}
115
+ <Text style={styles.unit}>m</Text>
116
+ </Text>
117
+ );
118
+ }
119
+
120
+ /** A place in the white card: a line icon, its name, a count when there is one; the current one tinted. */
121
+ function Place({
122
+ icon,
123
+ label,
124
+ active,
125
+ badge,
126
+ last,
127
+ onPress,
128
+ }: {
129
+ icon: IconName;
130
+ label: string;
131
+ active?: boolean;
132
+ badge?: number;
133
+ last?: boolean;
134
+ onPress: () => void;
135
+ }) {
136
+ return (
137
+ <Pressable
138
+ accessibilityRole="button"
139
+ accessibilityLabel={badge ? `${label}, ${badge} under way` : label}
140
+ accessibilityState={{ selected: !!active }}
141
+ onPress={onPress}
142
+ style={({ pressed }) => [
143
+ styles.place,
144
+ active && styles.placeActive,
145
+ pressed && !active && styles.pressedCard,
146
+ ]}
147
+ >
148
+ <Ionicons name={icon} size={20} color={active ? ui.accentText : ui.ink2} />
149
+ <View style={[styles.placeBody, !last && styles.placeRule]}>
150
+ <Text style={[styles.placeLabel, active && styles.placeLabelActive]} numberOfLines={1}>
151
+ {label}
152
+ </Text>
153
+ {badge ? (
154
+ <View style={styles.badge}>
155
+ <Text style={styles.badgeText}>{badge > 99 ? '99+' : badge}</Text>
156
+ </View>
157
+ ) : null}
158
+ {active ? null : <Ionicons name="chevron-forward" size={15} color={ui.faint} />}
159
+ </View>
160
+ </Pressable>
161
+ );
162
+ }
163
+
164
+ export default function CustomDrawer(props: any) {
165
+ const { navigation, state } = props;
166
+ const current = state?.routes?.[state?.index]?.name;
167
+ const insets = useSafeAreaInsets();
168
+ const version = useMemo(readAppVersion, []);
169
+ const { user } = useIsUserAuthenticated();
170
+
171
+ const close = () => navigation?.closeDrawer?.();
172
+ const navigate = (route: string, params?: object) => {
173
+ close();
174
+ navigation?.navigate?.(route, params);
175
+ };
176
+ // `at` makes a repeat tap scroll Home back to the top.
177
+ const goHome = () => navigate(CLOCKBOOK_ROUTES.HOME, { at: Date.now() });
178
+ const openOut = (url: string) => {
179
+ close();
180
+ openYantraUrl(url);
181
+ };
182
+ // Lucy's things: the sign-in prompt first when signed out (Login closes the drawer).
183
+ const { authenticated, gate, prompt } = useSignInGate(
184
+ (route, params) => navigation?.navigate?.(route, params),
185
+ close,
186
+ );
187
+ const newChat = () => gate('chat', () => navigate(CLOCKBOOK_ROUTES.CHAT, { fresh: Date.now(), at: Date.now() }));
188
+ const openChores = () => gate('chat', () => navigate(CLOCKBOOK_ROUTES.CHORES));
189
+ // iMessage: the real Text Lucy sheet (Messages at Lucy's line, this phone linked).
190
+ const [imessageOpen, setImessageOpen] = useState(false);
191
+ const textLucy = () =>
192
+ gate('imessage', () => {
193
+ close();
194
+ setImessageOpen(true);
195
+ });
196
+ const person = (authenticated && user ? user : null) as Person | null;
197
+ const signIn = () => navigate(AuthMobileNavigationRoutesEnum.Login, { redirect: 'back' });
198
+ // Signed out here, then Home (see useSignOut: the auth package's Logout screen stranded a sheet).
199
+ const signOut = useSignOut(goHome);
200
+ const list = useChoreList(Boolean(person));
201
+ const time = timeBackThisMonth(list);
202
+ const counted = Boolean(person && time.chores);
203
+ const choreCount = useChoreCount(Boolean(person));
204
+ const openChat = () => gate('chat', () => navigate(CLOCKBOOK_ROUTES.CHAT));
205
+
206
+ return (
207
+ <SafeAreaView style={styles.safeArea} edges={['left']}>
208
+ <DrawerContentScrollView
209
+ {...props}
210
+ style={styles.scroll}
211
+ contentContainerStyle={[styles.content, { paddingTop: Math.max(insets.top, 14) + 8 }]}
212
+ showsVerticalScrollIndicator={false}
213
+ >
214
+ <Pressable
215
+ accessibilityRole="button"
216
+ accessibilityLabel="Clockbook, home"
217
+ onPress={goHome}
218
+ hitSlop={6}
219
+ style={({ pressed }) => [styles.brand, pressed && { opacity: 0.6 }]}
220
+ >
221
+ <Mark size={24} />
222
+ <Text style={styles.brandTitle}>Clockbook</Text>
223
+ </Pressable>
224
+
225
+ {person ? (
226
+ <Pressable
227
+ accessibilityRole="button"
228
+ accessibilityLabel={`${displayName(person)}, account`}
229
+ onPress={() => navigate(CLOCKBOOK_ROUTES.ACCOUNT)}
230
+ style={({ pressed }) => [styles.me, pressed && styles.pressed]}
231
+ >
232
+ <Avatar person={person} size={42} />
233
+ <View style={{ flex: 1 }}>
234
+ <Text style={styles.meName} numberOfLines={1}>
235
+ {displayName(person)}
236
+ </Text>
237
+ {person.email && person.email !== displayName(person) ? (
238
+ <Text style={styles.meMail} numberOfLines={1}>
239
+ {person.email}
240
+ </Text>
241
+ ) : null}
242
+ </View>
243
+ <Ionicons name="chevron-forward" size={16} color={ui.faint} />
244
+ </Pressable>
245
+ ) : (
246
+ <Pressable
247
+ accessibilityRole="button"
248
+ onPress={signIn}
249
+ style={({ pressed }) => [styles.me, pressed && styles.pressed]}
250
+ >
251
+ <View style={styles.signInMark}>
252
+ <Ionicons name="person-outline" size={20} color={ui.accentText} />
253
+ </View>
254
+ <View style={{ flex: 1 }}>
255
+ <Text style={[styles.meName, { color: ui.accentText }]}>Sign in</Text>
256
+ <Text style={styles.meMail} numberOfLines={1}>
257
+ Chat with Lucy and see her chores
258
+ </Text>
259
+ </View>
260
+ <Ionicons name="chevron-forward" size={16} color={ui.faint} />
261
+ </Pressable>
262
+ )}
263
+
264
+ {/* Time back: the web's dark card, this month's; it opens the chores it counts. */}
265
+ <Pressable
266
+ accessibilityRole="button"
267
+ accessibilityHint="Opens Lucy’s chores"
268
+ onPress={openChores}
269
+ style={({ pressed }) => [styles.timeCard, pressed && { opacity: 0.9 }]}
270
+ >
271
+ <View style={styles.timeHead}>
272
+ <Text style={styles.timeEyebrow}>
273
+ {counted ? 'Time back this month' : 'Time back, every day'}
274
+ </Text>
275
+ <Ionicons name="arrow-forward" size={16} color={ui.accent} />
276
+ </View>
277
+ <Duration minutes={counted ? time.minutes : 38} />
278
+ <Text style={styles.timeNote}>
279
+ {counted
280
+ ? `from ${time.chores} ${time.chores === 1 ? 'chore' : 'chores'} Lucy did`
281
+ : 'Hand Lucy a chore to start yours'}
282
+ </Text>
283
+ </Pressable>
284
+
285
+ <Pressable
286
+ accessibilityRole="button"
287
+ accessibilityLabel="New chat with Lucy"
288
+ onPress={newChat}
289
+ style={({ pressed }) => [styles.newChat, pressed && styles.pressedCard]}
290
+ >
291
+ <Ionicons name="add" size={20} color={ui.ink} />
292
+ <Text style={styles.newChatText}>New chat</Text>
293
+ </Pressable>
294
+
295
+ <View style={styles.places}>
296
+ <Place
297
+ icon="home-outline"
298
+ label="Home"
299
+ active={current === CLOCKBOOK_ROUTES.HOME}
300
+ onPress={goHome}
301
+ />
302
+ <Place
303
+ icon="chatbubbles-outline"
304
+ label="Chat with Lucy"
305
+ active={current === CLOCKBOOK_ROUTES.CHAT}
306
+ onPress={openChat}
307
+ />
308
+ <Place
309
+ icon="time-outline"
310
+ label="Chat history"
311
+ active={current === CLOCKBOOK_ROUTES.HISTORY}
312
+ onPress={() => gate('chat', () => navigate(CLOCKBOOK_ROUTES.HISTORY))}
313
+ />
314
+ <Place
315
+ icon="checkmark-done-outline"
316
+ label="Lucy’s chores"
317
+ badge={choreCount.working || undefined}
318
+ active={current === CLOCKBOOK_ROUTES.CHORES}
319
+ onPress={openChores}
320
+ />
321
+ <Place
322
+ icon="apps-outline"
323
+ label="Connectors"
324
+ active={current === CLOCKBOOK_ROUTES.CONNECTORS}
325
+ onPress={() => gate('chat', () => navigate(CLOCKBOOK_ROUTES.CONNECTORS))}
326
+ last
327
+ />
328
+ </View>
329
+
330
+ <Pressable
331
+ accessibilityRole="button"
332
+ accessibilityLabel={`Text Lucy, right in ${MESSAGES_APP}`}
333
+ onPress={textLucy}
334
+ style={({ pressed }) => [styles.textLucy, pressed && styles.pressedCard]}
335
+ >
336
+ <View style={styles.textLucyIcon}>
337
+ <Ionicons name="chatbubble-ellipses-outline" size={17} color={ui.ok} />
338
+ </View>
339
+ <View style={{ flex: 1 }}>
340
+ <Text style={styles.textLucyTitle}>Text Lucy</Text>
341
+ <Text style={styles.textLucySub}>Right in {MESSAGES_APP}</Text>
342
+ </View>
343
+ </Pressable>
344
+ </DrawerContentScrollView>
345
+
346
+ {/* Pinned at the foot: For business, then Sign out and the version. */}
347
+ {/* The bottom inset is added here: inside the drawer, SafeAreaView's own bottom edge did not clear the home bar. */}
348
+ <View style={[styles.footer, { paddingBottom: Math.max(insets.bottom, 12) + 2 }]}>
349
+ <Pressable
350
+ accessibilityRole="link"
351
+ accessibilityLabel="For business, opens Yantra"
352
+ onPress={() => openOut(yantraAppUrl())}
353
+ style={({ pressed }) => [styles.business, pressed && styles.pressed]}
354
+ >
355
+ <Ionicons name="briefcase-outline" size={18} color={ui.ink2} />
356
+ <Text style={styles.businessText}>For business</Text>
357
+ <Text style={styles.businessOut}>Yantra ↗</Text>
358
+ </Pressable>
359
+ <View style={styles.footLine}>
360
+ {person ? (
361
+ <Pressable accessibilityRole="button" onPress={signOut} hitSlop={10}>
362
+ <Text style={styles.signOut}>Sign out</Text>
363
+ </Pressable>
364
+ ) : (
365
+ <View />
366
+ )}
367
+ <Text style={styles.version} accessibilityLabel={`Version ${version}`}>
368
+ v{version}
369
+ </Text>
370
+ </View>
371
+ </View>
372
+ {prompt}
373
+ <ImessageSheet
374
+ visible={imessageOpen}
375
+ onClose={() => setImessageOpen(false)}
376
+ onChatHere={() => {
377
+ setImessageOpen(false);
378
+ navigation?.navigate?.(CLOCKBOOK_ROUTES.CHAT);
379
+ }}
380
+ onSignIn={() => {
381
+ setImessageOpen(false);
382
+ navigation?.navigate?.(AuthMobileNavigationRoutesEnum.Login, { redirect: 'back' });
383
+ }}
384
+ />
385
+ </SafeAreaView>
386
+ );
387
+ }
388
+
389
+ const SIDE = 18;
390
+ /** The drawer's page: a shade warmer than the screens', so the white pieces on it lift. */
391
+ const SHEET = '#F4ECE4';
392
+ const DARK = '#1A1714';
393
+
394
+ const styles = StyleSheet.create({
395
+ safeArea: { flex: 1, backgroundColor: SHEET },
396
+ scroll: { backgroundColor: SHEET },
397
+ content: { paddingHorizontal: SIDE, paddingBottom: 24 },
398
+ pressed: { backgroundColor: 'rgba(26,23,20,0.05)' },
399
+ pressedCard: { backgroundColor: ui.fill },
400
+
401
+ brand: { flexDirection: 'row', alignItems: 'center', gap: 9, alignSelf: 'flex-start', marginBottom: 20 },
402
+ brandTitle: { fontSize: 18, fontWeight: '700', letterSpacing: -0.4, color: ui.ink },
403
+
404
+ me: {
405
+ flexDirection: 'row',
406
+ alignItems: 'center',
407
+ gap: 12,
408
+ paddingVertical: 8,
409
+ paddingHorizontal: 8,
410
+ marginHorizontal: -8,
411
+ borderRadius: 14,
412
+ },
413
+ meName: { fontSize: 16, fontWeight: '600', letterSpacing: -0.2, color: ui.ink },
414
+ meMail: { fontSize: 13, color: ui.muted, marginTop: 1 },
415
+ avatarFallback: { backgroundColor: ui.accentSoft, alignItems: 'center', justifyContent: 'center' },
416
+ avatarText: { fontWeight: '600', color: ui.accentText },
417
+ signInMark: {
418
+ width: 42,
419
+ height: 42,
420
+ borderRadius: 21,
421
+ backgroundColor: ui.accentSoft,
422
+ alignItems: 'center',
423
+ justifyContent: 'center',
424
+ },
425
+
426
+ timeCard: {
427
+ marginTop: 16,
428
+ borderRadius: 18,
429
+ paddingHorizontal: 16,
430
+ paddingTop: 14,
431
+ paddingBottom: 16,
432
+ backgroundColor: DARK,
433
+ },
434
+ timeHead: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
435
+ timeEyebrow: { fontSize: 12.5, fontWeight: '500', color: '#D8CEC5' },
436
+ big: {
437
+ marginTop: 6,
438
+ fontSize: 44,
439
+ lineHeight: 50,
440
+ fontWeight: '300',
441
+ letterSpacing: -1.5,
442
+ color: '#FFF7EF',
443
+ fontVariant: ['tabular-nums'],
444
+ },
445
+ unit: { fontSize: 24, fontWeight: '300', letterSpacing: 0, color: '#FFF7EF' },
446
+ timeNote: { fontSize: 12.5, color: '#B9AEA4', marginTop: 2 },
447
+
448
+ newChat: {
449
+ marginTop: 14,
450
+ height: 48,
451
+ borderRadius: 24,
452
+ flexDirection: 'row',
453
+ alignItems: 'center',
454
+ justifyContent: 'center',
455
+ gap: 6,
456
+ backgroundColor: ui.surface,
457
+ shadowColor: '#3A2410',
458
+ shadowOpacity: 0.07,
459
+ shadowRadius: 10,
460
+ shadowOffset: { width: 0, height: 3 },
461
+ elevation: 2,
462
+ },
463
+ newChatText: { fontSize: 15.5, fontWeight: '600', color: ui.ink },
464
+
465
+ places: { marginTop: 18, borderRadius: 16, overflow: 'hidden', backgroundColor: ui.surface },
466
+ place: { flexDirection: 'row', alignItems: 'center', gap: 13, paddingLeft: 14 },
467
+ placeActive: { backgroundColor: ui.accentSoft },
468
+ placeBody: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 48, paddingRight: 14 },
469
+ placeRule: { borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: ui.hairline },
470
+ placeLabel: { flex: 1, fontSize: 15.5, letterSpacing: -0.2, color: ui.ink },
471
+ placeLabelActive: { fontWeight: '600', color: ui.accentText },
472
+ badge: {
473
+ minWidth: 20,
474
+ height: 20,
475
+ paddingHorizontal: 6,
476
+ borderRadius: 10,
477
+ backgroundColor: ui.accent,
478
+ alignItems: 'center',
479
+ justifyContent: 'center',
480
+ },
481
+ badgeText: { fontSize: 12, fontWeight: '700', color: '#FFFFFF', fontVariant: ['tabular-nums'] },
482
+
483
+ textLucy: {
484
+ marginTop: 12,
485
+ flexDirection: 'row',
486
+ alignItems: 'center',
487
+ gap: 12,
488
+ padding: 12,
489
+ borderRadius: 16,
490
+ backgroundColor: ui.surface,
491
+ },
492
+ textLucyIcon: {
493
+ width: 36,
494
+ height: 36,
495
+ borderRadius: 10,
496
+ backgroundColor: ui.okSoft,
497
+ alignItems: 'center',
498
+ justifyContent: 'center',
499
+ },
500
+ textLucyTitle: { fontSize: 15, fontWeight: '600', color: ui.ink },
501
+ textLucySub: { fontSize: 12.5, color: ui.muted, marginTop: 1 },
502
+
503
+ footer: { paddingHorizontal: SIDE, paddingTop: 6, backgroundColor: SHEET },
504
+ business: {
505
+ flexDirection: 'row',
506
+ alignItems: 'center',
507
+ gap: 10,
508
+ minHeight: 44,
509
+ paddingHorizontal: 8,
510
+ marginHorizontal: -8,
511
+ borderRadius: 12,
512
+ },
513
+ businessText: { flex: 1, fontSize: 15, fontWeight: '500', color: ui.ink },
514
+ businessOut: { fontSize: 13, color: ui.muted },
515
+ footLine: {
516
+ flexDirection: 'row',
517
+ alignItems: 'center',
518
+ justifyContent: 'space-between',
519
+ paddingTop: 12,
520
+ marginTop: 4,
521
+ borderTopWidth: StyleSheet.hairlineWidth,
522
+ borderTopColor: 'rgba(26,23,20,0.1)',
523
+ },
524
+ signOut: { fontSize: 14.5, fontWeight: '600', color: ui.danger },
525
+ version: { fontSize: 12, fontWeight: '500', color: ui.muted, fontVariant: ['tabular-nums'] },
526
+ });