Multi step list and editor UI done
This commit is contained in:
@@ -90,10 +90,11 @@ class Queries{
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ProjectStep{
|
class ProjectStep{
|
||||||
ProjectStep(this.stepName,this.eta);
|
ProjectStep(this.stepName,this.eta,this.progress);
|
||||||
|
|
||||||
String stepName;
|
String stepName;
|
||||||
int eta;
|
int eta;
|
||||||
|
int progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ Future<void> showDurationSelector(BuildContext context, {required Function(Durat
|
|||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(30)),
|
borderRadius: BorderRadius.circular(30)),
|
||||||
backgroundColor: Colors.white10,
|
backgroundColor: Color(0xFF1F1F1F),
|
||||||
title: Align(alignment: Alignment.center,
|
title: Align(alignment: Alignment.center,
|
||||||
child: const Text('Select Time Range')),
|
child: const Text('Select Time Range')),
|
||||||
content: Row(
|
content: Row(
|
||||||
|
|||||||
@@ -39,155 +39,119 @@ class _NewProjectState extends State<NewProject> {
|
|||||||
appBar: AppBar(title: Text('New Project')),
|
appBar: AppBar(title: Text('New Project')),
|
||||||
body: Container(
|
body: Container(
|
||||||
height: MediaQuery.of(context).size.height,
|
height: MediaQuery.of(context).size.height,
|
||||||
child: Column(
|
child: Column(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||||
mainAxisSize: MainAxisSize.max,
|
SingleChildScrollView(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
child: Padding(
|
||||||
children: [
|
padding: EdgeInsets.fromLTRB(20, 50, 20, 50),
|
||||||
SingleChildScrollView(
|
child: Column(
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.fromLTRB(20, 50, 20, 50),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(0),
|
|
||||||
child: Text('Project Name')),
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(10),
|
|
||||||
child: TextField(
|
|
||||||
controller: nameController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText:
|
|
||||||
'ex: Cool science project, Build a new game etc...',
|
|
||||||
border: OutlineInputBorder()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Divider(),
|
|
||||||
Column(children: [
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(0),
|
|
||||||
child: Text('Related Category')),
|
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.all(10),
|
|
||||||
padding: EdgeInsets.symmetric(
|
|
||||||
horizontal: 12, vertical: 1),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white10,
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
border: Border.all(
|
|
||||||
color: Colors.grey, width: 2)),
|
|
||||||
child: DropdownButton<String>(
|
|
||||||
dropdownColor: Colors.black,
|
|
||||||
iconSize: 30,
|
|
||||||
elevation: 10,
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
value: selectedCat,
|
|
||||||
isExpanded: true,
|
|
||||||
items: getCategoryNames()
|
|
||||||
.map<DropdownMenuItem<String>>(
|
|
||||||
(String value) {
|
|
||||||
return DropdownMenuItem<String>(
|
|
||||||
value: value,
|
|
||||||
child: Text(value),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
onChanged: (String? _value) {
|
|
||||||
setState(() {
|
|
||||||
selectedCat = _value!;
|
|
||||||
});
|
|
||||||
})),
|
|
||||||
Divider(),
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(10),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text('This project is',
|
|
||||||
style: TextStyle(fontSize: 18)),
|
|
||||||
FlutterSwitch(
|
|
||||||
width: 130,
|
|
||||||
height: 35.0,
|
|
||||||
valueFontSize: 15.0,
|
|
||||||
toggleSize: 25.0,
|
|
||||||
toggleColor: Colors.white70,
|
|
||||||
activeTextColor: Colors.white,
|
|
||||||
inactiveTextColor: Colors.white,
|
|
||||||
value: multiLine,
|
|
||||||
borderRadius: 30.0,
|
|
||||||
showOnOff: true,
|
|
||||||
activeText: 'Multi step',
|
|
||||||
inactiveText: 'Single step',
|
|
||||||
activeColor: Colors.deepOrange,
|
|
||||||
activeIcon: Icon(Icons.linear_scale,
|
|
||||||
color: Colors.orange),
|
|
||||||
inactiveIcon: Icon(Icons.check,
|
|
||||||
color: Colors.green),
|
|
||||||
inactiveColor: Colors.green,
|
|
||||||
onToggle: (val) {
|
|
||||||
setState(() {
|
|
||||||
multiLine = val;
|
|
||||||
print(
|
|
||||||
"Multi=Step : $multiLine");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
)
|
|
||||||
])),
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
))),
|
|
||||||
Container(
|
|
||||||
padding:
|
|
||||||
EdgeInsets.symmetric(vertical: 10, horizontal: 20),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Container(padding: EdgeInsets.all(0), child: Text('Project Name')),
|
||||||
flex: 5,
|
Container(
|
||||||
child: Container(
|
padding: EdgeInsets.all(10),
|
||||||
padding: EdgeInsets.symmetric(
|
child: TextField(
|
||||||
horizontal: 10, vertical: 0),
|
controller: nameController,
|
||||||
child: ElevatedButton(
|
decoration:
|
||||||
style: ElevatedButton.styleFrom(
|
InputDecoration(hintText: 'ex: Cool science project, Build a new game etc...', border: OutlineInputBorder()),
|
||||||
primary: Colors.red,
|
),
|
||||||
shape: StadiumBorder()),
|
),
|
||||||
onPressed: () {
|
Divider(),
|
||||||
setState(() {
|
Column(children: [
|
||||||
Navigator.pop(context);
|
Container(padding: EdgeInsets.all(0), child: Text('Related Category')),
|
||||||
});
|
Container(
|
||||||
},
|
margin: EdgeInsets.all(10),
|
||||||
child: Text('Cancel',
|
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 1),
|
||||||
style: TextStyle(fontSize: 20))))),
|
decoration: BoxDecoration(
|
||||||
Expanded(
|
color: Colors.white10, borderRadius: BorderRadius.circular(12), border: Border.all(color: Colors.grey, width: 2)),
|
||||||
flex: 6,
|
child: DropdownButton<String>(
|
||||||
child: Container(
|
dropdownColor: Colors.black,
|
||||||
padding: EdgeInsets.symmetric(
|
iconSize: 30,
|
||||||
horizontal: 10, vertical: 0),
|
elevation: 10,
|
||||||
child: ElevatedButton(
|
borderRadius: BorderRadius.circular(10),
|
||||||
style: ElevatedButton.styleFrom(
|
value: selectedCat,
|
||||||
primary: Colors.green,
|
isExpanded: true,
|
||||||
shape: StadiumBorder()),
|
items: getCategoryNames().map<DropdownMenuItem<String>>((String value) {
|
||||||
onPressed: () {
|
return DropdownMenuItem<String>(
|
||||||
// add_action();
|
value: value,
|
||||||
if (nameController.text.length > 3) {
|
child: Text(value),
|
||||||
Navigator.of(context).push(
|
);
|
||||||
MaterialPageRoute(
|
}).toList(),
|
||||||
builder: (context) =>
|
onChanged: (String? _value) {
|
||||||
NewProject2(
|
setState(() {
|
||||||
projectName:
|
selectedCat = _value!;
|
||||||
nameController.text,
|
});
|
||||||
)));
|
})),
|
||||||
} else {
|
Divider(),
|
||||||
showAlertDialog(context, 'Really?',
|
Container(
|
||||||
'Enter a valid name for this project!');
|
padding: EdgeInsets.all(10),
|
||||||
}
|
child: Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||||
},
|
Text('This project is', style: TextStyle(fontSize: 18)),
|
||||||
child: Text('Next',
|
FlutterSwitch(
|
||||||
style: TextStyle(fontSize: 20))))),
|
width: 130,
|
||||||
|
height: 35.0,
|
||||||
|
valueFontSize: 15.0,
|
||||||
|
toggleSize: 25.0,
|
||||||
|
toggleColor: Colors.white70,
|
||||||
|
activeTextColor: Colors.white,
|
||||||
|
inactiveTextColor: Colors.white,
|
||||||
|
value: multiLine,
|
||||||
|
borderRadius: 30.0,
|
||||||
|
showOnOff: true,
|
||||||
|
activeText: 'Multi step',
|
||||||
|
inactiveText: 'Single step',
|
||||||
|
activeColor: Colors.deepOrange,
|
||||||
|
activeIcon: Icon(Icons.linear_scale, color: Colors.orange),
|
||||||
|
inactiveIcon: Icon(Icons.check, color: Colors.green),
|
||||||
|
inactiveColor: Colors.green,
|
||||||
|
onToggle: (val) {
|
||||||
|
setState(() {
|
||||||
|
multiLine = val;
|
||||||
|
print("Multi=Step : $multiLine");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
])),
|
||||||
|
]),
|
||||||
],
|
],
|
||||||
))
|
))),
|
||||||
])));
|
Container(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 5,
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(primary: Colors.red, shape: StadiumBorder()),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
Navigator.pop(context);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Text('Cancel', style: TextStyle(fontSize: 20))))),
|
||||||
|
Expanded(
|
||||||
|
flex: 6,
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(primary: Colors.green, shape: StadiumBorder()),
|
||||||
|
onPressed: () {
|
||||||
|
// add_action();
|
||||||
|
if (nameController.text.length > 3) {
|
||||||
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
|
builder: (context) => NewProject2(
|
||||||
|
projectName: nameController.text,
|
||||||
|
)));
|
||||||
|
} else {
|
||||||
|
showAlertDialog(context, 'Really?', 'Enter a valid name for this project!');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text('Next', style: TextStyle(fontSize: 20))))),
|
||||||
|
],
|
||||||
|
))
|
||||||
|
])));
|
||||||
}
|
}
|
||||||
|
|
||||||
void pickColor(BuildContext context) => showDialog(
|
void pickColor(BuildContext context) => showDialog(
|
||||||
@@ -216,8 +180,7 @@ class _NewProjectState extends State<NewProject> {
|
|||||||
String catName = nameController.value.text;
|
String catName = nameController.value.text;
|
||||||
|
|
||||||
if (catName.length < 2) {
|
if (catName.length < 2) {
|
||||||
showAlertDialog(context, 'Category needs a name',
|
showAlertDialog(context, 'Category needs a name', 'Please enter a name for this category');
|
||||||
'Please enter a name for this category');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var hex = '#${pickerColor.value.toRadixString(16)}';
|
var hex = '#${pickerColor.value.toRadixString(16)}';
|
||||||
@@ -272,14 +235,8 @@ class NewProject2 extends StatefulWidget {
|
|||||||
class _NewProject2State extends State<NewProject2> {
|
class _NewProject2State extends State<NewProject2> {
|
||||||
bool knowEta = false;
|
bool knowEta = false;
|
||||||
int etaHours = 1;
|
int etaHours = 1;
|
||||||
List<ProjectStep> steps = [
|
List<ProjectStep> steps = [];
|
||||||
ProjectStep('Step 1', 3),
|
DateTime deadline = DateTime.now().add(Duration(days: 7));
|
||||||
ProjectStep('Step 2', 2),
|
|
||||||
ProjectStep('Ez Step', 1),
|
|
||||||
ProjectStep('Very hard', 10),
|
|
||||||
ProjectStep('Finishing', 5)
|
|
||||||
];
|
|
||||||
DateTime deadline = DateTime.now().add(Duration(days:7));
|
|
||||||
late String? projectName;
|
late String? projectName;
|
||||||
_NewProject2State({String? pName}) {
|
_NewProject2State({String? pName}) {
|
||||||
projectName = pName;
|
projectName = pName;
|
||||||
@@ -291,192 +248,352 @@ class _NewProject2State extends State<NewProject2> {
|
|||||||
appBar: AppBar(title: Text(projectName ?? 'Error')),
|
appBar: AppBar(title: Text(projectName ?? 'Error')),
|
||||||
body: Container(
|
body: Container(
|
||||||
height: MediaQuery.of(context).size.height,
|
height: MediaQuery.of(context).size.height,
|
||||||
child: Column(
|
child: Column(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||||
mainAxisSize: MainAxisSize.max,
|
SingleChildScrollView(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
scrollDirection: Axis.vertical,
|
||||||
children: [
|
child: Container(
|
||||||
SingleChildScrollView(
|
padding: EdgeInsets.fromLTRB(20, 50, 20, 50),
|
||||||
child: Container(
|
child: (multiLine)
|
||||||
padding: EdgeInsets.fromLTRB(20, 50, 20, 50),
|
? Column(
|
||||||
child: (multiLine)
|
children: [
|
||||||
? Column(
|
Column(
|
||||||
children: [
|
mainAxisSize: MainAxisSize.max,
|
||||||
Column(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisSize: MainAxisSize.max,
|
children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
Container(padding: EdgeInsets.all(10), child: Text('List your steps down')),
|
||||||
children: [
|
LimitedBox(
|
||||||
Container(
|
maxHeight: 300,
|
||||||
padding: EdgeInsets.all(10),
|
child: Container(
|
||||||
child: Text('List your steps down')
|
decoration: BoxDecoration(
|
||||||
),
|
borderRadius: BorderRadius.circular(20),
|
||||||
Container(
|
color: Colors.white10,
|
||||||
decoration: BoxDecoration(
|
),
|
||||||
borderRadius: BorderRadius.circular(20),
|
padding: EdgeInsets.all(10),
|
||||||
color: Colors.white10,
|
child: SingleChildScrollView(
|
||||||
),
|
scrollDirection: Axis.vertical,
|
||||||
padding: EdgeInsets.all(10),
|
|
||||||
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
scrollDirection: Axis.vertical,
|
|
||||||
child:Column(
|
|
||||||
children: printSteps(),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: Column(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(10),
|
|
||||||
child: Text(
|
|
||||||
"Estimated Time to reach target")),
|
|
||||||
Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
children: [
|
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
|
||||||
showDurationSelector(context,selectedHour: etaHours, onChange: (newVal){
|
|
||||||
etaHours = newVal.inHours;
|
|
||||||
knowEta=true;
|
|
||||||
setState(() {
|
|
||||||
|
|
||||||
});
|
|
||||||
print("Selected $newVal");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
child: Column(
|
||||||
color: (knowEta) ? Colors.green:Colors.white10,
|
children: printSteps(),
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(30),
|
|
||||||
),
|
),
|
||||||
child: Padding(
|
)),
|
||||||
padding: const EdgeInsets.symmetric(
|
),
|
||||||
horizontal: 50, vertical: 10),
|
),
|
||||||
child: Text("${(knowEta)?etaHours:'?'} Hours"),
|
SizedBox(
|
||||||
),
|
height: 5,
|
||||||
),
|
),
|
||||||
),InkWell(
|
Container(
|
||||||
onTap: (){
|
decoration: BoxDecoration(
|
||||||
knowEta=false;
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
color: Colors.white10,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
int maxProgress = 100;
|
||||||
|
steps.forEach((element) {
|
||||||
|
maxProgress -= element.progress;
|
||||||
|
});
|
||||||
|
if (maxProgress > 0) {
|
||||||
|
showStepEditor(context, maxProgress: maxProgress, onChange: (step) {
|
||||||
|
steps.add(step);
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
showAlertDialog(context, 'Progress full',
|
||||||
|
'Progress has already reached 100%, Cannot add more steps since the work is done');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Container(margin: EdgeInsets.all(10), child: Icon(Icons.add))),
|
||||||
|
InkWell(
|
||||||
|
enableFeedback: (steps.length > 0),
|
||||||
|
onTap: () {
|
||||||
|
int maxProgress = 100;
|
||||||
|
steps.forEach((element) {
|
||||||
|
maxProgress -= element.progress;
|
||||||
|
});
|
||||||
|
int stepProgress = steps[selectedStep].progress;
|
||||||
|
showStepEditor(context,
|
||||||
|
editStep: steps[selectedStep],
|
||||||
|
maxProgress: (maxProgress > stepProgress) ? maxProgress : stepProgress, onChange: (step) {
|
||||||
|
steps[selectedStep] = step;
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
margin: EdgeInsets.all(10),
|
||||||
|
child: Icon(Icons.edit, color: (steps.length > 0) ? Colors.white : Colors.grey))),
|
||||||
|
InkWell(onTap: () {
|
||||||
|
if(steps.length <= 0){return;}
|
||||||
|
steps.remove(steps[selectedStep]);
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
}, child: Container(margin: EdgeInsets.all(10), child: Icon(Icons.remove, color: (steps.length > 0) ? Colors.white : Colors.grey))),
|
||||||
child: Container(
|
],
|
||||||
decoration: BoxDecoration(
|
))
|
||||||
borderRadius: BorderRadius.circular(30),
|
],
|
||||||
color: (knowEta) ? Colors.white10 :Colors.redAccent
|
)
|
||||||
),
|
],
|
||||||
child: Padding(
|
)
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20,vertical: 10),
|
: Column(
|
||||||
child: Text("I have no idea"),
|
mainAxisSize: MainAxisSize.max,
|
||||||
)
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
),
|
children: [
|
||||||
)
|
Container(padding: EdgeInsets.all(10), child: Text("Estimated Time to reach target")),
|
||||||
],
|
Row(
|
||||||
),
|
mainAxisSize: MainAxisSize.max,
|
||||||
SizedBox(
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
height: 20,
|
children: [
|
||||||
),
|
InkWell(
|
||||||
Container(
|
onTap: () {
|
||||||
padding: EdgeInsets.all(8),
|
showDurationSelector(context, selectedHour: etaHours, onChange: (newVal) {
|
||||||
child: Text("Deadline")),
|
etaHours = newVal.inHours;
|
||||||
InkWell(
|
knowEta = true;
|
||||||
onTap: () {
|
setState(() {});
|
||||||
DatePicker.showDatePicker(
|
print("Selected $newVal");
|
||||||
context,
|
|
||||||
showTitleActions: true,
|
|
||||||
minTime: DateTime.now(),
|
|
||||||
theme: DatePickerTheme(backgroundColor: Colors.white),
|
|
||||||
onChanged: (date) {
|
|
||||||
// print('change $date');
|
|
||||||
}, onConfirm: (date) {
|
|
||||||
setState(() {
|
|
||||||
if(deadline.isAfter(DateTime.now())){
|
|
||||||
deadline=date;
|
|
||||||
}else{
|
|
||||||
showAlertDialog(context, 'Come on!', 'Deadline was passed?');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
currentTime: deadline,
|
|
||||||
locale: LocaleType.en);
|
|
||||||
setState(() {
|
|
||||||
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white10,
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(30),
|
|
||||||
),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 100, vertical: 10),
|
|
||||||
child: Text(DateFormat("MMMM dd yyyy").format(deadline)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
))),
|
|
||||||
|
|
||||||
Container(
|
|
||||||
padding:
|
|
||||||
EdgeInsets.symmetric(vertical: 10, horizontal: 20),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
flex: 5,
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.symmetric(
|
|
||||||
horizontal: 10, vertical: 0),
|
|
||||||
child: ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
primary: Colors.red,
|
|
||||||
shape: StadiumBorder()),
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
Navigator.pop(context);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Text('Back',
|
child: Container(
|
||||||
style: TextStyle(fontSize: 20))))),
|
decoration: BoxDecoration(
|
||||||
Expanded(
|
color: (knowEta) ? Colors.green : Colors.white10,
|
||||||
flex: 6,
|
borderRadius: BorderRadius.circular(30),
|
||||||
child: Container(
|
),
|
||||||
padding: EdgeInsets.symmetric(
|
child: Padding(
|
||||||
horizontal: 10, vertical: 0),
|
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 10),
|
||||||
child: ElevatedButton(
|
child: Text("${(knowEta) ? etaHours : '?'} Hours"),
|
||||||
style: ElevatedButton.styleFrom(
|
),
|
||||||
primary: Colors.green,
|
),
|
||||||
shape: StadiumBorder()),
|
),
|
||||||
onPressed: () {},
|
InkWell(
|
||||||
child: Text('Next',
|
onTap: () {
|
||||||
style: TextStyle(fontSize: 20))))),
|
knowEta = false;
|
||||||
],
|
setState(() {});
|
||||||
))
|
},
|
||||||
])));
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(30), color: (knowEta) ? Colors.white10 : Colors.redAccent),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||||
|
child: Text("I have no idea"),
|
||||||
|
)),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Container(padding: EdgeInsets.all(8), child: Text("Deadline")),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
DatePicker.showDatePicker(context,
|
||||||
|
showTitleActions: true,
|
||||||
|
minTime: DateTime.now(),
|
||||||
|
theme: DatePickerTheme(backgroundColor: Colors.white), onChanged: (date) {
|
||||||
|
// print('change $date');
|
||||||
|
}, onConfirm: (date) {
|
||||||
|
setState(() {
|
||||||
|
if (deadline.isAfter(DateTime.now())) {
|
||||||
|
deadline = date;
|
||||||
|
} else {
|
||||||
|
showAlertDialog(context, 'Come on!', 'Deadline was passed?');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, currentTime: deadline, locale: LocaleType.en);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white10,
|
||||||
|
borderRadius: BorderRadius.circular(30),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 100, vertical: 10),
|
||||||
|
child: Text(DateFormat("MMMM dd yyyy").format(deadline)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
))),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 5,
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(primary: Colors.red, shape: StadiumBorder()),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
Navigator.pop(context);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Text('Back', style: TextStyle(fontSize: 20))))),
|
||||||
|
Expanded(
|
||||||
|
flex: 6,
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(primary: Colors.green, shape: StadiumBorder()),
|
||||||
|
onPressed: () {},
|
||||||
|
child: Text('Next', style: TextStyle(fontSize: 20))))),
|
||||||
|
],
|
||||||
|
))
|
||||||
|
])));
|
||||||
}
|
}
|
||||||
|
|
||||||
int selectedStep = 0;
|
int selectedStep = 0;
|
||||||
List<Widget> printSteps(){
|
List<Widget> printSteps() {
|
||||||
List<Widget> _steps = [];
|
List<Widget> _steps = [];
|
||||||
|
|
||||||
for(int i=0; i < steps.)
|
for (int i = 0; i < steps.length; i++) {
|
||||||
_steps.add(
|
ProjectStep value = steps[i];
|
||||||
InkWell(onTap:(){se},child: Container(padding:EdgeInsets.symmetric(horizontal: 10,vertical: 2),child: Row(mainAxisSize:MainAxisSize.max,mainAxisAlignment: MainAxisAlignment.spaceBetween,children: [Text(value.stepName), Icon(Icons.timelapse), Text(value.eta.toString() + " Hours")],))));
|
_steps.add(InkWell(
|
||||||
|
onTap: () {
|
||||||
|
selectedStep = i;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
height: 30,
|
||||||
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), color: (selectedStep == i) ? Colors.black26 : null),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 2),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(flex: 4, child: Text(value.stepName)),
|
||||||
|
// Expanded(flex:1,child: Icon(Icons.timelapse)),
|
||||||
|
Expanded(flex: 1, child: Text("${value.progress}%")),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text(
|
||||||
|
value.eta.toString() + " Hours",
|
||||||
|
textAlign: TextAlign.end,
|
||||||
|
))
|
||||||
|
],
|
||||||
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
return _steps;
|
return _steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> showStepEditor(BuildContext context, {required Function(ProjectStep) onChange, ProjectStep? editStep, int? maxProgress}) async {
|
||||||
|
TextEditingController nameController = TextEditingController();
|
||||||
|
int progress = 1;
|
||||||
|
int eta = 1;
|
||||||
|
bool editing = false;
|
||||||
|
int _maxP = maxProgress ?? 100;
|
||||||
|
|
||||||
|
if (editStep != null) {
|
||||||
|
editing = true;
|
||||||
|
nameController.text = editStep.stepName;
|
||||||
|
eta = editStep.eta;
|
||||||
|
progress = editStep.progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
return showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false, // user must tap button!
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return StatefulBuilder(builder: (context, setState) {
|
||||||
|
setState(() {});
|
||||||
|
return AlertDialog(
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
|
||||||
|
backgroundColor: Color(0xFF1F1F1F),
|
||||||
|
title: Align(alignment: Alignment.center, child: Text((editing) ? 'Edit step' : 'Add new step')),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text('Step name'),
|
||||||
|
TextField(
|
||||||
|
controller: nameController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
filled: true, hintText: 'Collect resources', border: OutlineInputBorder(borderRadius: BorderRadius.circular(20))),
|
||||||
|
style: TextStyle(fontSize: 15),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text('Progress : $progress%'),
|
||||||
|
Slider(
|
||||||
|
min: 1,
|
||||||
|
max: _maxP.toDouble(),
|
||||||
|
value: progress.toDouble(),
|
||||||
|
onChanged: (val) {
|
||||||
|
progress = val.toInt();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
label: 'Progress',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(4.0),
|
||||||
|
child: Text('Estimated Time'),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
showDurationSelector(context, selectedHour: eta, onChange: (newVal) {
|
||||||
|
eta = newVal.inHours;
|
||||||
|
setState(() {});
|
||||||
|
print("Selected $newVal");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white10,
|
||||||
|
borderRadius: BorderRadius.circular(30),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 10),
|
||||||
|
child: Text("${eta} Hours"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Cancel'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
MaterialButton(
|
||||||
|
color: Colors.green,
|
||||||
|
child: Text((editing) ? 'Apply' : 'Add'),
|
||||||
|
onPressed: () {
|
||||||
|
ProjectStep step = ProjectStep(nameController.text, eta, progress);
|
||||||
|
onChange(step);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user