Projects Details (fixed)
This commit is contained in:
@@ -1,58 +1,139 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:tasktracker/Projects.dart';
|
||||
import 'User.dart' as User;
|
||||
|
||||
import 'Data.dart';
|
||||
|
||||
class ProjectDetails extends StatefulWidget {
|
||||
const ProjectDetails({Key? key}) : super(key: key);
|
||||
|
||||
ProjectDetails({Key? key, required this.project}) : super(key: key);
|
||||
Project project;
|
||||
@override
|
||||
State<ProjectDetails> createState() => _ProjectDetailsState();
|
||||
State<ProjectDetails> createState() => _ProjectDetailsState(project);
|
||||
}
|
||||
|
||||
DateTime justDate(DateTime dateTime){
|
||||
return DateTime(dateTime.year, dateTime.month, dateTime.day);
|
||||
}
|
||||
|
||||
class _ProjectDetailsState extends State<ProjectDetails> {
|
||||
|
||||
_ProjectDetailsState(this.project);
|
||||
Project project ;
|
||||
int etaHours = 0;
|
||||
List<ProjectChartData> chartData = [];
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
List<Widget> stepsWidgets = printSteps();
|
||||
etaHours =0;
|
||||
steps.forEach((element) {
|
||||
project.steps.forEach((element) {
|
||||
etaHours+=element.eta;
|
||||
});
|
||||
|
||||
|
||||
int lastIndex = -1;
|
||||
int lastDay = -1;
|
||||
User.activities.forEach((element) {
|
||||
if(element.taskType.relatedProject == project){
|
||||
if(lastDay != element.startTime.day){
|
||||
chartData.add(ProjectChartData(justDate(element.startTime), element.endTime.difference(element.startTime).inMinutes));
|
||||
lastIndex++;
|
||||
lastDay = element.startTime.day;
|
||||
}else{
|
||||
chartData[lastIndex].timeSpent += element.endTime.difference(element.startTime).inMinutes;
|
||||
}
|
||||
}
|
||||
});
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Row(
|
||||
children: [
|
||||
FaIcon(FontAwesomeIcons.projectDiagram),
|
||||
SizedBox(width: 15,),
|
||||
Text('This app'),
|
||||
Text(project.name),
|
||||
],
|
||||
)),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Card(
|
||||
|
||||
Card(child: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,
|
||||
),
|
||||
Card(child: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Column(
|
||||
children: [
|
||||
Text("Time Management"),
|
||||
SizedBox(height: 10,),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(flex:1,child: Text('ETA :',textAlign: TextAlign.end,)),
|
||||
Expanded(flex: 3,child: Text( '${etaHours} Hours',textAlign: TextAlign.center,),)
|
||||
],
|
||||
),
|
||||
),
|
||||
) : Container(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(flex:1,child: Text('Deadline :',textAlign: TextAlign.end,)),
|
||||
Expanded(flex: 3,child: Text( '${DateFormat('yyyy-MM-dd').format(project.deadline)}',textAlign: TextAlign.center,),)
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(flex:1,child: Text('Remaining :',textAlign: TextAlign.end,)),
|
||||
Expanded(flex: 3,child: Text( '${durationToDays(project.deadline.difference(DateTime.now()))}',textAlign: TextAlign.center,),)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
height: 20,
|
||||
child: Text('Click on + to add steps')
|
||||
)),
|
||||
],
|
||||
),
|
||||
)),
|
||||
Card(child:Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Text('Steps',),
|
||||
LimitedBox(
|
||||
maxHeight: 300,
|
||||
child: Container(
|
||||
|
||||
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')
|
||||
)),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 40,vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
color: Colors.black26,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text("Total time : $etaHours Hours"),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),),
|
||||
|
||||
@@ -113,8 +194,8 @@ class _ProjectDetailsState extends State<ProjectDetails> {
|
||||
|
||||
// _steps.add(title);
|
||||
// _steps.add(Divider());
|
||||
for (int i = 0; i < steps.length; i++) {
|
||||
ProjectStep value = steps[i];
|
||||
for (int i = 0; i < project.steps.length; i++) {
|
||||
ProjectStep value = project.steps[i];
|
||||
_steps.add(InkWell(
|
||||
child: Container(
|
||||
height: 30,
|
||||
@@ -140,3 +221,12 @@ class _ProjectDetailsState extends State<ProjectDetails> {
|
||||
return _steps;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ProjectChartData{
|
||||
|
||||
ProjectChartData(this.day, this.timeSpent);
|
||||
|
||||
DateTime day;
|
||||
int timeSpent;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ class _ProjectsState extends State<Projects> {
|
||||
itemBuilder: (context,index){
|
||||
return InkWell(
|
||||
onTap: (){
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context)=> ProjectDetails()));
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context)=> ProjectDetails(project: User.projects[index],)));
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(color: Colors.black26, borderRadius: BorderRadius.circular(10)),
|
||||
@@ -225,6 +225,9 @@ class _ProjectsState extends State<Projects> {
|
||||
duration: const Duration(milliseconds: 200),
|
||||
height: 100,
|
||||
child: InkWell(
|
||||
onTap: (){
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context)=> ProjectDetails(project: project,)));
|
||||
},
|
||||
onLongPress: (){
|
||||
Dialogs.showProjectDetails(project);
|
||||
},
|
||||
|
||||
@@ -129,7 +129,7 @@ class _SignInPageState extends State<SignInPage> {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
(false) ? ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Colors.red),
|
||||
onPressed: () {
|
||||
@@ -139,7 +139,7 @@ class _SignInPageState extends State<SignInPage> {
|
||||
const offlineLoginPage()));
|
||||
},
|
||||
child: Text('Use Offline',
|
||||
style: TextStyle(fontSize: 20))),
|
||||
style: TextStyle(fontSize: 20))) : Container(),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
|
||||
@@ -221,8 +221,10 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
hourglassColors.add(element.color);
|
||||
hourglassStops.add(stopsTotal+thisStop);
|
||||
stopsTotal += thisStop;
|
||||
if(i < hourglassCatData.length-1){hourglassColors.add(hourglassCatData[i+1].color);
|
||||
hourglassStops.add(stopsTotal+thisStop + 0.001);}
|
||||
if(i < hourglassCatData.length-1){
|
||||
hourglassColors.add(hourglassCatData[i+1].color);
|
||||
hourglassStops.add(stopsTotal+thisStop + 0.001);
|
||||
}
|
||||
}
|
||||
print('total Stops ${stopsTotal}');
|
||||
print('maxT: $hourglassTotalTime');
|
||||
|
||||
Reference in New Issue
Block a user