No cache mod for web and other platforms
This commit is contained in:
@@ -6,6 +6,7 @@ import 'User.dart' as User;
|
||||
import 'Data.dart';
|
||||
import 'package:flutter_switch/flutter_switch.dart';
|
||||
import 'DateTimeRangeCustom.dart';
|
||||
import 'Dialogs.dart';
|
||||
|
||||
DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
DateFormat durationFormat = DateFormat("HH:mm:ss");
|
||||
@@ -145,7 +146,7 @@ class _NewProjectState extends State<NewProject> {
|
||||
projectName: nameController.text,
|
||||
)));
|
||||
} else {
|
||||
showAlertDialog(context, 'Really?', 'Enter a valid name for this project!');
|
||||
Dialogs.showAlertDialog(context, 'Really?', 'Enter a valid name for this project!');
|
||||
}
|
||||
},
|
||||
child: Text('Next', style: TextStyle(fontSize: 20))))),
|
||||
@@ -180,7 +181,7 @@ class _NewProjectState extends State<NewProject> {
|
||||
String catName = nameController.value.text;
|
||||
|
||||
if (catName.length < 2) {
|
||||
showAlertDialog(context, 'Category needs a name', 'Please enter a name for this category');
|
||||
Dialogs.showAlertDialog(context, 'Category needs a name', 'Please enter a name for this category');
|
||||
return;
|
||||
}
|
||||
var hex = '#${pickerColor.value.toRadixString(16)}';
|
||||
@@ -198,32 +199,7 @@ String _printDuration(Duration duration) {
|
||||
return "${twoDigits(duration.inHours)}:$twoDigitMinutes:$twoDigitSeconds";
|
||||
}
|
||||
|
||||
showAlertDialog(BuildContext context, String title, String message) {
|
||||
// set up the button
|
||||
Widget okButton = TextButton(
|
||||
child: Text("OK"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
|
||||
// set up the AlertDialog
|
||||
AlertDialog alert = AlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
okButton,
|
||||
],
|
||||
);
|
||||
|
||||
// show the dialog
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return alert;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class NewProject2 extends StatefulWidget {
|
||||
NewProject2({Key? key, this.projectName}) : super(key: key);
|
||||
@@ -244,6 +220,13 @@ class _NewProject2State extends State<NewProject2> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
List<Widget> stepsWidgets = printSteps();
|
||||
int totalHours = 0;
|
||||
steps.forEach((element) {
|
||||
totalHours+=element.eta;
|
||||
});
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(projectName ?? 'Error')),
|
||||
body: Container(
|
||||
@@ -261,22 +244,50 @@ class _NewProject2State extends State<NewProject2> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(padding: EdgeInsets.all(10), child: Text('List your steps down')),
|
||||
LimitedBox(
|
||||
maxHeight: 300,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
color: Colors.white10,
|
||||
SizedBox(height: 20,),
|
||||
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
|
||||
height: 30,
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: Colors.white10),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(flex: 4, child: Text(' Name')),
|
||||
// Expanded(flex:1,child: Icon(Icons.timelapse)),
|
||||
Expanded(flex: 2, child: Text("Progress")),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text('ETA',textAlign: TextAlign.end,))
|
||||
],
|
||||
)),
|
||||
Divider(),
|
||||
LimitedBox(
|
||||
maxHeight: 300,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
color: Colors.white10,
|
||||
),
|
||||
padding: EdgeInsets.all(10),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: (stepsWidgets.isNotEmpty) ? Container(
|
||||
child: Column(
|
||||
children: stepsWidgets,
|
||||
),
|
||||
) : Container(
|
||||
|
||||
height: 20,
|
||||
child: Text('Click on + to add steps')
|
||||
)),
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.all(10),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Container(
|
||||
child: Column(
|
||||
children: printSteps(),
|
||||
),
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
@@ -302,7 +313,7 @@ class _NewProject2State extends State<NewProject2> {
|
||||
setState(() {});
|
||||
});
|
||||
} else {
|
||||
showAlertDialog(context, 'Progress full',
|
||||
Dialogs.showAlertDialog(context, 'Progress full',
|
||||
'Progress has already reached 100%, Cannot add more steps since the work is done');
|
||||
}
|
||||
},
|
||||
@@ -332,8 +343,52 @@ class _NewProject2State extends State<NewProject2> {
|
||||
|
||||
});
|
||||
}, child: Container(margin: EdgeInsets.all(10), child: Icon(Icons.remove, color: (steps.length > 0) ? Colors.white : Colors.grey))),
|
||||
|
||||
],
|
||||
))
|
||||
)),
|
||||
SizedBox(height: 20,),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 40,vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
color: Colors.black26,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text("Total time : $totalHours Hours"),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 30,),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
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 {
|
||||
Dialogs.showAlertDialog(context, 'Come on!', 'Deadline was passed?');
|
||||
}
|
||||
});
|
||||
}, currentTime: deadline, locale: LocaleType.en);
|
||||
},
|
||||
child:Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 40,vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
color: Colors.white10,
|
||||
),
|
||||
child:Text(DateFormat("MMMM dd yyyy").format(deadline)),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
@@ -398,7 +453,7 @@ class _NewProject2State extends State<NewProject2> {
|
||||
if (deadline.isAfter(DateTime.now())) {
|
||||
deadline = date;
|
||||
} else {
|
||||
showAlertDialog(context, 'Come on!', 'Deadline was passed?');
|
||||
Dialogs.showAlertDialog(context, 'Come on!', 'Deadline was passed?');
|
||||
}
|
||||
});
|
||||
}, currentTime: deadline, locale: LocaleType.en);
|
||||
@@ -452,6 +507,26 @@ class _NewProject2State extends State<NewProject2> {
|
||||
List<Widget> printSteps() {
|
||||
List<Widget> _steps = [];
|
||||
|
||||
Widget title=Container(
|
||||
|
||||
height: 30,
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: Colors.white10),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(flex: 4, child: Text('Name')),
|
||||
// Expanded(flex:1,child: Icon(Icons.timelapse)),
|
||||
Expanded(flex: 2, child: Text("Progress")),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text('ETA',textAlign: TextAlign.end,))
|
||||
],
|
||||
));
|
||||
|
||||
// _steps.add(title);
|
||||
// _steps.add(Divider());
|
||||
for (int i = 0; i < steps.length; i++) {
|
||||
ProjectStep value = steps[i];
|
||||
_steps.add(InkWell(
|
||||
@@ -585,6 +660,8 @@ class _NewProject2State extends State<NewProject2> {
|
||||
color: Colors.green,
|
||||
child: Text((editing) ? 'Apply' : 'Add'),
|
||||
onPressed: () {
|
||||
if(nameController.text.length <=0){Dialogs.showAlertDialog(context, 'No name?', 'Please enter a name for this step... Pleeeaassee...'); return;}
|
||||
|
||||
ProjectStep step = ProjectStep(nameController.text, eta, progress);
|
||||
onChange(step);
|
||||
Navigator.of(context).pop();
|
||||
|
||||
Reference in New Issue
Block a user