Project Steps completion

This commit is contained in:
Sewmina
2022-03-28 07:02:55 +05:30
parent bfe3c7fa5d
commit 0763820b97
4 changed files with 468 additions and 169 deletions

View File

@@ -1,5 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -186,6 +187,81 @@ class Dialogs{
}
}
static completeStepDialog(Project project,Function(DateTime) onComplete, ProjectStep step) async{
context=navigatorKey.currentContext;
DateTime finishedDate = DateTime.now();
DateFormat dateFormat = DateFormat('yyyy-MM-dd');
if(context!=null) {
// return StatefulBuilder(builder: (context, setState) {
return showDialog(
context: context!,
builder: (BuildContext context) {
return StatefulBuilder(builder: (context, setState)
{
return AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
backgroundColor: Color(0xFF1C1C1C),
title: Text('Completed ${step.stepName}?'),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('When did you complete?'),
SizedBox(height: 20,),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () {
DatePicker.showDatePicker(context,
showTitleActions: true,
theme: DatePickerTheme(), onChanged: (date) {
// print('change $date');
}, onConfirm: (date) {
setState(() {
finishedDate = date;
});
}, currentTime: finishedDate, locale: LocaleType.en);
setState(() {});
},
child: Container(
decoration: BoxDecoration(
color: Colors.black26,
borderRadius: BorderRadius.circular(15)
),
padding: EdgeInsets.symmetric(horizontal: 25, vertical: 10),
child: Text((dateFormat.format(finishedDate) ==dateFormat.format(DateTime.now())) ? 'Today' : dateFormat.format(finishedDate), style: TextStyle(color: Colors.blue),),
),
),
],
)
],
),
actions: [
MaterialButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('No', style: TextStyle(color: Colors.red)),
),
MaterialButton(
color: Colors.green,
onPressed: () {
User.UserOperations.CompleteProjectStep(project, step, finishedDate);
Navigator.of(context).pop();
},
child: Text('Complete', style: TextStyle(color: Colors.white)),
),
],
);
});
}
);
}else{
print('context is null');
}
}
static hide(){
showing=false;
Navigator.of(navigatorKey.currentContext!).popUntil((route){