Upgrading UI

master
Arthur VALIN 2 years ago
parent b26c57abe0
commit b29d6a7d57

Binary file not shown.

Binary file not shown.

@ -1,30 +0,0 @@
import { Dimensions, Animated } from 'react-native';
export const animation = new Animated.Value(0);
export const startAnimation = () => {
Animated.timing(animation, {
toValue: 1,
duration: 400,
useNativeDriver: true,
}).start();
};
export const stopAnimation = () => {
Animated.timing(animation, {
toValue: 0,
duration: 400,
useNativeDriver: true,
}).start();
};
export const animatedStyles = {
transform: [
{
translateY: animation.interpolate({
inputRange: [0, 1],
outputRange: [0, -Dimensions.get('window').height/2]
}),
},
],
};

@ -7,44 +7,31 @@ interface kanjiListSeachPanelProps {
onSelect: (item: string, isSelected: Boolean) => void; onSelect: (item: string, isSelected: Boolean) => void;
} }
const KanjiListSearchPanel = (props: kanjiListSeachPanelProps) => { const GradeChipList = (props: kanjiListSeachPanelProps) => {
const navigator = useNavigation(); const navigator = useNavigation();
return ( return (
<View style={panelStyle.container}> <View style={panelStyle.container}>
<TextInput style={panelStyle.input} />
<FlatList <FlatList
data={[1, 2, 3, 4, 5, 6]} data={[1, 2, 3, 4, 5, 6]}
renderItem={(item) => <GradeChip grade={item.item} onSelect={props.onSelect} />} renderItem={(item) => <GradeChip grade={item.item} onSelect={props.onSelect} />}
horizontal={true} horizontal={true}
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}/>
>
</FlatList>
</View> </View>
); );
}; };
const panelStyle = StyleSheet.create({ const panelStyle = StyleSheet.create({
input: {
height: 40,
margin: 12,
borderWidth: 1,
padding: 10,
width: 200,
backgroundColor: "white",
borderRadius: 20,
borderColor: "black",
width: "80%"
},
container: { container: {
justifyContent: "center", justifyContent: "center",
alignItems: "center", alignItems: "center",
height: "20%" height: "10%",
marginTop: 5,
marginBottom: 5
} }
}) })
export default KanjiListSearchPanel; export default GradeChipList;

@ -21,7 +21,7 @@ const headerStyle = StyleSheet.create({
color: 'white', color: 'white',
textAlign: 'center', textAlign: 'center',
fontWeight: 'bold', fontWeight: 'bold',
fontSize: 30, fontSize: 40,
} }
}) })

