@shotik/react-native 0.1.1 → 0.2.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.
- package/CHANGELOG.md +16 -0
- package/LICENSE +26 -0
- package/README.md +36 -1
- package/README.ru.md +37 -1
- package/dist/analytics/core.d.ts +96 -11
- package/dist/analytics/core.js +295 -22
- package/dist/analytics/privacy.d.ts +4 -0
- package/dist/analytics/privacy.js +46 -0
- package/dist/analytics/replay.d.ts +41 -0
- package/dist/analytics/replay.js +192 -0
- package/dist/analytics/rn.d.ts +52 -2
- package/dist/analytics/rn.js +669 -62
- package/dist/analytics/wire.d.ts +54 -2
- package/dist/analytics/wire.js +44 -4
- package/dist/client.d.ts +93 -0
- package/dist/client.js +247 -9
- package/dist/flow.d.ts +48 -0
- package/dist/flow.js +56 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/parts.d.ts +42 -1
- package/dist/parts.js +72 -14
- package/dist/react.d.ts +24 -3
- package/dist/react.js +42 -15
- package/dist/sheet.d.ts +2 -1
- package/dist/sheet.js +206 -15
- package/dist/support.js +2 -2
- package/dist/theme.d.ts +43 -0
- package/dist/theme.js +88 -2
- package/package.json +15 -2
- package/recipe.json +1 -1
- package/src/analytics/README.md +10 -6
- package/src/analytics/core.ts +314 -25
- package/src/analytics/privacy.ts +50 -0
- package/src/analytics/recipe.json +1 -1
- package/src/analytics/replay.ts +190 -0
- package/src/analytics/rn.tsx +620 -63
- package/src/analytics/wire.ts +99 -8
- package/src/client.ts +334 -9
- package/src/flow.ts +100 -0
- package/src/index.ts +4 -4
- package/src/parts.tsx +102 -14
- package/src/react.tsx +57 -16
- package/src/sheet.tsx +422 -19
- package/src/support.ts +2 -2
- package/src/theme.ts +88 -2
package/src/sheet.tsx
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
// The chat sheet: a bottom sheet (drag handle, spring open and close, keyboard-avoiding) holding the conversation list
|
|
2
|
-
// or one thread with receipts, typing, quick replies, the handoff to a person, attachments
|
|
2
|
+
// or one thread with receipts, typing, quick replies, action buttons, the handoff to a person, attachments, the offline
|
|
3
|
+
// queue, the AI consent line and the rating; plus the Subscription screens with the honest cancel and refund (§3.10).
|
|
3
4
|
// Every visual and motion decision is logged in REFS.md.
|
|
4
5
|
|
|
5
6
|
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
|
7
|
+
import type { ReactNode } from 'react'
|
|
6
8
|
import {
|
|
7
9
|
AccessibilityInfo, ActionSheetIOS, Animated, Dimensions, FlatList, Image, Keyboard, LayoutAnimation, Modal, PanResponder, Platform, Pressable,
|
|
8
|
-
StatusBar, StyleSheet, TextInput, View, useWindowDimensions
|
|
10
|
+
ScrollView, StatusBar, StyleSheet, TextInput, View, useWindowDimensions
|
|
9
11
|
} from 'react-native'
|
|
10
12
|
import type { KeyboardEvent } from 'react-native'
|
|
11
|
-
import type { Conversation, LocalAttachment, Message, Receipt } from './client'
|
|
12
|
-
import { attachmentsOf, receiptOf } from './client'
|
|
13
|
-
import {
|
|
13
|
+
import type { ActionKind, ActionResult, Conversation, LocalAttachment, Message, Receipt, SupportAction } from './client'
|
|
14
|
+
import { actionsOf, attachmentsOf, receiptOf } from './client'
|
|
15
|
+
import { cancelReasons, canCancel, csatPrompt, runState, startFlow, stepFlow, storeName, subscriptionSummary } from './flow'
|
|
16
|
+
import type { CancelFlow, FlowEvent, RunState } from './flow'
|
|
17
|
+
import { Alert, ArrowUp, Avatar, Chevron, Clock, Cross, Dots, Forward, LoadingBar, Plus, Reveal, Spark, T, Thumb, Tick, Trash, attachPeers, captureScreen, font, motion, pickPhoto, useReduceMotion } from './parts'
|
|
14
18
|
import type { SupportApi } from './react'
|
|
15
19
|
import type { Copy, Resolved } from './theme'
|
|
16
20
|
import { fill } from './theme'
|
|
@@ -24,8 +28,14 @@ export interface SheetProps {
|
|
|
24
28
|
quickReplies: string[]
|
|
25
29
|
// 'inline' renders the panel at the parent's size, without Modal, backdrop, drag or open animation.
|
|
26
30
|
presentation?: 'modal' | 'inline'
|
|
31
|
+
appName?: string
|
|
27
32
|
}
|
|
28
33
|
|
|
34
|
+
type Run = (key: string, fn: () => Promise<ActionResult>) => void
|
|
35
|
+
|
|
36
|
+
// A host preview may hand in an older api without canRun; nothing then claims it can run.
|
|
37
|
+
const can = (s: SupportApi, kind: ActionKind, value?: string) => s.canRun?.(kind, value) ?? false
|
|
38
|
+
|
|
29
39
|
function insets(): { top: number; bottom: number } {
|
|
30
40
|
try {
|
|
31
41
|
const m = require('react-native-safe-area-context')?.initialWindowMetrics?.insets
|
|
@@ -34,12 +44,14 @@ function insets(): { top: number; bottom: number } {
|
|
|
34
44
|
return Platform.OS === 'ios' ? { top: 50, bottom: 20 } : { top: StatusBar.currentHeight ?? 24, bottom: 0 }
|
|
35
45
|
}
|
|
36
46
|
|
|
47
|
+
const day = (at: number) => new Date(at).toLocaleDateString([], { month: 'short', day: 'numeric', year: 'numeric' })
|
|
48
|
+
|
|
37
49
|
const clock = (at: number) => {
|
|
38
50
|
const d = new Date(at)
|
|
39
51
|
return new Date().toDateString() === d.toDateString() ? d.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' }) : d.toLocaleDateString([], { month: 'short', day: 'numeric' })
|
|
40
52
|
}
|
|
41
53
|
|
|
42
|
-
export function Sheet({ s, c, t, title, team, quickReplies, presentation = 'modal' }: SheetProps) {
|
|
54
|
+
export function Sheet({ s, c, t, title, team, quickReplies, presentation = 'modal', appName }: SheetProps) {
|
|
43
55
|
const inline = presentation === 'inline'
|
|
44
56
|
const { height } = useWindowDimensions()
|
|
45
57
|
const inset = useMemo(insets, [])
|
|
@@ -51,6 +63,56 @@ export function Sheet({ s, c, t, title, team, quickReplies, presentation = 'moda
|
|
|
51
63
|
const [composing, setComposing] = useState(false)
|
|
52
64
|
const [draft, setDraft] = useState('')
|
|
53
65
|
const [pending, setPending] = useState<LocalAttachment[]>([])
|
|
66
|
+
const [flow, setFlow] = useState<CancelFlow>(startFlow)
|
|
67
|
+
const [runs, setRuns] = useState<Record<string, RunState>>({})
|
|
68
|
+
const [erase, setErase] = useState<ErasePhase | null>(null)
|
|
69
|
+
|
|
70
|
+
const run: Run = (key, fn) => {
|
|
71
|
+
if (runs[key] === 'pending') return
|
|
72
|
+
setRuns((p) => ({ ...p, [key]: 'pending' }))
|
|
73
|
+
fn()
|
|
74
|
+
.catch((): ActionResult => 'failed')
|
|
75
|
+
.then((r) =>
|
|
76
|
+
setRuns((p) => {
|
|
77
|
+
const next = { ...p }
|
|
78
|
+
const state = runState(r)
|
|
79
|
+
if (state) next[key] = state
|
|
80
|
+
else delete next[key]
|
|
81
|
+
return next
|
|
82
|
+
})
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
const store = (kind: ActionKind, label: string) => run('sub.' + kind, () => s.runAction({ id: 'widget.' + kind, kind, label }))
|
|
86
|
+
const go = (e: FlowEvent) => {
|
|
87
|
+
const step = stepFlow(flow, e, s.widget?.offers ?? {})
|
|
88
|
+
for (const [kind, data] of step.track) s.track(kind, data)
|
|
89
|
+
setFlow(step.flow)
|
|
90
|
+
if (step.run === 'offer' && flow.reason && flow.offer) {
|
|
91
|
+
s.askForOffer(flow.reason)
|
|
92
|
+
setDraft(fill(t.offerDraft, { label: flow.offer.label }))
|
|
93
|
+
setComposing(true)
|
|
94
|
+
} else if (step.run === 'manage_subscription') store('manage_subscription', t.manage)
|
|
95
|
+
else if (step.run === 'request_refund') store('request_refund', t.refund)
|
|
96
|
+
}
|
|
97
|
+
const chat = () => {
|
|
98
|
+
setFlow(startFlow)
|
|
99
|
+
s.select(null)
|
|
100
|
+
setComposing(true)
|
|
101
|
+
}
|
|
102
|
+
// Delete my data (§3.13): the client wipes the device first, so everything this sheet holds goes with it.
|
|
103
|
+
const deleteAll = () => {
|
|
104
|
+
setErase('working')
|
|
105
|
+
Promise.resolve(s.deleteMyData?.() ?? 'done')
|
|
106
|
+
.catch((): 'pending' => 'pending')
|
|
107
|
+
.then((r) => {
|
|
108
|
+
setDraft('')
|
|
109
|
+
setPending(() => [])
|
|
110
|
+
setComposing(false)
|
|
111
|
+
setFlow(startFlow)
|
|
112
|
+
setRuns({})
|
|
113
|
+
setErase(r)
|
|
114
|
+
})
|
|
115
|
+
}
|
|
54
116
|
|
|
55
117
|
const animate = (open: boolean, done?: () => void) => {
|
|
56
118
|
const slide = reduce
|
|
@@ -67,6 +129,8 @@ export function Sheet({ s, c, t, title, team, quickReplies, presentation = 'moda
|
|
|
67
129
|
requestAnimationFrame(() => animate(true))
|
|
68
130
|
} else if (shown) {
|
|
69
131
|
Keyboard.dismiss()
|
|
132
|
+
setFlow(startFlow)
|
|
133
|
+
setErase((e) => (e === 'working' ? e : null))
|
|
70
134
|
animate(false, () => setShown(false))
|
|
71
135
|
}
|
|
72
136
|
}, [s.visible])
|
|
@@ -109,13 +173,19 @@ export function Sheet({ s, c, t, title, team, quickReplies, presentation = 'moda
|
|
|
109
173
|
: { color: c.faint, text: t.connecting }
|
|
110
174
|
|
|
111
175
|
const bottom = inline ? 0 : inset.bottom
|
|
176
|
+
const home = (
|
|
177
|
+
<HomeRows
|
|
178
|
+
s={s} c={c} t={t} reduce={reduce} rate={runs['sub.write_review']} appName={appName}
|
|
179
|
+
onOpen={() => go({ type: 'open' })} onErase={() => setErase('confirm')} onRate={() => store('write_review', appName ? fill(t.rateApp, { app: appName }) : t.rateThisApp)}
|
|
180
|
+
/>
|
|
181
|
+
)
|
|
112
182
|
const body = (
|
|
113
183
|
<>
|
|
114
184
|
<View {...(inline ? {} : pan.panHandlers)}>
|
|
115
185
|
<View style={[st.grabber, { backgroundColor: c.line }]} />
|
|
116
186
|
<View style={st.header}>
|
|
117
|
-
{inThread && s.conversations.length > 0 ? (
|
|
118
|
-
<Pressable onPress={back} hitSlop={10} accessibilityRole="button" accessibilityLabel={t.back} style={st.back}>
|
|
187
|
+
{erase === 'confirm' || (!erase && (flow.screen || (inThread && s.conversations.length > 0))) ? (
|
|
188
|
+
<Pressable onPress={erase ? () => setErase(null) : flow.screen ? () => go({ type: 'back' }) : back} hitSlop={10} accessibilityRole="button" accessibilityLabel={t.back} style={st.back}>
|
|
119
189
|
<Chevron color={c.text} />
|
|
120
190
|
</Pressable>
|
|
121
191
|
) : null}
|
|
@@ -133,14 +203,18 @@ export function Sheet({ s, c, t, title, team, quickReplies, presentation = 'moda
|
|
|
133
203
|
</View>
|
|
134
204
|
</View>
|
|
135
205
|
<View style={[st.hair, { backgroundColor: c.line }]} />
|
|
136
|
-
{
|
|
206
|
+
{erase ? (
|
|
207
|
+
<Erase c={c} t={t} reduce={reduce} phase={erase} inset={bottom} onDelete={deleteAll} onCancel={() => setErase(null)} onClose={s.close} />
|
|
208
|
+
) : flow.screen ? (
|
|
209
|
+
<Subscription s={s} c={c} t={t} flow={flow} go={go} runs={runs} store={store} reduce={reduce} inset={bottom} onChat={chat} />
|
|
210
|
+
) : inThread ? (
|
|
137
211
|
<Thread
|
|
138
212
|
s={s} c={c} t={t} team={team} conversation={active} quickReplies={quickReplies} reduce={reduce} inset={bottom}
|
|
139
213
|
draft={draft} setDraft={setDraft} pending={pending} setPending={setPending} onScreenshot={screenshot}
|
|
140
|
-
onSent={() => setComposing(false)}
|
|
214
|
+
onSent={() => setComposing(false)} runs={runs} run={run} home={home}
|
|
141
215
|
/>
|
|
142
216
|
) : (
|
|
143
|
-
<List s={s} c={c} t={t} inset={bottom} onNew={() => setComposing(true)} />
|
|
217
|
+
<List s={s} c={c} t={t} inset={bottom} onNew={() => setComposing(true)} home={home} />
|
|
144
218
|
)}
|
|
145
219
|
</>
|
|
146
220
|
)
|
|
@@ -160,11 +234,12 @@ export function Sheet({ s, c, t, title, team, quickReplies, presentation = 'moda
|
|
|
160
234
|
)
|
|
161
235
|
}
|
|
162
236
|
|
|
163
|
-
function List({ s, c, t, inset, onNew }: { s: SupportApi; c: Resolved; t: Copy; inset: number; onNew: () => void }) {
|
|
237
|
+
function List({ s, c, t, inset, onNew, home }: { s: SupportApi; c: Resolved; t: Copy; inset: number; onNew: () => void; home: ReactNode }) {
|
|
164
238
|
return (
|
|
165
239
|
<View style={st.fill}>
|
|
166
240
|
<FlatList
|
|
167
241
|
data={s.conversations}
|
|
242
|
+
ListHeaderComponent={<>{home}</>}
|
|
168
243
|
keyExtractor={(x) => x.id}
|
|
169
244
|
contentContainerStyle={st.listPad}
|
|
170
245
|
renderItem={({ item }) => <ConvRow c={c} t={t} conv={item} unread={!!s.unreadBy[item.id]} onPress={() => s.select(item.id)} />}
|
|
@@ -208,6 +283,7 @@ type Row =
|
|
|
208
283
|
| { k: string; kind: 'msg'; m: Message; label: string | null; receipt: Receipt | null; gap: number }
|
|
209
284
|
| { k: string; kind: 'typing'; who: string }
|
|
210
285
|
| { k: string; kind: 'chips'; items: string[]; talk: boolean }
|
|
286
|
+
| { k: string; kind: 'csat'; phase: 'ask' | 'thanks' }
|
|
211
287
|
|
|
212
288
|
interface ThreadProps {
|
|
213
289
|
s: SupportApi
|
|
@@ -224,9 +300,12 @@ interface ThreadProps {
|
|
|
224
300
|
setPending: (fn: (p: LocalAttachment[]) => LocalAttachment[]) => void
|
|
225
301
|
onScreenshot: () => void
|
|
226
302
|
onSent: () => void
|
|
303
|
+
runs: Record<string, RunState>
|
|
304
|
+
run: Run
|
|
305
|
+
home: ReactNode
|
|
227
306
|
}
|
|
228
307
|
|
|
229
|
-
function Thread({ s, c, t, team, conversation, quickReplies, reduce, inset, draft, setDraft, pending, setPending, onScreenshot, onSent }: ThreadProps) {
|
|
308
|
+
function Thread({ s, c, t, team, conversation, quickReplies, reduce, inset, draft, setDraft, pending, setPending, onScreenshot, onSent, runs, run, home }: ThreadProps) {
|
|
230
309
|
const id = s.activeConversationId
|
|
231
310
|
const messages = (id && s.messages[id]) || []
|
|
232
311
|
const typing = id ? s.typing[id] : undefined
|
|
@@ -234,6 +313,7 @@ function Thread({ s, c, t, team, conversation, quickReplies, reduce, inset, draf
|
|
|
234
313
|
const handed = conversation?.status === 'needs_human'
|
|
235
314
|
const closed = conversation?.status === 'resolved' || conversation?.status === 'closed'
|
|
236
315
|
const since = useRef(Date.now()).current
|
|
316
|
+
const [rated, setRated] = useState<string | null>(null)
|
|
237
317
|
|
|
238
318
|
const rows = useMemo(() => {
|
|
239
319
|
const out: Row[] = []
|
|
@@ -251,8 +331,10 @@ function Thread({ s, c, t, team, conversation, quickReplies, reduce, inset, draf
|
|
|
251
331
|
const q = Array.isArray(last.meta?.['quickReplies']) ? (last.meta['quickReplies'] as string[]) : []
|
|
252
332
|
out.push({ k: 'chips' + last.id, kind: 'chips', items: q.slice(0, 3), talk: true })
|
|
253
333
|
}
|
|
334
|
+
const csat = csatPrompt(conversation, !!id && rated === id)
|
|
335
|
+
if (csat && id) out.push({ k: 'csat' + id, kind: 'csat', phase: csat })
|
|
254
336
|
return out.reverse()
|
|
255
|
-
}, [messages, typing, conversation, offline, handed, closed, t, team])
|
|
337
|
+
}, [messages, typing, conversation, offline, handed, closed, t, team, rated, id])
|
|
256
338
|
|
|
257
339
|
const last = messages[messages.length - 1]
|
|
258
340
|
useEffect(() => {
|
|
@@ -276,6 +358,7 @@ function Thread({ s, c, t, team, conversation, quickReplies, reduce, inset, draf
|
|
|
276
358
|
<Avatar c={c} label={team} size={44} />
|
|
277
359
|
<T c={c} bold style={st.greet} accessibilityRole="header">{t.greeting}</T>
|
|
278
360
|
<Chips c={c} items={quickReplies} reduce={reduce} onPick={(q) => send(q)} center />
|
|
361
|
+
<View style={st.emptyHome}>{home}</View>
|
|
279
362
|
</View>
|
|
280
363
|
) : (
|
|
281
364
|
<FlatList
|
|
@@ -290,7 +373,19 @@ function Thread({ s, c, t, team, conversation, quickReplies, reduce, inset, draf
|
|
|
290
373
|
removeClippedSubviews={Platform.OS === 'android'}
|
|
291
374
|
renderItem={({ item }) =>
|
|
292
375
|
item.kind === 'msg' ? (
|
|
293
|
-
<Bubble
|
|
376
|
+
<Bubble
|
|
377
|
+
r={item} c={c} t={t} fresh={item.m.createdAt > since - 1000} reduce={reduce} url={s.url} onRetry={s.retry}
|
|
378
|
+
runs={runs} onRun={(key, a) => run(key, () => s.runAction(a, item.m.conversationId))}
|
|
379
|
+
/>
|
|
380
|
+
) : item.kind === 'csat' ? (
|
|
381
|
+
<Csat
|
|
382
|
+
c={c} t={t} reduce={reduce} phase={item.phase}
|
|
383
|
+
onRate={(score, comment) => {
|
|
384
|
+
if (!id) return
|
|
385
|
+
s.rate(id, score, comment)
|
|
386
|
+
setRated(id)
|
|
387
|
+
}}
|
|
388
|
+
/>
|
|
294
389
|
) : item.kind === 'typing' ? (
|
|
295
390
|
<View style={[st.theirs, st.typing]} accessible accessibilityLabel={fill(t.typing, { who: item.who })}>
|
|
296
391
|
<T c={c} style={[st.label, { color: c.sub }]}>{item.who}</T>
|
|
@@ -310,6 +405,21 @@ function Thread({ s, c, t, team, conversation, quickReplies, reduce, inset, draf
|
|
|
310
405
|
<T c={c} style={[st.stripText, { color: c.sub }]}>{t.handedOff}</T>
|
|
311
406
|
</View>
|
|
312
407
|
) : null}
|
|
408
|
+
{s.aiConsent === null ? (
|
|
409
|
+
<Reveal reduce={reduce} style={[st.consent, { backgroundColor: c.raised, borderRadius: c.radius - 4 }]}>
|
|
410
|
+
<T c={c} style={[st.consentText, { color: c.sub }]}>{t.consent}</T>
|
|
411
|
+
<View style={st.consentRow}>
|
|
412
|
+
{[{ label: t.consentPerson, allowed: false }, { label: t.consentAllow, allowed: true }].map((o) => (
|
|
413
|
+
<Pressable
|
|
414
|
+
key={o.label} onPress={() => s.setAiConsent(o.allowed)} hitSlop={6} accessibilityRole="button" accessibilityLabel={o.label}
|
|
415
|
+
style={({ pressed }) => [st.consentBtn, { borderColor: c.line, backgroundColor: pressed ? c.raised : c.bg }]}
|
|
416
|
+
>
|
|
417
|
+
<T c={c} bold style={st.consentBtnText}>{o.label}</T>
|
|
418
|
+
</Pressable>
|
|
419
|
+
))}
|
|
420
|
+
</View>
|
|
421
|
+
</Reveal>
|
|
422
|
+
) : null}
|
|
313
423
|
<Composer c={c} t={t} inset={inset} draft={draft} setDraft={setDraft} pending={pending} setPending={setPending} onScreenshot={onScreenshot} onSend={() => {
|
|
314
424
|
send(draft, pending)
|
|
315
425
|
setDraft('')
|
|
@@ -319,7 +429,10 @@ function Thread({ s, c, t, team, conversation, quickReplies, reduce, inset, draf
|
|
|
319
429
|
)
|
|
320
430
|
}
|
|
321
431
|
|
|
322
|
-
const Bubble = memo(function Bubble({ r, c, t, fresh, reduce, url, onRetry
|
|
432
|
+
const Bubble = memo(function Bubble({ r, c, t, fresh, reduce, url, onRetry, runs, onRun }: {
|
|
433
|
+
r: Extract<Row, { kind: 'msg' }>; c: Resolved; t: Copy; fresh: boolean; reduce: boolean; url: (p: string) => string; onRetry: (id: string) => void
|
|
434
|
+
runs: Record<string, RunState>; onRun: (key: string, a: SupportAction) => void
|
|
435
|
+
}) {
|
|
323
436
|
const { m } = r
|
|
324
437
|
const v = useRef(new Animated.Value(fresh && !reduce ? 0 : 1)).current
|
|
325
438
|
useEffect(() => {
|
|
@@ -336,8 +449,10 @@ const Bubble = memo(function Bubble({ r, c, t, fresh, reduce, url, onRetry }: {
|
|
|
336
449
|
const rc = r.receipt
|
|
337
450
|
const receiptText = rc ? (rc === 'failed' ? t.failed : t[rc] + (rc === 'seen' || rc === 'delivered' || rc === 'sent' ? ' · ' + clock(m.createdAt) : '')) : null
|
|
338
451
|
const anim = { opacity: v, transform: [{ translateY: v.interpolate({ inputRange: [0, 1], outputRange: [4, 0] }) }] }
|
|
452
|
+
const acts = mine ? [] : actionsOf(m)
|
|
453
|
+
const label = (mine ? t.you : r.label ?? '') + ': ' + (m.body || t.photo) + (receiptText ? '. ' + receiptText : '')
|
|
339
454
|
return (
|
|
340
|
-
<Animated.View style={[mine ? st.mine : st.theirs, { marginTop: r.gap }, anim]} accessible accessibilityLabel={
|
|
455
|
+
<Animated.View style={[mine ? st.mine : st.theirs, { marginTop: r.gap }, anim]} accessible={!acts.length} accessibilityLabel={acts.length ? undefined : label}>
|
|
341
456
|
{r.label ? (
|
|
342
457
|
<View style={st.labelRow}>
|
|
343
458
|
{m.author === 'ai' ? <Spark color={c.accent} size={6} /> : null}
|
|
@@ -350,10 +465,31 @@ const Bubble = memo(function Bubble({ r, c, t, fresh, reduce, url, onRetry }: {
|
|
|
350
465
|
return <Image key={i} source={{ uri: a.uri ?? url(a.path ?? '') }} style={[st.image, { width: w, height: h, borderRadius: c.radius - 4, backgroundColor: c.raised, opacity: m.pending ? 0.6 : 1 }]} accessibilityIgnoresInvertColors />
|
|
351
466
|
})}
|
|
352
467
|
{m.body ? (
|
|
353
|
-
<View
|
|
468
|
+
<View
|
|
469
|
+
accessible={!!acts.length} accessibilityLabel={acts.length ? label : undefined}
|
|
470
|
+
style={[st.bubble, { backgroundColor: mine ? c.accent : c.raised, borderRadius: c.radius, opacity: m.pending === 'failed' ? 0.6 : 1 }]}
|
|
471
|
+
>
|
|
354
472
|
<T c={c} style={[st.body, { color: mine ? c.onAccent : c.text }]}>{m.body}</T>
|
|
355
473
|
</View>
|
|
356
474
|
) : null}
|
|
475
|
+
{acts.length ? (
|
|
476
|
+
<View style={st.actions}>
|
|
477
|
+
{acts.map((a) => {
|
|
478
|
+
const key = m.id + ':' + a.id
|
|
479
|
+
const state = runs[key]
|
|
480
|
+
return (
|
|
481
|
+
<Pressable
|
|
482
|
+
key={a.id} onPress={() => onRun(key, a)} disabled={state === 'pending'} hitSlop={5}
|
|
483
|
+
accessibilityRole="button" accessibilityLabel={a.label} accessibilityState={{ busy: state === 'pending' }} accessibilityValue={state ? { text: stateWord(t, state) } : undefined}
|
|
484
|
+
style={({ pressed }) => [st.chip, st.action, { borderColor: state === 'failed' ? c.danger + '66' : c.line, backgroundColor: pressed ? c.raised : c.bg }]}
|
|
485
|
+
>
|
|
486
|
+
<T c={c} style={st.chipText} numberOfLines={1}>{a.label}</T>
|
|
487
|
+
<StateMark c={c} state={state} reduce={reduce} />
|
|
488
|
+
</Pressable>
|
|
489
|
+
)
|
|
490
|
+
})}
|
|
491
|
+
</View>
|
|
492
|
+
) : null}
|
|
357
493
|
{receiptText ? (
|
|
358
494
|
<Pressable disabled={rc !== 'failed'} onPress={() => m.localId && onRetry(m.localId)} hitSlop={8} style={st.receipt} accessibilityRole={rc === 'failed' ? 'button' : undefined}>
|
|
359
495
|
{rc === 'queued' ? <Clock color={c.faint} /> : null}
|
|
@@ -392,6 +528,239 @@ function Chips({ c, items, reduce, onPick, talk, onTalk, center }: { c: Resolved
|
|
|
392
528
|
)
|
|
393
529
|
}
|
|
394
530
|
|
|
531
|
+
const stateWord = (t: Copy, state: RunState) => (state === 'pending' ? t.actionPending : state === 'done' ? t.actionDone : t.actionFailed)
|
|
532
|
+
|
|
533
|
+
// Pending: a sliding bar; done: a tick; failed: an alert mark (dee68144). Idle shows the fallback (a row's chevron).
|
|
534
|
+
function StateMark({ c, state, reduce, fallback = null }: { c: Resolved; state?: RunState; reduce: boolean; fallback?: ReactNode }) {
|
|
535
|
+
if (state === 'pending') return <LoadingBar color={c.sub} reduce={reduce} />
|
|
536
|
+
if (state === 'done') return <Tick color={c.ok} />
|
|
537
|
+
if (state === 'failed') return <Alert color={c.danger} />
|
|
538
|
+
return <>{fallback}</>
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// "Did this help?" with Yes / No pills (Wolt), a one-line comment after No (WHOOP), then a small thanks line.
|
|
542
|
+
function Csat({ c, t, reduce, phase, onRate }: { c: Resolved; t: Copy; reduce: boolean; phase: 'ask' | 'thanks'; onRate: (score: 1 | -1, comment?: string) => void }) {
|
|
543
|
+
const [commenting, setCommenting] = useState(false)
|
|
544
|
+
const [text, setText] = useState('')
|
|
545
|
+
if (phase === 'thanks')
|
|
546
|
+
return (
|
|
547
|
+
<Reveal reduce={reduce} style={[st.system, st.csat]}>
|
|
548
|
+
<T c={c} style={[st.systemText, { color: c.sub }]}>{t.csatThanks}</T>
|
|
549
|
+
</Reveal>
|
|
550
|
+
)
|
|
551
|
+
const sendNo = () => onRate(-1, text.trim() || undefined)
|
|
552
|
+
return (
|
|
553
|
+
<Reveal reduce={reduce} style={st.csat}>
|
|
554
|
+
<T c={c} style={[st.systemText, { color: c.sub }]}>{t.csatAsk}</T>
|
|
555
|
+
{commenting ? (
|
|
556
|
+
<View style={[st.field, st.csatField, { borderColor: c.line, borderRadius: c.radius + 4, backgroundColor: c.bg }]}>
|
|
557
|
+
<TextInput
|
|
558
|
+
value={text} onChangeText={setText} placeholder={t.csatComment} placeholderTextColor={c.faint} maxLength={500} autoFocus
|
|
559
|
+
returnKeyType="send" onSubmitEditing={sendNo} maxFontSizeMultiplier={2} accessibilityLabel={t.csatComment}
|
|
560
|
+
style={[st.input, st.csatInput, font(c), { color: c.text }]}
|
|
561
|
+
/>
|
|
562
|
+
<Pressable onPress={sendNo} hitSlop={6} accessibilityRole="button" accessibilityLabel={t.send} style={[st.send, { backgroundColor: c.accent }]}>
|
|
563
|
+
<ArrowUp color={c.onAccent} />
|
|
564
|
+
</Pressable>
|
|
565
|
+
</View>
|
|
566
|
+
) : (
|
|
567
|
+
<View style={[st.chips, st.chipsCenter, st.csatRow]}>
|
|
568
|
+
{([1, -1] as const).map((score) => {
|
|
569
|
+
const word = score === 1 ? t.csatYes : t.csatNo
|
|
570
|
+
return (
|
|
571
|
+
<Pressable
|
|
572
|
+
key={score} onPress={() => (score === 1 ? onRate(1) : setCommenting(true))} hitSlop={5}
|
|
573
|
+
accessibilityRole="button" accessibilityLabel={t.csatAsk + ' ' + word}
|
|
574
|
+
style={({ pressed }) => [st.chip, st.action, { borderColor: c.line, backgroundColor: pressed ? c.raised : c.bg }]}
|
|
575
|
+
>
|
|
576
|
+
<Thumb up={score === 1} color={c.text} />
|
|
577
|
+
<T c={c} style={st.chipText}>{word}</T>
|
|
578
|
+
</Pressable>
|
|
579
|
+
)
|
|
580
|
+
})}
|
|
581
|
+
</View>
|
|
582
|
+
)}
|
|
583
|
+
</Reveal>
|
|
584
|
+
)
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
interface Item {
|
|
588
|
+
key: string
|
|
589
|
+
label: string
|
|
590
|
+
over?: string
|
|
591
|
+
detail?: string
|
|
592
|
+
danger?: boolean
|
|
593
|
+
state?: RunState
|
|
594
|
+
onPress: () => void
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// Grouped rows with hairlines between them (Stardust / Citi Bike subscription rows, Headspace settings list).
|
|
598
|
+
function Menu({ c, t, reduce, items }: { c: Resolved; t: Copy; reduce: boolean; items: (Item | false | null | undefined)[] }) {
|
|
599
|
+
const rows = items.filter((x): x is Item => !!x)
|
|
600
|
+
if (!rows.length) return null
|
|
601
|
+
return (
|
|
602
|
+
<View style={[st.group, { borderColor: c.line, borderRadius: c.radius - 4 }]}>
|
|
603
|
+
{rows.map((x, i) => (
|
|
604
|
+
<Pressable
|
|
605
|
+
key={x.key} onPress={x.onPress} disabled={x.state === 'pending'}
|
|
606
|
+
accessibilityRole="button" accessibilityLabel={[x.over, x.label, x.detail].filter(Boolean).join(', ')}
|
|
607
|
+
accessibilityState={{ busy: x.state === 'pending' }} accessibilityValue={x.state ? { text: stateWord(t, x.state) } : undefined}
|
|
608
|
+
style={({ pressed }) => [st.menuRow, i > 0 && { borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: c.line }, pressed && { backgroundColor: c.raised }]}
|
|
609
|
+
>
|
|
610
|
+
<View style={st.fill}>
|
|
611
|
+
{x.over ? <T c={c} style={[st.menuOver, { color: c.sub }]}>{x.over}</T> : null}
|
|
612
|
+
<T c={c} bold={!!x.over} style={[st.menuLabel, x.danger && { color: c.danger }]} numberOfLines={2}>{x.label}</T>
|
|
613
|
+
{x.detail ? <T c={c} style={[st.menuDetail, { color: c.sub }]} numberOfLines={1}>{x.detail}</T> : null}
|
|
614
|
+
</View>
|
|
615
|
+
<StateMark c={c} state={x.state} reduce={reduce} fallback={<Forward color={c.faint} />} />
|
|
616
|
+
</Pressable>
|
|
617
|
+
))}
|
|
618
|
+
</View>
|
|
619
|
+
)
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// One pill style for every choice on these screens, so no option outweighs another (b904b978 equal pair).
|
|
623
|
+
function Btn({ c, t, label, state, reduce, onPress, style, danger, disabled }: {
|
|
624
|
+
c: Resolved; t: Copy; label: string; state?: RunState; reduce: boolean; onPress: () => void; style?: object; danger?: boolean; disabled?: boolean
|
|
625
|
+
}) {
|
|
626
|
+
const off = disabled || state === 'pending'
|
|
627
|
+
return (
|
|
628
|
+
<Pressable
|
|
629
|
+
onPress={onPress} disabled={off} accessibilityRole="button" accessibilityLabel={label}
|
|
630
|
+
accessibilityState={{ busy: state === 'pending', disabled: off }} accessibilityValue={state ? { text: stateWord(t, state) } : undefined}
|
|
631
|
+
style={({ pressed }) => [st.btn, { backgroundColor: danger ? c.danger : pressed ? c.line : c.raised, opacity: danger && pressed ? 0.85 : disabled ? 0.5 : 1 }, style]}
|
|
632
|
+
>
|
|
633
|
+
<T c={c} bold style={[st.btnText, danger && { color: '#FFFFFF' }]} numberOfLines={2}>{label}</T>
|
|
634
|
+
<StateMark c={danger ? { ...c, sub: '#FFFFFF' } : c} state={state} reduce={reduce} />
|
|
635
|
+
</Pressable>
|
|
636
|
+
)
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
type ErasePhase = 'confirm' | 'working' | 'done' | 'pending'
|
|
640
|
+
|
|
641
|
+
// Delete my data: an inline confirm with Cancel and Delete side by side (Phantom), then one result and a single Close
|
|
642
|
+
// (Fresha for done, Shop for a request that finishes later).
|
|
643
|
+
function Erase({ c, t, reduce, phase, inset, onDelete, onCancel, onClose }: {
|
|
644
|
+
c: Resolved; t: Copy; reduce: boolean; phase: ErasePhase; inset: number; onDelete: () => void; onCancel: () => void; onClose: () => void
|
|
645
|
+
}) {
|
|
646
|
+
const result = phase === 'done' || phase === 'pending'
|
|
647
|
+
const mark = phase === 'done' ? c.ok : phase === 'pending' ? c.raised : c.danger
|
|
648
|
+
return (
|
|
649
|
+
<View style={[st.fill, st.erase, { paddingBottom: 16 + inset }]}>
|
|
650
|
+
<Reveal key={result ? 'result' : 'confirm'} reduce={reduce} style={st.eraseBody}>
|
|
651
|
+
<View style={[st.eraseMark, { backgroundColor: mark }]}>
|
|
652
|
+
{phase === 'done' ? <Tick color="#FFFFFF" size={26} /> : phase === 'pending' ? <Clock color={c.sub} size={26} /> : <Trash color="#FFFFFF" size={26} />}
|
|
653
|
+
</View>
|
|
654
|
+
<T c={c} bold style={st.eraseTitle} accessibilityRole="header">{phase === 'done' ? t.deleted : phase === 'pending' ? t.deletePending : t.deleteConfirm}</T>
|
|
655
|
+
</Reveal>
|
|
656
|
+
{result ? (
|
|
657
|
+
<Btn c={c} t={t} reduce={reduce} label={t.close} onPress={onClose} />
|
|
658
|
+
) : (
|
|
659
|
+
<View style={st.pair}>
|
|
660
|
+
<Btn c={c} t={t} reduce={reduce} label={t.cancel} disabled={phase === 'working'} onPress={onCancel} style={st.fill} />
|
|
661
|
+
<Btn c={c} t={t} reduce={reduce} label={t.deleteBtn} danger state={phase === 'working' ? 'pending' : undefined} onPress={onDelete} style={st.fill} />
|
|
662
|
+
</View>
|
|
663
|
+
)}
|
|
664
|
+
</View>
|
|
665
|
+
)
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// Home rows: the Subscription row (plan, price, next date) when the host gave one, and "Rate {app}" (§3.10, §3.11).
|
|
669
|
+
function HomeRows({ s, c, t, reduce, rate, appName, onOpen, onRate, onErase }: {
|
|
670
|
+
s: SupportApi; c: Resolved; t: Copy; reduce: boolean; rate?: RunState; appName?: string; onOpen: () => void; onRate: () => void; onErase: () => void
|
|
671
|
+
}) {
|
|
672
|
+
const sub = s.subscription && s.subscription.status !== 'none' ? s.subscription : null
|
|
673
|
+
const sum = sub ? subscriptionSummary(sub, t, day) : null
|
|
674
|
+
const items: (Item | null)[] = [
|
|
675
|
+
sum ? { key: 'sub', over: t.subscription, label: sum.plan, detail: sum.detail, onPress: onOpen } : null,
|
|
676
|
+
can(s, 'write_review') ? { key: 'rate', label: appName ? fill(t.rateApp, { app: appName }) : t.rateThisApp, state: rate, onPress: onRate } : null,
|
|
677
|
+
{ key: 'erase', label: t.deleteData, danger: true, onPress: onErase }
|
|
678
|
+
]
|
|
679
|
+
return (
|
|
680
|
+
<View style={st.home}>
|
|
681
|
+
<Menu c={c} t={t} reduce={reduce} items={items} />
|
|
682
|
+
</View>
|
|
683
|
+
)
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
// Subscription, cancel reason, the one alternative, and the help-first refund screen (§3.10).
|
|
687
|
+
function Subscription({ s, c, t, flow, go, runs, store, reduce, inset, onChat }: {
|
|
688
|
+
s: SupportApi; c: Resolved; t: Copy; flow: CancelFlow; go: (e: FlowEvent) => void; runs: Record<string, RunState>
|
|
689
|
+
store: (kind: ActionKind, label: string) => void; reduce: boolean; inset: number; onChat: () => void
|
|
690
|
+
}) {
|
|
691
|
+
const sub = s.subscription
|
|
692
|
+
const head = (text: string) => <T c={c} bold style={st.subTitle} accessibilityRole="header">{text}</T>
|
|
693
|
+
const row = (kind: ActionKind, label: string): Item | null => (can(s, kind) ? { key: kind, label, state: runs['sub.' + kind], onPress: () => store(kind, label) } : null)
|
|
694
|
+
const toStore = fill(t.cancelIn, { store: storeName(sub, Platform.OS === 'android') })
|
|
695
|
+
const sum = sub ? subscriptionSummary(sub, t, day) : null
|
|
696
|
+
let body: ReactNode = null
|
|
697
|
+
if (flow.screen === 'sub')
|
|
698
|
+
body = (
|
|
699
|
+
<>
|
|
700
|
+
{head(t.subscription)}
|
|
701
|
+
{sum ? (
|
|
702
|
+
<View style={[st.group, st.summary, { borderColor: c.line, borderRadius: c.radius - 4 }]} accessible accessibilityLabel={sum.plan + ', ' + sum.detail}>
|
|
703
|
+
<T c={c} bold style={st.plan}>{sum.plan}</T>
|
|
704
|
+
{sum.detail ? <T c={c} style={[st.menuDetail, { color: c.sub }]}>{sum.detail}</T> : null}
|
|
705
|
+
</View>
|
|
706
|
+
) : null}
|
|
707
|
+
<Menu
|
|
708
|
+
c={c} t={t} reduce={reduce}
|
|
709
|
+
items={[
|
|
710
|
+
row('manage_subscription', t.manage),
|
|
711
|
+
row('restore', t.restore),
|
|
712
|
+
row('redeem_code', t.redeem),
|
|
713
|
+
{ key: 'refund', label: t.refund, onPress: () => go({ type: 'refund' }) },
|
|
714
|
+
sub && canCancel(sub) ? { key: 'cancel', label: t.cancelSub, danger: true, onPress: () => go({ type: 'cancel' }) } : null
|
|
715
|
+
]}
|
|
716
|
+
/>
|
|
717
|
+
</>
|
|
718
|
+
)
|
|
719
|
+
else if (flow.screen === 'reason')
|
|
720
|
+
body = (
|
|
721
|
+
<>
|
|
722
|
+
{head(t.reasonTitle)}
|
|
723
|
+
<View style={st.options}>
|
|
724
|
+
{cancelReasons.map((r) => {
|
|
725
|
+
const label = t[('reason_' + r) as keyof Copy]
|
|
726
|
+
return (
|
|
727
|
+
<Pressable
|
|
728
|
+
key={r} onPress={() => go({ type: 'pick', reason: r })} accessibilityRole="button" accessibilityLabel={label}
|
|
729
|
+
style={({ pressed }) => [st.option, { borderColor: c.line, borderRadius: c.radius - 4, backgroundColor: pressed ? c.raised : c.bg }]}
|
|
730
|
+
>
|
|
731
|
+
<T c={c} style={st.menuLabel}>{label}</T>
|
|
732
|
+
</Pressable>
|
|
733
|
+
)
|
|
734
|
+
})}
|
|
735
|
+
</View>
|
|
736
|
+
<View style={st.pair}>
|
|
737
|
+
<Btn c={c} t={t} reduce={reduce} label={t.skip} onPress={() => go({ type: 'pick', reason: null })} style={st.fill} />
|
|
738
|
+
<Btn c={c} t={t} reduce={reduce} label={toStore} state={runs['sub.manage_subscription']} onPress={() => go({ type: 'store' })} style={st.fill} />
|
|
739
|
+
</View>
|
|
740
|
+
</>
|
|
741
|
+
)
|
|
742
|
+
else if (flow.screen === 'offer')
|
|
743
|
+
body = (
|
|
744
|
+
<>
|
|
745
|
+
{head(t.offerTitle)}
|
|
746
|
+
<View style={st.stack}>
|
|
747
|
+
<Btn c={c} t={t} reduce={reduce} label={flow.offer?.label ?? ''} onPress={() => go({ type: 'accept' })} />
|
|
748
|
+
<Btn c={c} t={t} reduce={reduce} label={t.continueCancel} state={runs['sub.manage_subscription']} onPress={() => go({ type: 'continue' })} />
|
|
749
|
+
</View>
|
|
750
|
+
</>
|
|
751
|
+
)
|
|
752
|
+
else if (flow.screen === 'refund')
|
|
753
|
+
body = (
|
|
754
|
+
<>
|
|
755
|
+
{head(t.refund)}
|
|
756
|
+
<T c={c} style={[st.subLine, { color: c.sub }]}>{t.refundHelp}</T>
|
|
757
|
+
<Menu c={c} t={t} reduce={reduce} items={[row('restore', t.restore), { key: 'chat', label: t.chatWithUs, onPress: onChat }]} />
|
|
758
|
+
<Btn c={c} t={t} reduce={reduce} label={t.refund} state={runs['sub.request_refund']} onPress={() => go({ type: 'requestRefund' })} style={st.below} />
|
|
759
|
+
</>
|
|
760
|
+
)
|
|
761
|
+
return <ScrollView contentContainerStyle={[st.subPad, { paddingBottom: 16 + inset }]}>{body}</ScrollView>
|
|
762
|
+
}
|
|
763
|
+
|
|
395
764
|
function useKeyboardInset(): number {
|
|
396
765
|
const [h, setH] = useState(0)
|
|
397
766
|
useEffect(() => {
|
|
@@ -534,5 +903,39 @@ const st = StyleSheet.create({
|
|
|
534
903
|
attach: { width: 38, height: 32, alignItems: 'center', justifyContent: 'center' },
|
|
535
904
|
attachGap: { width: 12 },
|
|
536
905
|
input: { flex: 1, minHeight: 32, maxHeight: 132, fontSize: 16, lineHeight: 21, paddingTop: 6, paddingBottom: 5, paddingHorizontal: 0 },
|
|
537
|
-
send: { width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center', marginStart: 6 }
|
|
906
|
+
send: { width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center', marginStart: 6 },
|
|
907
|
+
emptyHome: { alignSelf: 'stretch', marginTop: 8 },
|
|
908
|
+
actions: { flexDirection: 'row', flexWrap: 'wrap', gap: 6, marginTop: 6 },
|
|
909
|
+
action: { flexDirection: 'row', alignItems: 'center', gap: 6 },
|
|
910
|
+
consent: { marginHorizontal: 12, marginBottom: 6, paddingHorizontal: 12, paddingVertical: 10 },
|
|
911
|
+
consentText: { fontSize: 13, lineHeight: 18 },
|
|
912
|
+
consentRow: { flexDirection: 'row', justifyContent: 'flex-end', gap: 8, marginTop: 8 },
|
|
913
|
+
consentBtn: { minHeight: 32, borderRadius: 16, borderWidth: 1, paddingHorizontal: 14, justifyContent: 'center' },
|
|
914
|
+
consentBtnText: { fontSize: 14, lineHeight: 18 },
|
|
915
|
+
csat: { alignSelf: 'center', alignItems: 'center', marginTop: 16, maxWidth: '100%' },
|
|
916
|
+
csatRow: { marginTop: 8 },
|
|
917
|
+
csatField: { marginTop: 8, alignSelf: 'stretch', minWidth: 280 },
|
|
918
|
+
csatInput: { paddingStart: 14 },
|
|
919
|
+
home: { paddingHorizontal: 12, paddingTop: 8, paddingBottom: 4 },
|
|
920
|
+
group: { borderWidth: 1, overflow: 'hidden' },
|
|
921
|
+
menuRow: { flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 48, paddingHorizontal: 14, paddingVertical: 10 },
|
|
922
|
+
menuOver: { fontSize: 12, lineHeight: 16 },
|
|
923
|
+
menuLabel: { fontSize: 15, lineHeight: 20 },
|
|
924
|
+
menuDetail: { fontSize: 13, lineHeight: 18 },
|
|
925
|
+
subPad: { paddingHorizontal: 16, paddingTop: 16, gap: 12 },
|
|
926
|
+
subTitle: { fontSize: 20, lineHeight: 26 },
|
|
927
|
+
subLine: { fontSize: 14, lineHeight: 19, marginTop: -6 },
|
|
928
|
+
summary: { paddingHorizontal: 14, paddingVertical: 12, gap: 2 },
|
|
929
|
+
plan: { fontSize: 17, lineHeight: 22 },
|
|
930
|
+
options: { gap: 8 },
|
|
931
|
+
option: { minHeight: 48, borderWidth: 1, paddingHorizontal: 14, justifyContent: 'center' },
|
|
932
|
+
pair: { flexDirection: 'row', gap: 8 },
|
|
933
|
+
stack: { gap: 8 },
|
|
934
|
+
below: { marginTop: 4 },
|
|
935
|
+
btn: { minHeight: 46, borderRadius: 23, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8, paddingHorizontal: 18, paddingVertical: 8 },
|
|
936
|
+
btnText: { fontSize: 15, lineHeight: 20, textAlign: 'center', flexShrink: 1 },
|
|
937
|
+
erase: { paddingHorizontal: 16 },
|
|
938
|
+
eraseBody: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 16, paddingHorizontal: 8 },
|
|
939
|
+
eraseMark: { width: 56, height: 56, borderRadius: 28, alignItems: 'center', justifyContent: 'center' },
|
|
940
|
+
eraseTitle: { fontSize: 20, lineHeight: 26, textAlign: 'center' }
|
|
538
941
|
})
|
package/src/support.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The app-facing singleton: configure once, identify after sign-in, open the widget from anywhere. Calls made before
|
|
2
2
|
// configure() (an auth listener at module scope, a push token on launch) are held and applied when it runs.
|
|
3
3
|
|
|
4
|
-
import { Platform } from 'react-native'
|
|
4
|
+
import { Linking, Platform } from 'react-native'
|
|
5
5
|
import { SupportClient } from './client'
|
|
6
6
|
import type { SupportConfig, UserInfo } from './client'
|
|
7
7
|
import { nativeDevice, nativeStorage } from './native'
|
|
@@ -14,7 +14,7 @@ export const ShotikSupport = {
|
|
|
14
14
|
configure(config: SupportConfig): SupportClient {
|
|
15
15
|
if (current && current.config.appKey === config.appKey && current.config.serverUrl === config.serverUrl.replace(/\/+$/, '')) return current
|
|
16
16
|
current?.stop()
|
|
17
|
-
const c = new SupportClient({ storage: nativeStorage(), device: nativeDevice, ...config })
|
|
17
|
+
const c = new SupportClient({ storage: nativeStorage(), device: nativeDevice, openUrl: (url) => Linking.openURL(url).catch(() => {}), ...config })
|
|
18
18
|
current = c
|
|
19
19
|
if (held.push) c.setPushToken(held.push.token, held.push.platform).catch(() => {})
|
|
20
20
|
if (held.user) c.identify(held.user).catch(() => {})
|