371 lines
15 KiB
Dart
371 lines
15 KiB
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/contact_us_controller.dart';
|
|
import 'package:traderscircuit/controller/content_bytes_controller.dart';
|
|
import 'package:traderscircuit/model/ContentBytesModel/content_bytes_model.dart';
|
|
import 'package:traderscircuit/view/Sidemenu/ContentByte/PlayerWidget.dart';
|
|
import 'package:traderscircuit/view/onBoarding/splashScreen1.dart';
|
|
import 'package:traderscircuit/view_model/ContentBytesApi/content_bytes_api.dart';
|
|
|
|
class VideosMore extends StatefulWidget {
|
|
const VideosMore({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<VideosMore> createState() => _VideosMoreState();
|
|
}
|
|
|
|
class _VideosMoreState extends State<VideosMore> {
|
|
ContentBytesController contentBytesController =
|
|
Get.put(ContentBytesController());
|
|
var data;
|
|
RxBool isLoading = true.obs;
|
|
RxInt selectedFilterIndex = 100.obs;
|
|
|
|
TextEditingController searchController = TextEditingController();
|
|
|
|
@override
|
|
void initState() {
|
|
ContentBytesApi().getContentBytesData("", "video", "").then((value) {
|
|
contentBytesController.moreVideoModel =
|
|
ContentBytesModel.fromJson(value.data);
|
|
isLoading.value = false;
|
|
setState(() {});
|
|
});
|
|
super.initState();
|
|
}
|
|
|
|
void handleSearch(String query, String category) async {
|
|
await ContentBytesApi()
|
|
.getContentBytesData(
|
|
query, "video", contentBytesController.filterId.toString())
|
|
.then((value) {
|
|
contentBytesController.moreVideoModel =
|
|
ContentBytesModel.fromJson(value.data);
|
|
setState(() {});
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: const CommonAppbar(
|
|
titleTxt: "Videos",
|
|
),
|
|
backgroundColor: Colors.black,
|
|
extendBody: true,
|
|
body: Obx(
|
|
() => Stack(
|
|
children: [
|
|
const CommonBlurLeft(),
|
|
const CommonBlurRight(),
|
|
isLoading.value
|
|
? const Center(
|
|
child: CircularProgressIndicator(
|
|
color: Color(0xFF0093FF),
|
|
),
|
|
)
|
|
: SingleChildScrollView(
|
|
child: Stack(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 16, vertical: 8),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
SizedBox(
|
|
width: 295.w,
|
|
child: CustomTextFormField( autofocus: false,
|
|
textEditingController: searchController,
|
|
onInput: (value) {
|
|
// Call method to handle search
|
|
handleSearch(value, "");
|
|
},
|
|
hintText: "Search videos",
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 12.w,
|
|
),
|
|
filter(),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 10.h,
|
|
),
|
|
// Display search results or regular list
|
|
contentBytesController
|
|
.moreVideoModel.data!.video!.isEmpty
|
|
? Center(
|
|
child: Column(
|
|
children: [
|
|
const Gap(250),
|
|
text24W500("No Data Found !"),
|
|
],
|
|
))
|
|
: Container(
|
|
height: 0.75.sh,
|
|
child: ListView.separated(
|
|
padding: EdgeInsets.zero,
|
|
shrinkWrap: true,
|
|
itemCount: contentBytesController
|
|
.moreVideoModel.data!.video!.length,
|
|
itemBuilder: (ctx, index) {
|
|
return Container(
|
|
margin: const EdgeInsets.only(
|
|
bottom: 20,
|
|
),
|
|
child: videoCard(
|
|
contentBytesController
|
|
.moreVideoModel
|
|
.data!
|
|
.video![index]
|
|
.link ??
|
|
"",
|
|
contentBytesController
|
|
.moreVideoModel
|
|
.data!
|
|
.video![index]
|
|
.title ??
|
|
"",
|
|
contentBytesController
|
|
.moreVideoModel
|
|
.data!
|
|
.video![index]
|
|
.description ??
|
|
"",
|
|
contentBytesController
|
|
.moreVideoModel
|
|
.data!
|
|
.video![index]
|
|
.image ??
|
|
"",
|
|
contentBytesController
|
|
.moreVideoModel
|
|
.data!
|
|
.video![index]
|
|
.createdAt ??
|
|
""),
|
|
);
|
|
},
|
|
separatorBuilder: (ctx, inndex) {
|
|
return const SizedBox(
|
|
height: 10,
|
|
);
|
|
},
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
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(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Center(
|
|
child: SizedBox(
|
|
height: (Get.height *
|
|
contentBytesController
|
|
.contentBytesCategoriesModel.data!.length) /
|
|
12,
|
|
width: 180,
|
|
child: ListView.builder(
|
|
padding: EdgeInsets.zero,
|
|
shrinkWrap: true,
|
|
itemCount: contentBytesController
|
|
.contentBytesCategoriesModel.data!.length +
|
|
1,
|
|
itemBuilder: (ctx, index) {
|
|
return index == 0
|
|
? selectedFilterIndex.value == 100
|
|
? SizedBox()
|
|
: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
GestureDetector(
|
|
onTap: (() {
|
|
Get.back();
|
|
selectedFilterIndex.value = 100;
|
|
contentBytesController.filterId =
|
|
"";
|
|
handleSearch("", "");
|
|
}),
|
|
child: text16W600("Reset",
|
|
clr: const Color(0xFF9A0000)))
|
|
],
|
|
)
|
|
: InkWell(
|
|
onTap: () {
|
|
// contentBytesController.isApiCalling.value = true;
|
|
Get.back();
|
|
selectedFilterIndex.value = index - 1;
|
|
contentBytesController.filterId =
|
|
contentBytesController
|
|
.contentBytesCategoriesModel
|
|
.data![index - 1]
|
|
.id!
|
|
.toString();
|
|
|
|
handleSearch(
|
|
searchController.text,
|
|
contentBytesController.filterId
|
|
.toString());
|
|
},
|
|
child: itemFilter(
|
|
index - 1, selectedFilterIndex.value));
|
|
}),
|
|
),
|
|
),
|
|
],
|
|
))
|
|
];
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget itemFilter(int index, int selectedIndex) {
|
|
return Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
const Gap(8),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
selectedIndex == index
|
|
? const CircleAvatar(
|
|
radius: 12,
|
|
backgroundColor: Colors.white,
|
|
child: Center(
|
|
child: Icon(
|
|
Icons.check,
|
|
color: Colors.green,
|
|
),
|
|
),
|
|
)
|
|
: const SizedBox(),
|
|
selectedIndex == index ? const Gap(5) : const SizedBox(),
|
|
SizedBox(
|
|
width: 150,
|
|
child: text18W400(
|
|
contentBytesController
|
|
.contentBytesCategoriesModel.data![index].categoryName!,
|
|
texAl: TextAlign.center,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
index ==
|
|
contentBytesController
|
|
.contentBytesCategoriesModel.data!.length -
|
|
1
|
|
? const SizedBox()
|
|
: const Divider(
|
|
color: Color(0xFF2C2C2C),
|
|
thickness: 0.6,
|
|
endIndent: 0,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget searchResultsWidget() {
|
|
// Display search results here
|
|
return const SizedBox();
|
|
}
|
|
|
|
Widget videoCard(String video, String title, String description, String image,
|
|
String createdAt) {
|
|
ContactUsController contactUsController = Get.put(ContactUsController());
|
|
return InkWell(
|
|
onTap: () {
|
|
Get.to(() => const PlayerWidget(), arguments: {
|
|
"video_url": video,
|
|
});
|
|
},
|
|
child: commonGlassContainer(
|
|
borderradius: 8,
|
|
width: double.infinity,
|
|
height: 340.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(
|
|
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(title),
|
|
SizedBox(
|
|
width: 0.81.sw,
|
|
height: 50,
|
|
child: text16W400(description,
|
|
textOver: TextOverflow.ellipsis)),
|
|
text12W400_979797(
|
|
contactUsController.timeAgoConverter(createdAt)),
|
|
],
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
)),
|
|
);
|
|
}
|
|
}
|