@ -1,6 +1,5 @@
import React from 'react'; import React from 'react';
import { Animated, StyleSheet, TextInput } from 'react-native'; import { StyleSheet, TextInput, View } from 'react-native';
import { startAnimation, stopAnimation, animatedStyles } from '../assets/animations/answerAnimation'
interface kanjiAnswerFieldProps { interface kanjiAnswerFieldProps {
answer: string, answer: string,
@ -11,14 +10,14 @@ const KanjiAnswerField = (props: kanjiAnswerFieldProps) => {
return ( return (
<Animated.View style={[animatedStyles]}> <View>
<TextInput <TextInput
style={answerFieldStyle.input} style={answerFieldStyle.input}
onChangeText={props.setAnswer} onChangeText={props.setAnswer}
value={props.answer} value={props.answer}
placeholder="Answer here" placeholder="Answer here"
/> />
</Animated.View> </View>
); );
}; };

@ -4,7 +4,7 @@ import { useDispatch, useSelector } from 'react-redux';
import { Kanji } from '../model/kanji'; import { Kanji } from '../model/kanji';
import { KanjiListByGrade } from '../model/kanjiListByGrades'; import { KanjiListByGrade } from '../model/kanjiListByGrades';
import KanjiListCell from './KanjiListCell'; import KanjiListCell from './KanjiListCell';
import KanjiListSearchPanel from './KanjiListSearchPanel'; import GradeChipList from './GradeChipList';
const KanjiList = () => { const KanjiList = () => {
@ -37,12 +37,11 @@ const KanjiList = () => {
}, [dispatch]); }, [dispatch]);
return ( return (
<View> <View>
<KanjiListSearchPanel onSelect={updateSelectedItems} /> <GradeChipList onSelect={updateSelectedItems} />
<SectionList
{selectedItems.length ?
(<SectionList
sections={selectedItems} sections={selectedItems}
renderItem={ renderItem={
({ item }) => <KanjiListCell kanji={item} /> ({ item }) => <KanjiListCell kanji={item} />
@ -50,13 +49,12 @@ const KanjiList = () => {
renderSectionHeader={({ section }) => ( renderSectionHeader={({ section }) => (
<Text style={kanjiListStyle.sectionHeader}>{section.title}</Text> <Text style={kanjiListStyle.sectionHeader}>{section.title}</Text>
)} )}
keyExtractor={item => `basicListEntry-${item.character}` keyExtractor={item => `basicListEntry-${item.character}`}/>)
} : (
style={kanjiListStyle.list} <View style={kanjiListStyle.container}>
> <Text style={kanjiListStyle.text}>Select a grade</Text>
</SectionList> </View>
)}
</View> </View>
); );
}; };
@ -72,34 +70,20 @@ const kanjiListStyle_light = StyleSheet.create({
color: "black", color: "black",
backgroundColor: '#d5d5d5', backgroundColor: '#d5d5d5',
}, },
item: { text: {
padding: 10, textAlign: "center",
fontSize: 18, fontWeight: "bold",
height: 44, color: "black",
opacity: 0.5
}, },
input: { container: {
height: 40, flex: 1,
margin: 12, justifyContent: 'center',
borderWidth: 1, alignItems: 'center',
padding: 10,
width: 200,
backgroundColor: "white",
borderRadius: 20,
borderColor: "black"
}, },
}) })
const kanjiListStyle_dark = StyleSheet.create({ const kanjiListStyle_dark = StyleSheet.create({
list: {
},
chipList: {
height: 10
},
container: {
width: '100%',
height: '100%',
padding: 10
},
sectionHeader: { sectionHeader: {
paddingTop: 2, paddingTop: 2,
paddingLeft: 10, paddingLeft: 10,
@ -110,19 +94,16 @@ const kanjiListStyle_dark = StyleSheet.create({
color: "white", color: "white",
backgroundColor: '#0d0d0d', backgroundColor: '#0d0d0d',
}, },
item: { text: {
padding: 10, textAlign: "center",
fontSize: 18, fontWeight: "bold",
height: 44, color: "white",
opacity: 0.5
}, },
input: { container: {
height: 40, flex: 1,
margin: 12, justifyContent: 'center',
borderWidth: 1, alignItems: 'center',
padding: 10,
backgroundColor: "white",
borderRadius: 20,
borderColor: "black"
}, },
}) })

@ -28,9 +28,10 @@ const KanjiPlaygroundList = (props: kanjiPlaygroundListProps) => {
<View style={kanjiPlaygroundListStyle.container}> <View style={kanjiPlaygroundListStyle.container}>
<TextInput style={kanjiPlaygroundListStyle.input} <TextInput style={kanjiPlaygroundListStyle.input}
placeholder="Search kanji here" placeholder="Search kanji here"
placeholderTextColor="gray"
value={search} value={search}
onChangeText={setSearch} onChangeText={setSearch}
onBlur={async () => await (await searchKanjis(search))(dispatch)} onBlur={async () => await (await searchKanjis(search.toLowerCase()))(dispatch)}
></TextInput> ></TextInput>
<FlatList <FlatList
numColumns={4} numColumns={4}
@ -74,7 +75,7 @@ const kanjiPlaygroundListStyle_light = StyleSheet.create({
width: "75%", width: "75%",
backgroundColor: "white", backgroundColor: "white",
borderRadius: 20, borderRadius: 20,
alignSelf: "center" alignSelf: "center",
}, },
}) })
@ -105,7 +106,8 @@ const kanjiPlaygroundListStyle_dark = StyleSheet.create({
width: "75%", width: "75%",
backgroundColor: "white", backgroundColor: "white",
borderRadius: 20, borderRadius: 20,
alignSelf: "center" alignSelf: "center",
}, },
}) })

Loading…
Cancel
Save