frontend: rig frontend with sleep record queries
Pedro Lucas Porcellis porcellis@eletrotupi.com · 5 months ago
27c3a09ab88b4a7686f88e74b1f2313488de3a2b Browse filesParents
c00102eChanged files
1
Additions
+14
Deletions
-5
frontend/app/sleep/new.tsx
1 1
import {
2 2
View,
3 3
Text,
4 4
StyleSheet,
5 +
KeyboardAvoidingView,
5 6
ScrollView
6 7
} from 'react-native';
7 8
import { useEffect, useState } from 'react';
9 +
import { router } from 'expo-router';
8 10
9 11
import { Card } from '@/components/ui/Cards';
10 12
import { Input, TextArea } from '@/components/ui/Input';
11 13
import { Button } from '@/components/ui/Button';
12 14
import { Spacing, Typography, Colors, BorderRadius } from '@/constants/theme';
13 15
import { Ionicons } from '@expo/vector-icons';
14 16
import DatePickerField from '@/components/ui/DatePickerField';
15 17
import { ScaleSlider } from '@/components/ui/ScaleSlider';
18 +
import { useCreateSleepRecord } from '@/hooks';
16 19
17 20
export default function NewSleepRecord() {
18 21
const [date, setDate] = useState(new Date())
19 22
const [annotations, setAnnotations] = useState();
20 23
const [average, setAverage] = useState(7.5);
24 +
const createSleepRecord = useCreateSleepRecord();
21 25
22 26
const formatValue = (value: number): string => {
23 27
return String(value).replaceAll('.', ',');
24 28
};
25 29
29 33
annotations,
30 34
average
31 35
};
32 36
33 37
console.log("Sleep record:", data)
34 -
//await createSleepRecord.mutateAsync(data)
35 -
//router.replace("/")
38 +
await createSleepRecord.mutateAsync(data)
39 +
router.replace("/")
36 40
};
37 41
38 42
return (
39 -
<View>
43 +
<KeyboardAvoidingView
44 +
behavior='height'
45 +
style={styles.keyboardView}>
40 46
<ScrollView scrollEventThrottle={16}>
41 47
<View style={styles.container}>
42 48
<View style={styles.header}>
43 49
<View style={styles.innerHeaderWrapper}>
44 50
<View style={[styles.headerIcon, { backgroundColor: '#EFF6FF' }]}>
92 98
</Card>
93 99
94 100
<Button title="Salvar Registro" onPress={save} />
95 101
</View>
96 102
</ScrollView>
97 -
</View>
103 +
</KeyboardAvoidingView>
98 104
);
99 105
}
100 106
101 107
const styles = StyleSheet.create({
102 108
container: {
133 139
},
134 140
description: {
135 141
...Typography.bodyMd,
136 142
color: Colors.light.textSecondary,
137 143
marginTop: 20
138 -
}
144 +
},
145 +
keyboardView: {
146 +
flex: 1,
147 +
},
139 148
})