From fb74aad294e3bb436572c7b80b1278ef31232c2e Mon Sep 17 00:00:00 2001 From: AsmitaMishra24 <146121869+AsmitaMishra24@users.noreply.github.com> Date: Wed, 29 May 2024 02:42:25 +0530 Subject: [PATCH] Added Drawing Board --- lib/landing_page.dart | 2 +- lib/main.dart | 80 +------- lib/pages/explore.dart | 321 +++++++++++++++++---------------- lib/pages/explore/explore.dart | 184 ++++++++----------- lib/utils/route/routes.dart | 6 +- 5 files changed, 257 insertions(+), 336 deletions(-) diff --git a/lib/landing_page.dart b/lib/landing_page.dart index 09da76b..ba68fb0 100644 --- a/lib/landing_page.dart +++ b/lib/landing_page.dart @@ -86,7 +86,7 @@ class _LandingPageState extends State { onPressed: () { Navigator.popAndPushNamed( context, - AllRoutesConstant.mainhome, + AllRoutesConstant.mainhomeRoute, ); }, child: Text( diff --git a/lib/main.dart b/lib/main.dart index 571142b..d7f3bd0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,29 +1,7 @@ import 'package:flutter/material.dart'; import 'package:adaptive_theme/adaptive_theme.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:learn/pages/about.dart'; -import 'package:learn/pages/modules/flowers.dart'; -import 'package:learn/pages/modules/atoz.dart'; -import 'package:learn/pages/modules/birds.dart'; -import 'package:learn/pages/modules/animals.dart'; -import 'package:learn/pages/fruits.dart'; -import 'package:learn/pages/explore.dart'; -import 'package:learn/pages/favorite.dart'; -import 'package:learn/pages/modules/occupation.dart'; -import 'package:learn/pages/modules/parts.dart'; -import 'package:learn/pages/modules/seasons.dart'; -import 'package:learn/pages/modules/shapes.dart'; -import 'package:learn/pages/modules/planets.dart'; +import 'package:learn/landing_page.dart'; import 'package:learn/utils/route/routes.dart'; -import 'package:learn/utils/routes.dart'; -import 'package:learn/pages/modules/colours.dart'; -import 'package:learn/widgets/navbar/navbar.dart'; - -import 'cubit/index_cubit.dart'; -import 'pages/explore/drawingboard.dart'; -import 'pages/explore/quiz.dart'; -import 'pages/home.dart'; -import 'landing_page.dart'; DateTime? currentBackPressTime; @@ -40,54 +18,12 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return AdaptiveTheme( - light: ThemeData.light(), - dark: ThemeData.dark(), - initial: savedThemeMode ?? AdaptiveThemeMode.light, - builder: (theme, darkTheme) => BlocProvider( - create: (context) => IndexCubit(), - child: BlocBuilder( - builder: (context, index) { - return MaterialApp( - debugShowCheckedModeBanner: false, - title: 'Learn', - theme: theme, - darkTheme: darkTheme, - initialRoute: '/landing_page', - home: Scaffold( - body: const [ - MyHomePage(), - ExplorePage(), - FavoritePage(), - AboutPage(), - ][index], - bottomNavigationBar: const BottomNavBar(), - ), - onGenerateRoute: Routers.generateRoute, - routes: { - AllRoutes.homeRoute: (context) => const MyHomePage(), - AllRoutes.atozRoute: (context) => const AtoZ(), - AllRoutes.birdsRoute: (context) => BirdsPage(), - AllRoutes.shapesRoute: (context) => const ShapesPage(), - AllRoutes.partsRoute: (context) => const PartsPage(), - AllRoutes.solarRoute: (context) => PlanetsPage(), - AllRoutes.animalRoute: (context) => AnimalsPage(), - AllRoutes.colourRoute: (context) => const ColoursPage(), - AllRoutes.aboutRoute: (context) => const AboutPage(), - AllRoutes.flowerRoute: (context) => const FlowerPage(), - AllRoutes.exploreRoute: (context) => const ExplorePage(), - AllRoutes.favoriteRoute: (context) => const FavoritePage(), - AllRoutes.quizRoute: (context) => const QuizPage(), - AllRoutes.seasonRoute: (context) => const SeasonsPage(), - AllRoutes.occupationRoute: (context) => OccupationPage(), - AllRoutes.fruitRoute: (context) => FruitsPage(), - AllRoutes.drawingboardRoute: (context) => DrawingBoardPage(), - "/landing_page": (context) => const LandingPage(), - }, - ); - }, - ), - ), + return const MaterialApp( + debugShowCheckedModeBanner: false, + title: 'Learn', + themeMode: ThemeMode.system, + home: LandingPage(), + onGenerateRoute: Routers.generateRoute, ); } -} +} \ No newline at end of file diff --git a/lib/pages/explore.dart b/lib/pages/explore.dart index 0c47547..2fb78ea 100644 --- a/lib/pages/explore.dart +++ b/lib/pages/explore.dart @@ -2,7 +2,8 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:learn/utils/constants.dart'; -import '../utils/routes.dart'; +import 'package:learn/utils/route/route_constant.dart'; + import '../utils/const_dimensions.dart'; // Explore Page @@ -12,175 +13,183 @@ class ExplorePage extends StatelessWidget { @override Widget build(BuildContext context) { return SafeArea( - child: CustomScrollView( - slivers: [ - SliverAppBar( - 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), + child: CustomScrollView( + slivers: [ + SliverAppBar( + 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: SliverChildBuilderDelegate( - (context, index) { - return GestureDetector( - onTap: () => Navigator.push( - context, - AppConstants.modules[index].route, - ), - 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: () => Navigator.push( + context, + AppConstants.modules[index].route, + ), + 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, + ), + ), + 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, - ), - ], + 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, + ), + ], + ), ), - ), - ], + ], + ), ), ), - ), - ], + ], + ), ), - )), - ); - }, - childCount: AppConstants.modules.length, - ), - ), - GestureDetector( - onTap: () { - Navigator.pushNamed(context, '/quiz'); - }, - child: Container( - margin: const EdgeInsets.all(5.0), - 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: 50, - height: 50, - child: SvgPicture.asset('assets/explore/notebook.svg'), - ), - const SizedBox(width: 28.0), - const Text( - 'Quiz', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 30.0, - fontFamily: 'Comic', - color: Colors.white, ), - ), - ], + ); + }, + childCount: AppConstants.modules.length, ), ), - ), - GestureDetector( - onTap: () { - Navigator.pushNamed(context, AllRoutes.drawingboardRoute); - }, - child: Container( - margin: const EdgeInsets.all(5.0), - padding: const EdgeInsets.all(8.0), - decoration: BoxDecoration( - border: Border.all(color: Colors.black, width: 1.0), - borderRadius: BorderRadius.circular(8.0), - color: Colors.greenAccent, - ), - child: Row( - children: [ - SizedBox( - width: 50, - height: 50, - child: SvgPicture.asset('assets/explore/drawing_board.svg'), - ), - const SizedBox(width: 28.0), - const Text( - 'Drawing Board', - 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.all(5.0), + padding: const EdgeInsets.all(8.0), + decoration: BoxDecoration( + border: Border.all(color: Colors.black, width: 1.0), + borderRadius: BorderRadius.circular(8.0), + color: Colors.greenAccent, + ), + child: Row( + children: [ + SizedBox( + width: 50, + height: 50, + child: SvgPicture.asset( + 'assets/explore/drawing_board.svg', + ), ), - ), - ], + const SizedBox(width: 28.0), + const Text( + 'Drawing Board', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 30.0, + fontFamily: 'Comic', + color: Colors.white, + ), + ), + ], + ), ), ), - ), - ], - ), + ], + ), ); } } + + // GestureDetector( + // onTap: () { + // Navigator.pushNamed(context, '/quiz'); + // }, + // child: Container( + // margin: const EdgeInsets.all(5.0), + // 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: 50, + // height: 50, + // child: SvgPicture.asset('assets/explore/notebook.svg'), + // ), + // const SizedBox(width: 28.0), + // const Text( + // 'Quiz', + // style: TextStyle( + // fontWeight: FontWeight.bold, + // fontSize: 30.0, + // fontFamily: 'Comic', + // color: Colors.white, + // ), + // ), + // ], + // ), + // ), + // ), diff --git a/lib/pages/explore/explore.dart b/lib/pages/explore/explore.dart index 63b4ae9..a2fbfdc 100644 --- a/lib/pages/explore/explore.dart +++ b/lib/pages/explore/explore.dart @@ -1,9 +1,11 @@ import 'dart:ui'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:learn/utils/const_dimensions.dart'; import 'package:learn/utils/constants.dart'; -import '../../utils/routes.dart'; +import 'package:learn/utils/route/route_constant.dart'; + +import '../../utils/const_dimensions.dart'; // Explore Page class ExplorePage extends StatelessWidget { @@ -26,6 +28,79 @@ class ExplorePage extends StatelessWidget { ), ), ), + SliverList( + delegate: SliverChildListDelegate( + [ + GestureDetector( + onTap: () { + Navigator.pushNamed(context, '/quiz'); + }, + child: Container( + margin: const EdgeInsets.all(5.0), + 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.all(5.0), + padding: const EdgeInsets.all(8.0), + decoration: BoxDecoration( + border: Border.all(color: Colors.black, width: 1.0), + borderRadius: BorderRadius.circular(8.0), + color: Colors.greenAccent, + ), + child: Row( + children: [ + SizedBox( + width: ConstantDimensions.widthExtraLarge, + height: ConstantDimensions.heightExtraLarge, + child: SvgPicture.asset('assets/explore/drawing_board.svg'), + ), + const SizedBox(width: ConstantDimensions.widthMedium_Large), + const Text( + 'Drawing Board', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 30.0, + fontFamily: 'Comic', + color: Colors.white, + ), + ), + ], + ), + ), + ), + ], + ), + ), SliverList( delegate: SliverChildBuilderDelegate( (context, index) { @@ -56,7 +131,8 @@ class ExplorePage extends StatelessWidget { alignment: Alignment.center, children: [ ImageFiltered( - imageFilter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), + imageFilter: + ImageFilter.blur(sigmaX: 5, sigmaY: 5), child: Image.asset( AppConstants.modules[index].thumbnailPath, fit: BoxFit.cover, @@ -113,108 +189,8 @@ class ExplorePage extends StatelessWidget { childCount: AppConstants.modules.length, ), ), - GestureDetector( - onTap: () { - Navigator.pushNamed(context, '/quiz'); - }, - child: Container( - margin: const EdgeInsets.all(5.0), - 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: 50, - height: 50, - child: SvgPicture.asset('assets/explore/notebook.svg'), - ), - const SizedBox(width: 28.0), - const Text( - 'Quiz', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 30.0, - fontFamily: 'Comic', - color: Colors.white, - ), - ), - ], - ), - ), - ), - GestureDetector( - onTap: () { - Navigator.pushNamed(context, AllRoutes.drawingboardRoute); - }, - child: Container( - margin: const EdgeInsets.all(5.0), - padding: const EdgeInsets.all(8.0), - decoration: BoxDecoration( - border: Border.all(color: Colors.black, width: 1.0), - borderRadius: BorderRadius.circular(8.0), - color: Colors.greenAccent, - ), - child: Row( - children: [ - SizedBox( - width: 50, - height: 50, - child: SvgPicture.asset('assets/explore/drawing_board.svg'), - ), - const SizedBox(width: 28.0), - const Text( - 'Drawing Board', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 30.0, - fontFamily: 'Comic', - color: Colors.white, - ), - ), - ], - ), - ), - ), - - // GestureDetector( - // onTap: () { - // Navigator.pushNamed(context, '/quiz'); - // }, - // child: Container( - // margin: const EdgeInsets.all(5.0), - // 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: 50, - // height: 50, - // child: SvgPicture.asset('assets/explore/notebook.svg'), - // ), - // const SizedBox(width: 28.0), - // const Text( - // 'Quiz', - // style: TextStyle( - // fontWeight: FontWeight.bold, - // fontSize: 30.0, - // fontFamily: 'Comic', - // color: Colors.white, - // ), - // ), - // ], - // ), - // ), - // ), ], ), ); } -} +} \ No newline at end of file diff --git a/lib/utils/route/routes.dart b/lib/utils/route/routes.dart index 3ef276d..4fb1872 100644 --- a/lib/utils/route/routes.dart +++ b/lib/utils/route/routes.dart @@ -58,9 +58,9 @@ class Routers { return slidePageRoute(FruitsPage()); case AllRoutesConstant.drawingboardRoute: return slidePageRoute(const DrawingBoardPage()); - case AllRoutesConstant.landing: + case AllRoutesConstant.landingRoute: return slidePageRoute(const LandingPage()); - case AllRoutesConstant.mainhome: + case AllRoutesConstant.mainhomeRoute: return slidePageRoute(MainHome()); default: return MaterialPageRoute( @@ -72,4 +72,4 @@ class Routers { ); } } -} +} \ No newline at end of file