Files
Traders_Circuit/lib/view/Sidemenu/ContentByte/ContentBytes.dart
2024-04-10 12:56:06 +05:30

919 lines
31 KiB
Dart

import 'dart:developer';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:traderscircuit/Utils/Common/CommonAppbar.dart';
import 'package:traderscircuit/Utils/Common/CustomTextFormField.dart';
import 'package:traderscircuit/Utils/Common/comonGlassmorphicContainer.dart';
import 'package:traderscircuit/Utils/Common/sized_box.dart';
import 'package:traderscircuit/Utils/text.dart';
import 'package:traderscircuit/controller/content_bytes_controller.dart';
import 'package:traderscircuit/model/ContentBytesModel/content_bytes_categories_model.dart';
import 'package:traderscircuit/model/ContentBytesModel/content_bytes_model.dart';
import 'package:traderscircuit/view/Sidemenu/ContentByte/PlayerWidget.dart';
import 'package:traderscircuit/view/Sidemenu/ContentByte/Reels.dart';
import 'package:traderscircuit/view/onBoarding/splashScreen1.dart';
import 'package:traderscircuit/view_model/ContentBytesApi/content_bytes_api.dart';
class ContentBytes extends StatefulWidget {
const ContentBytes({super.key});
@override
State<ContentBytes> createState() => _ContentBytesState();
}
class _ContentBytesState extends State<ContentBytes> {
GlobalKey<ScaffoldState> _scaffoldKey1 = GlobalKey<ScaffoldState>();
final selectedIndex = 0.obs;
List<String> reels = [
"assets/images/png/sidemenu/reels1.png",
"assets/images/png/sidemenu/reels2.png",
"assets/images/png/sidemenu/reels3.png",
"assets/images/png/sidemenu/reels4.png",
];
List<String> audionewimage = [
"assets/images/png/sidemenu/audionew1.png",
"assets/images/png/sidemenu/audionew2.png",
"assets/images/png/sidemenu/audionew1.png",
];
List<String> mostread = [
"assets/images/png/sidemenu/Read1.png",
"assets/images/png/sidemenu/Read2.png",
"assets/images/png/sidemenu/Read1.png",
];
List<String> audio = [
"assets/images/png/sidemenu/audio1.png",
"assets/images/png/sidemenu/audio2.png",
"assets/images/png/sidemenu/audio3.png",
"assets/images/png/sidemenu/audio4.png",
"assets/images/png/sidemenu/audio1.png",
"assets/images/png/sidemenu/audio2.png",
];
List<String> audioname = [
"Week of 21st March 2024",
"Week of 21st March 2024",
"Week of 21st March 2024",
"Week of 21st March 2024",
"Week of 21st March 2024",
"Week of 21st March 2024",
];
List<String> audionamenewrelease = [
"Week of 21st March 2024",
"Week of 21st March 2024",
"Week of 21st March 2024",
];
ContentBytesController contentBytesController =
Get.put(ContentBytesController());
@override
void initState() {
ContentBytesApi().getContentBytesCategoriesData().then((value) {
contentBytesController.contentBytesCategoriesModel =
ContentBytesCategoriesModel.fromJson(value.data);
});
ContentBytesApi().getContentBytesData("").then((value) {
contentBytesController.contentBytesModel =
ContentBytesModel.fromJson(value.data);
contentBytesController.isApiCalling.value = false;
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey1,
backgroundColor: Colors.black,
extendBody: true,
appBar: const CommonAppbar(titleTxt: "Content Bytes"),
body: Stack(
children: [
const CommonBlurLeft(),
const CommonBlurRight(),
Stack(
children: [
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
child: ListView(
children: [
const SizedBox(
height: 10,
),
DefaultTabController(
length: 3,
// initialIndex: selectedIndex.value,
child: Column(
children: [
ContentTabBar(),
SizedBox(
height: 30.h,
),
SizedBox(
height: 600.h,
child: TabBarView(
children: [
Videos(images: reels),
Audios(
audio: audio,
audioname: audioname,
audionewimage: audionewimage,
audionamenewrelease: audionamenewrelease),
Reads(mostread: mostread),
],
),
),
],
),
),
sizedBoxHeight(40.h),
],
),
),
],
),
],
),
);
}
}
class Reads extends StatelessWidget {
const Reads({
super.key,
required this.mostread,
});
final List<String> mostread;
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const SizedBox(
width: 300,
child: CustomTextFormField(
leadingIcon: Icon(Icons.search),
),
),
SizedBox(
width: 15.w,
),
Image.asset(
"assets/images/png/filter.png",
height: 30.h,
width: 30.w,
),
],
),
SizedBox(
height: 10.h,
),
text22W600('Harnessing the Power of Ebooks"'),
sizedBoxHeight(20.h),
commonGlassContainer(
borderradius: 8,
width: double.infinity,
height: 150.h,
customWidget: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
const SizedBox(
width: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Spacer(),
SizedBox(
width: 235.w,
child: text20W400('"Stock Market Essentials"'),
),
sizedBoxHeight(10.h),
SizedBox(
width: 230.w,
child: text16W400(
'A Comprehensive Guide to Understanding the Market'),
),
const Spacer()
],
),
const SizedBox(
width: 20,
),
Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Image.asset(
"assets/images/png/sidemenu/book1.png",
height: 110,
),
],
)
],
),
),
sizedBoxHeight(20.h),
commonGlassContainer(
borderradius: 8,
width: double.infinity,
height: 150.h,
customWidget: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
const SizedBox(
width: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Spacer(),
SizedBox(
width: 235.w,
child: text20W400('"Stock Market Essentials"'),
),
sizedBoxHeight(10.h),
SizedBox(
width: 230.w,
child: text16W400(
'A Comprehensive Guide to Understanding the Market'),
),
const Spacer()
],
),
const SizedBox(
width: 20,
),
Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Image.asset(
"assets/images/png/sidemenu/book1.png",
height: 110,
),
],
)
],
),
),
sizedBoxHeight(30.h),
text22W500("Most Read"),
sizedBoxHeight(25.h),
Container(
height: 220.h,
child: ListView.separated(
separatorBuilder: (context, index) {
return SizedBox(
width: 10.w,
);
},
scrollDirection: Axis.horizontal,
itemCount: 3,
itemBuilder: (context, index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 216.h,
width: 150.w,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Colors.white.withOpacity(0.1),
const Color(0xFFFFFFFF).withOpacity(0.05),
],
stops: [
0.1,
1,
],
),
borderRadius: BorderRadius.circular(8),
),
child: Image.asset(mostread[index]),
),
],
);
},
),
),
sizedBoxHeight(30.h),
text22W500("Previous Read"),
sizedBoxHeight(20.h),
Container(
height: 90.h,
child: ListView.separated(
separatorBuilder: (context, index) {
return SizedBox(
width: 10.w,
);
},
scrollDirection: Axis.horizontal,
itemCount: 2,
itemBuilder: (context, index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 85.h,
width: 230.w,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Colors.white.withOpacity(0.1),
const Color(0xFFFFFFFF).withOpacity(0.05),
],
stops: [
0.1,
1,
],
),
borderRadius: BorderRadius.circular(8),
),
child: Row(
// mainAxisAlignment:
// MainAxisAlignment.start,
children: [
const SizedBox(
width: 10,
),
Image.asset(mostread[index]),
SizedBox(
width: 15.w,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SizedBox(
width: 135.w,
child: text12W500("Stock Market Essentials"),
),
SizedBox(
width: 130.w,
child: text10W300(
"A Comprehensive Guide to Understanding the Market"),
)
],
)
],
),
),
],
);
},
),
),
],
),
);
}
}
class Audios extends StatelessWidget {
const Audios({
super.key,
required this.audio,
required this.audioname,
required this.audionewimage,
required this.audionamenewrelease,
});
final List<String> audio;
final List<String> audioname;
final List<String> audionewimage;
final List<String> audionamenewrelease;
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const SizedBox(
width: 300,
child: CustomTextFormField(
leadingIcon: Icon(Icons.search),
),
),
SizedBox(
width: 15.w,
),
Image.asset(
"assets/images/png/filter.png",
height: 30.h,
width: 30.w,
),
],
),
SizedBox(
height: 10.h,
),
text22W600('Content Bytes'),
sizedBoxHeight(8.w),
text16W400_DADADA('The Beauty and Power of Video'),
sizedBoxHeight(20.h),
Container(
height: 550,
child: GridView.builder(
physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
mainAxisExtent: 172,
crossAxisCount: 2, // number of items in each row
mainAxisSpacing: 8.0, // spacing between rows
crossAxisSpacing: 8.0, // spacing between columns
),
itemCount: 6, // total number of items
itemBuilder: (context, index) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Colors.white.withOpacity(0.1),
const Color(0xFFFFFFFF).withOpacity(0.05),
],
stops: [
0.1,
1,
],
),
borderRadius: BorderRadius.circular(8),
),
child: Stack(
children: [
Image.asset(
audio[index],
),
Positioned(
bottom: 5,
left: 5,
child: Row(
children: [
CircleAvatar(
radius: 18.sp,
child: const Icon(Icons.headphones),
),
SizedBox(
width: 5.w,
),
SizedBox(
width: 125.w,
child: text14W500(audioname[index]),
),
],
),
),
],
),
);
},
),
),
SizedBox(
height: 20.h,
),
text22W600("New Release"),
SizedBox(
height: 25.h,
),
Container(
height: 250.h,
child: ListView.separated(
separatorBuilder: (context, index) {
return const SizedBox(
width: 10,
);
},
scrollDirection: Axis.horizontal,
itemCount: 3,
itemBuilder: (context, index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 183.h,
width: 148.w,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Colors.white.withOpacity(0.1),
const Color(0xFFFFFFFF).withOpacity(0.05),
],
stops: [
0.1,
1,
],
),
borderRadius: BorderRadius.circular(8),
),
child: Stack(
children: [
Image.asset(audionewimage[index]),
const Positioned(
right: 5,
top: 5,
child: CircleAvatar(
radius: 15,
child: Icon(
Icons.headphones,
size: 20,
),
),
),
],
),
),
const SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
width: 148.w,
child: text14W500Overflow(audionamenewrelease[index]),
),
],
)
],
);
},
),
)
],
),
);
}
}
class Videos extends StatefulWidget {
const Videos({
super.key,
required this.images,
});
final List<String> images;
@override
State<Videos> createState() => _VideosState();
}
class _VideosState extends State<Videos> {
ContentBytesController contentBytesController =
Get.put(ContentBytesController());
Widget itemFilter(int index) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Gap(8),
text18W400(
contentBytesController
.contentBytesCategoriesModel.data![index].title!,
texAl: TextAlign.center,
),
index ==
contentBytesController
.contentBytesCategoriesModel.data!.length -
1
? const SizedBox()
: const Divider(
color: Color(0xFF2C2C2C),
thickness: 0.6,
endIndent: 0,
),
],
);
}
Widget filter() {
return PopupMenuButton(
icon: Image.asset(
"assets/images/png/filter.png",
height: 30.h,
width: 30.w,
),
color: const Color(0xFF191919),
itemBuilder: (context) {
return [
PopupMenuItem(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: (Get.height *
contentBytesController
.contentBytesCategoriesModel.data!.length) /
17,
width: 150,
child: ListView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
itemCount: contentBytesController
.contentBytesCategoriesModel.data!.length,
itemBuilder: (ctx, index) {
return InkWell(
onTap: () {
// contentBytesController.isApiCalling.value = true;
Get.back();
contentBytesController.filterId =
contentBytesController
.contentBytesCategoriesModel
.data![index]
.categoryId!;
log(contentBytesController.filterId.toString());
},
child: itemFilter(index));
}),
),
// GestureDetector(
// onTap: () async {
// // contentBytesController.isApiCalling.value = true;
// Get.back();
// // await InventoriesApi()
// // .getInventoriesData(
// // searchController.text,
// // filterList,
// // inventoriesController.fromWarehouse
// // ? inventoriesController.wareHouseId
// // : 0)
// // .then((value) async {
// // inventoriesController.inventoriesDataModel.value =
// // InventoriesDataModel.fromJson(value.data);
// // inventoriesController.isApiCalling.value = false;
// // });
// },
// child: Container(
// padding:
// EdgeInsets.symmetric(horizontal: 30.w, vertical: 10.h),
// margin:
// EdgeInsets.symmetric(horizontal: 30.w, vertical: 25.h),
// decoration: BoxDecoration(
// color: AppColors.buttoncolour,
// borderRadius: BorderRadius.circular(20)),
// child: Center(child: textWhite16('Apply Now')),
// ))
],
))
];
},
);
}
Widget videoCard(Video video) {
return InkWell(
onTap: () {
Get.to(() => PlayerWidget(), arguments: {
"video_url": video.file,
});
},
child: commonGlassContainer(
borderradius: 8,
width: double.infinity,
height: 300.h,
customWidget: Padding(
padding: EdgeInsets.symmetric(vertical: 10.h, horizontal: 10.w),
child: Column(
children: [
Container(
height: 200.h,
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.r),
image: DecorationImage(
image: NetworkImage(
video.image!,
))),
child: Center(
child: SvgPicture.asset(
'assets/images/svg/gridicons_play.svg',
height: 56.h,
width: 56.w,
),
),
),
sizedBoxHeight(20.h),
Row(
children: [
CircleAvatar(
radius: 23.r,
backgroundImage: const AssetImage(
'assets/images/png/Ellipse 1494.png'),
),
sizedBoxWidth(10.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text18W500(video.title!),
// sizedBoxHeight(10.h),
text12W400_979797('20k views . 2 days ago'),
],
)
],
)
],
),
)),
);
}
@override
Widget build(BuildContext context) {
return Obx(
() => SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const SizedBox(
width: 295,
child: CustomTextFormField(
leadingIcon: Icon(Icons.search),
),
),
SizedBox(
width: 15.w,
),
filter(),
],
),
SizedBox(
height: 10.h,
),
text22W600('Content Bytes'),
sizedBoxHeight(8.w),
text16W400_DADADA('The Beauty and Power of Video'),
sizedBoxHeight(20.h),
contentBytesController.isApiCalling.value
? const Column(
children: [
Gap(50),
Center(
child: CircularProgressIndicator(
color: Color(0xFF9A0000),
),
),
],
)
: Column(
children: [
contentBytesController
.contentBytesModel.data!.video!.length <
1
? const SizedBox()
: videoCard(contentBytesController
.contentBytesModel.data!.video![0]),
contentBytesController
.contentBytesModel.data!.video!.length <=
1
? const SizedBox()
: sizedBoxHeight(20.h),
contentBytesController
.contentBytesModel.data!.video!.length <
2
? const SizedBox()
: videoCard(contentBytesController
.contentBytesModel.data!.video![1]),
sizedBoxHeight(15.h),
text22W600("Reels"),
sizedBoxHeight(25.h),
Container(
height: 500,
child: GridView.builder(
physics: const NeverScrollableScrollPhysics(),
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
mainAxisExtent: 215,
crossAxisCount: 2, // number of items in each row
mainAxisSpacing: 8.0, // spacing between rows
crossAxisSpacing: 8.0, // spacing between columns
),
itemCount: 4, // total number of items
itemBuilder: (context, index) {
return InkWell(
onTap: () {
Get.to(
() => const Reels(),
);
},
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Colors.white.withOpacity(0.1),
const Color(0xFFFFFFFF).withOpacity(0.05),
],
stops: [
0.1,
1,
],
),
borderRadius: BorderRadius.circular(8),
),
child: Image.asset(widget.images[index]),
),
);
},
),
),
// sizedBoxHeight(10.h),
contentBytesController
.contentBytesModel.data!.video!.length <
3
? const SizedBox()
: ListView.builder(
physics: NeverScrollableScrollPhysics(),
itemCount: contentBytesController
.contentBytesModel.data!.video!.length -
2,
shrinkWrap: true,
itemBuilder: (ctx, index) {
return Container(
margin: EdgeInsets.only(
bottom: 20,
),
child: videoCard(contentBytesController
.contentBytesModel
.data!
.video![index + 2]),
);
})
],
),
],
),
),
);
}
}
class ContentTabBar extends StatelessWidget {
// Set the desired height
@override
Widget build(BuildContext context) {
return TabBar(
tabAlignment: TabAlignment.fill,
isScrollable: false,
dividerColor: Colors.transparent,
labelStyle: TextStyle(
fontSize: 18.sp,
color: Colors.white,
fontWeight: FontWeight.w500,
fontFamily: 'hiragino'),
indicatorSize: TabBarIndicatorSize.tab,
indicatorWeight: 2,
indicatorColor: const Color(0xff6C0000),
labelColor: Colors.white,
unselectedLabelColor: const Color(0xFF464646),
overlayColor: MaterialStateProperty.all(const Color(0xFFFFFFFF)),
tabs: const [
Tab(
text: 'Videos',
),
Tab(
text: 'Audios',
),
Tab(
text: 'Reads',
),
]);
}
}