Commit 7f7851c9 by OuiAtichat

demo add timer

parent 190fbc8f
...@@ -11,6 +11,7 @@ import SwipeableRow from '../../../components/SwipeableRow'; ...@@ -11,6 +11,7 @@ import SwipeableRow from '../../../components/SwipeableRow';
import DatePicker from 'react-native-date-picker'; import DatePicker from 'react-native-date-picker';
import { height } from '../../../constants/Layout'; import { height } from '../../../constants/Layout';
import InputField from '../../../components/InputField'; import InputField from '../../../components/InputField';
import { isIphoneX } from '../../../utils/isPhoneX';
// mock data // mock data
const MultipleMockData = [ const MultipleMockData = [
...@@ -340,15 +341,20 @@ export default class TimerScreen extends Component { ...@@ -340,15 +341,20 @@ export default class TimerScreen extends Component {
</TouchableOpacity> </TouchableOpacity>
), ),
}); });
state = { state = {
date: new Date(), currentTime: new Date(),
isVisible: false, isVisible: false,
}; };
renderTimerFab = () => { renderTimerFab = () => {
return ( return (
<Fab <Fab
containerStyle={{ bottom: '15%' }} containerStyle={{
bottom: '15%',
// right: '50%', // centerFAB
// marginRight: -28,
}}
style={{ backgroundColor: color.primary }} style={{ backgroundColor: color.primary }}
position="bottomRight" position="bottomRight"
onPress={() => this.setState({ isVisible: true })} onPress={() => this.setState({ isVisible: true })}
...@@ -379,6 +385,7 @@ export default class TimerScreen extends Component { ...@@ -379,6 +385,7 @@ export default class TimerScreen extends Component {
heading={item.tabName} heading={item.tabName}
> >
<FlatList <FlatList
contentContainerStyle={{ paddingBottom: isIphoneX() ? 90 : 55 }}
data={item.timer} data={item.timer}
ListEmptyComponent={() => ( ListEmptyComponent={() => (
<View> <View>
...@@ -400,19 +407,14 @@ export default class TimerScreen extends Component { ...@@ -400,19 +407,14 @@ export default class TimerScreen extends Component {
animationType="slide" animationType="slide"
visible={this.state.isVisible} visible={this.state.isVisible}
> >
<View <View style={{ flex: 1, backgroundColor: 'rgba(0, 0, 0,0.5)' }}>
style={{
flex: 1,
backgroundColor: 'rgba(0, 0, 0,0.5)',
}}
>
<ScrollView contentContainerStyle={styles.scrollContainer}> <ScrollView contentContainerStyle={styles.scrollContainer}>
<Text style={theme.title}>Create Timer</Text> <Text style={theme.title}>Create Timer</Text>
<View> <View>
<Text style={[theme.normalText, theme.textDark]}>Set Time</Text> <Text style={[theme.normalText, theme.textDark]}>Set Time</Text>
<DatePicker <DatePicker
date={this.state.date} date={this.state.currentTime}
onDateChange={date => this.setState({ date })} onDateChange={date => this.setState({ currentTime: date })}
mode="time" mode="time"
style={{ height: 100 }} style={{ height: 100 }}
/> />
...@@ -443,7 +445,6 @@ export default class TimerScreen extends Component { ...@@ -443,7 +445,6 @@ export default class TimerScreen extends Component {
))} ))}
</View> </View>
</View> </View>
<View style={{ flexDirection: 'row', justifyContent: 'space-evenly' }}> <View style={{ flexDirection: 'row', justifyContent: 'space-evenly' }}>
<Button <Button
transparent transparent
...@@ -459,7 +460,41 @@ export default class TimerScreen extends Component { ...@@ -459,7 +460,41 @@ export default class TimerScreen extends Component {
justifyContent: 'center', justifyContent: 'center',
backgroundColor: color.primary, backgroundColor: color.primary,
}} }}
onPress={() => this.setState({ isVisible: false })} onPress={() => {
this.setState({ isVisible: false });
let hours = this.state.currentTime.getHours();
let minutes = this.state.currentTime.getMinutes();
if (minutes < 10) {
minutes = '0' + minutes;
}
let suffix = 'AM';
if (hours >= 12) {
suffix = 'PM';
hours = hours - 12;
}
if (hours == 0) {
hours = 12;
}
{
MultipleMockData[1].timer.push({
time: `${hours}:${minutes}`,
period: suffix,
name: 'Slot 1',
active: true,
power: true,
day: [
{ day: 'S', dayActive: true },
{ day: 'M', dayActive: true },
{ day: 'T', dayActive: true },
{ day: 'W', dayActive: true },
{ day: 'T', dayActive: false },
{ day: 'F', dayActive: true },
{ day: 'S', dayActive: true },
],
});
}
}}
> >
<Text style={{ color: color.white }}>Confirm</Text> <Text style={{ color: color.white }}>Confirm</Text>
</Button> </Button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment