Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 128 additions & 22 deletions lib/client/screens/learning_screen.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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,
Expand All @@ -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
// ),
// ),
],
),
),
),
],
),
),
),
),
],
),

);
}
}
147 changes: 147 additions & 0 deletions lib/client/screens/shortScreens/inventoryShorts.dart
Original file line number Diff line number Diff line change
@@ -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<InventoryShorts> {
final List<String> 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,
),
),
),
],
),
);
}
}
Loading