Related Project added to TaskType
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:tasktracker/NewCategory.dart';
|
||||
import 'package:tasktracker/NewProject.dart';
|
||||
import 'User.dart' as User;
|
||||
|
||||
DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
@@ -24,7 +25,19 @@ List<String> getCategoryNames(){
|
||||
return _cats;
|
||||
}
|
||||
|
||||
List<String> getProjectNames(){
|
||||
List<String> _projects = [];
|
||||
_projects.add("None");
|
||||
_projects.add('+Add New Project');
|
||||
User.projects.forEach((element) {
|
||||
String name = element.getName();
|
||||
_projects.add(name);
|
||||
});
|
||||
return _projects;
|
||||
}
|
||||
|
||||
String selectedCat = User.categories[0].name;
|
||||
String selectedProj = "None";
|
||||
class _NewTaskState extends State<NewTask> {
|
||||
TextEditingController nameController = TextEditingController();
|
||||
bool productive = true;
|
||||
@@ -96,6 +109,48 @@ class _NewTaskState extends State<NewTask> {
|
||||
}
|
||||
setState(() {
|
||||
|
||||
});
|
||||
})),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 20, 0, 10),
|
||||
child: Text('Related Project'),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 1),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blueGrey,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: Colors.grey, width: 2)),
|
||||
child: DropdownButton<String>(
|
||||
dropdownColor: Colors.blueGrey,
|
||||
iconSize: 30,
|
||||
elevation: 10,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
value: selectedProj,
|
||||
isExpanded: true,
|
||||
items: getProjectNames().map<DropdownMenuItem<String>>(
|
||||
(String value) {
|
||||
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String? _value) {
|
||||
if(_value != null) {
|
||||
if (_value.contains("+Add New Project")) {
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context)=>NewProject()));
|
||||
}else{
|
||||
selectedProj = _value!;
|
||||
if(_value.contains("None")){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
setState(() {
|
||||
|
||||
});
|
||||
})),
|
||||
Container(
|
||||
@@ -157,7 +212,7 @@ class _NewTaskState extends State<NewTask> {
|
||||
showAlertDialog(context, 'Category needs a name', 'Please enter a name for this category');
|
||||
return;
|
||||
}
|
||||
await User.UserOperations.addTaskType(catName,selectedCat);
|
||||
await User.UserOperations.addTaskType(catName,selectedCat,relatedProject: (selectedProj == 'None') ? '' : selectedProj);
|
||||
Navigator.of(context).popUntil((route){
|
||||
return route.isFirst;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user