xref: /expo/home/menu/DevMenuServerInfo.tsx (revision da751fd5)
1import Constants from 'expo-constants';
2import { Row, View, Text, Spacer } from 'expo-dev-client-components';
3import React from 'react';
4import { StyleSheet } from 'react-native';
5
6import DevIndicator from '../components/DevIndicator';
7import FriendlyUrls from '../legacy/FriendlyUrls';
8
9type Props = {
10  task: { manifestUrl: string; manifestString: string };
11};
12
13export function DevMenuServerInfo({ task }: Props) {
14  const manifest = task.manifestString
15    ? (JSON.parse(task.manifestString) as typeof Constants.manifest | typeof Constants.manifest2)
16    : null;
17  const taskUrl = task.manifestUrl ? FriendlyUrls.toFriendlyString(task.manifestUrl) : '';
18  const devServerName =
19    manifest && manifest.extra?.expoGo?.developer ? manifest.extra.expoGo.developer.tool : null;
20
21  return (
22    <View bg="default" padding="medium">
23      {devServerName ? (
24        <>
25          <Text size="small" type="InterRegular">
26            Connected to {devServerName}
27          </Text>
28          <Spacer.Vertical size="tiny" />
29        </>
30      ) : null}
31      <Row align="center">
32        {devServerName ? (
33          <DevIndicator style={styles.taskDevServerIndicator} isActive isNetworkAvailable />
34        ) : null}
35        <Text type="InterRegular" size="medium" numberOfLines={1}>
36          {taskUrl}
37        </Text>
38      </Row>
39    </View>
40  );
41}
42
43const styles = StyleSheet.create({
44  taskDevServerIndicator: {
45    marginRight: 8,
46  },
47});
48