1
0
mirror of https://github.com/Uttkarsh-raj/Plannerly.git synced 2025-11-29 21:57:34 +02:00

urgents page done

This commit is contained in:
Uttkarsh-raj
2023-11-04 23:01:31 +05:30
parent c14b6bfbf1
commit dcad9560da
4 changed files with 607 additions and 537 deletions

View File

@@ -89,6 +89,16 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
urgent: task["urgent"],
);
}).toList();
emit(
HomeLoadedSuccessState(
regualarTasks,
urgentTasks,
totalUrgentTasks,
totalRegularTasks,
urgentTasksCompleted,
regularTasksCompleted,
),
);
} else {
emit(HomeUnableTofetchTasks(message: response["error"]));
}
@@ -96,17 +106,6 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
emit(HomeUnableTofetchTasks(message: "Unable to get the data."));
log(e.toString());
}
emit(
HomeLoadedSuccessState(
regualarTasks,
urgentTasks,
totalUrgentTasks,
totalRegularTasks,
urgentTasksCompleted,
regularTasksCompleted,
),
);
}
FutureOr<void> homeUrgentTasksViewAllClickedEvent(

View File

@@ -93,21 +93,7 @@ class _HomeScreenState extends State<HomeScreen> {
),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
// else if (state is HomeNewTaskAddedState) {
// var snackBar = SnackBar(
// backgroundColor: Colors.red[500],
// content: Text(
// "state.message",
// style: const TextStyle(
// fontSize: 16,
// color: AppColors.white,
// ),
// ),
// );
// ScaffoldMessenger.of(context).showSnackBar(snackBar);
// }
else if (state is HomeNewTaskAddedState) {
} else if (state is HomeNewTaskAddedState) {
showDialog(
context: context,
builder: (BuildContext context) {
@@ -238,450 +224,459 @@ class _HomeScreenState extends State<HomeScreen> {
padding: const EdgeInsets.all(14.0),
child: Stack(
children: [
SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: size.height * 0.03),
const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Icon(
Icons.menu_outlined,
size: 28,
color: AppColors.white,
),
Icon(
Icons.notifications_outlined,
size: 28,
color: AppColors.white,
),
],
),
SizedBox(height: size.height * 0.03),
const Text(
"Hi, Jason",
style: TextStyle(
color: AppColors.white,
fontSize: 18,
fontWeight: FontWeight.w300,
RefreshIndicator(
onRefresh: () async {
homeBloc.add(HomeInitialEvent());
},
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: size.height * 0.03),
const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Icon(
Icons.menu_outlined,
size: 28,
color: AppColors.white,
),
Icon(
Icons.notifications_outlined,
size: 28,
color: AppColors.white,
),
],
),
),
SizedBox(height: size.height * 0.01),
const Text(
"Be productivity today",
style: TextStyle(
color: AppColors.white,
fontSize: 24,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: size.height * 0.038),
Center(
child: Container(
decoration: BoxDecoration(
color: AppColors.backgroundLight,
borderRadius: BorderRadius.circular(18),
SizedBox(height: size.height * 0.03),
const Text(
"Hi, Jason",
style: TextStyle(
color: AppColors.white,
fontSize: 18,
fontWeight: FontWeight.w300,
),
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
const Expanded(
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Search task',
hintStyle: TextStyle(
color: AppColors.grey,
fontSize: 18,
),
SizedBox(height: size.height * 0.01),
const Text(
"Be productivity today",
style: TextStyle(
color: AppColors.white,
fontSize: 24,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: size.height * 0.038),
Center(
child: Container(
decoration: BoxDecoration(
color: AppColors.backgroundLight,
borderRadius: BorderRadius.circular(18),
),
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
const Expanded(
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Search task',
hintStyle: TextStyle(
color: AppColors.grey,
fontSize: 18,
),
contentPadding: EdgeInsets.all(10),
),
contentPadding: EdgeInsets.all(10),
),
),
),
IconButton(
onPressed: () {},
icon: Icon(
Icons.search_outlined,
size: 28,
color: AppColors.white.withOpacity(0.6),
IconButton(
onPressed: () {},
icon: Icon(
Icons.search_outlined,
size: 28,
color:
AppColors.white.withOpacity(0.6),
),
),
),
],
],
),
),
),
),
),
SizedBox(height: size.height * 0.025),
Center(
child: Container(
decoration: BoxDecoration(
color: AppColors.backgroundLight,
borderRadius: BorderRadius.circular(18),
),
child: Padding(
padding: const EdgeInsets.all(18.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
const Text(
"Task Progress",
style: TextStyle(
color: AppColors.white,
fontSize: 20,
fontWeight: FontWeight.w400,
SizedBox(height: size.height * 0.025),
Center(
child: Container(
decoration: BoxDecoration(
color: AppColors.backgroundLight,
borderRadius: BorderRadius.circular(18),
),
child: Padding(
padding: const EdgeInsets.all(18.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
const Text(
"Task Progress",
style: TextStyle(
color: AppColors.white,
fontSize: 20,
fontWeight: FontWeight.w400,
),
),
),
const SizedBox(height: 8),
Text(
"${state.totalRegularTasksCompleted + state.totalUrgentTasksCompleted}/${state.totalRegularTasks + state.totalUrgentTasks} task completed.",
style: TextStyle(
color: AppColors.white
.withOpacity(0.4),
fontSize: 14,
fontWeight: FontWeight.w400,
const SizedBox(height: 8),
Text(
"${state.totalRegularTasksCompleted + state.totalUrgentTasksCompleted}/${state.totalRegularTasks + state.totalUrgentTasks} task completed.",
style: TextStyle(
color: AppColors.white
.withOpacity(0.4),
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
),
],
),
),
Stack(
children: [
SizedBox(
height: size.height * 0.07,
width: size.height * 0.07,
child: CircularProgressIndicator(
value: ((state.totalRegularTasksCompleted +
state
.totalUrgentTasksCompleted) ==
0)
? 0
: (state.totalRegularTasksCompleted +
state
.totalUrgentTasksCompleted) /
(state.totalRegularTasks +
state.totalUrgentTasks),
strokeWidth: 7,
valueColor:
const AlwaysStoppedAnimation(
AppColors.buttonBlue),
backgroundColor: AppColors.white
.withOpacity(0.2),
color: AppColors.white,
),
],
),
SizedBox(
height: size.height * 0.07,
width: size.height * 0.07,
child: Center(
child: Text(
((state.totalRegularTasksCompleted +
),
Stack(
children: [
SizedBox(
height: size.height * 0.07,
width: size.height * 0.07,
child: CircularProgressIndicator(
value: ((state.totalRegularTasksCompleted +
state
.totalUrgentTasksCompleted) ==
0)
? "0%"
: "${((state.totalRegularTasksCompleted + state.totalUrgentTasksCompleted) / (state.totalRegularTasks + state.totalUrgentTasks) * 100).toStringAsFixed(1)}%",
style: TextStyle(
color: AppColors.white
.withOpacity(0.8),
fontSize: 18,
fontWeight: FontWeight.w600,
? 0
: (state.totalRegularTasksCompleted +
state
.totalUrgentTasksCompleted) /
(state.totalRegularTasks +
state
.totalUrgentTasks),
strokeWidth: 7,
valueColor:
const AlwaysStoppedAnimation(
AppColors.buttonBlue),
backgroundColor: AppColors.white
.withOpacity(0.2),
color: AppColors.white,
),
),
SizedBox(
height: size.height * 0.07,
width: size.height * 0.07,
child: Center(
child: Text(
((state.totalRegularTasksCompleted +
state
.totalUrgentTasksCompleted) ==
0)
? "0%"
: "${((state.totalRegularTasksCompleted + state.totalUrgentTasksCompleted) / (state.totalRegularTasks + state.totalUrgentTasks) * 100).toStringAsFixed(1)}%",
style: TextStyle(
color: AppColors.white
.withOpacity(0.8),
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
),
),
],
),
],
),
),
),
),
SizedBox(height: size.height * 0.04),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: size.height * 0.25,
width: size.width * 0.45,
decoration: BoxDecoration(
color: AppColors.backgroundLight,
borderRadius: BorderRadius.circular(18),
),
child: Padding(
padding: const EdgeInsets.all(5.0)
.copyWith(top: 12, bottom: 12),
child: Column(
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
const Text(
"Urgent Tasks Progress",
textAlign: TextAlign.center,
style: TextStyle(
color: AppColors.white,
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 20),
Center(
child: Stack(
children: [
SizedBox(
height: size.height * 0.1,
width: size.height * 0.1,
child:
CircularProgressIndicator(
value: (state
.totalUrgentTasksCompleted ==
0)
? 0
: (state.totalUrgentTasksCompleted /
state
.totalUrgentTasks),
strokeWidth: 7,
valueColor:
AlwaysStoppedAnimation(
Colors.red[400]),
backgroundColor: AppColors
.white
.withOpacity(0.2),
color: AppColors.white,
),
),
SizedBox(
height: size.height * 0.1,
width: size.height * 0.1,
child: Center(
child: Text(
(state.totalUrgentTasksCompleted ==
0)
? "0%"
: "${((state.totalUrgentTasksCompleted / state.totalUrgentTasks) * 100).toStringAsFixed(1)}%",
style: TextStyle(
color: AppColors.white
.withOpacity(0.8),
fontSize: 22,
fontWeight:
FontWeight.w600,
),
),
),
),
],
),
),
const SizedBox(height: 16),
Center(
child: Text(
"${state.totalUrgentTasksCompleted}/${state.totalUrgentTasks}",
style: TextStyle(
color: AppColors.white
.withOpacity(0.4),
fontSize: 22,
fontWeight: FontWeight.w400,
),
),
),
],
),
],
),
],
),
),
),
),
),
SizedBox(height: size.height * 0.04),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: size.height * 0.25,
width: size.width * 0.45,
decoration: BoxDecoration(
color: AppColors.backgroundLight,
borderRadius: BorderRadius.circular(18),
),
child: Padding(
padding: const EdgeInsets.all(5.0)
.copyWith(top: 12, bottom: 12),
child: Column(
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
const Text(
"Urgent Tasks Progress",
textAlign: TextAlign.center,
style: TextStyle(
color: AppColors.white,
fontSize: 18,
fontWeight: FontWeight.w500,
Container(
height: size.height * 0.25,
width: size.width * 0.45,
decoration: BoxDecoration(
color: AppColors.backgroundLight,
borderRadius: BorderRadius.circular(18),
),
child: Padding(
padding: const EdgeInsets.all(5.0)
.copyWith(top: 12, bottom: 12),
child: Column(
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
const Text(
"Regular Tasks Progress",
textAlign: TextAlign.center,
style: TextStyle(
color: AppColors.white,
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(height: 20),
Center(
child: Stack(
children: [
SizedBox(
height: size.height * 0.1,
width: size.height * 0.1,
child:
CircularProgressIndicator(
value: (state
.totalUrgentTasksCompleted ==
0)
? 0
: (state.totalUrgentTasksCompleted /
state
.totalUrgentTasks),
strokeWidth: 7,
valueColor:
AlwaysStoppedAnimation(
Colors.red[400]),
backgroundColor: AppColors
.white
.withOpacity(0.2),
color: AppColors.white,
),
),
SizedBox(
height: size.height * 0.1,
width: size.height * 0.1,
child: Center(
child: Text(
(state.totalUrgentTasksCompleted ==
const SizedBox(height: 20),
Center(
child: Stack(
children: [
SizedBox(
height: size.height * 0.1,
width: size.height * 0.1,
child:
CircularProgressIndicator(
value: (state
.totalRegularTasksCompleted ==
0)
? "0%"
: "${((state.totalUrgentTasksCompleted / state.totalUrgentTasks) * 100).toStringAsFixed(1)}%",
style: TextStyle(
color: AppColors.white
.withOpacity(0.8),
fontSize: 22,
fontWeight:
FontWeight.w600,
? 0
: (state.totalRegularTasksCompleted /
state
.totalRegularTasks),
strokeWidth: 7,
valueColor:
AlwaysStoppedAnimation(
Colors
.green[400]),
backgroundColor: AppColors
.white
.withOpacity(0.2),
color: AppColors.white,
),
),
SizedBox(
height: size.height * 0.1,
width: size.height * 0.1,
child: Center(
child: Text(
(state.totalRegularTasksCompleted ==
0)
? "0%"
: "${((state.totalRegularTasksCompleted / state.totalRegularTasks) * 100).toStringAsFixed(1)}%",
style: TextStyle(
color: AppColors.white
.withOpacity(0.8),
fontSize: 22,
fontWeight:
FontWeight.w600,
),
),
),
),
),
],
),
),
const SizedBox(height: 16),
Center(
child: Text(
"${state.totalUrgentTasksCompleted}/${state.totalUrgentTasks}",
style: TextStyle(
color: AppColors.white
.withOpacity(0.4),
fontSize: 22,
fontWeight: FontWeight.w400,
],
),
),
),
],
),
],
),
),
),
Container(
height: size.height * 0.25,
width: size.width * 0.45,
decoration: BoxDecoration(
color: AppColors.backgroundLight,
borderRadius: BorderRadius.circular(18),
),
child: Padding(
padding: const EdgeInsets.all(5.0)
.copyWith(top: 12, bottom: 12),
child: Column(
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
const Text(
"Regular Tasks Progress",
textAlign: TextAlign.center,
style: TextStyle(
color: AppColors.white,
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 20),
Center(
child: Stack(
children: [
SizedBox(
height: size.height * 0.1,
width: size.height * 0.1,
child:
CircularProgressIndicator(
value: (state
.totalRegularTasksCompleted ==
0)
? 0
: (state.totalRegularTasksCompleted /
state
.totalRegularTasks),
strokeWidth: 7,
valueColor:
AlwaysStoppedAnimation(
Colors.green[400]),
backgroundColor: AppColors
.white
.withOpacity(0.2),
color: AppColors.white,
),
const SizedBox(height: 16),
Center(
child: Text(
"${state.totalRegularTasksCompleted}/${state.totalRegularTasks}",
style: TextStyle(
color: AppColors.white
.withOpacity(0.4),
fontSize: 22,
fontWeight: FontWeight.w400,
),
SizedBox(
height: size.height * 0.1,
width: size.height * 0.1,
child: Center(
child: Text(
(state.totalRegularTasksCompleted ==
0)
? "0%"
: "${((state.totalRegularTasksCompleted / state.totalRegularTasks) * 100).toStringAsFixed(1)}%",
style: TextStyle(
color: AppColors.white
.withOpacity(0.8),
fontSize: 22,
fontWeight:
FontWeight.w600,
),
),
),
),
],
),
),
const SizedBox(height: 16),
Center(
child: Text(
"${state.totalRegularTasksCompleted}/${state.totalRegularTasks}",
style: TextStyle(
color: AppColors.white
.withOpacity(0.4),
fontSize: 22,
fontWeight: FontWeight.w400,
),
),
),
],
),
],
],
),
],
),
),
),
),
],
),
SizedBox(height: size.height * 0.045),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"Urgent Tasks",
style: TextStyle(
color: AppColors.white,
fontSize: 24,
fontWeight: FontWeight.w500,
),
),
TextButton(
onPressed: () {
homeBloc.add(
HomeUrgentTasksViewAllClickedEvent());
},
child: const Text(
'View all',
],
),
SizedBox(height: size.height * 0.045),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"Urgent Tasks",
style: TextStyle(
color: AppColors.buttonBlue,
fontSize: 14,
color: AppColors.white,
fontSize: 24,
fontWeight: FontWeight.w500,
),
),
),
],
),
ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => Task(
bloc: homeBloc,
task: successState.urgentTasks[index],
),
itemCount: (successState.urgentTasks.length < 2)
? successState.urgentTasks.length
: 2,
separatorBuilder:
(BuildContext context, int index) {
return const SizedBox(height: 15);
},
),
SizedBox(height: size.height * 0.04),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"Regular Tasks",
style: TextStyle(
color: AppColors.white,
fontSize: 24,
fontWeight: FontWeight.w500,
TextButton(
onPressed: () {
homeBloc.add(
HomeUrgentTasksViewAllClickedEvent());
},
child: const Text(
'View all',
style: TextStyle(
color: AppColors.buttonBlue,
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
],
),
ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => Task(
bloc: homeBloc,
task: successState.urgentTasks[index],
),
TextButton(
onPressed: () {
homeBloc.add(
HomeRegularTasksViewAllClickedEvent());
},
child: const Text(
'View all',
itemCount: (successState.urgentTasks.length < 2)
? successState.urgentTasks.length
: 2,
separatorBuilder:
(BuildContext context, int index) {
return const SizedBox(height: 15);
},
),
SizedBox(height: size.height * 0.04),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"Regular Tasks",
style: TextStyle(
color: AppColors.buttonBlue,
fontSize: 14,
color: AppColors.white,
fontSize: 24,
fontWeight: FontWeight.w500,
),
),
),
],
),
ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => Task(
bloc: homeBloc,
task: successState.regularTasks[index],
TextButton(
onPressed: () {
homeBloc.add(
HomeRegularTasksViewAllClickedEvent());
},
child: const Text(
'View all',
style: TextStyle(
color: AppColors.buttonBlue,
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
],
),
itemCount: (successState.regularTasks.length < 2)
? successState.regularTasks.length
: 2,
separatorBuilder:
(BuildContext context, int index) {
return const SizedBox(height: 15);
},
),
SizedBox(height: size.height * 0.1),
],
ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => Task(
bloc: homeBloc,
task: successState.regularTasks[index],
),
itemCount: (successState.regularTasks.length < 2)
? successState.regularTasks.length
: 2,
separatorBuilder:
(BuildContext context, int index) {
return const SizedBox(height: 15);
},
),
SizedBox(height: size.height * 0.1),
],
),
),
),
Positioned(

View File

@@ -1,140 +1,216 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:plannerly/bloc/home/home_bloc.dart';
import 'package:plannerly/screens/widgets/task.dart';
import 'package:plannerly/utils/colors/colors.dart';
class UrgentTasks extends StatelessWidget {
class UrgentTasks extends StatefulWidget {
const UrgentTasks({super.key});
@override
State<UrgentTasks> createState() => _UrgentTasksState();
}
class _UrgentTasksState extends State<UrgentTasks> {
final HomeBloc homeBloc = HomeBloc();
@override
void initState() {
homeBloc.add(HomeInitialEvent());
super.initState();
}
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
backgroundColor: AppColors.backgroundDark,
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(14.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: size.height * 0.03),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
IconButton(
onPressed: () {},
icon: const Icon(
Icons.arrow_back_outlined,
color: AppColors.white,
size: 30,
),
),
SizedBox(width: size.width * 0.2),
const Text(
"Urgent Tasks",
style: TextStyle(
color: AppColors.white,
fontSize: 24,
fontWeight: FontWeight.w500,
),
),
],
),
SizedBox(height: size.height * 0.045),
Center(
child: Container(
decoration: BoxDecoration(
color: AppColors.backgroundLight,
borderRadius: BorderRadius.circular(18),
),
return BlocConsumer<HomeBloc, HomeState>(
bloc: homeBloc,
listenWhen: (previous, current) => current is HomeActionState,
buildWhen: (previous, current) => current is! HomeActionState,
listener: (context, state) {
if (state is HomePopState) {
Navigator.of(context).pop();
}
},
builder: (context, state) {
switch (state.runtimeType) {
case HomeLoadingState:
return const Scaffold(
backgroundColor: AppColors.backgroundDark,
body: Center(child: CircularProgressIndicator()),
);
case HomeLoadedSuccessState:
final successState = state as HomeLoadedSuccessState;
return Scaffold(
backgroundColor: AppColors.backgroundDark,
body: RefreshIndicator(
onRefresh: () async {
homeBloc.add(HomeInitialEvent());
},
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Padding(
padding: const EdgeInsets.all(18.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
padding: const EdgeInsets.all(14.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"Urgent Task Progress",
style: TextStyle(
color: AppColors.white,
fontSize: 20,
fontWeight: FontWeight.w400,
),
),
const SizedBox(height: 8),
Text(
"30/40 task completed.",
style: TextStyle(
color: AppColors.white.withOpacity(0.4),
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
],
),
),
Stack(
SizedBox(height: size.height * 0.03),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
height: size.height * 0.07,
width: size.height * 0.07,
child: CircularProgressIndicator(
value: 0.8,
strokeWidth: 7,
valueColor:
AlwaysStoppedAnimation(Colors.red[400]),
backgroundColor:
AppColors.white.withOpacity(0.2),
IconButton(
onPressed: () {
homeBloc.add(
HomeAddNewTaskCloseButtonClickedEvent());
},
icon: const Icon(
Icons.arrow_back_outlined,
color: AppColors.white,
semanticsValue: "80%",
size: 30,
),
),
SizedBox(
height: size.height * 0.07,
width: size.height * 0.07,
child: Center(
child: Text(
"80%",
style: TextStyle(
color: AppColors.white.withOpacity(0.8),
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
SizedBox(width: size.width * 0.2),
const Text(
"Urgent Tasks",
style: TextStyle(
color: AppColors.white,
fontSize: 24,
fontWeight: FontWeight.w500,
),
),
],
),
SizedBox(height: size.height * 0.045),
Center(
child: Container(
decoration: BoxDecoration(
color: AppColors.backgroundLight,
borderRadius: BorderRadius.circular(18),
),
child: Padding(
padding: const EdgeInsets.all(18.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
const Text(
"Urgent Task Progress",
style: TextStyle(
color: AppColors.white,
fontSize: 20,
fontWeight: FontWeight.w400,
),
),
const SizedBox(height: 8),
Text(
"${successState.totalUrgentTasksCompleted}/${successState.totalUrgentTasks} task completed.",
style: TextStyle(
color: AppColors.white
.withOpacity(0.4),
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
],
),
),
Stack(
children: [
SizedBox(
height: size.height * 0.073,
width: size.height * 0.073,
child: CircularProgressIndicator(
value: (successState
.totalUrgentTasksCompleted ==
0)
? 0
: (successState
.totalUrgentTasksCompleted /
successState
.totalUrgentTasks),
strokeWidth: 7,
valueColor: AlwaysStoppedAnimation(
Colors.red[400]),
backgroundColor:
AppColors.white.withOpacity(0.2),
color: AppColors.white,
),
),
SizedBox(
height: size.height * 0.073,
width: size.height * 0.073,
child: Center(
child: Text(
(successState
.totalUrgentTasksCompleted ==
0)
? "0%"
: "${((successState.totalUrgentTasksCompleted / successState.totalUrgentTasks) * 100).toStringAsFixed(1)}%",
style: TextStyle(
color: AppColors.white
.withOpacity(0.8),
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
),
),
],
),
],
),
),
),
),
SizedBox(height: size.height * 0.03),
const Text(
"Urgent Tasks",
style: TextStyle(
color: AppColors.white,
fontSize: 24,
fontWeight: FontWeight.w500,
),
),
ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => Task(
task: successState.urgentTasks[index],
bloc: homeBloc,
),
itemCount: successState.totalUrgentTasks,
separatorBuilder: (BuildContext context, int index) {
return const SizedBox(height: 15);
},
),
SizedBox(height: size.height * 0.04),
],
),
),
),
),
SizedBox(height: size.height * 0.03),
const Text(
"Urgent Tasks",
style: TextStyle(
color: AppColors.white,
fontSize: 24,
fontWeight: FontWeight.w500,
);
case HomeLoadedErrorState:
return Scaffold(
backgroundColor: AppColors.backgroundDark,
body: Center(
child: Text(
'Some error ocurred!',
style: TextStyle(
fontSize: 20,
color: AppColors.white.withOpacity(0.3),
),
),
),
// ListView.separated(
// shrinkWrap: true,
// physics: const NeverScrollableScrollPhysics(),
// itemBuilder: (context, index) => Task(),
// itemCount: 5,
// separatorBuilder: (BuildContext context, int index) {
// return SizedBox(height: 15);
// },
// ),
SizedBox(height: size.height * 0.04),
],
),
),
),
);
default:
return SizedBox();
}
},
);
}
}

View File

@@ -87,7 +87,7 @@ class _TaskState extends State<Task> {
),
),
IconButton(
onPressed: () {
onPressed: () async {
widget.bloc.add(
HomeTasksDeleteButtonClicked(
taskDeleted: widget.task,