Summary page done
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/painting.dart';
|
||||
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'User.dart' as User;
|
||||
@@ -31,6 +32,7 @@ class _NewActivity extends State<NewActivity> {
|
||||
|
||||
DateTime startTime = DateTime.now();
|
||||
DateTime endTime = DateTime.now().add(Duration(minutes: 30));
|
||||
TextEditingController metadataController = TextEditingController();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -50,6 +52,7 @@ class _NewActivity extends State<NewActivity> {
|
||||
Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Text('Task')),
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 1),
|
||||
@@ -78,6 +81,25 @@ class _NewActivity extends State<NewActivity> {
|
||||
selectedCat = _value ?? 'n/a';
|
||||
});
|
||||
})),
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
child:Column(
|
||||
children: [
|
||||
|
||||
TextField(
|
||||
controller: metadataController,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Description (optional)',
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(20)
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
Container(
|
||||
child: Divider(
|
||||
height: 30,
|
||||
@@ -85,82 +107,107 @@ class _NewActivity extends State<NewActivity> {
|
||||
Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Text('Start Time')),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 1),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: Colors.grey, width: 2)),
|
||||
child: MaterialButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
DatePicker.showDateTimePicker(
|
||||
context,
|
||||
showTitleActions: true,
|
||||
onChanged: (date) {
|
||||
// print('change $date');
|
||||
}, onConfirm: (date) {
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
QuickTimeButton('Last', Function: (){
|
||||
if(User.activities.length > 0) {
|
||||
startTime= User.activities[0].endTime;
|
||||
}
|
||||
})
|
||||
,
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 1),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: Colors.grey, width: 2)),
|
||||
child: MaterialButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if(endTime.compareTo(date) < 0){
|
||||
const snackBar = SnackBar(
|
||||
content: Text('You cannot start something after you ended it!'),
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}else {
|
||||
startTime = date;
|
||||
}
|
||||
DatePicker.showDateTimePicker(
|
||||
context,
|
||||
showTitleActions: true,
|
||||
onChanged: (date) {
|
||||
// print('change $date');
|
||||
}, onConfirm: (date) {
|
||||
setState(() {
|
||||
if(endTime.compareTo(date) < 0){
|
||||
const snackBar = SnackBar(
|
||||
content: Text('You cannot start something after you ended it!'),
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}else {
|
||||
startTime = date;
|
||||
}
|
||||
});
|
||||
},
|
||||
currentTime: startTime,
|
||||
locale: LocaleType.en);
|
||||
});
|
||||
},
|
||||
currentTime: startTime,
|
||||
locale: LocaleType.en);
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
dateFormat.format(startTime),
|
||||
style: TextStyle(
|
||||
color: Colors.blue)))),
|
||||
child: Text(
|
||||
dateFormat.format(startTime),
|
||||
style: TextStyle(
|
||||
color: Colors.blue)))),
|
||||
QuickTimeButton('Now', Function: (){
|
||||
startTime = DateTime.now();
|
||||
})
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Text('Ended Time')),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 1),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: Colors.grey, width: 2)),
|
||||
child: MaterialButton(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Container(width: 60,),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 1),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: Colors.grey, width: 2)),
|
||||
child: MaterialButton(
|
||||
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
DatePicker.showDateTimePicker(
|
||||
context,
|
||||
showTitleActions: true,
|
||||
onChanged: (date) {
|
||||
// print('change $date');
|
||||
}, onConfirm: (date) {
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if(startTime.compareTo(date) > 0){
|
||||
const snackBar = SnackBar(
|
||||
content: Text('You cannot end something before you start it!'),
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}else {
|
||||
endTime = date;
|
||||
}
|
||||
DatePicker.showDateTimePicker(
|
||||
context,
|
||||
showTitleActions: true,
|
||||
onChanged: (date) {
|
||||
// print('change $date');
|
||||
}, onConfirm: (date) {
|
||||
setState(() {
|
||||
if(startTime.compareTo(date) > 0){
|
||||
const snackBar = SnackBar(
|
||||
content: Text('You cannot end something before you start it!'),
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}else {
|
||||
endTime = date;
|
||||
}
|
||||
});
|
||||
},
|
||||
currentTime: endTime,
|
||||
locale: LocaleType.en);
|
||||
});
|
||||
},
|
||||
currentTime: endTime,
|
||||
locale: LocaleType.en);
|
||||
});
|
||||
},
|
||||
child: Text(dateFormat.format(endTime),
|
||||
style: TextStyle(
|
||||
color: Colors.blue)))),
|
||||
child: Text(dateFormat.format(endTime),
|
||||
style: TextStyle(
|
||||
color: Colors.blue)))),
|
||||
QuickTimeButton('Now', Function: (){
|
||||
endTime = DateTime.now();
|
||||
})
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
@@ -173,6 +220,12 @@ class _NewActivity extends State<NewActivity> {
|
||||
Divider(
|
||||
height: 30,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
],
|
||||
)
|
||||
]),
|
||||
],
|
||||
))),
|
||||
@@ -194,9 +247,7 @@ class _NewActivity extends State<NewActivity> {
|
||||
shape: StadiumBorder()
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
Navigator.pop(context);
|
||||
});
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text('Back',
|
||||
style: TextStyle(fontSize: 20))))),
|
||||
@@ -212,10 +263,6 @@ class _NewActivity extends State<NewActivity> {
|
||||
onPressed: () {
|
||||
|
||||
add_action();
|
||||
setState(() {
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
child: Text('Add Entry',
|
||||
style: TextStyle(fontSize: 20))))),
|
||||
@@ -224,14 +271,33 @@ class _NewActivity extends State<NewActivity> {
|
||||
])));
|
||||
}
|
||||
|
||||
Widget QuickTimeButton(text, {Function}){
|
||||
return InkWell(
|
||||
child: Container(
|
||||
padding:EdgeInsets.symmetric(horizontal: 15),
|
||||
height: 30,
|
||||
decoration:BoxDecoration(
|
||||
color: Colors.blueAccent,
|
||||
borderRadius: BorderRadius.circular(50)
|
||||
),
|
||||
child:Align(child: Text(text),alignment: Alignment.center,)
|
||||
),
|
||||
|
||||
onTap: (){
|
||||
Function();
|
||||
setState(() {
|
||||
|
||||
});
|
||||
},);
|
||||
}
|
||||
|
||||
void add_action() async{
|
||||
|
||||
print('adding Task Type : $selectedCat at $startTime - $endTime');
|
||||
bool failed=false;
|
||||
await User.UserOperations.addActivity(selectedCat,startTime.toString(), endTime.toString(), onOverlap: (overlapCount){
|
||||
await User.UserOperations.addActivity(selectedCat,startTime.toString(), endTime.toString(),metadata:metadataController.text, onOverlap: (overlapCount){
|
||||
showAlertDialog(context, 'Error adding activity', 'Cannot add activity between ${dateFormat.format(startTime)} - ${dateFormat.format(endTime)}, $overlapCount activities are already added within this time range');
|
||||
failed=true;
|
||||
|
||||
});
|
||||
|
||||
if(!failed)
|
||||
|
||||
Reference in New Issue
Block a user