From c69f5fd17af0e3755173f4732ea7143bbbd61158 Mon Sep 17 00:00:00 2001 From: msarkrish Date: Sat, 16 Oct 2021 00:37:27 +0530 Subject: [PATCH 1/3] Date Picker added for DOB field in Profile screen --- lib/views/admin/screens/upload_profile.dart | 27 +++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/views/admin/screens/upload_profile.dart b/lib/views/admin/screens/upload_profile.dart index bcdfbd5..b4cc870 100644 --- a/lib/views/admin/screens/upload_profile.dart +++ b/lib/views/admin/screens/upload_profile.dart @@ -5,6 +5,7 @@ import 'package:firebase_storage/firebase_storage.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:intl/intl.dart'; import 'package:student_app/models.dart'; class UploadProfile extends StatefulWidget { @@ -34,7 +35,7 @@ class _UploadProfile extends State { List year = []; List department = []; List classes = []; - + TextEditingController dobController = TextEditingController(); DatabaseReference obj = DatabaseReference(); @override @@ -368,8 +369,27 @@ class _UploadProfile extends State { } Widget buildDOBField() { + DateTime currentDateTime = DateTime.now(), + initialDateTime = currentDateTime.add(Duration(days: -(10 * 365))), + firstDateTime = currentDateTime.add(Duration(days: -(60 * 365))), + lastDateTime = currentDateTime.add(Duration(days: -(5 * 365))); return TextFormField( keyboardType: TextInputType.phone, + controller: dobController, + readOnly: true, + onTap: () { + showDatePicker( + context: context, + initialDate: initialDateTime, + firstDate: firstDateTime, + lastDate: lastDateTime, + ).then((newDateTime) { + if (newDateTime != null) { + dobController.text = DateFormat('dd-MM-yyyy').format(newDateTime); + dob = DateFormat('dd-MM-yyyy').format(newDateTime); + } + }); + }, decoration: const InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.all( @@ -383,13 +403,10 @@ class _UploadProfile extends State { ), validator: (String? value) { if (value!.isEmpty) { - return 'Address Required'; + return 'Date of Birth Required'; } return null; }, - onSaved: (String? value) { - dob = value.toString(); - }, ); } From f6f8b6f49cc71506c269b9885bfe4af5fd843586 Mon Sep 17 00:00:00 2001 From: msarkrish Date: Sat, 16 Oct 2021 01:36:41 +0530 Subject: [PATCH 2/3] Some part of image hided by status bar and Text overflow in Onboarding screen fixed --- lib/views/common/onboarding_screen.dart | 111 ++++++++++++------------ 1 file changed, 54 insertions(+), 57 deletions(-) diff --git a/lib/views/common/onboarding_screen.dart b/lib/views/common/onboarding_screen.dart index e46434a..95f8e6a 100644 --- a/lib/views/common/onboarding_screen.dart +++ b/lib/views/common/onboarding_screen.dart @@ -36,64 +36,61 @@ class _OnBoardingPageState extends State { imagePadding: EdgeInsets.zero, ); - return IntroductionScreen( - key: introKey, - pages: [ - PageViewModel( - title: 'Timetables', - body: 'Get up-to-date timetables in single click.', - image: _buildImage('timetable'), - decoration: pageDecoration, - ), - PageViewModel( - title: 'Events', - body: 'Learn about events and fest.', - image: _buildImage('candidate'), - decoration: pageDecoration, - ), - PageViewModel( - title: 'Grades', - body: 'Check your grades and assessment exams scores.', - image: _buildImage('grade'), - decoration: pageDecoration, - ), - PageViewModel( - title: 'Announcements', - body: 'Get latest news via push notification.', - image: _buildImage('announce'), - decoration: pageDecoration, - ), - PageViewModel( - title: 'Notes and Question banks', - body: 'View and download notes on the go', - image: _buildImage('notes'), - decoration: pageDecoration, - ), - PageViewModel( - title: 'Q/A', - bodyWidget: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: const [ - Text('Submit your question in global chat ', style: bodyStyle), - ], + return SafeArea( + child: IntroductionScreen( + key: introKey, + pages: [ + PageViewModel( + title: 'Timetables', + body: 'Get up-to-date timetables in single click.', + image: _buildImage('timetable'), + decoration: pageDecoration, + ), + PageViewModel( + title: 'Events', + body: 'Learn about events and fest.', + image: _buildImage('candidate'), + decoration: pageDecoration, + ), + PageViewModel( + title: 'Grades', + body: 'Check your grades and assessment exams scores.', + image: _buildImage('grade'), + decoration: pageDecoration, + ), + PageViewModel( + title: 'Announcements', + body: 'Get latest news via push notification.', + image: _buildImage('announce'), + decoration: pageDecoration, + ), + PageViewModel( + title: 'Notes and Question banks', + body: 'View and download notes on the go', + image: _buildImage('notes'), + decoration: pageDecoration, + ), + PageViewModel( + title: 'Q/A', + body: 'Submit your question in global chat', + image: _buildImage('announce'), + decoration: pageDecoration, + ), + ], + onDone: () => _onIntroEnd(context), + //onSkip: () => _onIntroEnd(context), // You can override onSkip callback + showSkipButton: true, + skipFlex: 0, + nextFlex: 0, + skip: const Text('Skip'), + next: const Icon(Icons.arrow_forward), + done: const Text('Done', style: TextStyle(fontWeight: FontWeight.w600)), + dotsDecorator: const DotsDecorator( + size: Size(10.0, 10.0), + activeSize: Size(22.0, 10.0), + activeShape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(25.0)), ), - image: _buildImage('announce'), - decoration: pageDecoration, - ), - ], - onDone: () => _onIntroEnd(context), - //onSkip: () => _onIntroEnd(context), // You can override onSkip callback - showSkipButton: true, - skipFlex: 0, - nextFlex: 0, - skip: const Text('Skip'), - next: const Icon(Icons.arrow_forward), - done: const Text('Done', style: TextStyle(fontWeight: FontWeight.w600)), - dotsDecorator: const DotsDecorator( - size: Size(10.0, 10.0), - activeSize: Size(22.0, 10.0), - activeShape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(25.0)), ), ), ); From 64691c8aab6df9539830f79ad660b46e5c1ea7fc Mon Sep 17 00:00:00 2001 From: msarkrish Date: Sat, 16 Oct 2021 23:04:09 +0530 Subject: [PATCH 3/3] Empty state added in Notes search page, In profile upload page some improvement added, In login screen textfield some improvement, error text added and some code optimization done --- lib/views/admin/screens/upload_profile.dart | 5 + lib/views/common/login.dart | 482 ++++++++++---------- lib/views/student/screens/grade.dart | 4 - lib/views/student/screens/notes_viewer.dart | 4 +- lib/views/student/screens/view_notes.dart | 96 ++-- 5 files changed, 302 insertions(+), 289 deletions(-) diff --git a/lib/views/admin/screens/upload_profile.dart b/lib/views/admin/screens/upload_profile.dart index b4cc870..d442dc2 100644 --- a/lib/views/admin/screens/upload_profile.dart +++ b/lib/views/admin/screens/upload_profile.dart @@ -168,6 +168,7 @@ class _UploadProfile extends State { onSaved: (String? value) { name = value; }, + textInputAction: TextInputAction.next, ); } @@ -194,6 +195,7 @@ class _UploadProfile extends State { onSaved: (String? value) { rollNo = value; }, + textInputAction: TextInputAction.next, ); } @@ -221,6 +223,7 @@ class _UploadProfile extends State { onSaved: (String? value) { regNo = value!; }, + textInputAction: TextInputAction.next, ); } @@ -237,6 +240,7 @@ class _UploadProfile extends State { contentPadding: EdgeInsets.all(15.0), filled: true, ), + keyboardType: TextInputType.emailAddress, validator: (String? value) { if (value!.isEmpty) { return 'Email Required'; @@ -251,6 +255,7 @@ class _UploadProfile extends State { onSaved: (String? value) { email = value; }, + textInputAction: TextInputAction.next, ); } diff --git a/lib/views/common/login.dart b/lib/views/common/login.dart index a921918..06eb7fd 100644 --- a/lib/views/common/login.dart +++ b/lib/views/common/login.dart @@ -21,30 +21,19 @@ class LoginPage extends StatefulWidget { class _LoginPageState extends State with SingleTickerProviderStateMixin { - //FocusNode Keys - final FocusNode myFocusNodeEmailLogin = FocusNode(); - final FocusNode myFocusNodePasswordLogin = FocusNode(); - final FocusNode myFocusNodePassword = FocusNode(); - final FocusNode myFocusNodeEmail = FocusNode(); - final FocusNode myFocusNodeName = FocusNode(); - //GlobalKeys final GlobalKey _scaffoldKey = GlobalKey(); final snack = GlobalKey(); - final ukey = GlobalKey(); - final passkey = GlobalKey(); - final adminuserkey = GlobalKey(); - final adminpasskey = GlobalKey(); - final adminkey = GlobalKey(); + final studentFormKey = GlobalKey(); + final staffFormKey = GlobalKey(); //TextEditingController Objects and other controllers - TextEditingController loginEmailController = TextEditingController(); - TextEditingController loginPasswordController = TextEditingController(); - TextEditingController signupEmailController = TextEditingController(); - TextEditingController signupNameController = TextEditingController(); - TextEditingController signupPasswordController = TextEditingController(); - TextEditingController signupConfirmPasswordController = - TextEditingController(); + TextEditingController registerNoController = TextEditingController(); + TextEditingController studentPasswordController = TextEditingController(); + TextEditingController keyController = TextEditingController(); + TextEditingController emailAddressController = TextEditingController(); + TextEditingController staffPasswordController = TextEditingController(); + PageController? _pageController; //FirebaseReferences and its variables @@ -66,27 +55,13 @@ class _LoginPageState extends State bool? valid; Color left = Colors.black; Color right = Colors.white; - String? _batch, - _dept, - _regno, - password, - givenkey, - givenuser, - givenpass, - foundclass, - initialname, - pword; - - void processdata() { - ukey.currentState!.save(); - passkey.currentState!.save(); - formValidation(); - } + String? _batch, _dept, _regno, password, foundclass, registerNo; void formValidation() { - _batch = '20${initialname!.substring(4, 6)}'; - _dept = initialname!.substring(6, 9); - _regno = initialname; + registerNo = registerNoController.text; + _batch = '20${registerNo!.substring(4, 6)}'; + _dept = registerNo!.substring(6, 9); + _regno = registerNo; switch (_dept) { case '101': { @@ -166,7 +141,7 @@ class _LoginPageState extends State if (value.docs.isNotEmpty) { for (var element in value.docs) { password = element.data()['DOB'].toString(); - if (password != pword) { + if (password != studentPasswordController.text) { invalidSnackBar('Password is incorrect'); } else { foundclass = cls[i].name; @@ -243,10 +218,6 @@ class _LoginPageState extends State @override void dispose() { - loginEmailController.dispose(); - myFocusNodePassword.dispose(); - myFocusNodeEmail.dispose(); - myFocusNodeName.dispose(); _pageController?.dispose(); super.dispose(); @@ -365,91 +336,101 @@ class _LoginPageState extends State width: 300.0, height: 220.0, child: SingleChildScrollView( - child: Column( - children: [ - Padding( - padding: const EdgeInsets.only( - top: 15.0, bottom: 15.0, left: 25.0, right: 25.0), - child: TextFormField( - autocorrect: false, - maxLength: 12, - key: ukey, - focusNode: myFocusNodeEmailLogin, - keyboardType: TextInputType.emailAddress, - style: const TextStyle(fontSize: 16.0), - decoration: const InputDecoration( - border: InputBorder.none, - icon: Icon( - Icons.person, - size: 22.0, + child: Form( + key: studentFormKey, + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only( + top: 15.0, + bottom: 15.0, + left: 25.0, + right: 25.0), + child: TextFormField( + autocorrect: false, + maxLength: 12, + keyboardType: TextInputType.number, + style: const TextStyle(fontSize: 16.0), + controller: registerNoController, + decoration: const InputDecoration( + border: InputBorder.none, + icon: Icon( + Icons.person, + size: 22.0, + ), + hintText: 'Register No', + hintStyle: TextStyle(fontSize: 17.0), ), - hintText: 'Register No.', - hintStyle: TextStyle(fontSize: 17.0), + validator: (input) { + if (input!.isEmpty) { + return 'Enter Register No'; + } + + return null; + }, + textInputAction: TextInputAction.next, ), - validator: (String? input) { - if (!RegExp(r'^[0-9]{12}$').hasMatch(input!)) { - return 'Invalid Details'; - } - - return null; - }, - onSaved: (String? input) { - initialname = input; - }, ), - ), - const Divider( - thickness: 2.0, - ), - Padding( - padding: const EdgeInsets.only( - top: 15.0, bottom: 15.0, left: 25.0, right: 25.0), - child: TextFormField( - autocorrect: false, - key: passkey, - focusNode: myFocusNodePasswordLogin, - maxLength: 10, - obscureText: _obscureTextLogin, - style: const TextStyle( - fontSize: 16.0, - ), - decoration: InputDecoration( - border: InputBorder.none, - icon: const Icon( - FontAwesomeIcons.lock, - size: 22.0, + const Divider( + thickness: 2.0, + ), + Padding( + padding: const EdgeInsets.only( + top: 15.0, + bottom: 15.0, + left: 25.0, + right: 25.0), + child: TextFormField( + autocorrect: false, + maxLength: 10, + obscureText: _obscureTextLogin, + controller: studentPasswordController, + style: const TextStyle( + fontSize: 16.0, ), - hintText: 'Password', - hintStyle: const TextStyle(fontSize: 17.0), - suffixIcon: GestureDetector( - onTap: _toggleLogin, - child: Icon( - _obscureTextLogin - ? FontAwesomeIcons.eye - : FontAwesomeIcons.eyeSlash, - size: 15.0, + onFieldSubmitted: (input) { + if (studentFormKey.currentState!.validate()) { + formValidation(); + } + }, + decoration: InputDecoration( + border: InputBorder.none, + icon: const Icon( + FontAwesomeIcons.lock, + size: 22.0, + ), + hintText: 'Password', + hintStyle: const TextStyle(fontSize: 17.0), + suffixIcon: GestureDetector( + onTap: _toggleLogin, + child: Icon( + _obscureTextLogin + ? FontAwesomeIcons.eye + : FontAwesomeIcons.eyeSlash, + size: 15.0, + ), ), ), + validator: (input) { + if (input!.isEmpty) { + return 'Enter Password'; + } else if (!RegExp(r'^[0-9/-]{10}$') + .hasMatch(input)) { + return 'Password is incorrect'; + } + + return null; + }, ), - onSaved: (String? input) { - pword = input.toString(); - }, - validator: (String? input) { - if (!RegExp(r'^[0-9/-]{10}$').hasMatch(input!)) { - return 'Password is incorrect'; - } - - return null; - }, ), - ), - ], + ], + ), ), ), ), ), Container( - margin: const EdgeInsets.only(top: 200.0), + margin: const EdgeInsets.only(top: 210.0), decoration: const BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(5.0)), boxShadow: [ @@ -477,11 +458,9 @@ class _LoginPageState extends State child: MaterialButton( highlightColor: Colors.transparent, splashColor: theme.GradientColors.loginGradientEnd, - onPressed: () async { - if (ukey.currentState!.validate()) { - if (passkey.currentState!.validate()) { - processdata(); - } + onPressed: () { + if (studentFormKey.currentState!.validate()) { + formValidation(); } }, child: const Padding( @@ -517,7 +496,7 @@ class _LoginPageState extends State void validateKey() { for (var i = 0; i < keys1.length; i++) { - if (keys1[i].name == givenkey) { + if (keys1[i].name == keyController.text) { validSnackBar('Loading...'); adminAuth(); break; @@ -535,7 +514,8 @@ class _LoginPageState extends State User? user; try { user = (await _auth.signInWithEmailAndPassword( - email: givenuser!, password: givenpass!)) + email: emailAddressController.text, + password: staffPasswordController.text)) .user; } catch (e) { ScaffoldMessenger.of(context).showSnackBar( @@ -570,137 +550,154 @@ class _LoginPageState extends State ), child: SizedBox( width: 300.0, - height: 270.0, + height: 310.0, child: SingleChildScrollView( - child: Column( - children: [ - Padding( - padding: const EdgeInsets.only( - top: 10.0, bottom: 10.0, left: 25.0, right: 25.0), - child: TextFormField( - key: adminkey, - //key form field - focusNode: myFocusNodeName, - controller: signupNameController, - keyboardType: TextInputType.visiblePassword, - textCapitalization: TextCapitalization.words, - inputFormatters: [ - FilteringTextInputFormatter.deny( - RegExp(r'\s\b|\b\s')) - ], - onSaved: (input) async { - givenkey = input; - }, - style: const TextStyle(fontSize: 16.0), - decoration: const InputDecoration( - border: InputBorder.none, - icon: Icon( - FontAwesomeIcons.key, + child: Form( + key: staffFormKey, + child: Column( + children: [ + SizedBox( + height: 89, + child: Padding( + padding: const EdgeInsets.only( + top: 10.0, + bottom: 10.0, + left: 25.0, + right: 25.0), + child: TextFormField( + controller: keyController, + keyboardType: TextInputType.visiblePassword, + textCapitalization: TextCapitalization.words, + inputFormatters: [ + FilteringTextInputFormatter.deny( + RegExp(r'\s\b|\b\s')) + ], + style: const TextStyle(fontSize: 16.0), + textInputAction: TextInputAction.next, + decoration: const InputDecoration( + border: InputBorder.none, + icon: Icon( + FontAwesomeIcons.key, + ), + hintText: 'Key', + hintStyle: TextStyle(fontSize: 16.0), + ), + validator: (input) { + if (input!.isEmpty) { + return 'Enter Key'; + } else if (input.length < 5) { + return 'key length must be greater than 5'; + } + return null; + // return null; + }, ), - hintText: 'Key', - hintStyle: TextStyle(fontSize: 16.0), ), - validator: (String? input) { - if (input!.length < 5) { - return 'key length must be greater than 5'; - } - return null; - // return null; - }, ), - ), - const Divider( - thickness: 2.0, - ), - Padding( - padding: const EdgeInsets.only( - top: 10.0, bottom: 10.0, left: 25.0, right: 25.0), - child: TextFormField( - autocorrect: false, - key: adminuserkey, - //EmailAdress field - focusNode: myFocusNodeEmail, - controller: signupEmailController, - onSaved: (input) { - givenuser = input.toString(); - }, - // onFieldSubmitted: (String input) { - // adminuserkey.currentState.validate(); - // }, - keyboardType: TextInputType.emailAddress, - inputFormatters: [ - FilteringTextInputFormatter.deny( - RegExp(r'\s\b|\b\s')) - ], - style: const TextStyle(fontSize: 16.0), - decoration: const InputDecoration( - border: InputBorder.none, - icon: Icon( - FontAwesomeIcons.envelope, + const Divider( + thickness: 2.0, + ), + SizedBox( + height: 89, + child: Padding( + padding: const EdgeInsets.only( + top: 10.0, + bottom: 10.0, + left: 25.0, + right: 25.0), + child: TextFormField( + autocorrect: false, + controller: emailAddressController, + keyboardType: TextInputType.emailAddress, + inputFormatters: [ + FilteringTextInputFormatter.deny( + RegExp(r'\s\b|\b\s')) + ], + style: const TextStyle(fontSize: 16.0), + textInputAction: TextInputAction.next, + decoration: const InputDecoration( + border: InputBorder.none, + icon: Icon( + FontAwesomeIcons.envelope, + ), + hintText: 'Email Address', + hintStyle: TextStyle(fontSize: 16.0), + ), + validator: (String? input) { + if (input!.isEmpty) { + return 'Enter Email Address'; + } else if (!RegExp( + r"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?") + .hasMatch(input)) { + return 'Valid Email Required'; + } + return null; + }, ), - hintText: 'Email Address', - hintStyle: TextStyle(fontSize: 16.0), ), - validator: (String? input) { - if (input!.isEmpty) { - return 'Email Required'; - } - if (!RegExp( - r"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?") - .hasMatch(input)) { - return 'Valid Email Required'; - } - return null; - }, ), - ), - const Divider( - thickness: 2.0, - ), - Padding( - padding: const EdgeInsets.only( - top: 10.0, bottom: 10.0, left: 25.0, right: 25.0), - child: TextFormField( - autocorrect: false, - key: adminpasskey, - //PasswordField - focusNode: myFocusNodePassword, - controller: signupPasswordController, - obscureText: _obscureTextSignup, - style: const TextStyle(fontSize: 16.0), - onSaved: (input) { - givenpass = input.toString(); - }, - inputFormatters: [ - FilteringTextInputFormatter.deny( - RegExp(r'\s\b|\b\s')) - ], - decoration: InputDecoration( - border: InputBorder.none, - icon: const Icon( - FontAwesomeIcons.lock, - ), - hintText: 'Password', - hintStyle: const TextStyle(fontSize: 16.0), - suffixIcon: GestureDetector( - onTap: _toggleSignup, - child: Icon( - _obscureTextSignup - ? FontAwesomeIcons.eye - : FontAwesomeIcons.eyeSlash, - size: 15.0, + const Divider( + thickness: 2.0, + ), + SizedBox( + height: 89, + child: Padding( + padding: const EdgeInsets.only( + top: 10.0, + bottom: 10.0, + left: 25.0, + right: 25.0), + child: TextFormField( + autocorrect: false, + controller: staffPasswordController, + obscureText: _obscureTextSignup, + style: const TextStyle(fontSize: 16.0), + validator: (input) { + if (input!.isEmpty) { + return 'Enter Password'; + } + }, + onFieldSubmitted: (input) { + processKey(); + if (staffFormKey.currentState!.validate()) { + validateKey(); + } + }, + inputFormatters: [ + FilteringTextInputFormatter.deny( + RegExp(r'\s\b|\b\s')) + ], + decoration: InputDecoration( + border: InputBorder.none, + icon: const Icon( + FontAwesomeIcons.lock, + ), + hintText: 'Password', + hintStyle: const TextStyle(fontSize: 16.0), + suffixIcon: GestureDetector( + onTap: _toggleSignup, + child: Icon( + _obscureTextSignup + ? FontAwesomeIcons.eye + : FontAwesomeIcons.eyeSlash, + size: 15.0, + ), + ), ), ), ), ), - ), - ], + SizedBox( + height: 10, + ) + ], + ), ), ), ), ), Container( - margin: const EdgeInsets.only(top: 260.0), + margin: const EdgeInsets.only(top: 300.0), decoration: const BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(5.0)), boxShadow: [ @@ -729,15 +726,10 @@ class _LoginPageState extends State //Button field highlightColor: Colors.transparent, splashColor: theme.GradientColors.loginGradientEnd, - onPressed: () async { + onPressed: () { processKey(); - adminkey.currentState!.save(); - adminuserkey.currentState!.save(); - adminpasskey.currentState!.save(); - if (adminkey.currentState!.validate()) { - if (adminuserkey.currentState!.validate()) { - validateKey(); - } + if (staffFormKey.currentState!.validate()) { + validateKey(); } }, child: const Padding( diff --git a/lib/views/student/screens/grade.dart b/lib/views/student/screens/grade.dart index 5a723b7..94bad63 100644 --- a/lib/views/student/screens/grade.dart +++ b/lib/views/student/screens/grade.dart @@ -1,6 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:webview_flutter/webview_flutter.dart'; -import 'package:flutter/foundation.dart' show kIsWeb; /// grade UI class Grade extends StatefulWidget { @@ -17,8 +15,6 @@ class Grade extends StatefulWidget { class _GradeState extends State { String url = 'https://coe1.annauniv.edu/home/'; bool isLoading = true; - final _key = UniqueKey(); - late WebViewController _controller; @override void initState() { diff --git a/lib/views/student/screens/notes_viewer.dart b/lib/views/student/screens/notes_viewer.dart index 2262a3d..be07e4c 100644 --- a/lib/views/student/screens/notes_viewer.dart +++ b/lib/views/student/screens/notes_viewer.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_pdfview/flutter_pdfview.dart'; -import 'package:path/path.dart'; class PDFViewerPage extends StatefulWidget { final File file; @@ -23,7 +22,6 @@ class _PDFViewerPageState extends State { @override Widget build(BuildContext context) { - final name = basename(widget.file.path); final text = '${indexPage + 1} of $pages'; return Scaffold( @@ -50,7 +48,7 @@ class _PDFViewerPageState extends State { ), body: PDFView( filePath: widget.file.path, - onRender: (pages) => setState(() => this.pages = pages!), + onRender: (pages) => setState(() => this.pages = pages!), onViewCreated: (controller) => setState(() => this.controller = controller), onPageChanged: (indexPage, _) => diff --git a/lib/views/student/screens/view_notes.dart b/lib/views/student/screens/view_notes.dart index 937594e..4513a0a 100644 --- a/lib/views/student/screens/view_notes.dart +++ b/lib/views/student/screens/view_notes.dart @@ -50,7 +50,6 @@ class _NotesState extends State { } } - void openPDF(BuildContext context, File file) => Navigator.of(context).push( MaterialPageRoute(builder: (context) => PDFViewerPage(file: file)), ); @@ -85,22 +84,28 @@ class _NotesState extends State { hintStyle: TextStyle(fontSize: 18.0), border: InputBorder.none, ), + textInputAction: TextInputAction.search, onChanged: onSearchTextChanged, + onSubmitted: onSearchTextChanged, ), - trailing: IconButton( - icon: const Icon( - Icons.close, - ), - onPressed: () { - controller.clear(); - onSearchTextChanged(''); - }, - ), + trailing: controller.text.isNotEmpty + ? IconButton( + icon: const Icon( + Icons.close, + ), + onPressed: () { + if (controller.text.isNotEmpty) { + controller.clear(); + onSearchTextChanged(''); + } + }, + ) + : null, ), ), ), Expanded( - child: _searchResult.isNotEmpty || controller.text.isNotEmpty + child: _searchResult.isNotEmpty && controller.text.isNotEmpty ? ListView.builder( itemCount: _searchResult.length, itemBuilder: (context, index) { @@ -114,6 +119,7 @@ class _NotesState extends State { ), ], ), + margin: EdgeInsets.all(2.0), child: GestureDetector( onTap: () async { sendURL(_notesList[index].name); @@ -138,34 +144,50 @@ class _NotesState extends State { ); }, ) - : ListView.builder( - itemCount: _notesList.length, - itemBuilder: (context, index) { - return GestureDetector( - onTap: () async { - sendURL(_notesList[index].name); - }, - child: Card( - child: ListTile( - trailing: IconButton( - icon: const Icon( - Icons.arrow_downward, - color: Colors.green, - ), - onPressed: () { - openURL(_notesList[index].name.toString()); - }, - ), - leading: const Icon( - Icons.insert_drive_file, - color: Colors.deepOrange, + : _searchResult.isEmpty && controller.text.isNotEmpty + ? Center( + child: Text( + 'Notes Not Available', + style: TextStyle(fontSize: 20.0), + ), + ) + : _notesList.isNotEmpty + ? ListView.builder( + itemCount: _notesList.length, + itemBuilder: (context, index) { + return GestureDetector( + onTap: () async { + sendURL(_notesList[index].name); + }, + child: Card( + child: ListTile( + trailing: IconButton( + icon: const Icon( + Icons.arrow_downward, + color: Colors.green, + ), + onPressed: () { + openURL(_notesList[index] + .name + .toString()); + }, + ), + leading: const Icon( + Icons.insert_drive_file, + color: Colors.deepOrange, + ), + title: Text(_notesList[index].name), + ), + ), + ); + }, + ) + : Center( + child: Text( + 'Notes Not Available', + style: TextStyle(fontSize: 20.0), ), - title: Text(_notesList[index].name), ), - ), - ); - }, - ), ), ], ),