Day Seperation bug fixed
This commit is contained in:
@@ -25,6 +25,8 @@ class _NewActivity extends State<NewActivity> {
|
||||
late DateTime init_eTime;
|
||||
late String init_selectedTask;
|
||||
_NewActivity({DateTime? eTime, DateTime? sTime, String? metadata, String? selectedCat}){
|
||||
editing = sTime != null && eTime!=null && selectedCat!=null;
|
||||
|
||||
this.init_sTime=this.startTime = sTime ?? DateTime.now();
|
||||
this.init_eTime=this.endTime = eTime ??DateTime.now().add(Duration(minutes: 30));
|
||||
this.metadataController.text = metadata ?? "";
|
||||
@@ -38,6 +40,9 @@ class _NewActivity extends State<NewActivity> {
|
||||
TextEditingController metadataController = TextEditingController();
|
||||
late String selectedCat;
|
||||
|
||||
|
||||
bool editing=false;
|
||||
|
||||
List<String> getActivities(){
|
||||
List<String> _cats = [];
|
||||
print(User.taskTypes[0].name + " : " + selectedCat);
|
||||
@@ -53,7 +58,7 @@ class _NewActivity extends State<NewActivity> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text('New Activity')),
|
||||
appBar: AppBar(title: Text((editing) ? 'Edit Activity':'New Activity')),
|
||||
body:Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@@ -283,10 +288,13 @@ class _NewActivity extends State<NewActivity> {
|
||||
shape: StadiumBorder()
|
||||
),
|
||||
onPressed: () {
|
||||
|
||||
add_action();
|
||||
if(editing){
|
||||
edit_action();
|
||||
}else {
|
||||
add_action();
|
||||
}
|
||||
},
|
||||
child: Text('Add Entry',
|
||||
child: Text((editing) ? 'Apply':'Add Activity',
|
||||
style: TextStyle(fontSize: 20))))),
|
||||
],
|
||||
)),
|
||||
@@ -331,6 +339,24 @@ class _NewActivity extends State<NewActivity> {
|
||||
print("Failed adding new activity");
|
||||
}
|
||||
}
|
||||
|
||||
void edit_action() async{
|
||||
print('adding Task Type : $selectedCat at $startTime - $endTime');
|
||||
bool failed=false;
|
||||
await User.UserOperations.editActivity(init_sTime,init_eTime,selectedCat,startTime, endTime,metadata:metadataController.text, onOverlap: (overlapCount){
|
||||
showAlertDialog(context, 'Error editing activity', 'Cannot add activity between ${dateFormat.format(startTime)} - ${dateFormat.format(endTime)}, $overlapCount activities are already added within this time range');
|
||||
failed=true;
|
||||
});
|
||||
|
||||
if(!failed) {
|
||||
print("popping : ${navigatorKey.currentWidget?.toStringShort() ?? "n/a"}");
|
||||
Navigator.of(navigatorKey.currentContext!).popUntil((route){
|
||||
return route.isFirst;
|
||||
});
|
||||
}else{
|
||||
print("Failed editing new activity");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String _printDuration(Duration duration) {
|
||||
|
||||
Reference in New Issue
Block a user