diff --git a/lib/favorite_page_provider.dart b/lib/favorite_page_provider.dart new file mode 100644 index 0000000..3111012 --- /dev/null +++ b/lib/favorite_page_provider.dart @@ -0,0 +1,51 @@ +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +class FavouriteScreenProvider with ChangeNotifier { + bool _drawingBoard = false; + bool get drawingBoard => _drawingBoard; + + List _selectedItemList = []; + + List get selectedItemList => _selectedItemList; + + FavouriteScreenProvider() { + loadFromPrefs(); + } + + void setDrawingBoard() { + _drawingBoard = !_drawingBoard; + notifyListeners(); + saveToPrefs(); + } + + void setList(int item) { + _selectedItemList.add(item); + notifyListeners(); + saveToPrefs(); + } + + void removeList(int item) { + _selectedItemList.remove(item); + notifyListeners(); + saveToPrefs(); + } + + Future loadFromPrefs() async { + final prefs = await SharedPreferences.getInstance(); + _drawingBoard = prefs.getBool('drawingBoard') ?? false; + _selectedItemList = prefs + .getStringList('selectedItemList') + ?.map((e) => int.parse(e)) + .toList() ?? + []; + notifyListeners(); + } + + Future saveToPrefs() async { + final prefs = await SharedPreferences.getInstance(); + await prefs.setBool('drawingBoard', _drawingBoard); + await prefs.setStringList('selectedItemList', + _selectedItemList.map((e) => e.toString()).toList()); + } +} diff --git a/lib/main.dart b/lib/main.dart index d6204a6..5da1da9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:adaptive_theme/adaptive_theme.dart'; +import 'package:learn/favorite_page_provider.dart'; import 'package:learn/landing_page.dart'; import 'package:learn/pages/main_home.dart'; import 'package:learn/utils/route/routes.dart'; @@ -9,20 +10,25 @@ import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; DateTime? currentBackPressTime; -bool visitedGettingStartedPageOnceBool=false; //to store the value of +bool visitedGettingStartedPageOnceBool = false; //to store the value of void main() async { WidgetsFlutterBinding.ensureInitialized(); final savedThemeMode = await AdaptiveTheme.getThemeMode(); final prefs = await SharedPreferences.getInstance(); - visitedGettingStartedPageOnceBool = prefs.getBool('visitedGettingStartedPageOnce')??false; //if its is null i.e first time then set to false + visitedGettingStartedPageOnceBool = + prefs.getBool('visitedGettingStartedPageOnce') ?? + false; //if its is null i.e first time then set to false - runApp( - ChangeNotifierProvider( - create: (context) => ThemeProvider(), - child: MyApp(savedThemeMode: savedThemeMode), - ), - ); + runApp(MultiProvider( + providers: [ + ChangeNotifierProvider( + create: (context) => ThemeProvider(), + ), + ChangeNotifierProvider(create: (context) => FavouriteScreenProvider()), + ], + child: MyApp(savedThemeMode: savedThemeMode), + )); } class MyApp extends StatelessWidget { @@ -40,7 +46,9 @@ class MyApp extends StatelessWidget { theme: ThemeData.light(), darkTheme: ThemeData.dark(), themeMode: themeProvider.themeMode, - home: visitedGettingStartedPageOnceBool? const MainHome(): const LandingPage(), //if page opened for first time , show landing page (getting started page), else show home page + home: visitedGettingStartedPageOnceBool + ? const MainHome() + : const LandingPage(), //if page opened for first time , show landing page (getting started page), else show home page onGenerateRoute: Routers.generateRoute, ); }, diff --git a/lib/pages/explore/explore.dart b/lib/pages/explore/explore.dart index c931b57..d72913f 100644 --- a/lib/pages/explore/explore.dart +++ b/lib/pages/explore/explore.dart @@ -11,6 +11,7 @@ import 'package:learn/pages/modules/shapes.dart'; import 'package:learn/utils/constants.dart'; import 'package:learn/utils/route/route_constant.dart'; import 'package:provider/provider.dart'; +import '../../favorite_page_provider.dart'; import '../../theme_provider.dart'; import '../../utils/const_dimensions.dart'; import '../../widgets/drawer.dart'; @@ -24,315 +25,422 @@ class ExplorePage extends StatefulWidget { } class _ExplorePageState extends State { + bool _isLoading = true; + + @override + void initState() { + super.initState(); + _loadPrefs(); + } + + Future _loadPrefs() async { + await Provider.of(context, listen: false) + .loadFromPrefs(); + setState(() { + _isLoading = false; + }); + } + @override Widget build(BuildContext context) { final themeProvider = Provider.of(context); - return Scaffold( - appBar: AppBar( - title: const Text( - 'Explore', - style: TextStyle(fontWeight: FontWeight.bold), - ), - actions: [ - Padding( - padding: const EdgeInsets.only(right: 16, top: 1), - child: IconButton( - icon: Icon( - themeProvider.themeMode == ThemeMode.dark - ? Icons.dark_mode - : Icons.light_mode, + final provider = + Provider.of(context, listen: false); + List selectItem = provider.selectedItemList; + return _isLoading + ? Center(child: CircularProgressIndicator()) + : Scaffold( + appBar: AppBar( + title: const Text( + 'Explore', + style: TextStyle(fontWeight: FontWeight.bold), ), - onPressed: () { - themeProvider.toggleTheme(); - }, + actions: [ + Padding( + padding: const EdgeInsets.only(right: 16, top: 1), + child: IconButton( + icon: Icon( + themeProvider.themeMode == ThemeMode.dark + ? Icons.dark_mode + : Icons.light_mode, + ), + onPressed: () { + themeProvider.toggleTheme(); + }, + ), + ), + ], ), - ), - ], - ), - body: SafeArea( - child: CustomScrollView( - slivers: [ - // SliverAppBar( - // pinned: true, - // title: Padding( - // padding: const EdgeInsets.fromLTRB(0, 12, 16, 4), - // child: Text( - // "Explore", - // style: Theme.of(context) - // .textTheme - // .headlineLarge! - // .copyWith(fontWeight: FontWeight.bold, fontSize: 30.0), - // ), - // ), - // ), - SliverList( - delegate: SliverChildListDelegate( - [ - // GestureDetector( - // onTap: () { - // Navigator.push( - // context, - // (MaterialPageRoute( - // builder: (context) => const Quiz()))); - // }, - // child: Container( - // margin: const EdgeInsets.symmetric( - // horizontal: 18.0, vertical: 8), - // padding: const EdgeInsets.all(8.0), - // decoration: BoxDecoration( - // border: Border.all(color: Colors.black, width: 1.0), - // borderRadius: BorderRadius.circular(8.0), - // color: Colors.blueAccent, - // ), - // child: Row( - // children: [ - // SizedBox( - // width: ConstantDimensions.widthExtraLarge, - // height: ConstantDimensions.heightExtraLarge, - // child: - // SvgPicture.asset('assets/explore/notebook.svg'), - // ), - // const SizedBox( - // width: ConstantDimensions.widthMedium_Large), - // const Text( - // 'Quiz', - // style: TextStyle( - // fontWeight: FontWeight.bold, - // fontSize: 30.0, - // fontFamily: 'Comic', - // color: Colors.white, - // ), - // ), - // ], + body: SafeArea( + child: CustomScrollView( + slivers: [ + // SliverAppBar( + // pinned: true, + // title: Padding( + // padding: const EdgeInsets.fromLTRB(0, 12, 16, 4), + // child: Text( + // "Explore", + // style: Theme.of(context) + // .textTheme + // .headlineLarge! + // .copyWith(fontWeight: FontWeight.bold, fontSize: 30.0), // ), // ), // ), - GestureDetector( - onTap: () { - Navigator.pushNamed( - context, AllRoutesConstant.drawingboardRoute); - }, - child: Container( - margin: const EdgeInsets.symmetric( - horizontal: 24, vertical: 12), - height: ConstantDimensions.heightExtraLarge * 4, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(16), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.2), - spreadRadius: 2, - blurRadius: 5, - offset: const Offset(0, 3), - ), - ], - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(16), - child: Stack( - fit: StackFit.expand, - alignment: Alignment.center, - children: [ - ImageFiltered( - imageFilter: - ImageFilter.blur(sigmaX: 5, sigmaY: 5), - child: SvgPicture.asset( - 'assets/explore/drawing_board.svg', - fit: BoxFit.cover, - ), + SliverList( + delegate: SliverChildListDelegate( + [ + // GestureDetector( + // onTap: () { + // Navigator.push( + // context, + // (MaterialPageRoute( + // builder: (context) => const Quiz()))); + // }, + // child: Container( + // margin: const EdgeInsets.symmetric( + // horizontal: 18.0, vertical: 8), + // padding: const EdgeInsets.all(8.0), + // decoration: BoxDecoration( + // border: Border.all(color: Colors.black, width: 1.0), + // borderRadius: BorderRadius.circular(8.0), + // color: Colors.blueAccent, + // ), + // child: Row( + // children: [ + // SizedBox( + // width: ConstantDimensions.widthExtraLarge, + // height: ConstantDimensions.heightExtraLarge, + // child: + // SvgPicture.asset('assets/explore/notebook.svg'), + // ), + // const SizedBox( + // width: ConstantDimensions.widthMedium_Large), + // const Text( + // 'Quiz', + // style: TextStyle( + // fontWeight: FontWeight.bold, + // fontSize: 30.0, + // fontFamily: 'Comic', + // color: Colors.white, + // ), + // ), + // ], + // ), + // ), + // ), + GestureDetector( + onTap: () { + Navigator.pushNamed( + context, AllRoutesConstant.drawingboardRoute); + }, + child: Container( + margin: const EdgeInsets.symmetric( + horizontal: 24, vertical: 12), + height: ConstantDimensions.heightExtraLarge * 4, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.2), + spreadRadius: 2, + blurRadius: 5, + offset: const Offset(0, 3), + ), + ], ), - Positioned.fill( - child: Align( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Drawing Board", - style: Theme.of(context) - .textTheme - .headlineMedium! - .copyWith( - color: Colors.white, - fontWeight: FontWeight.bold, - shadows: [ - const Shadow( - color: Colors.black, - offset: Offset(2, 1), - blurRadius: 4, - ), - ], - ), + child: ClipRRect( + borderRadius: BorderRadius.circular(16), + child: Stack( + fit: StackFit.expand, + alignment: Alignment.center, + children: [ + ImageFiltered( + imageFilter: ImageFilter.blur( + sigmaX: 5, sigmaY: 5), + child: SvgPicture.asset( + 'assets/explore/drawing_board.svg', + fit: BoxFit.cover, ), - Text( - "Drawing Board for Artist Kids!", - style: Theme.of(context) - .textTheme - .bodyMedium! - .copyWith( - color: Colors.white, - fontWeight: FontWeight.bold, - shadows: [ - const Shadow( - color: Colors.black, - offset: Offset(2, 1), - blurRadius: 2, + ), + Positioned.fill( + child: Align( + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Text( + "Drawing Board", + style: Theme.of(context) + .textTheme + .headlineMedium! + .copyWith( + color: Colors.white, + fontWeight: FontWeight.bold, + shadows: [ + const Shadow( + color: Colors.black, + offset: Offset(2, 1), + blurRadius: 4, + ), + ], + ), + ), + Text( + "Drawing Board for Artist Kids!", + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Colors.white, + fontWeight: FontWeight.bold, + shadows: [ + const Shadow( + color: Colors.black, + offset: Offset(2, 1), + blurRadius: 2, + ), + ], + ), ), ], ), ), - ], - ), + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Container( + width: 40, + height: 40, + margin: const EdgeInsets.all(5), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: + BorderRadius.circular(10), + ), + child: + Consumer( + builder: (context, item, child) { + return IconButton( + onPressed: () { + item.setDrawingBoard(); + }, + icon: item.drawingBoard + ? const Icon( + Icons.favorite, + size: 25, + color: Colors.red, + ) + : const Icon( + Icons.favorite_border, + size: 25, + ), + ); + }, + ), + ), + ], + ) + ], ), - ), - ], - ), - )), - ), - ], - ), - ), - SliverList( - delegate: SliverChildBuilderDelegate( - (context, index) { - return GestureDetector( - onTap: () { - try { - switch (index) { - case 0: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => const Quiz()))); - break; - case 1: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => const AtoZ()))); - break; - case 2: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => BirdsPage()))); - break; - case 3: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => - const ColoursPage()))); - break; - case 4: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => BirdsPage()))); - break; - case 5: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => const ShapesPage()))); - break; - case 6: - Navigator.push( - context, - (MaterialPageRoute( - builder: (context) => PlanetsPage()))); - break; - default: - break; - } - } catch (e) { - // ignore: avoid_print - print(e); - } - }, - child: Container( - margin: const EdgeInsets.symmetric( - horizontal: 24, vertical: 12), - height: ConstantDimensions.heightExtraLarge * 4, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(16), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.2), - spreadRadius: 2, - blurRadius: 5, - offset: const Offset(0, 3), - ), - ], + )), ), - child: ClipRRect( - borderRadius: BorderRadius.circular(16), - child: Stack( - fit: StackFit.expand, - alignment: Alignment.center, - children: [ - ImageFiltered( - imageFilter: - ImageFilter.blur(sigmaX: 5, sigmaY: 5), - child: Image.asset( - AppConstants.modules[index].thumbnailPath, - fit: BoxFit.cover, - ), + ], + ), + ), + SliverList( + delegate: SliverChildBuilderDelegate( + (context, index) { + return GestureDetector( + onTap: () { + try { + switch (index) { + case 0: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => const Quiz()))); + break; + case 1: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => const AtoZ()))); + break; + case 2: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => BirdsPage()))); + break; + case 3: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => + const ColoursPage()))); + break; + case 4: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => BirdsPage()))); + break; + case 5: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => + const ShapesPage()))); + break; + case 6: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => + PlanetsPage()))); + break; + default: + break; + } + } catch (e) { + // ignore: avoid_print + print(e); + } + }, + child: Container( + margin: const EdgeInsets.symmetric( + horizontal: 24, vertical: 12), + height: ConstantDimensions.heightExtraLarge * 4, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.2), + spreadRadius: 2, + blurRadius: 5, + offset: const Offset(0, 3), + ), + ], ), - Positioned.fill( - child: Align( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - AppConstants.modules[index].name, - style: Theme.of(context) - .textTheme - .headlineMedium! - .copyWith( - color: Colors.white, - fontWeight: FontWeight.bold, - shadows: [ - const Shadow( - color: Colors.black, - offset: Offset(2, 1), - blurRadius: 4, - ), - ], - ), + child: ClipRRect( + borderRadius: BorderRadius.circular(16), + child: Stack( + fit: StackFit.expand, + alignment: Alignment.center, + children: [ + ImageFiltered( + imageFilter: ImageFilter.blur( + sigmaX: 5, sigmaY: 5), + child: Image.asset( + AppConstants + .modules[index].thumbnailPath, + fit: BoxFit.cover, ), - Text( - AppConstants.modules[index].description, - style: Theme.of(context) - .textTheme - .bodyMedium! - .copyWith( - color: Colors.white, - fontWeight: FontWeight.bold, - shadows: [ - const Shadow( - color: Colors.black, - offset: Offset(2, 1), - blurRadius: 2, + ), + Positioned.fill( + child: Align( + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Text( + AppConstants.modules[index].name, + style: Theme.of(context) + .textTheme + .headlineMedium! + .copyWith( + color: Colors.white, + fontWeight: FontWeight.bold, + shadows: [ + const Shadow( + color: Colors.black, + offset: Offset(2, 1), + blurRadius: 4, + ), + ], + ), + ), + Text( + AppConstants + .modules[index].description, + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Colors.white, + fontWeight: FontWeight.bold, + shadows: [ + const Shadow( + color: Colors.black, + offset: Offset(2, 1), + blurRadius: 2, + ), + ], + ), ), ], ), ), - ], - ), + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Container( + width: 40, + height: 40, + margin: const EdgeInsets.all(5), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: + BorderRadius.circular(10), + ), + child: + Consumer( + builder: (context, item, child) { + return IconButton( + onPressed: () { + if (item.selectedItemList + .contains(index)) { + item.removeList(index); + } else { + print(selectItem); + item.setList(index); + } + }, + icon: selectItem.contains(index) + ? const Icon( + Icons.favorite, + size: 25, + color: Colors.red, + ) + : const Icon( + Icons.favorite_border, + size: 25, + ), + ); + }, + ), + ), + ], + ) + ], ), - ), - ], - ), - )), - ); - }, - childCount: AppConstants.modules.length, + )), + ); + }, + childCount: AppConstants.modules.length, + ), + ), + ], ), ), - ], - ), - ), - drawer: const MyDrawer(), - ); + drawer: const MyDrawer(), + ); } } diff --git a/lib/pages/favorite.dart b/lib/pages/favorite.dart index 092b179..60998e0 100644 --- a/lib/pages/favorite.dart +++ b/lib/pages/favorite.dart @@ -1,16 +1,444 @@ +import 'dart:ui'; + import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:learn/pages/explore/quiz.dart'; +import 'package:learn/pages/modules/atoz.dart'; +import 'package:learn/pages/modules/birds.dart'; +import 'package:learn/pages/modules/colours.dart'; +import 'package:learn/pages/modules/planets.dart'; +import 'package:learn/pages/modules/shapes.dart'; +import 'package:learn/utils/constants.dart'; +import 'package:learn/utils/route/route_constant.dart'; +import 'package:provider/provider.dart'; +import '../../favorite_page_provider.dart'; +import '../../theme_provider.dart'; +import '../../utils/const_dimensions.dart'; +import '../../widgets/drawer.dart'; -class FavoritePage extends StatelessWidget { +// Explore Page +class FavoritePage extends StatefulWidget { const FavoritePage({super.key}); - // Favorite Page - // All the favorited modules by the user will be placed here - // todo: Implement the Favorite Page + @override + State createState() => _FavoritePageState(); +} + +class _FavoritePageState extends State { + bool _isLoading = true; + + @override + void initState() { + super.initState(); + _loadPrefs(); + } + + Future _loadPrefs() async { + await Provider.of(context, listen: false) + .loadFromPrefs(); + setState(() { + _isLoading = false; + }); + } @override Widget build(BuildContext context) { - return const Center( - child: Text("Favorited Items here"), - ); + final themeProvider = Provider.of(context); + final provider = + Provider.of(context, listen: false); + List selectItem = provider.selectedItemList; + return (provider.selectedItemList.isEmpty && !provider.drawingBoard) + ? Center( + child: Text("No Favorite Items"), + ) + : _isLoading + ? Center(child: CircularProgressIndicator()) + : Scaffold( + appBar: AppBar( + title: const Text( + 'Favorite', + style: TextStyle(fontWeight: FontWeight.bold), + ), + actions: [ + Padding( + padding: const EdgeInsets.only(right: 16, top: 1), + child: IconButton( + icon: Icon( + themeProvider.themeMode == ThemeMode.dark + ? Icons.dark_mode + : Icons.light_mode, + ), + onPressed: () { + themeProvider.toggleTheme(); + }, + ), + ), + ], + ), + body: SafeArea( + child: CustomScrollView( + slivers: [ + SliverList( + delegate: SliverChildListDelegate( + [ + GestureDetector( + onTap: () { + Navigator.pushNamed(context, + AllRoutesConstant.drawingboardRoute); + }, + child: !provider.drawingBoard + ? Container( + height: 0, + ) + : Container( + margin: const EdgeInsets.symmetric( + horizontal: 24, vertical: 12), + height: + ConstantDimensions.heightExtraLarge * + 4, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: + Colors.black.withOpacity(0.2), + spreadRadius: 2, + blurRadius: 5, + offset: const Offset(0, 3), + ), + ], + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(16), + child: Stack( + fit: StackFit.expand, + alignment: Alignment.center, + children: [ + ImageFiltered( + imageFilter: ImageFilter.blur( + sigmaX: 5, sigmaY: 5), + child: SvgPicture.asset( + 'assets/explore/drawing_board.svg', + fit: BoxFit.cover, + ), + ), + Positioned.fill( + child: Align( + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Text( + "Drawing Board", + style: Theme.of(context) + .textTheme + .headlineMedium! + .copyWith( + color: Colors.white, + fontWeight: + FontWeight.bold, + shadows: [ + const Shadow( + color: Colors.black, + offset: + Offset(2, 1), + blurRadius: 4, + ), + ], + ), + ), + Text( + "Drawing Board for Artist Kids!", + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Colors.white, + fontWeight: + FontWeight.bold, + shadows: [ + const Shadow( + color: Colors.black, + offset: + Offset(2, 1), + blurRadius: 2, + ), + ], + ), + ), + ], + ), + ), + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.end, + children: [ + Container( + width: 40, + height: 40, + margin: + const EdgeInsets.all(5), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: + BorderRadius.circular( + 10), + ), + child: Consumer< + FavouriteScreenProvider>( + builder: + (context, item, child) { + return IconButton( + onPressed: () { + item.setDrawingBoard(); + setState(() {}); + }, + icon: item.drawingBoard + ? const Icon( + Icons.favorite, + size: 25, + color: + Colors.red, + ) + : const Icon( + Icons + .favorite_border, + size: 25, + ), + ); + }, + ), + ), + ], + ) + ], + ), + )), + ), + ], + ), + ), + SliverList( + delegate: SliverChildBuilderDelegate( + childCount: AppConstants.modules.length, + (context, index) { + print(selectItem); + + return GestureDetector( + onTap: () { + try { + switch (index) { + case 0: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => + const Quiz()))); + break; + case 1: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => + const AtoZ()))); + break; + case 2: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => + BirdsPage()))); + break; + case 3: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => + const ColoursPage()))); + break; + case 4: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => + BirdsPage()))); + break; + case 5: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => + const ShapesPage()))); + break; + case 6: + Navigator.push( + context, + (MaterialPageRoute( + builder: (context) => + PlanetsPage()))); + break; + default: + break; + } + } catch (e) { + // ignore: avoid_print + print(e); + } + }, + child: !(selectItem.contains(index)) + ? Container() + : Container( + margin: const EdgeInsets.symmetric( + horizontal: 24, vertical: 12), + height: + ConstantDimensions.heightExtraLarge * + 4, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: + Colors.black.withOpacity(0.2), + spreadRadius: 2, + blurRadius: 5, + offset: const Offset(0, 3), + ), + ], + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(16), + child: Stack( + fit: StackFit.expand, + alignment: Alignment.center, + children: [ + ImageFiltered( + imageFilter: ImageFilter.blur( + sigmaX: 5, sigmaY: 5), + child: Image.asset( + AppConstants.modules[index] + .thumbnailPath, + fit: BoxFit.cover, + ), + ), + Positioned.fill( + child: Align( + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Text( + AppConstants + .modules[index].name, + style: Theme.of(context) + .textTheme + .headlineMedium! + .copyWith( + color: Colors.white, + fontWeight: + FontWeight.bold, + shadows: [ + const Shadow( + color: Colors.black, + offset: + Offset(2, 1), + blurRadius: 4, + ), + ], + ), + ), + Text( + AppConstants + .modules[index] + .description, + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Colors.white, + fontWeight: + FontWeight.bold, + shadows: [ + const Shadow( + color: Colors.black, + offset: + Offset(2, 1), + blurRadius: 2, + ), + ], + ), + ), + ], + ), + ), + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.end, + children: [ + Container( + width: 40, + height: 40, + margin: + const EdgeInsets.all(5), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: + BorderRadius.circular( + 10), + ), + child: Consumer< + FavouriteScreenProvider>( + builder: + (context, item, child) { + return IconButton( + onPressed: () { + if (item + .selectedItemList + .contains( + index)) { + print(selectItem); + item.removeList( + index); + setState(() {}); + } else { + item.setList(index); + } + }, + icon: selectItem + .contains(index) + ? const Icon( + Icons.favorite, + size: 25, + color: + Colors.red, + ) + : const Icon( + Icons + .favorite_border, + size: 25, + ), + ); + }, + ), + ), + ], + ) + ], + ), + )), + ); + }, + ), + ), + ], + ), + ), + drawer: const MyDrawer(), + ); } }