From 817fbc146bc4a21ec038d5811a791f8c8134f9fd Mon Sep 17 00:00:00 2001 From: Atharva Date: Sat, 20 Jul 2024 02:03:16 +0530 Subject: [PATCH] changing attendeence ui and improved the ui of alert box --- .../attendance_screen/attendance_screen.dart | 56 ++++---- .../widgets/attendance_subject_widget.dart | 125 +++++++++--------- .../profile_screen/profile_screen.dart | 47 ++++--- 3 files changed, 125 insertions(+), 103 deletions(-) diff --git a/lib/new_ui/screens/attendance_screen/attendance_screen.dart b/lib/new_ui/screens/attendance_screen/attendance_screen.dart index 85d9399..df0197c 100644 --- a/lib/new_ui/screens/attendance_screen/attendance_screen.dart +++ b/lib/new_ui/screens/attendance_screen/attendance_screen.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:tsec_app/new_ui/colors.dart'; import 'package:tsec_app/new_ui/screens/attendance_screen/widgets/attendance_subject_widget.dart'; //make this a consumer widget later @@ -7,55 +8,62 @@ class AttendanceScreen extends StatelessWidget { @override Widget build(BuildContext context) { + var present =8; + var totalLec=10; //put the attendance from a provider here - double attendance = 0.5; + double attendance = present/totalLec; var size = MediaQuery.of(context).size; return SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ - const SizedBox(height: 20,), - Text( - attendance < 0.75 ? 'Your attendance is low' : 'Your attendance is good', - style: TextStyle(color: Colors.white, fontSize: 20), - ), + // const SizedBox(height: 20,), + // Text( + // attendance < 0.75 ? 'Your attendance is low' : 'Your attendance is good', + // style: TextStyle(color: Colors.white, fontSize: 20), + // ), const SizedBox(height: 30,), Stack( children: [ Positioned.fill( child: Align( alignment: Alignment.center, - child: Text( - '${attendance * 100} %' , - style: TextStyle(color: Colors.white, fontSize: 50), - ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '' , + style: TextStyle(color: Colors.white, fontSize: 4), + ), + Text( + '${attendance * 100}%' , + style: TextStyle(color: Colors.white, fontSize: 17), + ), + Text( + '${present}/${totalLec}' , + style: TextStyle(color: Colors.white, fontSize: 14), + ), + ], + ), ), ), SizedBox( - width: size.width * 0.8, - height: size.height * 0.4, + width: 100, + height: 100, child: CircularProgressIndicator( value: attendance, backgroundColor: Colors.white, - valueColor: AlwaysStoppedAnimation(Colors.blue), - strokeWidth: 20, - strokeCap: StrokeCap.round, + valueColor: AlwaysStoppedAnimation(oldDateSelectBlue), + strokeWidth: 3, + strokeAlign: BorderSide.strokeAlignInside, + strokeCap: StrokeCap.butt, ), ), ], ), const SizedBox(height: 20,), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text("Present: 5", style: TextStyle(color: Colors.white),), - Text("Absent: 5", style: TextStyle(color: Colors.white),), - ], - ), - const SizedBox(height: 20,), //put the subject attendance cards from here - AttendanceSubjectWidget(attendance: 0.5), const SizedBox(height: 10,), AttendanceSubjectWidget(attendance: 0.75), ], diff --git a/lib/new_ui/screens/attendance_screen/widgets/attendance_subject_widget.dart b/lib/new_ui/screens/attendance_screen/widgets/attendance_subject_widget.dart index 19cf73c..a83ae26 100644 --- a/lib/new_ui/screens/attendance_screen/widgets/attendance_subject_widget.dart +++ b/lib/new_ui/screens/attendance_screen/widgets/attendance_subject_widget.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:tsec_app/new_ui/colors.dart'; class AttendanceSubjectWidget extends StatelessWidget { final double attendance; @@ -7,68 +8,74 @@ class AttendanceSubjectWidget extends StatelessWidget { @override Widget build(BuildContext context) { return Card( - color: const Color(0xff464544), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Row( - //crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - 'Subject Name', - style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold), - ), - SizedBox(width: 5,), - Text( - '5/10', - style: TextStyle(color: Colors.white, fontSize: 12), - ), - Expanded( - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text( - '50%', - style: TextStyle(color: Colors.white, fontSize: 16), - ), - ], + child: Container( + decoration: BoxDecoration( + border: Border.all(color: timePickerBorder, width: 1.0), // Change the color and width as needed + borderRadius: BorderRadius.circular(10.0), + color: timePickerBg, + ), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Row( + //crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + 'Subject Name', + style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold), ), - ), - ], - ), - const SizedBox(height: 10,), - const Text("Not accepted", style: TextStyle(color: Colors.white, fontSize: 12),), - const SizedBox(height: 10,), - LinearProgressIndicator( - value: attendance, - backgroundColor: Colors.white, - valueColor: const AlwaysStoppedAnimation(Colors.blue), - ), - const SizedBox(height: 15,), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - ElevatedButton( - onPressed: (){}, - child: const Text('Present', style: TextStyle(color: Colors.white),), - style: ElevatedButton.styleFrom( - backgroundColor: Colors.green, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), - ), + SizedBox(width: 5,), + Text( + '5/10', + style: TextStyle(color: Colors.white, fontSize: 12), ), - ElevatedButton( - onPressed: (){}, - child: const Text('Absent', style: TextStyle(color: Colors.white),), - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), - ), + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text( + '50%', + style: TextStyle(color: Colors.white, fontSize: 16), + ), + ], + ), ), - ], - ) - ], + ], + ), + const SizedBox(height: 10,), + const Text("Not accepted", style: TextStyle(color: Colors.white, fontSize: 12),), + const SizedBox(height: 10,), + LinearProgressIndicator( + value: attendance, + backgroundColor: Colors.white, + valueColor: const AlwaysStoppedAnimation(Colors.blue), + ), + const SizedBox(height: 15,), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // ElevatedButton( + // onPressed: (){}, + // child: const Text('Present', style: TextStyle(color: Colors.white),), + // style: ElevatedButton.styleFrom( + // backgroundColor: Colors.green, + // shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), + // ), + // ), + // ElevatedButton( + // onPressed: (){}, + // child: const Text('Absent', style: TextStyle(color: Colors.white),), + // style: ElevatedButton.styleFrom( + // backgroundColor: Colors.red, + // shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), + // ), + // ), + ], + ) + ], + ), ), ) ); diff --git a/lib/new_ui/screens/profile_screen/profile_screen.dart b/lib/new_ui/screens/profile_screen/profile_screen.dart index 7262812..eaed8e7 100644 --- a/lib/new_ui/screens/profile_screen/profile_screen.dart +++ b/lib/new_ui/screens/profile_screen/profile_screen.dart @@ -354,12 +354,13 @@ class _ProfilePageState extends ConsumerState { context: context, builder: (context) { return AlertDialog( + content: SizedBox( - height: 180, child: Container( - padding: const EdgeInsets.all(20.0), + height: MediaQuery.of(context).size.height* 0.25, + padding: const EdgeInsets.all(5.0), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ RichText( text: TextSpan( @@ -375,23 +376,29 @@ class _ProfilePageState extends ConsumerState { ], ), ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - TextButton( - onPressed: () { - Navigator.of(context).pop(); - }, - child: const Text("Cancel") - ), - TextButton( - onPressed: () async { - bool changesSaved = await saveChanges(ref); - if (changesSaved) GoRouter.of(context).go('/main'); - }, - child: const Text("Proceed") - ), - ], + Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text("Cancel") + ), + ), + Container( + child: TextButton( + onPressed: () async { + bool changesSaved = await saveChanges(ref); + if (changesSaved) GoRouter.of(context).go('/main'); + }, + child: const Text("Proceed") + ), + ), + ], + ), ), ], ),