-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: tree & tree species information screens (#8)
* Added tree info screen. * Added edit mode for individual trees. * Added species info view. * Implemented data persistence for tree information. * Added tree species info screen. --------- Co-authored-by: Chris Torres <[email protected]>
- Loading branch information
1 parent
d52cbf9
commit 6d4bb48
Showing
49 changed files
with
2,197 additions
and
380 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { Text, View } from 'react-native'; | ||
import { Dropdown as DropdownElement } from 'react-native-element-dropdown'; | ||
import { Icon } from 'react-native-elements'; | ||
import colors from '@/styles/colors'; | ||
import styles from './styles'; | ||
|
||
type DropdownProps<T extends string[]> = { | ||
options: T; | ||
setValue: (value: T[number]) => any; | ||
value: string; | ||
displayValue?: (s: string) => string; | ||
}; | ||
|
||
type Option = { | ||
label: string; | ||
value: string; | ||
i: number; | ||
}; | ||
|
||
function Dropdown<T extends string[]>({ | ||
options, | ||
setValue, | ||
value, | ||
displayValue = s => s, | ||
}: DropdownProps<T>) { | ||
return ( | ||
<View> | ||
<DropdownElement | ||
mode="default" | ||
style={styles.dropdown} | ||
placeholderStyle={[styles.text, styles.textContainer]} | ||
selectedTextStyle={[styles.text, styles.textContainer]} | ||
inputSearchStyle={styles.text} | ||
itemTextStyle={[styles.text, styles.gray4]} | ||
containerStyle={styles.dropdownContainer} | ||
dropdownPosition="bottom" | ||
iconStyle={styles.iconStyle} | ||
data={options.map((option: T[number], i: number) => { | ||
return { i, label: displayValue(option), value: option }; | ||
})} | ||
maxHeight={400} | ||
labelField="label" | ||
valueField="value" | ||
placeholder="Select..." | ||
value={value} | ||
renderItem={(item: Option, selected: boolean | undefined) => { | ||
return ( | ||
<Text | ||
style={[ | ||
styles.text, | ||
styles.gray4, | ||
styles.itemContainer, | ||
selected && styles.selectedBar, | ||
{ borderBottomLeftRadius: 0, borderTopLeftRadius: 0 }, | ||
item.i === 0 && { | ||
borderTopLeftRadius: 5, | ||
}, | ||
item.i === options.length - 1 && { | ||
borderBottomLeftRadius: 5, | ||
}, | ||
]} | ||
> | ||
{item.label} | ||
</Text> | ||
); | ||
}} | ||
renderRightIcon={visible => | ||
visible ? ( | ||
<Icon | ||
name="arrow-drop-up" | ||
type="material" | ||
color={colors.gray4} | ||
size={24} | ||
/> | ||
) : ( | ||
<Icon | ||
name="arrow-drop-down" | ||
type="material" | ||
color={colors.gray4} | ||
size={24} | ||
/> | ||
) | ||
} | ||
onChange={(item: Option) => { | ||
setValue(item.value); | ||
}} | ||
/> | ||
</View> | ||
); | ||
} | ||
|
||
export default Dropdown; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { StyleSheet } from 'react-native'; | ||
import colors from '@/styles/colors'; | ||
import typography from '@/styles/typography'; | ||
|
||
export default StyleSheet.create({ | ||
gray4: { | ||
color: colors.gray4, | ||
}, | ||
|
||
black3: { | ||
color: colors.gray3, | ||
}, | ||
|
||
textContainer: { | ||
paddingHorizontal: 20, | ||
}, | ||
|
||
selectedBar: { | ||
borderLeftWidth: 8, | ||
borderColor: colors.primary, | ||
overflow: 'hidden', | ||
paddingHorizontal: 20 - 8, | ||
margin: 0, | ||
}, | ||
|
||
text: { | ||
...typography.normalRegular, | ||
color: colors.gray3, | ||
textTransform: 'capitalize', | ||
textAlign: 'left', | ||
}, | ||
|
||
outer: { | ||
position: 'relative', | ||
zIndex: 1, | ||
}, | ||
|
||
label: { | ||
marginBottom: 8, | ||
}, | ||
|
||
dropdown: { | ||
height: 47, | ||
borderWidth: 1, | ||
borderRadius: 10, | ||
paddingRight: 10, | ||
textAlign: 'left', | ||
flex: 1, | ||
alignItems: 'center', | ||
borderColor: colors.gray5, | ||
}, | ||
|
||
dropdownContainer: { | ||
borderRadius: 5, | ||
borderWidth: 1, | ||
borderColor: colors.gray5, | ||
position: 'relative', | ||
}, | ||
|
||
itemContainer: { | ||
paddingHorizontal: 20, | ||
paddingVertical: 14, | ||
}, | ||
|
||
icon: { | ||
marginRight: 5, | ||
}, | ||
|
||
iconStyle: { | ||
width: 20, | ||
height: 20, | ||
}, | ||
}); |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import { Fragment } from 'react'; | ||
import { Text, TextInput, View } from 'react-native'; | ||
import SvgBear from '@/icons/Bear'; | ||
import SvgFlash from '@/icons/Flash'; | ||
import SvgFruit from '@/icons/Fruit'; | ||
import SvgLeaf from '@/icons/Leaf'; | ||
import Lightbulb from '@/icons/Lightbulb'; | ||
import SvgLocationPin from '@/icons/Location'; | ||
import SvgRuler from '@/icons/Ruler'; | ||
import SvgShapes from '@/icons/Shapes'; | ||
import SvgWarning2 from '@/icons/Warning2'; | ||
import SvgWateringCan from '@/icons/WateringCan'; | ||
import { Species } from '@/types/species'; | ||
import { displayValue, Tree } from '@/types/tree'; | ||
import styles from './styles'; | ||
|
||
type SpeciesDisplayProps = { | ||
speciesData: Partial<Species>; | ||
treeData: Tree[]; | ||
}; | ||
export default function SpeciesDisplay({ | ||
speciesData, | ||
treeData, | ||
}: SpeciesDisplayProps) { | ||
return ( | ||
<View style={styles.main}> | ||
<Text style={styles.text}>{speciesData.description}</Text> | ||
|
||
<View style={styles.funFactHeader}> | ||
<Lightbulb /> | ||
<Text style={styles.funFact}>Fun Fact</Text> | ||
</View> | ||
|
||
<TextInput | ||
style={styles.textInput} | ||
value={speciesData.fun_fact ?? ''} | ||
editable={false} | ||
multiline | ||
numberOfLines={4} | ||
/> | ||
|
||
<View style={styles.separator}></View> | ||
|
||
<Text style={styles.header}>Properties</Text> | ||
<View style={styles.properties}> | ||
{speciesData.height_ft && ( | ||
<View style={styles.property}> | ||
<SvgRuler /> | ||
<Text style={styles.propertyText}>{speciesData.height_ft} ft</Text> | ||
</View> | ||
)} | ||
|
||
{speciesData.tree_shape && ( | ||
<View style={styles.property}> | ||
<SvgShapes /> | ||
<Text style={styles.propertyText}> | ||
{displayValue(speciesData.tree_shape)} | ||
</Text> | ||
</View> | ||
)} | ||
|
||
{speciesData.water_amount && ( | ||
<View style={styles.property}> | ||
<SvgWateringCan /> | ||
<Text style={styles.propertyText}> | ||
{displayValue(speciesData.water_amount)} | ||
</Text> | ||
</View> | ||
)} | ||
|
||
{speciesData.root_damage_potential && ( | ||
<View style={styles.property}> | ||
<SvgWarning2 /> | ||
<Text style={styles.propertyText}> | ||
{displayValue(speciesData.root_damage_potential)} | ||
</Text> | ||
</View> | ||
)} | ||
|
||
{speciesData.fruit_type && ( | ||
<View style={styles.property}> | ||
<SvgFruit /> | ||
<Text style={styles.propertyText}> | ||
{displayValue(speciesData.fruit_type)} Fruit | ||
</Text> | ||
</View> | ||
)} | ||
|
||
{speciesData.ca_native && ( | ||
<View style={styles.property}> | ||
<SvgBear /> | ||
<Text style={styles.propertyText}>CA Native</Text> | ||
</View> | ||
)} | ||
|
||
{speciesData.evegreen && ( | ||
<View style={styles.property}> | ||
<SvgLeaf /> | ||
<Text style={styles.propertyText}>Evegreen</Text> | ||
</View> | ||
)} | ||
|
||
{speciesData.powerline_friendly && ( | ||
<View style={styles.property}> | ||
<SvgFlash /> | ||
<Text style={styles.propertyText}>Powerline Friendly</Text> | ||
</View> | ||
)} | ||
</View> | ||
|
||
{treeData?.length > 0 && ( | ||
<> | ||
<Text style={styles.header}>Location</Text> | ||
<View style={styles.locations}> | ||
{treeData?.map(tree => ( | ||
<View style={styles.locationEntry} key={tree.tree_id}> | ||
<SvgLocationPin /> | ||
<Text style={styles.propertyText}> | ||
Bank #{tree.bank ?? 0} {' '}|{' '} Row #{tree.row ?? 0} | ||
{/* TODO: Needs to support range of rows */} | ||
</Text> | ||
</View> | ||
))} | ||
</View> | ||
</> | ||
)} | ||
</View> | ||
); | ||
} |
Oops, something went wrong.