Refactor category type to use enum
This commit is contained in:
parent
6ca505d505
commit
bdc2ca22f6
6 changed files with 22 additions and 15 deletions
|
|
@ -1,10 +1,11 @@
|
|||
|
||||
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
||||
import { useTheme } from "../../app/contexts/ThemeContext";
|
||||
import { CategoryType } from "../../services/database";
|
||||
|
||||
export type TypeSelectorSwitchProperties = {
|
||||
handleButtonPress: (type: string) => void,
|
||||
currentSelected: string,
|
||||
handleButtonPress: (type: CategoryType) => void,
|
||||
currentSelected: CategoryType,
|
||||
}
|
||||
|
||||
const TypeSelectorSwitch = (properties: TypeSelectorSwitchProperties) => {
|
||||
|
|
@ -14,17 +15,17 @@ const TypeSelectorSwitch = (properties: TypeSelectorSwitchProperties) => {
|
|||
<View style={styles.containerStyle}>
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
properties.handleButtonPress("expense");
|
||||
properties.handleButtonPress(CategoryType.EXPENSE);
|
||||
}}
|
||||
style={[styles.touchableOpacityStyle, properties.currentSelected == "expense" ? {backgroundColor: colors.accentColor} : {backgroundColor: colors.elementDefaultColor}]
|
||||
style={[styles.touchableOpacityStyle, properties.currentSelected == CategoryType.EXPENSE ? {backgroundColor: colors.accentColor} : {backgroundColor: colors.elementDefaultColor}]
|
||||
}>
|
||||
<Text style={[styles.textStyle, {color: colors.primaryText}]}>Expenses</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
properties.handleButtonPress("saving");
|
||||
onPress={() => {
|
||||
properties.handleButtonPress(CategoryType.SAVING);
|
||||
}}
|
||||
style={[styles.touchableOpacityStyle, properties.currentSelected == "saving" ? {backgroundColor: colors.accentColor} : {backgroundColor: colors.elementDefaultColor}]
|
||||
style={[styles.touchableOpacityStyle, properties.currentSelected == CategoryType.SAVING ? {backgroundColor: colors.accentColor} : {backgroundColor: colors.elementDefaultColor}]
|
||||
}>
|
||||
<Text style={[styles.textStyle, {color: colors.primaryText}]}>Savings</Text>
|
||||
</TouchableOpacity>
|
||||
|
|
|
|||
Reference in a new issue