From ad37445663f228c9beca050083d7db09cb1dc854 Mon Sep 17 00:00:00 2001 From: Anushka-Yadav Date: Tue, 19 Sep 2023 21:32:57 +0530 Subject: [PATCH] short screen added --- lib/client/screens/learning_screen.dart | 150 +++++++++++++++--- .../screens/shortScreens/inventoryShorts.dart | 147 +++++++++++++++++ .../shortScreens/marketplace_shorts.dart | 148 +++++++++++++++++ .../{ => shortScreens}/short_screen.dart | 4 +- .../screens/shortScreens/wool_shorts.dart | 147 +++++++++++++++++ lib/routes/page_routes.dart | 29 +++- 6 files changed, 598 insertions(+), 27 deletions(-) create mode 100644 lib/client/screens/shortScreens/inventoryShorts.dart create mode 100644 lib/client/screens/shortScreens/marketplace_shorts.dart rename lib/client/screens/{ => shortScreens}/short_screen.dart (98%) create mode 100644 lib/client/screens/shortScreens/wool_shorts.dart diff --git a/lib/client/screens/learning_screen.dart b/lib/client/screens/learning_screen.dart index ea6aff6..7fda075 100644 --- a/lib/client/screens/learning_screen.dart +++ b/lib/client/screens/learning_screen.dart @@ -1,6 +1,7 @@ +import 'dart:ui'; import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; import 'package:sih1309/utils/dimensions.dart'; - import '../../utils/Colors.dart'; class LearningScreen extends StatelessWidget { @@ -9,6 +10,7 @@ class LearningScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( + backgroundColor: AppColors.lightModePrimary, appBar: AppBar( iconTheme: IconThemeData(color: Colors.black), backgroundColor: Colors.white, @@ -26,41 +28,145 @@ class LearningScreen extends StatelessWidget { body: Column( children: [ Padding( - padding: EdgeInsets.only(top: Dimension.val20), + padding: EdgeInsets.only(top: Dimension.val40), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Container( - width: 100, - height: 100, - decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(20.0), + GestureDetector( + onTap: () { + context.go('/inventoryvideo'); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(Dimension.val10), + border: Border.all( + color: AppColors.shadowColor, + width: 2, + ), + ), + alignment: Alignment.centerLeft, + width: Dimension.width105, + height: Dimension.height128, + child: Image.network( + 'https://i.imgur.com/5MYDzGl.png', + fit: BoxFit.cover, + ), ), ), - Container( - width: 100, - height: 100, - decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(20.0), + GestureDetector( + onTap: () { + context.go('/woolvedio'); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(Dimension.val10), + border: Border.all( + color: AppColors.shadowColor, + width: 2, + ), + ), + alignment: Alignment.centerLeft, + width: Dimension.width105, + height: Dimension.height128, + child: Image.network( + 'https://i.imgur.com/10FFINf.png', + fit: BoxFit.cover, + ), ), ), - Container( - width: 100, - height: 100, - decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(20.0), + GestureDetector( + onTap: () { + context.go('/marketvideo'); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(Dimension.val10), + border: Border.all( + color: AppColors.shadowColor, + width: 2, + ), + ), + alignment: Alignment.centerLeft, + width: Dimension.width105, + height: Dimension.height128, + child: Image.network( + 'https://i.imgur.com/I6dEne0.png', + fit: BoxFit.cover, + ), ), ), ], ), ), - + Padding( + padding: EdgeInsets.only(top: Dimension.val20, left: Dimension.val20), + child: Align( + alignment: Alignment.centerLeft, + child: Text( + "Shorts", + style: TextStyle( + color: Colors.black, + fontFamily: 'poppins', + letterSpacing: 1, + fontWeight: FontWeight.bold, + fontSize: Dimension.font20, + ), + ), + ), + ), + Padding( + padding: EdgeInsets.only(top: Dimension.val40, left: Dimension.val20), + child: Align( + alignment: Alignment.centerLeft, + child: SizedBox( + height: Dimension.screenHeight / 2 + Dimension.val60, + width: Dimension.width360, // Adjust as needed + child: ListView( + scrollDirection: Axis.horizontal, + children: [ + for (int index = 0; index < 6; index++) + GestureDetector( + onTap: () { + context.go('/shorts'); + }, + child: Container( + margin: EdgeInsets.only( + left: index == 0 ? 0 : Dimension.val20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(Dimension.val10), + border: Border.all( + color: AppColors.shadowColor, + width: 2, + ), + ), + width: Dimension.width220, + child: Column( + children: [ + Center( + child: Image.network( + 'https://i.imgur.com/LYxs4rV.png', + fit: BoxFit.fill, // You can adjust the fit as needed + ), + ), + // Text( + // 'Box $index', // Replace with box content + // style: TextStyle( + // color: Colors.black, + // fontFamily: 'poppins', + // fontSize: Dimension.font16, // Adjust as needed + // ), + // ), + ], + ), + ), + ), + ], + ), + ), + ), + ), ], ), - ); } } diff --git a/lib/client/screens/shortScreens/inventoryShorts.dart b/lib/client/screens/shortScreens/inventoryShorts.dart new file mode 100644 index 0000000..2ede999 --- /dev/null +++ b/lib/client/screens/shortScreens/inventoryShorts.dart @@ -0,0 +1,147 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; +import 'package:sih1309/utils/Dimensions.dart'; +import 'package:youtube_player_flutter/youtube_player_flutter.dart'; + +class InventoryShorts extends StatefulWidget { + const InventoryShorts({Key? key}) : super(key: key); + + @override + _InventoryShortsState createState() => _InventoryShortsState(); +} + +class _InventoryShortsState extends State { + final List videoIds = [ + 'nGvmVpuV0uc', // Replace with your YouTube video IDs + 'P7IKEeK06RY', + 'Y3g_S4xu9yM', + ]; + + int currentVideoIndex = 0; + + late YoutubePlayerController _controller; + + @override + void initState() { + super.initState(); + _controller = YoutubePlayerController( + initialVideoId: videoIds[currentVideoIndex], + flags: YoutubePlayerFlags( + autoPlay: true, + mute: false, + controlsVisibleAtStart: false, // Hide controls initially + ), + ); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + void playNextVideo() { + if (currentVideoIndex < videoIds.length - 1) { + currentVideoIndex++; + } else { + currentVideoIndex = 0; // Loop back to the first video + } + _controller.load(videoIds[currentVideoIndex]); + } + + void playPreviousVideo() { + if (currentVideoIndex > 0) { + currentVideoIndex--; + } else { + currentVideoIndex = videoIds.length - 1; // Go to the last video when at the first one + } + _controller.load(videoIds[currentVideoIndex]); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.black, // Set the background color to black + appBar: AppBar( + leading: IconButton( + icon: Icon(Icons.arrow_back), + color: Colors.white, + onPressed: () { + context.go('/Learning'); + }, + ), + backgroundColor: Colors.transparent, // Make the app bar transparent + title: const Text( + "Inventory Shorts Screen", + style: TextStyle(color: Colors.white), + ), + ), + body: GestureDetector( + onVerticalDragUpdate: (details) { + // Adjust this value to control the sensitivity of the swipe gesture + if (details.delta.dy > 20) { + // Swipe down + playPreviousVideo(); + } else if (details.delta.dy < -20) { + // Swipe up + playNextVideo(); + } + }, + child: Center( + child: AspectRatio( + aspectRatio: MediaQuery.of(context).size.width / MediaQuery.of(context).size.height, + child: YoutubePlayer( + controller: _controller, + showVideoProgressIndicator: true, + progressIndicatorColor: Colors.blueAccent, + onReady: (){ + Text("wait patiently"); + }, + onEnded: (_) { + playNextVideo(); // Play the next video when the current video ends + }, + ), + ), + ), + ), + floatingActionButton: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: EdgeInsets.only(left: Dimension.val35), + child: Align( + alignment: Alignment.bottomLeft, + child: FloatingActionButton.small( + onPressed: () { + playPreviousVideo(); + }, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + backgroundColor: Colors.white, + foregroundColor: Colors.black, + child: Icon( + Icons.skip_previous, + ), + ), + ), + ), + Align( + alignment: Alignment.bottomRight, + child: FloatingActionButton.small( + + onPressed: () { + playNextVideo(); + }, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + backgroundColor: Colors.white, + foregroundColor: Colors.black, + child: Icon( + Icons.skip_next, + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/client/screens/shortScreens/marketplace_shorts.dart b/lib/client/screens/shortScreens/marketplace_shorts.dart new file mode 100644 index 0000000..b30af27 --- /dev/null +++ b/lib/client/screens/shortScreens/marketplace_shorts.dart @@ -0,0 +1,148 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; +import 'package:sih1309/utils/Dimensions.dart'; +import 'package:youtube_player_flutter/youtube_player_flutter.dart'; + +class MarketplaceShorts extends StatefulWidget { + const MarketplaceShorts({Key? key}) : super(key: key); + + @override + _MarketplaceShortsState createState() => _MarketplaceShortsState(); +} + +class _MarketplaceShortsState extends State { + final List videoIds = [ + 'nGvmVpuV0uc', // Replace with your YouTube video IDs + 'P7IKEeK06RY', + 'Y3g_S4xu9yM', + ]; + + int currentVideoIndex = 0; + + late YoutubePlayerController _controller; + + @override + void initState() { + super.initState(); + _controller = YoutubePlayerController( + initialVideoId: videoIds[currentVideoIndex], + flags: YoutubePlayerFlags( + autoPlay: true, + mute: false, + controlsVisibleAtStart: false, // Hide controls initially + ), + ); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + void playNextVideo() { + if (currentVideoIndex < videoIds.length - 1) { + currentVideoIndex++; + } else { + currentVideoIndex = 0; // Loop back to the first video + } + _controller.load(videoIds[currentVideoIndex]); + } + + void playPreviousVideo() { + if (currentVideoIndex > 0) { + currentVideoIndex--; + } else { + currentVideoIndex = videoIds.length - 1; // Go to the last video when at the first one + } + _controller.load(videoIds[currentVideoIndex]); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.black, // Set the background color to black + appBar: AppBar( + leading: IconButton( + icon: Icon(Icons.arrow_back), + color: Colors.white, + onPressed: () { + + context.go('/Learning'); + }, + ), + backgroundColor: Colors.transparent, // Make the app bar transparent + title: const Text( + "Market Place Shorts Screen", + style: TextStyle(color: Colors.white), + ), + ), + body: GestureDetector( + onVerticalDragUpdate: (details) { + // Adjust this value to control the sensitivity of the swipe gesture + if (details.delta.dy > 20) { + // Swipe down + playPreviousVideo(); + } else if (details.delta.dy < -20) { + // Swipe up + playNextVideo(); + } + }, + child: Center( + child: AspectRatio( + aspectRatio: MediaQuery.of(context).size.width / MediaQuery.of(context).size.height, + child: YoutubePlayer( + controller: _controller, + showVideoProgressIndicator: true, + progressIndicatorColor: Colors.blueAccent, + onReady: (){ + Text("wait patiently"); + }, + onEnded: (_) { + playNextVideo(); // Play the next video when the current video ends + }, + ), + ), + ), + ), + floatingActionButton: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: EdgeInsets.only(left: Dimension.val35), + child: Align( + alignment: Alignment.bottomLeft, + child: FloatingActionButton.small( + onPressed: () { + playPreviousVideo(); + }, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + backgroundColor: Colors.white, + foregroundColor: Colors.black, + child: Icon( + Icons.skip_previous, + ), + ), + ), + ), + Align( + alignment: Alignment.bottomRight, + child: FloatingActionButton.small( + + onPressed: () { + playNextVideo(); + }, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + backgroundColor: Colors.white, + foregroundColor: Colors.black, + child: Icon( + Icons.skip_next, + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/client/screens/short_screen.dart b/lib/client/screens/shortScreens/short_screen.dart similarity index 98% rename from lib/client/screens/short_screen.dart rename to lib/client/screens/shortScreens/short_screen.dart index 65e5a83..a44e117 100644 --- a/lib/client/screens/short_screen.dart +++ b/lib/client/screens/shortScreens/short_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; import 'package:sih1309/utils/Dimensions.dart'; import 'package:youtube_player_flutter/youtube_player_flutter.dart'; @@ -67,8 +68,7 @@ class _YoutubeScreenState extends State { icon: Icon(Icons.arrow_back), color: Colors.white, onPressed: () { - // Navigate back to the homepage - Navigator.pop(context); + context.go("/Learning"); }, ), backgroundColor: Colors.transparent, // Make the app bar transparent diff --git a/lib/client/screens/shortScreens/wool_shorts.dart b/lib/client/screens/shortScreens/wool_shorts.dart new file mode 100644 index 0000000..946203c --- /dev/null +++ b/lib/client/screens/shortScreens/wool_shorts.dart @@ -0,0 +1,147 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; +import 'package:sih1309/utils/Dimensions.dart'; +import 'package:youtube_player_flutter/youtube_player_flutter.dart'; + +class WoolQualityShorts extends StatefulWidget { + const WoolQualityShorts({Key? key}) : super(key: key); + + @override + _WoolQualityShortsState createState() => _WoolQualityShortsState(); +} + +class _WoolQualityShortsState extends State { + final List videoIds = [ + 'nGvmVpuV0uc', // Replace with your YouTube video IDs + 'P7IKEeK06RY', + 'Y3g_S4xu9yM', + ]; + + int currentVideoIndex = 0; + + late YoutubePlayerController _controller; + + @override + void initState() { + super.initState(); + _controller = YoutubePlayerController( + initialVideoId: videoIds[currentVideoIndex], + flags: YoutubePlayerFlags( + autoPlay: true, + mute: false, + controlsVisibleAtStart: false, // Hide controls initially + ), + ); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + void playNextVideo() { + if (currentVideoIndex < videoIds.length - 1) { + currentVideoIndex++; + } else { + currentVideoIndex = 0; // Loop back to the first video + } + _controller.load(videoIds[currentVideoIndex]); + } + + void playPreviousVideo() { + if (currentVideoIndex > 0) { + currentVideoIndex--; + } else { + currentVideoIndex = videoIds.length - 1; // Go to the last video when at the first one + } + _controller.load(videoIds[currentVideoIndex]); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.black, // Set the background color to black + appBar: AppBar( + leading: IconButton( + icon: Icon(Icons.arrow_back), + color: Colors.white, + onPressed: () { + context.go('/Learning'); + }, + ), + backgroundColor: Colors.transparent, // Make the app bar transparent + title: const Text( + "Wool Quality Shorts Screen", + style: TextStyle(color: Colors.white), + ), + ), + body: GestureDetector( + onVerticalDragUpdate: (details) { + // Adjust this value to control the sensitivity of the swipe gesture + if (details.delta.dy > 20) { + // Swipe down + playPreviousVideo(); + } else if (details.delta.dy < -20) { + // Swipe up + playNextVideo(); + } + }, + child: Center( + child: AspectRatio( + aspectRatio: MediaQuery.of(context).size.width / MediaQuery.of(context).size.height, + child: YoutubePlayer( + controller: _controller, + showVideoProgressIndicator: true, + progressIndicatorColor: Colors.blueAccent, + onReady: (){ + Text("wait patiently"); + }, + onEnded: (_) { + playNextVideo(); // Play the next video when the current video ends + }, + ), + ), + ), + ), + floatingActionButton: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: EdgeInsets.only(left: Dimension.val35), + child: Align( + alignment: Alignment.bottomLeft, + child: FloatingActionButton.small( + onPressed: () { + playPreviousVideo(); + }, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + backgroundColor: Colors.white, + foregroundColor: Colors.black, + child: Icon( + Icons.skip_previous, + ), + ), + ), + ), + Align( + alignment: Alignment.bottomRight, + child: FloatingActionButton.small( + + onPressed: () { + playNextVideo(); + }, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + backgroundColor: Colors.white, + foregroundColor: Colors.black, + child: Icon( + Icons.skip_next, + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/routes/page_routes.dart b/lib/routes/page_routes.dart index a683d21..d1d9f12 100644 --- a/lib/routes/page_routes.dart +++ b/lib/routes/page_routes.dart @@ -3,10 +3,13 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:go_router/go_router.dart'; import 'package:sih1309/client/screens/learning_screen.dart'; -import 'package:sih1309/client/screens/news_api.dart'; import 'package:sih1309/client/screens/news_screen.dart'; +import 'package:sih1309/client/screens/shortScreens/inventoryShorts.dart'; +import 'package:sih1309/client/screens/shortScreens/marketplace_shorts.dart'; +import 'package:sih1309/client/screens/shortScreens/short_screen.dart'; +import 'package:sih1309/client/screens/shortScreens/wool_shorts.dart'; + -import 'package:sih1309/client/screens/short_screen.dart'; import 'package:sih1309/client/screens/wool_quality.dart'; @@ -67,7 +70,7 @@ class App extends StatelessWidget { path: 'Learning', builder: (BuildContext context, GoRouterState state) => - const YoutubeScreen() + const LearningScreen() ), GoRoute( @@ -86,6 +89,26 @@ class App extends StatelessWidget { builder: (BuildContext context, GoRouterState state) => const MarketPlace(), ), + GoRoute( + path: 'inventoryvideo', + builder: (BuildContext context, GoRouterState state) => + const InventoryShorts(), + ), + GoRoute( + path: 'woolvedio', + builder: (BuildContext context, GoRouterState state) => + const WoolQualityShorts(), + ), + GoRoute( + path: 'marketvideo', + builder: (BuildContext context, GoRouterState state) => + const MarketplaceShorts(), + ), + GoRoute( + path: 'shorts', + builder: (BuildContext context, GoRouterState state) => + const YoutubeScreen(), + ), ], path: '/',