diff --git a/.all-contributorsrc b/.all-contributorsrc index 4e5b5a853..19e950193 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -731,6 +731,15 @@ "bug", "translation" ] + }, + { + "login": "jamesg1", + "name": "James Gosbell", + "avatar_url": "https://avatars3.githubusercontent.com/u/3621147?v=4", + "profile": "https://github.com/jamesg1", + "contributions": [ + "code" + ] } ] } diff --git a/src/components/section-list.component.js b/src/components/section-list.component.js index 38a786151..d999fd8ed 100644 --- a/src/components/section-list.component.js +++ b/src/components/section-list.component.js @@ -1,6 +1,7 @@ import React from 'react'; -import { StyleSheet, Text, View, ActivityIndicator } from 'react-native'; +import { ActivityIndicator } from 'react-native'; import { List, ListItem, Button } from 'react-native-elements'; +import styled from 'styled-components'; import { colors, fonts } from 'config'; @@ -15,26 +16,45 @@ type Props = { buttonAction: Function, }; -const styles = StyleSheet.create({ - section: { - marginTop: 15, - }, - topHeader: { - flex: 1, - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'center', - }, - sectionTitle: { - color: colors.black, - padding: 15, - ...fonts.fontPrimaryBold, +const Section = styled.View` + margin-top: 15; +`; +const Header = styled.View` + flex-direction: row; + justify-content: space-between; + align-items: center; +`; +const SectionTitle = styled.Text` + color: ${colors.black}; + padding: 15px; + ${fonts.fontPrimaryBold}; +`; +const TitleView = styled.View` + padding: 15px; +`; +const StyledList = styled(List).attrs({ + containerStyle: { + marginTop: 0, + borderBottomColor: colors.grey, + borderBottomWidth: 1, }, - listTitle: { +})``; +const StyledListItem = styled(ListItem).attrs({ + titleStyle: { color: colors.black, ...fonts.fontPrimary, }, - button: { +})``; +const LoadingIcon = styled(ActivityIndicator)` + margin: 20px 0; +`; +const StyledButton = styled(Button).attrs({ + textStyle: { + ...fonts.fontPrimaryBold, + }, + fontSize: 13, + color: colors.primaryDark, + buttonStyle: { backgroundColor: colors.white, borderColor: colors.primaryDark, borderWidth: 1, @@ -42,15 +62,7 @@ const styles = StyleSheet.create({ paddingVertical: 5, paddingHorizontal: 10, }, - list: { - marginTop: 0, - borderBottomColor: colors.grey, - borderBottomWidth: 1, - }, - loadingIcon: { - marginVertical: 20, - }, -}); +})``; export const SectionList = ({ loading, @@ -65,17 +77,9 @@ export const SectionList = ({ let listDisplay; if (loading) { - listDisplay = ( - - ); + listDisplay = ; } else if (noItems) { - listDisplay = ( - - ); + listDisplay = ; } else { listDisplay = children; } @@ -83,30 +87,23 @@ export const SectionList = ({ let sectionTitle = ''; if (typeof title === 'string') { - sectionTitle = {title}; + sectionTitle = {title}; } else { - sectionTitle = {title}; + sectionTitle = {title}; } return ( - - +
+
{sectionTitle} {showButton && !loading && ( -
+ {listDisplay} +
); };