diff --git a/lib/new_ui/screens/AnnouncementScreen/announcementscreen.dart b/lib/new_ui/screens/AnnouncementScreen/announcementscreen.dart index 7c2a73c..deb32f4 100644 --- a/lib/new_ui/screens/AnnouncementScreen/announcementscreen.dart +++ b/lib/new_ui/screens/AnnouncementScreen/announcementscreen.dart @@ -196,7 +196,16 @@ class AnnouncementListItem extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(announcementModel.title.toString(),style: TextStyle(fontSize: 22,fontWeight: FontWeight.w500,color: Colors.white),), + Expanded( + child: Text( + announcementModel.title.toString(), + style: TextStyle( + fontSize: 22, + fontWeight: FontWeight.w500, + color: Colors.white + ), + ) + ), if(announcementModel.docURL !=null || announcementModel.docURL !="") InkWell(splashFactory: NoSplash.splashFactory,onTap: ()=>launchUrl(Uri.parse(announcementModel.docURL.toString(),),) ,child:Icon(Icons.link,color: Colors.blue,), diff --git a/lib/new_ui/screens/attendance_screen/attendance_screen.dart b/lib/new_ui/screens/attendance_screen/attendance_screen.dart index 19e0757..31f6f89 100644 --- a/lib/new_ui/screens/attendance_screen/attendance_screen.dart +++ b/lib/new_ui/screens/attendance_screen/attendance_screen.dart @@ -183,101 +183,145 @@ class _AttendanceScreenState extends State { text: attendanceInfo["present"] .toString()); + final _updateformKey = GlobalKey(); + return AlertDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15), ), title: Text('Update Subject'), - content: SingleChildScrollView( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - TextField( - controller: subjectNameController, - style: TextStyle(color: Colors.white), - decoration: InputDecoration( - labelText: 'Subject Name', - labelStyle: TextStyle( - color: Colors.white70), - border: OutlineInputBorder( - borderRadius: - BorderRadius.circular(10), + content: Form( + key: _updateformKey, + child: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextFormField( + validator: (val) { + if (val == null || val.isEmpty) { + return "Please enter some value"; + } + }, + controller: subjectNameController, + style: TextStyle(color: Colors.white), + decoration: InputDecoration( + labelText: 'Subject Name', + labelStyle: TextStyle( + color: Colors.white70), + border: OutlineInputBorder( + borderRadius: + BorderRadius.circular(10), + ), + filled: true, + fillColor: Colors.transparent, + contentPadding: + EdgeInsets.symmetric( + horizontal: 15, + vertical: 10), + errorStyle: TextStyle(fontSize: 12), ), - filled: true, - fillColor: Colors.transparent, - contentPadding: - EdgeInsets.symmetric( - horizontal: 15, - vertical: 10), ), - ), - SizedBox(height: 20), - TextField( - controller: - attendedLecturesController, - style: TextStyle(color: Colors.white), - decoration: InputDecoration( - labelText: 'Attended Lectures', - labelStyle: TextStyle( - color: Colors.white70), - border: OutlineInputBorder( - borderRadius: - BorderRadius.circular(10), + SizedBox(height: 20), + TextFormField( + validator: (val) { + String totalLectures = + totalLecturesController.text; + + if (val == null || val.isEmpty) { + return "Please enter some value"; + } else if (totalLectures.isNotEmpty && + int.parse(val) > int.parse(totalLectures)) { + return "Please enter correct value"; + } + }, + controller: + attendedLecturesController, + style: TextStyle(color: Colors.white), + decoration: InputDecoration( + labelText: 'Attended Lectures', + labelStyle: TextStyle( + color: Colors.white70), + border: OutlineInputBorder( + borderRadius: + BorderRadius.circular(10), + ), + filled: true, + errorStyle: TextStyle(fontSize: 12), + focusColor: Colors.red, + fillColor: Colors.transparent, + contentPadding: + EdgeInsets.symmetric( + horizontal: 15, + vertical: 10), ), - filled: true, - fillColor: Colors.transparent, - contentPadding: - EdgeInsets.symmetric( - horizontal: 15, - vertical: 10), + keyboardType: TextInputType.number, ), - keyboardType: TextInputType.number, - ), - SizedBox(height: 20), - TextField( - controller: totalLecturesController, - style: TextStyle(color: Colors.white), - decoration: InputDecoration( - labelText: - 'Total Lectures Till Now', - labelStyle: TextStyle( - color: Colors.white70), - border: OutlineInputBorder( - borderRadius: - BorderRadius.circular(10), + SizedBox(height: 20), + TextFormField( + validator: (val) { + String attendedLectures = + attendedLecturesController.text; + if (val == null || val.isEmpty) { + return "Please enter some value"; + } else if (attendedLectures.isNotEmpty && + int.parse(val) < + int.parse(attendedLectures)) { + return "Please enter correct value"; + } + }, + controller: totalLecturesController, + style: TextStyle(color: Colors.white), + decoration: InputDecoration( + labelText: + 'Total Lectures Till Now', + labelStyle: TextStyle( + color: Colors.white70), + border: OutlineInputBorder( + borderRadius: + BorderRadius.circular(10), + ), + filled: true, + errorStyle: TextStyle(fontSize: 12), + focusColor: Colors.red, + fillColor: Colors.transparent, + contentPadding: + EdgeInsets.symmetric( + horizontal: 15, + vertical: 10), ), - filled: true, - fillColor: Colors.transparent, - contentPadding: - EdgeInsets.symmetric( - horizontal: 15, - vertical: 10), + keyboardType: TextInputType.number, ), - keyboardType: TextInputType.number, - ), - ], + ], + ), ), ), actions: [ TextButton( onPressed: () async { - String subjectName = - subjectNameController.text; - int totalLectures = int.parse( - totalLecturesController.text); - int attendedLectures = int.parse( - attendedLecturesController.text); - - Map updatedSubject = { - "subject_name": subjectName, - "total": totalLectures, - "present": attendedLectures - }; - - await AttendanceService.updateSubject( - attendanceList, - index, - updatedSubject); + + if (_updateformKey.currentState!.validate()) + { + String subjectName = + subjectNameController.text; + int totalLectures = int.parse( + totalLecturesController.text); + int attendedLectures = int.parse( + attendedLecturesController.text); + + Map updatedSubject = { + "subject_name": subjectName, + "total": totalLectures, + "present": attendedLectures + }; + + await AttendanceService.updateSubject( + attendanceList, + index, + updatedSubject); + + Navigator.of(context).pop(); + } + /*DocumentSnapshot doc = await FirebaseFirestore.instance .collection("Attendance") @@ -306,13 +350,14 @@ class _AttendanceScreenState extends State { } }*/ - Navigator.of(context).pop(); + }, child: Text('Update', style: TextStyle(color: Colors.blue)), ), TextButton( onPressed: () async { + await AttendanceService.deleteSubject( attendanceList, index);