-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimeline.js
205 lines (197 loc) · 10.5 KB
/
timeline.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import React, { useState } from 'react';
import { View, Text, TextInput,Pressable } from 'react-native';
import { styles, colors } from './styles'
import Icon from 'react-native-vector-icons/FontAwesome5';
import OvenTop from './assets/Oven Direction Top.svg'
import OvenBottom from './assets/Oven Direction Bottom.svg'
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
import CircularSlider from 'rn-circular-slider'
import Slider from '@react-native-community/slider'
import { Button } from 'react-native-elements';
import Ficon from 'react-native-vector-icons/Fontisto';
const TemperatureSlider = (props) => {
return (
<View>
{
props.top && <View style={{ flexDirection: 'row', width: '100%', marginLeft: 4, marginBottom: -12 }}>
{props.icon}
<Text style={{ textAlign: 'right', width: '85%', color: 'grey' }}> {Math.round(props.handler.value)}°C </Text>
</View>
}
<Slider
maximumValue={250}
minimumValue={0}
maximumTrackTintColor={colors.grey}
minimumTrackTintColor={colors.yellow}
step={5}
onSlidingComplete={value => { props.handler.setValue(value); ReactNativeHapticFeedback.trigger("impactLight"); }}
value={props.handler.value}
style={{ marginBottom: -12 }}
thumbTintColor="transparent"
/>
{
props.bottom && <View style={{ flexDirection: 'row', width: '100%', marginLeft: 4 }}>
{props.icon}
<Text style={{ textAlign: 'right', width: '85%', color: 'grey' }}> {Math.round(props.handler.value)}°C </Text>
</View>
}
</View>
)
}
const Title = (props) => {
return (
<View style={{ flexDirection: 'row' }}>
<View style={[styles.detailsCircle, { backgroundColor: props.color }]}>
<Icon name={props.icon} size={12} color={colors.white} style={{ padding: 4, alignSelf: 'center' }} solid />
</View>
<Text style={styles.autoTitle}> {props.type}</Text>
<Button
onPress={() =>props.removeItem(props.id)}
icon={<Ficon name="close-a" size={6} color={colors.white} />}
buttonStyle={styles.closeButtonS}
containerStyle={styles.closeButtonPaddingS}
/>
</View>
)
}
const Checkbox = (props) => {
const [checked, setchecked] = useState(props.checked);
return (
<View style={{ flexDirection: 'row' }}>
<Pressable style={[styles.detailsCircle, { backgroundColor: checked ? props.color : colors.white, borderWidth:2, borderColor: props.color }]} onPress={() => setchecked(!checked)}>
{checked && <Icon name={props.icon} size={12} color={colors.white} style={{ padding: 2, alignSelf: 'center' }} solid />}
</Pressable>
<Text style={styles.autoTitle}> {props.type}</Text>
</View>
)
}
export const Preheat = (props) => {
const [timeSlider, setTimeSlider] = useState(parseInt(props.temp));
return (
<View style={[styles.autoContainer]}>
<Title type="Preheat" color={colors.orange} icon="fire-alt" id={props.id} removeItem={props.removeItem} />
<CircularSlider
step={1} min={0} max={250} value={timeSlider} onChange={(v) => { setTimeSlider(v); if (v % 2 == 0) ReactNativeHapticFeedback.trigger("impactLight"); }} contentContainerStyle={styles.contentContainerStyle} strokeWidth={4} buttonBorderColor={colors.red}
openingRadian={Math.PI / 4} buttonRadius={8} radius={40} linearGradient={[{ stop: '0%', color: colors.orange }, { stop: '100%', color: colors.red }]}
>
<Text style={{'color':colors.red,'fontSize':18}}>{timeSlider}°C</Text>
{/* <Text style={[styles.min,{color:colors.red}]}></Text> */}
</CircularSlider>
</View>
)
}
export const Cook = (props) => {
const [topTemp, setTopTemp] = useState(parseInt(props.topTemp));
const [bottomTemp, setBottomTemp] = useState(parseInt(props.bottomTemp));
const [timeSlider, setTimeSlider] = useState(parseInt(props.duration));
return (
<View style={[styles.autoContainer]}>
<Title type="Cook" color={colors.yellow} icon="utensils" id={props.id} removeItem={props.removeItem} />
<View style={{ flexDirection: 'row', marginTop: 14 }}>
<View style={{ width: '60%', marginLeft: 20 }}>
<TemperatureSlider top icon={<OvenTop height={22} width={22} fill={colors.black} />} handler={{ value: topTemp, setValue: setTopTemp }} />
<TemperatureSlider bottom icon={<OvenBottom height={22} width={22} fill={colors.black} />} handler={{ value: bottomTemp, setValue: setBottomTemp }} />
</View>
<View style={{ paddingLeft: 5, justifyContent: 'center' }}>
<CircularSlider
step={2} min={0} max={90} value={timeSlider} onChange={(v) => { setTimeSlider(v); if (v % 15 == 0) ReactNativeHapticFeedback.trigger("impactLight"); }} contentContainerStyle={styles.contentContainerStyle} strokeWidth={4} buttonBorderColor={colors.orange}
openingRadian={Math.PI / 4} buttonRadius={8} radius={40} linearGradient={[{ stop: '0%', color: colors.yellow }, { stop: '100%', color: colors.orange }]}
>
<Text style={[styles.value, { color: colors.orange }]}>{timeSlider}</Text>
<Text style={[styles.min, { color: colors.orange }]}>min</Text>
</CircularSlider>
</View>
</View>
</View>)
}
export const Checkpoint = (props) => {
const [timeSlider, setTimeSlider] = useState(parseInt(props.timeout));
return (
<View style={[styles.autoContainer]}>
<Title type='Checkpoint' color={colors.blue} icon="flag" id={props.id} removeItem={props.removeItem} />
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ paddingLeft: 14, justifyContent: 'center' }}>
<CircularSlider
step={5} min={0} max={60} value={timeSlider} onChange={(v) => { setTimeSlider(v); if (v % 20 == 0) ReactNativeHapticFeedback.trigger("impactLight"); }} contentContainerStyle={styles.contentContainerStyle} strokeWidth={4} buttonBorderColor={colors.blue}
openingRadian={Math.PI / 4} buttonRadius={8} radius={40} linearGradient={[{ stop: '0%', color: colors.blue }, { stop: '100%', color: colors.blue }]}
>
<Text style={styles.value}>{timeSlider}</Text>
<Text style={styles.min}>sec</Text>
</CircularSlider>
</View>
<View style={{ width: '60%', marginLeft: 14, marginTop: 15 }}>
<Checkbox type="Wait for conformation" color={colors.blue} icon="check" checked={props.wait} />
</View>
</View>
</View>
)
}
// export const Pause = (props) => {
// return (
// <View style={[styles.autoContainer]}>
// <Title type='Pause' color={colors.textGrey} icon="pause" id={props.id} removeItem={props.removeItem} />
// <View style={{ margin: 20 }}>
// <Ficon name="pause" size={38} color={colors.textGrey} style={{ alignSelf: 'center', marginTop: 18 }} solid />
// </View>
// </View>
// )
// }
export const Notify = (props) => {
const destiColor = ["lightRed", "orange", "yellow", "blue"]
const [title, changeTitle] = useState(props.title);
const [msg, changeMsg] = useState(props.message);
return (
<View style={[styles.autoContainer]}>
<Title type='Notify' color={colors.purple} icon="bell" id={props.id} removeItem={props.removeItem} />
<View style={{ marginTop: 10 }}>
<TextInput
style={[styles.notifyMsg, { fontWeight: 'bold' }]}
onChangeText={changeTitle}
value={title}
/>
<TextInput
style={styles.notifyMsg}
onChangeText={changeMsg}
value={msg}
/>
{/* <View style={{ flexDirection: 'row', width: '100%', height: 90, flexWrap: 'wrap', padding: 10 }}>
{
props.destination.map((item, i) => (
<View key={i} style={{ flexDirection: 'row', width: '32%' }}>
<View style={[styles.detailsCircle, { backgroundColor: colors[destiColor[i % 4]] }]}>
<Icon name='check' size={10} color={colors.white} style={{ padding: 4, alignSelf: 'center' }} solid />
</View>
<Text style={styles.autoTitle}> {item}</Text>
</View>
))
}
</View> */}
</View>
</View>
)
}
export const PowerOff = (props) => {
return (
<View style={[styles.autoContainer]}>
<Title type='Power Off' color={colors.lightRed} icon="power-off" id={props.id} removeItem={props.removeItem} />
<View style={{ margin: 20 }}>
<Icon name="power-off" size={38} color={colors.lightRed} style={{ alignSelf: 'center', marginTop: 18 }} solid />
</View>
</View>
)
}
export const Cooling = (props) => {
const [timeSlider, setTimeSlider] = useState(parseInt(props.duration));
return (
<View style={[styles.autoContainer]}>
<Title type="Cooling Time" color={colors.turquoise} icon="snowflake" id={props.id} removeItem={props.removeItem} />
<CircularSlider
step={1} min={0} max={10} value={timeSlider} onChange={(v) => { setTimeSlider(v); if (v % 2 == 0) ReactNativeHapticFeedback.trigger("impactLight"); }} contentContainerStyle={styles.contentContainerStyle} strokeWidth={4} buttonBorderColor={colors.turquoise}
openingRadian={Math.PI / 4} buttonRadius={8} radius={40} linearGradient={[{ stop: '0%', color: colors.blue }, { stop: '100%', color: colors.turquoise }]}
>
<Text style={styles.value}>{timeSlider}</Text>
<Text style={styles.min}>min</Text>
</CircularSlider>
</View>
)
}