Todo basics added

This commit is contained in:
Sewmina
2022-03-31 15:12:31 +05:30
parent ead2c466d1
commit 62ae8bad01
12 changed files with 1698 additions and 830 deletions

View File

@@ -37,11 +37,13 @@ bool editing = false;
bool multiLine = true;
String selectedCat = User.categories[0].name;
String oldName = '[]';
class _NewProjectState extends State<NewProject> {
_NewProjectState({bool? multiline, String? pname, String? selectedCategory, List<ProjectStep>? m_steps, int? m_eta}){
multiLine=multiline ?? true;
nameController.text = pname ?? '';
if(pname!=null){oldName=pname;}
if(selectedCategory!=null){selectedCat = selectedCategory;}
if(m_steps!=null){steps=m_steps;}else{print('no steps?');}
if(multiline!=null && pname != null && selectedCategory != null && m_steps!=null){
@@ -500,7 +502,12 @@ class _NewProject2State extends State<NewProject2> {
child: ElevatedButton(
style: ElevatedButton.styleFrom(primary: Colors.green, shape: StadiumBorder()),
onPressed: () {
OnClickAdd();
if(editing){
OnClickEdit();
}else{
OnClickAdd();
}
},
child: Text((editing) ? 'Apply' : 'Add', style: TextStyle(fontSize: 20))))),
],
@@ -688,6 +695,16 @@ class _NewProject2State extends State<NewProject2> {
return route.isFirst;
});
}
void OnClickEdit() async{
if(projectName==null || deadline.isBefore(DateTime.now())){showAlertDialog(context, 'Error', 'Please make sure you have entered correct information'); return;}
User.UserOperations.editProject(oldName,projectName!, selectedCat, steps,etaHours, deadline);
Navigator.of(navigatorKey.currentContext!).popUntil((route){
return route.isFirst;
});
}
}