-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathServerList.tsx
More file actions
56 lines (51 loc) · 1.27 KB
/
ServerList.tsx
File metadata and controls
56 lines (51 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from "react";
import { Button, List, ListItem } from "@ui-kitten/components";
import { StyleSheet } from "react-native";
import { useTranslation } from "react-i18next";
import { EvccInstance } from "types";
interface ServerListProps {
entries: EvccInstance[];
onSelect: (url: string) => Promise<void>;
}
export default function ServerList({
entries = [],
onSelect,
}: ServerListProps): React.ReactElement {
const { t } = useTranslation();
const renderItemAccessory = (index: number, url: string) => {
return (
<Button
size="small"
onPress={() => {
onSelect(url);
}}
testID={`serverSearchListItem${index}Button`}
>
{t("servers.select")}
</Button>
);
};
return (
<List<EvccInstance>
style={styles.container}
data={entries}
renderItem={({ index, item }) => {
return (
<ListItem
title={item.title}
description={item.url}
accessoryRight={() => renderItemAccessory(index, item.url)}
testID={"serverSearchListItem" + index}
/>
);
}}
testID="serverSearchList"
/>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "transparent",
},
});