diff --git a/lib/app/view/course_enrolment/course_enrolment.dart b/lib/app/view/course_enrolment/course_enrolment.dart index bc15116..8ed820c 100644 --- a/lib/app/view/course_enrolment/course_enrolment.dart +++ b/lib/app/view/course_enrolment/course_enrolment.dart @@ -13,12 +13,27 @@ class CourseEnrolmentPage extends StatelessWidget { } } -class CourseEnrolmentScreen extends StatelessWidget { +class CourseEnrolmentScreen extends StatefulWidget { CourseEnrolmentScreen({ Key? key, }) : super(key: key); - List? listCourses; + @override + State createState() => _CourseEnrolmentScreenState(); +} + +class _CourseEnrolmentScreenState extends State { + List listCourses = [ + Course( + title: 'Algorithms[PC-A+PC-B][Spring-22]', + id: 14226, + enrollmentKey: 'CSE1234', + ) + ]; + + TextEditingController urlController = TextEditingController(); + + TextEditingController enrollkeyController = TextEditingController(); @override Widget build(BuildContext context) { @@ -31,57 +46,73 @@ class CourseEnrolmentScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - if (listCourses != null) - ...listCourses!.map( - (e) => ListTile( - leading: IconButton( - icon: const Icon(Icons.tiktok), - onPressed: () {}, - ), - title: Text(e.title), - trailing: IconButton( - icon: const Icon(Icons.delete), - onPressed: () {}, - ), + ...listCourses.map( + (e) => ListTile( + leading: IconButton( + icon: const Icon(Icons.tiktok), + onPressed: () {}, + ), + title: Text(e.title), + trailing: IconButton( + icon: const Icon(Icons.delete), + onPressed: () { + setState(() { + listCourses.removeWhere((element) => element.id == e.id); + }); + }, ), ), + ), Padding( padding: const EdgeInsets.symmetric(horizontal: 25), child: ElevatedButton( onPressed: () { showDialog( - context: context, - builder: (ctx) => AlertDialog( - title: const Text('Add your course'), - content: Container( - height: 150, - child: Column( - children: const [ - TextField( - decoration: InputDecoration( - label: Text('URL'), - ), - ), - SizedBox( - height: 10, - ), - TextField( - decoration: InputDecoration( - label: Text('Enroll key'), - ), - ), - ], + context: context, + builder: (ctx) => AlertDialog( + title: const Text('Add your course'), + content: Container( + height: 150, + child: Column( + children: [ + TextField( + controller: urlController, + decoration: const InputDecoration( + label: Text('URL'), ), ), - actions: [ - TextButton( - child: const Text('Add'), - onPressed: () { - Navigator.pop(context); - }, - ) - ], - )); + const SizedBox( + height: 10, + ), + TextField( + controller: enrollkeyController, + decoration: const InputDecoration( + label: Text('Enroll key'), + ), + ), + ], + ), + ), + actions: [ + TextButton( + child: const Text('Add'), + onPressed: () { + setState(() { + listCourses.add( + Course( + id: 111, + title: urlController.text, + enrollmentKey: enrollkeyController.text, + ), + ); + }); + + Navigator.pop(context); + }, + ) + ], + ), + ); }, style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.black12), diff --git a/lib/app/view/course_enrolment/models/course.dart b/lib/app/view/course_enrolment/models/course.dart index 44e1ac0..7d0aeb2 100644 --- a/lib/app/view/course_enrolment/models/course.dart +++ b/lib/app/view/course_enrolment/models/course.dart @@ -2,8 +2,9 @@ class Course { Course({ required this.title, required this.enrollmentKey, + required this.id, }); - + int id; String title; String enrollmentKey; } diff --git a/lib/app/view/menus_page/menus_page.dart b/lib/app/view/menus_page/menus_page.dart index 473c107..f2a3018 100644 --- a/lib/app/view/menus_page/menus_page.dart +++ b/lib/app/view/menus_page/menus_page.dart @@ -12,101 +12,24 @@ class MenuesPage extends StatelessWidget { const MenuesPage({Key? key}) : super(key: key); static const pathName = '/menus'; + @override + Widget build(BuildContext context) { + return MenueScreen(); + } +} + +class MenueScreen extends StatelessWidget { + const MenueScreen({ + Key? key, + }) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( appBar: const MyAppbar( title: Text('DIUSpeeder'), ), - body: ListView.builder( - itemCount: menus.length, - padding: const EdgeInsets.only(top: 10, left: 20, right: 20), - itemBuilder: (ctx, index) => Stack( - children: [ - Container( - height: 140, - width: double.infinity, - decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.cover, - colorFilter: ColorFilter.mode( - Colors.blueGrey.withOpacity(0.1), - BlendMode.dstATop, - ), - image: menus[index].image, - ), - borderRadius: BorderRadius.circular(15), - gradient: menus[index].gradient, - ), - margin: const EdgeInsets.only(bottom: 15), - child: InkWell( - onTap: () { - if (!menus[index].isComingSoon) { - if (menus[index].isLoginRequired) { - if (BlocProvider.of(context).state - is AuthblcLoginState) { - Navigator.of(context).pushNamed(menus[index].pageOpen); - } else { - Navigator.of(context).pushNamed( - LoginPage.pathName, - arguments: menus[index].pageOpen, - ); - } - } else { - Navigator.of(context).pushNamed(menus[index].pageOpen); - } - } else { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text( - 'This option is coming soon 🥺. Stay with us. ', - ), - ), - ); - } - }, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - menus[index].icon, - size: 50, - color: menus[index].titleIconColor, - ), - const SizedBox( - height: 5, - ), - Text( - menus[index].title, - style: Theme.of(context).textTheme.titleLarge!.copyWith( - color: menus[index].titleIconColor.withOpacity(0.8), - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), - ), - if (menus[index].isComingSoon) - Container( - height: 140, - width: double.infinity, - decoration: BoxDecoration( - color: Colors.black38, - borderRadius: BorderRadius.circular(15), - ), - child: Center( - child: FittedBox( - child: Text( - 'Coming soon', - style: Theme.of(context).textTheme.headline4, - ), - ), - ), - ), - ], - ), - ), + body: const MenuItemWidgets(), bottomNavigationBar: Container( decoration: BoxDecoration( border: Border.all(width: 0.7, color: Colors.white10), @@ -157,3 +80,102 @@ class MenuesPage extends StatelessWidget { ); } } + +class MenuItemWidgets extends StatelessWidget { + const MenuItemWidgets({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return ListView.builder( + itemCount: menus.length, + padding: const EdgeInsets.only(top: 10, left: 20, right: 20), + itemBuilder: (ctx, index) => Stack( + children: [ + Container( + height: 140, + width: double.infinity, + decoration: BoxDecoration( + image: DecorationImage( + fit: BoxFit.cover, + colorFilter: ColorFilter.mode( + Colors.blueGrey.withOpacity(0.1), + BlendMode.dstATop, + ), + image: menus[index].image, + ), + borderRadius: BorderRadius.circular(15), + gradient: menus[index].gradient, + ), + margin: const EdgeInsets.only(bottom: 15), + child: InkWell( + onTap: () { + if (!menus[index].isComingSoon) { + if (menus[index].isLoginRequired) { + if (BlocProvider.of(context).state + is AuthblcLoginState) { + Navigator.of(context).pushNamed(menus[index].pageOpen); + } else { + Navigator.of(context).pushNamed( + LoginPage.pathName, + arguments: menus[index].pageOpen, + ); + } + } else { + Navigator.of(context).pushNamed(menus[index].pageOpen); + } + } else { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text( + 'This option is coming soon 🥺. Stay with us. ', + ), + ), + ); + } + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + menus[index].icon, + size: 50, + color: menus[index].titleIconColor, + ), + const SizedBox( + height: 5, + ), + Text( + menus[index].title, + style: Theme.of(context).textTheme.titleLarge!.copyWith( + color: menus[index].titleIconColor.withOpacity(0.8), + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + ), + if (menus[index].isComingSoon) + Container( + height: 140, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.black38, + borderRadius: BorderRadius.circular(15), + ), + child: Center( + child: FittedBox( + child: Text( + 'Coming soon', + style: Theme.of(context).textTheme.headline4, + ), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/app/view/menus_page/model/menus.dart b/lib/app/view/menus_page/model/menus.dart index dbb7e54..9a2f61c 100644 --- a/lib/app/view/menus_page/model/menus.dart +++ b/lib/app/view/menus_page/model/menus.dart @@ -51,7 +51,7 @@ const List menus = [ icon: Icons.join_full_outlined, title: 'Course enrolment', titleIconColor: Colors.white, - isComingSoon: false, + isComingSoon: true, ), Menu( image: AssetImage('assets/sgpaBar.png'), diff --git a/lib/core/themes/app_theme.dart b/lib/core/themes/app_theme.dart index 719659d..4a13050 100644 --- a/lib/core/themes/app_theme.dart +++ b/lib/core/themes/app_theme.dart @@ -32,7 +32,7 @@ class AppTheme { ); static Brightness get currentSystemBrightness => - SchedulerBinding.instance!.window.platformBrightness; + SchedulerBinding.instance.window.platformBrightness; static void setStatusBarAndNavigationBarColors(ThemeMode themeMode) { SystemChrome.setSystemUIOverlayStyle( diff --git a/pubspec.lock b/pubspec.lock index 81b505d..d974a1d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -456,7 +456,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -692,7 +692,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -832,7 +832,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" very_good_analysis: dependency: "direct dev" description: diff --git a/pubspec.yaml b/pubspec.yaml index 30f807b..da069a0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.2+4 +version: 1.0.3+5 environment: sdk: ">=2.17.0-69.2.beta <3.0.0"