From fbbedcce395100c13a54d44bb8a032f0da9f4d68 Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Tue, 31 Oct 2023 20:22:44 +0530 Subject: [PATCH] added blocs for completed and delete buttons --- .../plannerly/lib/bloc/home/home_bloc.dart | 74 ++ .../plannerly/lib/bloc/home/home_event.dart | 7 + .../plannerly/lib/bloc/home/home_state.dart | 8 +- Frontend/plannerly/lib/models/task_model.dart | 21 + Frontend/plannerly/lib/models/user_model.dart | 19 + Frontend/plannerly/lib/screens/home/home.dart | 768 ++++++++++-------- .../regular_tasks/regular_tasks_page.dart | 139 ++++ .../urgent_tasks/urgent_tasks_page.dart | 140 ++++ .../plannerly/lib/screens/widgets/task.dart | 27 +- 9 files changed, 843 insertions(+), 360 deletions(-) create mode 100644 Frontend/plannerly/lib/models/task_model.dart create mode 100644 Frontend/plannerly/lib/models/user_model.dart create mode 100644 Frontend/plannerly/lib/screens/regular_tasks/regular_tasks_page.dart create mode 100644 Frontend/plannerly/lib/screens/urgent_tasks/urgent_tasks_page.dart diff --git a/Frontend/plannerly/lib/bloc/home/home_bloc.dart b/Frontend/plannerly/lib/bloc/home/home_bloc.dart index bdb5cc8..5e05e36 100644 --- a/Frontend/plannerly/lib/bloc/home/home_bloc.dart +++ b/Frontend/plannerly/lib/bloc/home/home_bloc.dart @@ -2,24 +2,98 @@ import 'dart:async'; import 'package:bloc/bloc.dart'; import 'package:meta/meta.dart'; +import 'package:plannerly/models/task_model.dart'; part 'home_event.dart'; part 'home_state.dart'; class HomeBloc extends Bloc { HomeBloc() : super(HomeInitial()) { + on(homeInitialEvent); on(homeUrgentTasksViewAllClickedEvent); on( homeRegularTasksViewAllClickedEvent); + on(homeTasksCompletedButtonClicked); + on(homeTasksDeleteButtonClicked); + } + + FutureOr homeInitialEvent( + HomeInitialEvent event, Emitter emit) async { + emit(HomeLoadingState()); + await Future.delayed(Duration(seconds: 3)); + List regualarTasks = [ + TaskModel( + taskId: "000000000000000000000000", + userId: "653a2f71e2330ac369e93c9b", + title: "Task 3", + description: "This is the First task of regular type.", + time: "10:00:00", + date: "24/10/2023", + completed: false, + urgent: false, + ), + TaskModel( + taskId: "000000000000000000000001", + userId: "653a2f71e2330ac369e93c9b", + title: "Task 4", + description: "This is the Second task of regular type.", + time: "10:00:00", + date: "25/10/2023", + completed: false, + urgent: false, + ) + ]; + List urgentTasks = [ + TaskModel( + taskId: "000000000000000000000000", + userId: "653a2f71e2330ac369e93c9b", + title: "Task 1", + description: + "This is the First taska.sfshlfhslfhlshfljsf.sdkjfjhahfksahihas", + time: "10:00:00", + date: "24/10/2023", + completed: false, + urgent: true, + ), + TaskModel( + taskId: "000000000000000000000001", + userId: "653a2f71e2330ac369e93c9b", + title: "Task 2", + description: "This is the Second task", + time: "10:00:00", + date: "25/10/2023", + completed: false, + urgent: true, + ) + ]; + + emit( + HomeLoadedSuccessState( + regualarTasks, + urgentTasks, + ), + ); } FutureOr homeUrgentTasksViewAllClickedEvent( HomeUrgentTasksViewAllClickedEvent event, Emitter emit) { print('View Urgent Page'); + emit(HomeNavigateToUrgentTasksPage()); } FutureOr homeRegularTasksViewAllClickedEvent( HomeRegularTasksViewAllClickedEvent event, Emitter emit) { print('View Regular Page'); + emit(HomeNavigateToRegularTasksPage()); + } + + FutureOr homeTasksCompletedButtonClicked( + HomeTasksCompletedButtonClicked event, Emitter emit) { + print("Task completed button clicked"); + } + + FutureOr homeTasksDeleteButtonClicked( + HomeTasksDeleteButtonClicked event, Emitter emit) { + print("Task deleted button clicked"); } } diff --git a/Frontend/plannerly/lib/bloc/home/home_event.dart b/Frontend/plannerly/lib/bloc/home/home_event.dart index fe60a8f..c4df0f9 100644 --- a/Frontend/plannerly/lib/bloc/home/home_event.dart +++ b/Frontend/plannerly/lib/bloc/home/home_event.dart @@ -3,6 +3,13 @@ part of 'home_bloc.dart'; @immutable sealed class HomeEvent {} +class HomeInitialEvent + extends HomeEvent {} // the one event that is called as soon as the app is opened i.e. the first thing to be called + class HomeUrgentTasksViewAllClickedEvent extends HomeEvent {} class HomeRegularTasksViewAllClickedEvent extends HomeEvent {} + +class HomeTasksDeleteButtonClicked extends HomeEvent {} + +class HomeTasksCompletedButtonClicked extends HomeEvent {} diff --git a/Frontend/plannerly/lib/bloc/home/home_state.dart b/Frontend/plannerly/lib/bloc/home/home_state.dart index 2a948c3..fff4d26 100644 --- a/Frontend/plannerly/lib/bloc/home/home_state.dart +++ b/Frontend/plannerly/lib/bloc/home/home_state.dart @@ -10,7 +10,13 @@ final class HomeInitial extends HomeState {} class HomeLoadingState extends HomeState {} -class HomeLoadedSuccessState extends HomeState {} +class HomeLoadedSuccessState extends HomeState { + final List regularTasks; + final List urgentTasks; + HomeLoadedSuccessState(this.regularTasks, this.urgentTasks); +} + +class HomeLoadedErrorState extends HomeState {} class HomeErrorState extends HomeState {} diff --git a/Frontend/plannerly/lib/models/task_model.dart b/Frontend/plannerly/lib/models/task_model.dart new file mode 100644 index 0000000..5ec6bba --- /dev/null +++ b/Frontend/plannerly/lib/models/task_model.dart @@ -0,0 +1,21 @@ +// ignore_for_file: public_member_api_docs, sort_constructors_first +class TaskModel { + final String taskId; + final String userId; + final String title; + final String description; + final String time; + final String date; + final bool completed; + final bool urgent; + TaskModel({ + required this.taskId, + required this.userId, + required this.title, + required this.description, + required this.time, + required this.date, + required this.completed, + required this.urgent, + }); +} diff --git a/Frontend/plannerly/lib/models/user_model.dart b/Frontend/plannerly/lib/models/user_model.dart new file mode 100644 index 0000000..bde5d14 --- /dev/null +++ b/Frontend/plannerly/lib/models/user_model.dart @@ -0,0 +1,19 @@ +class User { + // ID primitive.ObjectID `bson:"_id"` + // First_name *string `json:"first_name" validate:"required,min=2,max=100"` + // Last_name *string `json:"last_name" validate:"required,min=2,max=100"` + // Password *string `json:"password" validate:"required,min=6"` + // Email *string `json:"email" validate:"email,required"` + // Phone *string `json:"phone" validate:"required"` + // Token *string `json:"token"` + // Refresh_token *string `json:"refresh_token"` + // Created_at time.Time `json:"created_at"` + // Updated_at time.Time `json:"updated_at"` + // User_id string `json:"user_id"` + String? firstName; + String? lastName; + String? email; + String? token; + String? phone; + String? userId; +} diff --git a/Frontend/plannerly/lib/screens/home/home.dart b/Frontend/plannerly/lib/screens/home/home.dart index 7ec3e45..2d89afc 100644 --- a/Frontend/plannerly/lib/screens/home/home.dart +++ b/Frontend/plannerly/lib/screens/home/home.dart @@ -1,415 +1,483 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:plannerly/screens/regular_tasks/regular_tasks_page.dart'; +import 'package:plannerly/screens/urgent_tasks/urgent_tasks_page.dart'; import 'package:plannerly/screens/widgets/task.dart'; import 'package:plannerly/utils/colors/colors.dart'; import '../../bloc/home/home_bloc.dart'; -class HomeScreen extends StatelessWidget { +class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); + @override + State createState() => _HomeScreenState(); +} + +class _HomeScreenState extends State { + final HomeBloc homeBloc = HomeBloc(); + @override + void initState() { + homeBloc.add(HomeInitialEvent()); + super.initState(); + } + @override Widget build(BuildContext context) { Size size = MediaQuery.of(context).size; - final HomeBloc homeBloc = HomeBloc(); + return BlocConsumer( bloc: homeBloc, - // listenWhen: (previous, current) {}, - // buildWhen: (previous, current) {}, + listenWhen: (previous, current) => + current is HomeActionState, //listen to changes when home action state + buildWhen: (previous, current) => current + is! HomeActionState, //any other state other than the home action state listener: (context, state) { - // TODO: implement listener + if (state is HomeNavigateToUrgentTasksPage) { + Navigator.of(context).push( + MaterialPageRoute(builder: (context) => const UrgentTasks())); + } else if (state is HomeNavigateToRegularTasksPage) { + Navigator.of(context).push( + MaterialPageRoute(builder: (context) => const RegularTasks())); + } }, builder: (context, state) { - 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), - const Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + 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: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(14.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Icon( - Icons.menu_outlined, - size: 28, - color: AppColors.white, + 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, + ), + ], ), - 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, - ), - ), - 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), - ), - ), - ), - IconButton( - onPressed: () {}, - icon: Icon( - Icons.search_outlined, - size: 28, - color: AppColors.white.withOpacity(0.6), - ), - ), - ], + SizedBox(height: size.height * 0.03), + const Text( + "Hi, Jason", + style: TextStyle( + color: AppColors.white, + fontSize: 18, + fontWeight: FontWeight.w300, ), ), - ), - ), - SizedBox(height: size.height * 0.025), - Center( - child: Container( - decoration: BoxDecoration( - color: AppColors.backgroundLight, - borderRadius: BorderRadius.circular(18), + SizedBox(height: size.height * 0.01), + const Text( + "Be productivity today", + style: TextStyle( + color: AppColors.white, + fontSize: 24, + fontWeight: FontWeight.w500, + ), ), - 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( - "30/40 task completed.", - style: TextStyle( - color: AppColors.white.withOpacity(0.4), - fontSize: 14, - fontWeight: FontWeight.w400, - ), - ), - ], - ), - ), - Stack( + 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: [ - SizedBox( - height: size.height * 0.07, - width: size.height * 0.07, - child: CircularProgressIndicator( - value: 0.8, - strokeWidth: 7, - valueColor: const AlwaysStoppedAnimation( - AppColors.buttonBlue), - backgroundColor: - AppColors.white.withOpacity(0.2), - color: AppColors.white, - semanticsValue: "80%", + const Expanded( + child: TextField( + decoration: InputDecoration( + border: InputBorder.none, + hintText: 'Search task', + hintStyle: TextStyle( + color: AppColors.grey, + fontSize: 18, + ), + contentPadding: EdgeInsets.all(10), + ), ), ), - 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, - ), - ), + IconButton( + onPressed: () {}, + icon: Icon( + Icons.search_outlined, + size: 28, + color: AppColors.white.withOpacity(0.6), ), ), ], ), - ], + ), ), ), - ), - ), - 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: 0.8, - strokeWidth: 7, - valueColor: AlwaysStoppedAnimation( - Colors.red[400]), - backgroundColor: AppColors.white - .withOpacity(0.2), - color: AppColors.white, - semanticsValue: "80%", - ), + 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.1, - width: size.height * 0.1, - child: Center( - child: Text( - "80%", - style: TextStyle( - color: AppColors.white - .withOpacity(0.8), - fontSize: 22, - fontWeight: FontWeight.w600, - ), - ), - ), + ), + const SizedBox(height: 8), + Text( + "30/40 task completed.", + style: TextStyle( + color: + AppColors.white.withOpacity(0.4), + fontSize: 14, + fontWeight: FontWeight.w400, ), - ], - ), + ), + ], ), - const SizedBox(height: 16), - Center( - child: Text( - "30/40", - style: TextStyle( - color: AppColors.white.withOpacity(0.4), - fontSize: 22, - fontWeight: FontWeight.w400, + ), + Stack( + children: [ + SizedBox( + height: size.height * 0.07, + width: size.height * 0.07, + child: CircularProgressIndicator( + value: 0.8, + strokeWidth: 7, + valueColor: + const AlwaysStoppedAnimation( + AppColors.buttonBlue), + backgroundColor: + AppColors.white.withOpacity(0.2), + color: AppColors.white, + semanticsValue: "80%", ), ), + 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(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: 0.8, + strokeWidth: 7, + valueColor: + AlwaysStoppedAnimation( + Colors.red[400]), + backgroundColor: AppColors.white + .withOpacity(0.2), + color: AppColors.white, + semanticsValue: "80%", + ), + ), + SizedBox( + height: size.height * 0.1, + width: size.height * 0.1, + child: Center( + child: Text( + "80%", + style: TextStyle( + color: AppColors.white + .withOpacity(0.8), + fontSize: 22, + fontWeight: FontWeight.w600, + ), + ), + ), + ), + ], + ), + ), + const SizedBox(height: 16), + Center( + child: Text( + "30/40", + 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, + 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: [ - 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: 0.5, - strokeWidth: 7, - valueColor: AlwaysStoppedAnimation( - Colors.green[400]), - backgroundColor: AppColors.white - .withOpacity(0.2), - color: AppColors.white, - semanticsValue: "80%", - ), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + const Text( + "Regular Tasks Progress", + textAlign: TextAlign.center, + style: TextStyle( + color: AppColors.white, + fontSize: 18, + fontWeight: FontWeight.w500, ), - SizedBox( - height: size.height * 0.1, - width: size.height * 0.1, - child: Center( - child: Text( - "50%", - style: TextStyle( - color: AppColors.white - .withOpacity(0.8), - fontSize: 22, - fontWeight: FontWeight.w600, + ), + const SizedBox(height: 20), + Center( + child: Stack( + children: [ + SizedBox( + height: size.height * 0.1, + width: size.height * 0.1, + child: CircularProgressIndicator( + value: 0.5, + strokeWidth: 7, + valueColor: + AlwaysStoppedAnimation( + Colors.green[400]), + backgroundColor: AppColors.white + .withOpacity(0.2), + color: AppColors.white, + semanticsValue: "80%", ), ), + SizedBox( + height: size.height * 0.1, + width: size.height * 0.1, + child: Center( + child: Text( + "50%", + style: TextStyle( + color: AppColors.white + .withOpacity(0.8), + fontSize: 22, + fontWeight: FontWeight.w600, + ), + ), + ), + ), + ], + ), + ), + const SizedBox(height: 16), + Center( + child: Text( + "5/10", + style: TextStyle( + color: AppColors.white + .withOpacity(0.4), + fontSize: 22, + fontWeight: FontWeight.w400, ), ), - ], - ), - ), - const SizedBox(height: 16), - Center( - child: Text( - "5/10", - 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, - ), + 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', + style: TextStyle( + color: AppColors.buttonBlue, + fontSize: 14, + fontWeight: FontWeight.w500, + ), + ), + ), + ], ), - TextButton( - onPressed: () { - homeBloc.add(HomeUrgentTasksViewAllClickedEvent()); + 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); }, - child: const Text( - 'View all', - style: TextStyle( - color: AppColors.buttonBlue, - fontSize: 14, - fontWeight: FontWeight.w500, + ), + 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(HomeRegularTasksViewAllClickedEvent()); + }, + 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(), - itemCount: 2, - separatorBuilder: (BuildContext context, int index) { - return 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, + ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) => Task( + bloc: homeBloc, + task: successState.regularTasks[index], ), - ), - TextButton( - onPressed: () { - homeBloc.add(HomeRegularTasksViewAllClickedEvent()); + itemCount: (successState.regularTasks.length < 2) + ? successState.regularTasks.length + : 2, + separatorBuilder: (BuildContext context, int index) { + return const SizedBox(height: 15); }, - 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(), - itemCount: 2, - separatorBuilder: (BuildContext context, int index) { - return SizedBox(height: 15); - }, - ), - ], + ), ), - ), - ), - ); + ); + case HomeLoadedErrorState: + return Scaffold( + backgroundColor: AppColors.backgroundDark, + body: Center( + child: Text( + 'Some error ocurred!', + style: TextStyle( + fontSize: 20, + color: AppColors.white.withOpacity(0.3), + ), + ), + ), + ); + default: + return const SizedBox(); + } }, ); } diff --git a/Frontend/plannerly/lib/screens/regular_tasks/regular_tasks_page.dart b/Frontend/plannerly/lib/screens/regular_tasks/regular_tasks_page.dart new file mode 100644 index 0000000..f039988 --- /dev/null +++ b/Frontend/plannerly/lib/screens/regular_tasks/regular_tasks_page.dart @@ -0,0 +1,139 @@ +import 'package:flutter/material.dart'; +import 'package:plannerly/screens/widgets/task.dart'; +import 'package:plannerly/utils/colors/colors.dart'; + +class RegularTasks extends StatelessWidget { + const RegularTasks({super.key}); + + @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( + "Regular 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( + "REgular Task Progress", + style: TextStyle( + color: AppColors.white, + fontSize: 20, + fontWeight: FontWeight.w400, + ), + ), + const SizedBox(height: 8), + Text( + "5/10 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: 0.5, + strokeWidth: 7, + valueColor: + AlwaysStoppedAnimation(Colors.green[400]), + backgroundColor: + AppColors.white.withOpacity(0.2), + color: AppColors.white, + ), + ), + SizedBox( + height: size.height * 0.07, + width: size.height * 0.07, + child: Center( + child: Text( + "50%", + 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(), + // itemCount: 5, + // separatorBuilder: (BuildContext context, int index) { + // return SizedBox(height: 15); + // }, + // ), + SizedBox(height: size.height * 0.04), + ], + ), + ), + ), + ); + } +} diff --git a/Frontend/plannerly/lib/screens/urgent_tasks/urgent_tasks_page.dart b/Frontend/plannerly/lib/screens/urgent_tasks/urgent_tasks_page.dart new file mode 100644 index 0000000..2fd72f2 --- /dev/null +++ b/Frontend/plannerly/lib/screens/urgent_tasks/urgent_tasks_page.dart @@ -0,0 +1,140 @@ +import 'package:flutter/material.dart'; +import 'package:plannerly/screens/widgets/task.dart'; +import 'package:plannerly/utils/colors/colors.dart'; + +class UrgentTasks extends StatelessWidget { + const UrgentTasks({super.key}); + + @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), + ), + 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( + "30/40 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: 0.8, + strokeWidth: 7, + valueColor: + AlwaysStoppedAnimation(Colors.red[400]), + backgroundColor: + AppColors.white.withOpacity(0.2), + color: AppColors.white, + semanticsValue: "80%", + ), + ), + 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(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(), + // itemCount: 5, + // separatorBuilder: (BuildContext context, int index) { + // return SizedBox(height: 15); + // }, + // ), + SizedBox(height: size.height * 0.04), + ], + ), + ), + ), + ); + } +} diff --git a/Frontend/plannerly/lib/screens/widgets/task.dart b/Frontend/plannerly/lib/screens/widgets/task.dart index 0481de8..216d422 100644 --- a/Frontend/plannerly/lib/screens/widgets/task.dart +++ b/Frontend/plannerly/lib/screens/widgets/task.dart @@ -1,10 +1,13 @@ import 'package:flutter/material.dart'; +import 'package:plannerly/bloc/home/home_bloc.dart'; +import 'package:plannerly/models/task_model.dart'; import '../../utils/colors/colors.dart'; class Task extends StatefulWidget { - const Task({super.key}); - + const Task({super.key, required this.task, required this.bloc}); + final TaskModel task; + final HomeBloc bloc; @override State createState() => _TaskState(); } @@ -25,7 +28,9 @@ class _TaskState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ IconButton( - onPressed: () {}, + onPressed: () { + widget.bloc.add(HomeTasksCompletedButtonClicked()); + }, icon: Icon( Icons.done_outline, color: AppColors.white.withOpacity(0.3), //Colors.green @@ -37,9 +42,9 @@ class _TaskState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text( - "Title of the task", - style: TextStyle( + Text( + widget.task.title, + style: const TextStyle( color: AppColors.white, fontSize: 20, fontWeight: FontWeight.w400, @@ -47,7 +52,9 @@ class _TaskState extends State { ), const SizedBox(height: 8), Text( - "description: task description here.", + // "description: task description here.", + widget.task.description, + maxLines: 3, style: TextStyle( color: AppColors.white.withOpacity(0.4), fontSize: 16, @@ -56,7 +63,7 @@ class _TaskState extends State { ), const SizedBox(height: 5), Text( - "date: 22/12/2023 time: 10:00:00", + "date: ${widget.task.date} time: ${widget.task.time}", style: TextStyle( color: AppColors.white.withOpacity(0.4), fontSize: 12, @@ -67,7 +74,9 @@ class _TaskState extends State { ), ), IconButton( - onPressed: () {}, + onPressed: () { + widget.bloc.add(HomeTasksDeleteButtonClicked()); + }, icon: Icon( Icons.delete_outline, color: Colors.red[400],