Created
January 13, 2021 18:37
-
-
Save aleksejkozin/364e6c80d628066fe11054f8331a6ccd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import {FlatList, StyleSheet, View} from 'react-native' | |
import AddModal from '../../../components/AddModal' | |
import LoadingIndicator from '../../../components/LoadingIndicator' | |
import BrowserItem from '../../../components/BrowserItem' | |
const styles = StyleSheet.create({ | |
container: { | |
justifyContent: 'center', | |
alignItems: 'center', | |
}, | |
}) | |
export type Browser = { | |
fullname: string | |
image: string | |
linkToBrowser: string | |
minMemory: string | |
currentVersion: string | |
minimumRAM: string | |
description: string | |
windows: boolean | |
mac: boolean | |
linux: boolean | |
ubuntu: boolean | |
fedora: boolean | |
stars: number | |
} | |
export type BrowsersListProps = { | |
loading: boolean | |
browsers?: Browser[] | |
selectedBrowser?: Browser | |
setSelectedBrowser: (browser?: Browser) => void | |
} | |
export function BrowsersList(props: BrowsersListProps) { | |
const {loading, selectedBrowser, setSelectedBrowser, browsers} = props | |
return ( | |
<View style={styles.container}> | |
{loading ? ( | |
<LoadingIndicator /> | |
) : ( | |
<View> | |
<AddModal | |
modalVisible={Boolean(selectedBrowser)} | |
onClose={() => setSelectedBrowser(undefined)} | |
description={selectedBrowser?.description} | |
/> | |
<FlatList | |
data={browsers} | |
keyExtractor={(browser) => browser.fullname} | |
renderItem={({item}) => ( | |
<BrowserItem | |
browser={item} | |
onPress={() => setSelectedBrowser(item)} | |
/> | |
)} | |
/> | |
</View> | |
)} | |
</View> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment