Skip to content

Commit e8bd4d4

Browse files
authored
feat(mobile): polish unreachable host state (#387)
1 parent 9fe21a1 commit e8bd4d4

4 files changed

Lines changed: 29 additions & 7 deletions

File tree

apps/mobile/e2e/flows/add-host.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ appId: com.arcboxlabs.linkcode.mobile
4949
# Naming the URL back is the assertion that matters: it can only come from text that made it
5050
# out of the field, into the store, and back onto a screen.
5151
- assertVisible: 'Unable to reach the host at http://127.0.0.1:19599.'
52+
- assertVisible: 'Host unavailable'
53+
- tapOn: 'Retry'
54+
- assertVisible: 'Connecting to the host…'
5255

5356
# Best-effort tidy-up, deliberately `optional`. Removal is a list swipe action, and revealing one
5457
# needs a drag longer than Maestro's element-relative swipe produces — an element swipe either does

apps/mobile/src/components/host/host-connection-state.tsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import { Button, Host, ProgressView, Text, VStack } from '@expo/ui/swift-ui';
2-
import { font, foregroundStyle, multilineTextAlignment } from '@expo/ui/swift-ui/modifiers';
1+
import { Button, Host, Image, ProgressView, Text, VStack } from '@expo/ui/swift-ui';
2+
import {
3+
buttonStyle,
4+
font,
5+
multilineTextAlignment,
6+
textSelection,
7+
} from '@expo/ui/swift-ui/modifiers';
8+
import { FOOTNOTE, SECONDARY } from '@mobile/components/form/styles';
39
import { useTranslations } from 'use-intl';
410

5-
const SECONDARY = foregroundStyle({ type: 'hierarchical', style: 'secondary' });
6-
const FOOTNOTE = font({ textStyle: 'footnote' });
11+
const CENTERED = multilineTextAlignment('center');
12+
const TITLE = font({ textStyle: 'title2', weight: 'semibold' });
713

814
export interface HostConnectionStateProps {
915
status: 'connecting' | 'error';
@@ -32,13 +38,24 @@ export function HostConnectionState({
3238
</>
3339
) : (
3440
<>
35-
<Text modifiers={[multilineTextAlignment('center')]}>{t('error', { url })}</Text>
41+
<Image systemName="wifi.exclamationmark" size={44} modifiers={[SECONDARY]} />
42+
<VStack spacing={6}>
43+
<Text modifiers={[TITLE, CENTERED]}>{t('unavailableTitle')}</Text>
44+
<Text modifiers={[SECONDARY, CENTERED, textSelection(true)]}>
45+
{t('error', { url })}
46+
</Text>
47+
</VStack>
48+
<Button
49+
label={t('retry')}
50+
systemImage="arrow.clockwise"
51+
modifiers={[buttonStyle('borderedProminent')]}
52+
onPress={onRetry}
53+
/>
3654
{failure ? (
37-
<Text modifiers={[FOOTNOTE, SECONDARY, multilineTextAlignment('center')]}>
55+
<Text modifiers={[FOOTNOTE, SECONDARY, CENTERED, textSelection(true)]}>
3856
{failure}
3957
</Text>
4058
) : null}
41-
<Button label={t('retry')} onPress={onRetry} />
4259
</>
4360
)}
4461
</VStack>

packages/presentation/i18n/src/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,7 @@ export const en = {
13021302
},
13031303
connection: {
13041304
connecting: 'Connecting to the host…',
1305+
unavailableTitle: 'Host unavailable',
13051306
error: 'Unable to reach the host at {url}.',
13061307
retry: 'Retry',
13071308
},

packages/presentation/i18n/src/locales/zh-cn.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,7 @@ export const zhCN = {
12681268
},
12691269
connection: {
12701270
connecting: '正在连接 host…',
1271+
unavailableTitle: '无法连接 host',
12711272
error: '无法连接 host({url})。',
12721273
retry: '重试',
12731274
},

0 commit comments

Comments
 (0)