391 lines
16 KiB
Dart
391 lines
16 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:flutter_svg/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_model.dart';
|
|
import 'package:traderscircuit/resources/routes/route_name.dart';
|
|
import 'package:traderscircuit/view/Sidemenu/ContentByte/PlayerWidget.dart';
|
|
import 'package:traderscircuit/view/Sidemenu/ContentByte/read_pdf.dart';
|
|
import 'package:traderscircuit/view/onBoarding/splashScreen1.dart';
|
|
import 'package:traderscircuit/view_model/ContentBytesApi/content_bytes_api.dart';
|
|
|
|
class ReadMore extends StatefulWidget {
|
|
const ReadMore({super.key});
|
|
|
|
@override
|
|
State<ReadMore> createState() => _VideosMoreState();
|
|
}
|
|
|
|
class _VideosMoreState extends State<ReadMore> {
|
|
ContentBytesController contentBytesController =
|
|
Get.put(ContentBytesController());
|
|
var data;
|
|
RxBool isLoading = true.obs;
|
|
RxInt selectedFilterIndex = 100.obs;
|
|
TextEditingController searchController = TextEditingController();
|
|
|
|
@override
|
|
void initState() {
|
|
ContentBytesApi().getContentBytesData("", "reads", "").then((value) {
|
|
contentBytesController.moreReadsModel =
|
|
ContentBytesModel.fromJson(value.data);
|
|
isLoading.value = false;
|
|
setState(() {});
|
|
});
|
|
super.initState();
|
|
}
|
|
|
|
void handleSearch(String query, String category) async {
|
|
await ContentBytesApi()
|
|
.getContentBytesData(
|
|
query, "reads", contentBytesController.filterId.toString())
|
|
.then((value) {
|
|
contentBytesController.moreReadsModel =
|
|
ContentBytesModel.fromJson(value.data);
|
|
setState(() {});
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: const CommonAppbar(
|
|
titleTxt: "Read",
|
|
),
|
|
backgroundColor: Colors.black,
|
|
extendBody: true,
|
|
body: Obx(
|
|
() => Stack(
|
|
children: [
|
|
const CommonBlurLeft(),
|
|
const CommonBlurRight(),
|
|
isLoading.value
|
|
? const Center(
|
|
child: CircularProgressIndicator(
|
|
color: Color(0xFF9A0000),
|
|
),
|
|
)
|
|
: Stack(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 16, vertical: 16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
text16W400_DADADA('The Beauty and Power of Audios'),
|
|
sizedBoxHeight(8.w),
|
|
Row(
|
|
children: [
|
|
SizedBox(
|
|
width: 295.w,
|
|
child: CustomTextFormField(
|
|
textEditingController: searchController,
|
|
onInput: (value) {
|
|
// Call method to handle search
|
|
handleSearch(value, "");
|
|
},
|
|
hintText: "Search Books",
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 12.w,
|
|
),
|
|
filter(),
|
|
],
|
|
),
|
|
// SizedBox(
|
|
// height: 10.h,
|
|
// ),
|
|
|
|
sizedBoxHeight(20.h),
|
|
contentBytesController
|
|
.moreReadsModel.data!.read!.isEmpty
|
|
? Center(
|
|
child: Column(
|
|
children: [
|
|
Gap(250),
|
|
text24W500("No Data Found !"),
|
|
],
|
|
))
|
|
: ListView.builder(
|
|
itemCount: contentBytesController
|
|
.moreReadsModel.data!.read!.length,
|
|
shrinkWrap: true,
|
|
physics: NeverScrollableScrollPhysics(),
|
|
itemBuilder: (ctx, index) {
|
|
return Column(
|
|
children: [
|
|
InkWell(
|
|
onTap: () {
|
|
Get.to(ReadPDF(
|
|
title: contentBytesController
|
|
.moreReadsModel
|
|
.data!
|
|
.read![index]
|
|
.title,
|
|
pdfUrfl: contentBytesController
|
|
.moreReadsModel
|
|
.data!
|
|
.read![index]
|
|
.file,
|
|
));
|
|
},
|
|
child: 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(
|
|
contentBytesController
|
|
.moreReadsModel
|
|
.data!
|
|
.read![index]
|
|
.title!),
|
|
),
|
|
sizedBoxHeight(10.h),
|
|
SizedBox(
|
|
width: 230.w,
|
|
height: 50,
|
|
child: text16W400(
|
|
contentBytesController
|
|
.moreReadsModel
|
|
.data!
|
|
.read![index]
|
|
.description!),
|
|
),
|
|
const Spacer()
|
|
],
|
|
),
|
|
Image.network(
|
|
"${contentBytesController.moreReadsModel.data!.read![index].image}",
|
|
height: 110,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
sizedBoxHeight(20.h),
|
|
],
|
|
);
|
|
}),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
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 videoCard(Video video) {
|
|
return InkWell(
|
|
onTap: () {
|
|
Get.to(() => const PlayerWidget(), arguments: {
|
|
"video_url": video.file,
|
|
});
|
|
},
|
|
child: commonGlassContainer(
|
|
borderradius: 8,
|
|
width: double.infinity,
|
|
height: 320.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!),
|
|
text16W400(video.description!),
|
|
// sizedBoxHeight(10.h),
|
|
//text12W400_979797('20k views . 2 days ago'),
|
|
text12W400_979797('2 days ago'),
|
|
],
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
)),
|
|
);
|
|
}
|