faq like dislike, content bytes

This commit is contained in:
jayesh
2024-04-11 18:53:14 +05:30
parent 486ed2ae96
commit cc08510485
13 changed files with 841 additions and 304 deletions

View File

@@ -26,6 +26,7 @@ class ApiUrls {
//FAQ API //FAQ API
static String faqApi = "${base}getFaq"; static String faqApi = "${base}getFaq";
static String faqLikeDislikeApi = "${base}userFaqLikeDislike";
//RISK PROFILE API //RISK PROFILE API
static String getRiskProfileQuestionAnswerApi = "${base}riskProfileQueAns"; static String getRiskProfileQuestionAnswerApi = "${base}riskProfileQueAns";

View File

@@ -1,11 +1,176 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:just_audio/just_audio.dart';
import 'package:traderscircuit/model/ContentBytesModel/content_bytes_categories_model.dart'; import 'package:traderscircuit/model/ContentBytesModel/content_bytes_categories_model.dart';
import 'package:traderscircuit/model/ContentBytesModel/content_bytes_model.dart'; import 'package:traderscircuit/model/ContentBytesModel/content_bytes_model.dart';
import '../view/Sidemenu/ContentByte/ContentBytes.dart';
class ContentBytesController extends GetxController { class ContentBytesController extends GetxController {
ContentBytesCategoriesModel contentBytesCategoriesModel = ContentBytesCategoriesModel contentBytesCategoriesModel =
ContentBytesCategoriesModel(); ContentBytesCategoriesModel();
ContentBytesModel contentBytesModel = ContentBytesModel(); ContentBytesModel contentBytesModel = ContentBytesModel();
int filterId = 0; int filterId = 0;
RxBool isApiCalling = true.obs; RxBool isApiCalling = true.obs;
RxBool isAudioSeekBarVisible = false.obs;
RxInt indexForAudios = 0.obs;
RxBool titlePlaying = false.obs;
RxList<bool>? titlePlayingList = <bool>[].obs;
final progressNotifier = ValueNotifier<ProgressBarState>(
ProgressBarState(
current: Duration.zero,
buffered: Duration.zero,
total: Duration.zero,
),
);
final buttonNotifier = ValueNotifier<ButtonState>(ButtonState.paused);
late AudioPlayer _audioPlayer;
ContentBytesController() {
init(0);
}
void init(index) async {
_audioPlayer = AudioPlayer();
try {
await _audioPlayer.setUrl(contentBytesModel.data!.audio![index].file ??
'https://ghantalele.com/uploads/files/data-78/38825/Besharam%20Rang_192(Ghantalele.com).mp3');
// await _audioPlayer.setAsset(url);
} on PlayerException catch (e) {
print("Error code: ${e.code}");
// iOS/macOS: maps to NSError.localizedDescription
// Android: maps to ExoPlaybackException.getMessage()
// Web/Linux: a generic message
// Windows: MediaPlayerError.message
print("Error message: ${e.message}");
}
//Catching errors during playback (e.g. lost network connection)
_audioPlayer.playbackEventStream.listen((event) {},
onError: (Object e, StackTrace st) {
if (e is PlayerException) {
print('Error code: ${e.code}');
print('Error message: ${e.message}');
} else {
print('An error occurred: $e');
}
});
_audioPlayer.playerStateStream.listen((playerState) {
final isPlaying = playerState.playing;
final processingState = playerState.processingState;
if (!isPlaying) {
buttonNotifier.value = ButtonState.paused;
} else if (processingState != ProcessingState.completed) {
buttonNotifier.value = ButtonState.playing;
} else {
_playNextTrack();
// _audioPlayer.seek(Duration.zero);
// _audioPlayer.pause();
}
});
_audioPlayer.positionStream.listen((position) {
final oldState = progressNotifier.value;
progressNotifier.value = ProgressBarState(
current: position,
buffered: oldState.buffered,
total: oldState.total,
);
});
_audioPlayer.bufferedPositionStream.listen((bufferedPosition) {
final oldState = progressNotifier.value;
progressNotifier.value = ProgressBarState(
current: oldState.current,
buffered: bufferedPosition,
total: oldState.total,
);
});
_audioPlayer.durationStream.listen((totalDuration) {
final oldState = progressNotifier.value;
progressNotifier.value = ProgressBarState(
current: oldState.current,
buffered: oldState.buffered,
total: totalDuration ?? Duration.zero,
);
});
}
void _playNextTrack() {
// Determine the index of the next track (you need to implement this logic)
int nextIndex = getNextTrackIndex();
if (nextIndex != -1) {
// Play the next track
updateTitlePlaying(nextIndex);
if (isPlaying()) {
stop();
}
init(nextIndex);
play(nextIndex);
} else {
_audioPlayer.seek(Duration.zero);
_audioPlayer.pause();
}
}
int getNextTrackIndex() {
if (indexForAudios.value == contentBytesModel.data!.audio!.length - 1) {
return -1;
} else {
return indexForAudios.value + 1;
}
// You need to implement this logic based on your playlist structure
// For example, if you have a list of tracks, return the index of the next track
// If there is no next track, return -1
// This logic depends on how you manage your playlist
// Example: return currentTrackIndex + 1;
}
void play(index) {
_audioPlayer.play();
isAudioSeekBarVisible.value = false;
isAudioSeekBarVisible.value = true;
indexForAudios.value = index;
}
void pause() {
_audioPlayer.pause();
}
void seek(Duration position) {
_audioPlayer.seek(position);
}
void stop() {
_audioPlayer.stop();
}
bool isPlaying() {
return _audioPlayer.playing;
}
addTitles() {
titlePlayingList = List<bool>.generate(
contentBytesModel.data!.audio!.length,
(index) => false,
).obs;
}
void updateTitlePlaying(int index) {
// Check if the index is within valid range
if (index >= 0 && index < titlePlayingList!.length) {
// Set all values to false
titlePlayingList!.assignAll(List.generate(
titlePlayingList!.length,
(index) => false,
));
// Set the specified index to true
titlePlayingList![index] = true;
}
}
} }

View File

@@ -64,7 +64,10 @@ class NetworkApiServices extends BaseApiServices {
} }
@override @override
Future<ResponseData> postApi(data, String url, {bool isAuth = false}) async { Future<ResponseData> postApi(
data,
String url,
) async {
if (kDebugMode) { if (kDebugMode) {
print("data >>> $data"); print("data >>> $data");
print("api url is >>> $url"); print("api url is >>> $url");

View File

@@ -1,3 +1,5 @@
import 'package:get/get.dart';
class FAQModel { class FAQModel {
String? status; String? status;
int? statusCode; int? statusCode;
@@ -97,6 +99,7 @@ class FaqQueAns {
String? deletedAt; String? deletedAt;
String? createdAt; String? createdAt;
String? updatedAt; String? updatedAt;
List<UserLikes>? userLikes;
FaqQueAns( FaqQueAns(
{this.id, {this.id,
@@ -108,7 +111,8 @@ class FaqQueAns {
this.modifiedBy, this.modifiedBy,
this.deletedAt, this.deletedAt,
this.createdAt, this.createdAt,
this.updatedAt}); this.updatedAt,
this.userLikes});
FaqQueAns.fromJson(Map<String, dynamic> json) { FaqQueAns.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
@@ -121,6 +125,12 @@ class FaqQueAns {
deletedAt = json['deleted_at'] ?? ""; deletedAt = json['deleted_at'] ?? "";
createdAt = json['created_at']; createdAt = json['created_at'];
updatedAt = json['updated_at']; updatedAt = json['updated_at'];
if (json['user_likes'] != null) {
userLikes = <UserLikes>[];
json['user_likes'].forEach((v) {
userLikes!.add(UserLikes.fromJson(v));
});
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -133,6 +143,53 @@ class FaqQueAns {
data['created_by'] = createdBy; data['created_by'] = createdBy;
data['modified_by'] = modifiedBy; data['modified_by'] = modifiedBy;
data['deleted_at'] = deletedAt; data['deleted_at'] = deletedAt;
data['created_at'] = createdAt;
data['updated_at'] = updatedAt;
if (userLikes != null) {
data['user_likes'] = userLikes!.map((v) => v.toJson()).toList();
}
return data;
}
}
class UserLikes {
int? id;
int? userId;
int? faqId;
int? status; //RxInt? status;
String? isActive;
String? createdAt;
String? updatedAt;
UserLikes(
{this.id,
this.userId,
this.faqId,
this.status,
this.isActive,
this.createdAt,
this.updatedAt});
UserLikes.fromJson(Map<String, dynamic> json) {
id = json['id'];
userId = json['user_id'];
faqId = json['faq_id'];
status = (json['status']); // RxInt(json['status']);
isActive = json['is_active'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['user_id'] = userId;
data['faq_id'] = faqId;
data['status'] = status;
data['is_active'] = isActive;
data['created_at'] = createdAt; data['created_at'] = createdAt;
data['updated_at'] = updatedAt; data['updated_at'] = updatedAt;
return data; return data;

View File

@@ -244,9 +244,9 @@ Widget ActiveCallsTab() {
children: [ children: [
InkWell( InkWell(
onTap: () { onTap: () {
Get.to( Get.to(() => PlayerWidget(), arguments: {
() => PlayerWidget(), "video_url": "",
); });
}, },
child: Container( child: Container(
height: 200.h, height: 200.h,

View File

@@ -194,9 +194,9 @@ class _ShortTradeState extends State<ShortTrade> {
children: [ children: [
InkWell( InkWell(
onTap: () { onTap: () {
Get.to( Get.to(() => PlayerWidget(), arguments: {
() => PlayerWidget(), "video_url": "",
); });
}, },
child: Container( child: Container(
height: 200.h, height: 200.h,

View File

@@ -1,5 +1,6 @@
import 'dart:developer'; import 'dart:developer';
import 'package:audio_video_progress_bar/audio_video_progress_bar.dart';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@@ -19,6 +20,19 @@ import 'package:traderscircuit/view/Sidemenu/ContentByte/Reels.dart';
import 'package:traderscircuit/view/onBoarding/splashScreen1.dart'; import 'package:traderscircuit/view/onBoarding/splashScreen1.dart';
import 'package:traderscircuit/view_model/ContentBytesApi/content_bytes_api.dart'; import 'package:traderscircuit/view_model/ContentBytesApi/content_bytes_api.dart';
class ProgressBarState {
ProgressBarState({
required this.current,
required this.buffered,
required this.total,
});
final Duration current;
final Duration buffered;
final Duration total;
}
enum ButtonState { paused, playing }
class ContentBytes extends StatefulWidget { class ContentBytes extends StatefulWidget {
const ContentBytes({super.key}); const ContentBytes({super.key});
@@ -37,27 +51,12 @@ class _ContentBytesState extends State<ContentBytes> {
"assets/images/png/sidemenu/reels4.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 = [ List<String> mostread = [
"assets/images/png/sidemenu/Read1.png", "assets/images/png/sidemenu/Read1.png",
"assets/images/png/sidemenu/Read2.png", "assets/images/png/sidemenu/Read2.png",
"assets/images/png/sidemenu/Read1.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 = [ List<String> audioname = [
"Week of 21st March 2024", "Week of 21st March 2024",
"Week of 21st March 2024", "Week of 21st March 2024",
@@ -93,6 +92,122 @@ class _ContentBytesState extends State<ContentBytes> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
key: _scaffoldKey1, key: _scaffoldKey1,
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: Obx(() => contentBytesController
.isAudioSeekBarVisible.value
? Container(
width: Get.size.width,
height: 100,
decoration: const BoxDecoration(
color: Colors.red,
),
child: Row(
children: [
Expanded(
flex: 1,
child: Align(
child: ClipRRect(
borderRadius: BorderRadius.circular(100),
child: Image.network(
contentBytesController
.contentBytesModel
.data!
.audio![
contentBytesController.indexForAudios.value]
.image!,
width: 57,
height: 57,
fit: BoxFit.cover,
),
),
),
),
Expanded(
flex: 3,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
contentBytesController
.contentBytesModel
.data!
.audio![
contentBytesController.indexForAudios.value]
.title!,
style: const TextStyle(
fontSize: 14,
color: Colors.black,
fontFamily: 'SFPRO',
fontWeight: FontWeight.w600,
height: 1.5,
),
),
// SizedBox(height: 5),
Text(
contentBytesController
.contentBytesModel
.data!
.audio![
contentBytesController.indexForAudios.value]
.description!,
style: const TextStyle(
fontSize: 14,
color: Colors.black,
fontFamily: 'SFPRO',
fontWeight: FontWeight.w600,
height: 1.5,
),
),
ValueListenableBuilder<ProgressBarState>(
valueListenable:
contentBytesController.progressNotifier,
builder: (context, value, _) {
return ProgressBar(
progress: value.current,
buffered: value.buffered,
total: value.total,
onSeek: contentBytesController.seek,
barHeight: 4,
thumbRadius: 6,
thumbGlowRadius: 15,
thumbColor: Colors.black,
baseBarColor: Colors.black.withOpacity(0.3),
progressBarColor: Colors.black,
bufferedBarColor: Colors.black.withOpacity(0.3),
);
},
),
],
),
),
Expanded(
flex: 1,
child: ValueListenableBuilder<ButtonState>(
valueListenable: contentBytesController.buttonNotifier,
builder: (context, value, _) {
switch (value) {
case ButtonState.paused:
return IconButton(
icon: const Icon(Icons.play_arrow_rounded),
iconSize: 50.0,
onPressed: () => contentBytesController.play(
contentBytesController.indexForAudios.value),
);
case ButtonState.playing:
return IconButton(
icon: const Icon(Icons.pause),
iconSize: 50.0,
onPressed: contentBytesController.pause,
);
}
},
),
),
],
),
)
: Container()),
backgroundColor: Colors.black, backgroundColor: Colors.black,
extendBody: true, extendBody: true,
appBar: const CommonAppbar(titleTxt: "Content Bytes"), appBar: const CommonAppbar(titleTxt: "Content Bytes"),
@@ -124,11 +239,7 @@ class _ContentBytesState extends State<ContentBytes> {
child: TabBarView( child: TabBarView(
children: [ children: [
Videos(images: reels), Videos(images: reels),
Audios( Audios(),
audio: audio,
audioname: audioname,
audionewimage: audionewimage,
audionamenewrelease: audionamenewrelease),
Reads(mostread: mostread), Reads(mostread: mostread),
], ],
), ),
@@ -162,27 +273,27 @@ class Reads extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( // Row(
children: [ // children: [
const SizedBox( // const SizedBox(
width: 300, // width: 300,
child: CustomTextFormField( // child: CustomTextFormField(
leadingIcon: Icon(Icons.search), // leadingIcon: Icon(Icons.search),
), // ),
), // ),
SizedBox( // SizedBox(
width: 15.w, // width: 15.w,
), // ),
Image.asset( // Image.asset(
"assets/images/png/filter.png", // "assets/images/png/filter.png",
height: 30.h, // height: 30.h,
width: 30.w, // width: 30.w,
), // ),
], // ],
), // ),
SizedBox( // SizedBox(
height: 10.h, // height: 10.h,
), // ),
text22W600('Harnessing the Power of Ebooks"'), text22W600('Harnessing the Power of Ebooks"'),
sizedBoxHeight(20.h), sizedBoxHeight(20.h),
commonGlassContainer( commonGlassContainer(
@@ -391,19 +502,18 @@ class Reads extends StatelessWidget {
} }
} }
class Audios extends StatelessWidget { class Audios extends StatefulWidget {
const Audios({ const Audios({
super.key, super.key,
required this.audio,
required this.audioname,
required this.audionewimage,
required this.audionamenewrelease,
}); });
final List<String> audio; @override
final List<String> audioname; State<Audios> createState() => _AudiosState();
final List<String> audionewimage; }
final List<String> audionamenewrelease;
class _AudiosState extends State<Audios> {
ContentBytesController contentBytesController =
Get.put(ContentBytesController());
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -411,89 +521,90 @@ class Audios extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( // Row(
children: [ // children: [
const SizedBox( // const SizedBox(
width: 300, // width: 300,
child: CustomTextFormField( // child: CustomTextFormField(
leadingIcon: Icon(Icons.search), // leadingIcon: Icon(Icons.search),
), // ),
), // ),
SizedBox( // SizedBox(
width: 15.w, // width: 15.w,
), // ),
Image.asset( // Image.asset(
"assets/images/png/filter.png", // "assets/images/png/filter.png",
height: 30.h, // height: 30.h,
width: 30.w, // width: 30.w,
), // ),
], // ],
), // ),
SizedBox( // SizedBox(
height: 10.h, // height: 10.h,
), // ),
text22W600('Content Bytes'), text22W600('Content Bytes'),
sizedBoxHeight(8.w), sizedBoxHeight(8.w),
text16W400_DADADA('The Beauty and Power of Video'), text16W400_DADADA('The Beauty and Power of Audios'),
sizedBoxHeight(20.h), sizedBoxHeight(20.h),
Container( GridView.builder(
height: 550, shrinkWrap: true,
child: GridView.builder( physics: const NeverScrollableScrollPhysics(),
physics: const NeverScrollableScrollPhysics(), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( mainAxisExtent: 172,
mainAxisExtent: 172, crossAxisCount: 2, // number of items in each row
crossAxisCount: 2, // number of items in each row mainAxisSpacing: 8.0, // spacing between rows
mainAxisSpacing: 8.0, // spacing between rows crossAxisSpacing: 8.0, // spacing between columns
crossAxisSpacing: 8.0, // spacing between columns ),
),
itemCount: 6, // total number of items itemCount: contentBytesController
itemBuilder: (context, index) { .contentBytesModel.data!.audio!.length, // total number of items
return Container( itemBuilder: (context, index) {
decoration: BoxDecoration( return Container(
gradient: LinearGradient( decoration: BoxDecoration(
begin: Alignment.topLeft, gradient: LinearGradient(
end: Alignment.bottomRight, begin: Alignment.topLeft,
colors: [ end: Alignment.bottomRight,
Colors.white.withOpacity(0.1), colors: [
const Color(0xFFFFFFFF).withOpacity(0.05), Colors.white.withOpacity(0.1),
], const Color(0xFFFFFFFF).withOpacity(0.05),
stops: [ ],
0.1, stops: [
1, 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]),
),
],
),
),
], ],
), ),
); borderRadius: BorderRadius.circular(8),
}, ),
), child: Stack(
children: [
Image.network(
contentBytesController
.contentBytesModel.data!.audio![index].image!,
),
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(contentBytesController
.contentBytesModel.data!.audio![index].title!),
),
],
),
),
],
),
);
},
), ),
SizedBox( SizedBox(
height: 20.h, height: 20.h,
@@ -511,7 +622,8 @@ class Audios extends StatelessWidget {
); );
}, },
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: 3, itemCount:
contentBytesController.contentBytesModel.data!.audio!.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@@ -536,7 +648,10 @@ class Audios extends StatelessWidget {
), ),
child: Stack( child: Stack(
children: [ children: [
Image.asset(audionewimage[index]), Image.network(
contentBytesController
.contentBytesModel.data!.audio![index].image!,
),
const Positioned( const Positioned(
right: 5, right: 5,
top: 5, top: 5,
@@ -559,7 +674,10 @@ class Audios extends StatelessWidget {
children: [ children: [
SizedBox( SizedBox(
width: 148.w, width: 148.w,
child: text14W500Overflow(audionamenewrelease[index]), child: text14W500Overflow(
contentBytesController
.contentBytesModel.data!.audio![index].title!,
),
), ),
], ],
) )
@@ -695,7 +813,7 @@ class _VideosState extends State<Videos> {
Widget videoCard(Video video) { Widget videoCard(Video video) {
return InkWell( return InkWell(
onTap: () { onTap: () {
Get.to(() => PlayerWidget(), arguments: { Get.to(() => const PlayerWidget(), arguments: {
"video_url": video.file, "video_url": video.file,
}); });
}, },
@@ -756,23 +874,23 @@ class _VideosState extends State<Videos> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( // Row(
children: [ // children: [
const SizedBox( // const SizedBox(
width: 295, // width: 295,
child: CustomTextFormField( // child: CustomTextFormField(
leadingIcon: Icon(Icons.search), // leadingIcon: Icon(Icons.search),
), // ),
), // ),
SizedBox( // SizedBox(
width: 15.w, // width: 15.w,
), // ),
filter(), // filter(),
], // ],
), // ),
SizedBox( // SizedBox(
height: 10.h, // height: 10.h,
), // ),
text22W600('Content Bytes'), text22W600('Content Bytes'),
sizedBoxHeight(8.w), sizedBoxHeight(8.w),
text16W400_DADADA('The Beauty and Power of Video'), text16W400_DADADA('The Beauty and Power of Video'),
@@ -808,64 +926,66 @@ class _VideosState extends State<Videos> {
: videoCard(contentBytesController : videoCard(contentBytesController
.contentBytesModel.data!.video![1]), .contentBytesModel.data!.video![1]),
sizedBoxHeight(15.h), sizedBoxHeight(15.h),
text22W600("Reels"), // text22W600("Reels"),
sizedBoxHeight(25.h), // sizedBoxHeight(25.h),
Container( // Container(
height: 500, // height: 500,
child: GridView.builder( // child: GridView.builder(
physics: const NeverScrollableScrollPhysics(), // physics: const NeverScrollableScrollPhysics(),
gridDelegate: // gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount( // const SliverGridDelegateWithFixedCrossAxisCount(
mainAxisExtent: 215, // mainAxisExtent: 215,
crossAxisCount: 2, // number of items in each row // crossAxisCount: 2, // number of items in each row
mainAxisSpacing: 8.0, // spacing between rows // mainAxisSpacing: 8.0, // spacing between rows
crossAxisSpacing: 8.0, // spacing between columns // 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]),
// ),
// );
// },
// ),
// ),
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), // sizedBoxHeight(10.h),
contentBytesController contentBytesController
.contentBytesModel.data!.video!.length < .contentBytesModel.data!.video!.length <
3 3
? const SizedBox() ? const SizedBox()
: ListView.builder( : ListView.builder(
physics: NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
itemCount: contentBytesController itemCount: contentBytesController
.contentBytesModel.data!.video!.length - .contentBytesModel.data!.video!.length -
2, 2,
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (ctx, index) { itemBuilder: (ctx, index) {
return Container( return Container(
margin: EdgeInsets.only( margin: const EdgeInsets.only(
bottom: 20, bottom: 20,
), ),
child: videoCard(contentBytesController child: videoCard(contentBytesController

View File

@@ -13,7 +13,9 @@ class PlayerWidget extends StatefulWidget {
class _PlayerWidgetState extends State<PlayerWidget> { class _PlayerWidgetState extends State<PlayerWidget> {
late VideoPlayerController videoPlayerController; late VideoPlayerController videoPlayerController;
late ChewieController chewieController; late ChewieController chewieController;
var videoUrl = Get.arguments["video_url"]; var videoUrl = Get.arguments["video_url"] == ""
? "https://player.vimeo.com/progressive_redirect/playback/930595309/rendition/360p/file.mp4?loc=external&signature=55ffa7ff72b807e1b3830cd6d308b092d4b1f82baadf6c20e7c235cd9a33bcdf"
: Get.arguments["video_url"];
@override @override
void initState() { void initState() {
_initializePlayer(); _initializePlayer();
@@ -41,6 +43,13 @@ class _PlayerWidgetState extends State<PlayerWidget> {
looping: false); looping: false);
} }
@override
void dispose() {
videoPlayerController.dispose();
chewieController.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return videoPlayerController != null && return videoPlayerController != null &&

View File

@@ -1,7 +1,10 @@
import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:traderscircuit/Utils/Common/CommonAppBar.dart'; import 'package:traderscircuit/Utils/Common/CommonAppBar.dart';
import 'package:traderscircuit/Utils/Common/CustomTextFormField.dart'; import 'package:traderscircuit/Utils/Common/CustomTextFormField.dart';
import 'package:traderscircuit/Utils/Common/comonGlassmorphicContainer.dart'; import 'package:traderscircuit/Utils/Common/comonGlassmorphicContainer.dart';
@@ -11,6 +14,8 @@ import 'package:traderscircuit/model/FAQModel/faq_model.dart';
import 'package:traderscircuit/view/onBoarding/splashScreen1.dart'; import 'package:traderscircuit/view/onBoarding/splashScreen1.dart';
import 'package:traderscircuit/view_model/FaqApi/faq_api.dart'; import 'package:traderscircuit/view_model/FaqApi/faq_api.dart';
Rx<FAQModel> faqModel = FAQModel().obs;
class FaqScreen extends StatefulWidget { class FaqScreen extends StatefulWidget {
const FaqScreen({super.key}); const FaqScreen({super.key});
@@ -22,23 +27,29 @@ class _FaqScreenState extends State<FaqScreen> {
List<String> categoryList = []; List<String> categoryList = [];
RxBool isLoading = true.obs; RxBool isLoading = true.obs;
FAQModel faqModel = FAQModel();
@override @override
void initState() { void initState() {
getData();
FAQApi().getFAQData().then((value) { FAQApi().getFAQData().then((value) {
faqModel = FAQModel.fromJson(value.data); faqModel.value = FAQModel.fromJson(value.data);
for (var a in faqModel.data!) { for (var a in faqModel.value.data!) {
categoryList.add(a.categoryName!); categoryList.add(a.categoryName!);
} }
isExpandedList = RxList.generate( isExpandedList = RxList.generate(
faqModel.data![selectedIndex.value].faqQueAns!.length, faqModel.value.data![selectedIndex.value].faqQueAns!.length,
(index) => index == 0); (index) => index == 0);
isLoading.value = false; isLoading.value = false;
}); });
super.initState(); super.initState();
} }
String? token;
getData() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
token = prefs.getString('accessToken');
}
final selectedIndex = 0.obs; final selectedIndex = 0.obs;
late RxList<bool> isExpandedList; late RxList<bool> isExpandedList;
@@ -95,6 +106,7 @@ class _FaqScreenState extends State<FaqScreen> {
selectedIndex.value = index; selectedIndex.value = index;
isExpandedList = RxList.generate( isExpandedList = RxList.generate(
faqModel faqModel
.value
.data![selectedIndex.value] .data![selectedIndex.value]
.faqQueAns! .faqQueAns!
.length, .length,
@@ -114,16 +126,33 @@ class _FaqScreenState extends State<FaqScreen> {
Obx(() { Obx(() {
return Column( return Column(
children: List.generate( children: List.generate(
faqModel.data![selectedIndex.value] faqModel
.faqQueAns!.length, (index) { .value
.data![selectedIndex.value]
.faqQueAns!
.length, (index) {
return customExpandableItem( return customExpandableItem(
index: index,
selectedIndex: selectedIndex.value,
faqModel1: faqModel.value,
isExpanded: isExpandedList[index], isExpanded: isExpandedList[index],
title: faqModel.data![selectedIndex.value] title: faqModel
.faqQueAns![index].faqQuestion!, .value
content: faqModel.data![selectedIndex.value] .data![selectedIndex.value]
.faqQueAns![index].faqAnswer!, .faqQueAns![index]
.faqQuestion!,
content: faqModel
.value
.data![selectedIndex.value]
.faqQueAns![index]
.faqAnswer!,
toggleExpansion: () => toggleExpansion: () =>
toggleExpansion(index), toggleExpansion(index),
faqId: faqModel
.value
.data![selectedIndex.value]
.faqQueAns![index]
.id!,
); );
})); }));
}), }),
@@ -144,13 +173,21 @@ class _FaqScreenState extends State<FaqScreen> {
borderRadius: BorderRadius.circular(5), borderRadius: BorderRadius.circular(5),
color: const Color(0XFF3F0502), color: const Color(0XFF3F0502),
border: Border.all(color: const Color(0xFF9A0000), width: 1)), border: Border.all(color: const Color(0xFF9A0000), width: 1)),
child: Center(child: text16W500(text)), child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: FittedBox(child: text16W500(text)),
)),
) )
: commonGlassContainer( : commonGlassContainer(
width: 136.w, width: 136.w,
height: 38.h, height: 38.h,
borderradius: 5, borderradius: 5,
customWidget: Center(child: text16W400(text)), customWidget: Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 9),
child: FittedBox(child: text16W400(text)),
)),
); );
}); });
} }
@@ -171,6 +208,10 @@ class _FaqScreenState extends State<FaqScreen> {
required String title, required String title,
required String content, required String content,
required VoidCallback toggleExpansion, required VoidCallback toggleExpansion,
required int faqId,
required FAQModel faqModel1,
required int selectedIndex,
required int index,
}) { }) {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@@ -230,58 +271,123 @@ class _FaqScreenState extends State<FaqScreen> {
child: Text( child: Text(
content, content,
style: TextStyle( style: TextStyle(
color: const Color(0xFFFFFFFF),
color: Color(0xFFFFFFFF),
fontFamily: 'hiragino', fontFamily: 'hiragino',
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
), ),
), ),
), ),
), ),
sizedBoxHeight(12.h), token == null || token!.isEmpty
commonGlassContainer( ? const SizedBox()
width: double.infinity, : sizedBoxHeight(12.h),
height: 65.h, token == null || token!.isEmpty
borderradius: 8, ? const SizedBox()
customWidget: Padding( : commonGlassContainer(
padding: EdgeInsets.only(right: 8.w, left: 13.w), width: double.infinity,
child: Center( height: 65.h,
child: Row(children: [ borderradius: 8,
Text( customWidget: Padding(
'Was this answer helpful?', padding: EdgeInsets.only(right: 8.w, left: 13.w),
style: TextStyle( child: Center(
fontFamily: 'hiragino', child: Row(children: [
fontSize: 16.sp, Text(
fontWeight: FontWeight.w500, 'Was this answer helpful?',
color: Colors.white, style: TextStyle(
), fontFamily: 'hiragino',
), fontSize: 16.sp,
const Spacer(), fontWeight: FontWeight.w500,
Row( color: Colors.white,
crossAxisAlignment: CrossAxisAlignment.center, ),
children: [ ),
text16W500('Yes'), const Spacer(),
sizedBoxWidth(2.w), Row(
SvgPicture.asset( crossAxisAlignment: CrossAxisAlignment.center,
'assets/images/svg/thumbs-up.svg'),
sizedBoxWidth(8.w),
text16W500('No'),
sizedBoxWidth(2.w),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
sizedBoxHeight(5.h), InkWell(
SvgPicture.asset( onTap: () {
'assets/images/svg/thumbs-down.svg'), FAQApi()
.updaeFAQLikeDisklikeData(faqId, 1)
.then((value) {
FAQApi().getFAQData().then((value) {
faqModel.value =
FAQModel.fromJson(value.data);
setState(() {});
});
});
},
child: Row(
children: [
text16W500('Yes'),
sizedBoxWidth(2.w),
(faqModel
.value
.data![selectedIndex]
.faqQueAns![index]
.userLikes!
.isNotEmpty &&
faqModel
.value
.data![selectedIndex]
.faqQueAns![index]
.userLikes![0]
.status! ==
1)
? Icon(Icons.check)
: SvgPicture.asset(
'assets/images/svg/thumbs-up.svg'),
],
),
),
sizedBoxWidth(8.w),
InkWell(
onTap: () {
FAQApi()
.updaeFAQLikeDisklikeData(faqId, 0)
.then((value) {
FAQApi().getFAQData().then((value) {
faqModel.value =
FAQModel.fromJson(value.data);
});
});
},
child: Row(
children: [
text16W500('No'),
sizedBoxWidth(2.w),
Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
sizedBoxHeight(5.h),
(faqModel
.value
.data![selectedIndex]
.faqQueAns![index]
.userLikes!
.isNotEmpty &&
faqModel
.value
.data![
selectedIndex]
.faqQueAns![index]
.userLikes![0]
.status! ==
0)
? Icon(Icons.cancel)
: SvgPicture.asset(
'assets/images/svg/thumbs-down.svg'),
],
)
],
),
)
], ],
) ),
], ]),
) )))
]),
)))
], ],
), ),
), ),

View File

@@ -9,6 +9,8 @@ import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:traderscircuit/resources/routes/route_name.dart'; import 'package:traderscircuit/resources/routes/route_name.dart';
import '../../Utils/Common/noInternet.dart';
class SplashScreen extends StatefulWidget { class SplashScreen extends StatefulWidget {
const SplashScreen({super.key}); const SplashScreen({super.key});
@@ -44,52 +46,55 @@ class _SplashScreenState extends State<SplashScreen>
void initState() { void initState() {
super.initState(); super.initState();
checkInternet(); checkInternet();
log(_connectionStatus.toString());
Future.delayed(Duration(seconds: 2), () async {
Get.toNamed(RouteName.sliderscreen1);
// if (_connectionStatus == ConnectivityResult.none) {
// var result = await Get.to(NoInternet());
// if (result != null && result) {
// Timer(const Duration(seconds: 1), () async {
// SharedPreferences prefs = await SharedPreferences.getInstance();
// token = prefs.getString('token');
// myusername = prefs.getString('name');
// phonenumber = prefs.getString('contact_number');
// OnBoard = prefs.getBool('OnBoard') ?? false;
// if (OnBoard == false) {
// Get.toNamed(RouteName.sliderscreen1);
// } else {
// if (token == null || token!.isEmpty) {
// Get.offAndToNamed(RouteName.loginScreen);
// } else {
// GetProfile().GetProfileAPI().then((value) {
// Get.toNamed(RouteName.mainScreen, arguments: 0);
// });
// }
// }
// });
// }
// } else {
// Timer(const Duration(seconds: 2), () async {
// SharedPreferences prefs = await SharedPreferences.getInstance();
// token = prefs.getString('token'); Future.delayed(Duration(seconds: 2), () async {
// myusername = prefs.getString('name'); if (_connectionStatus == ConnectivityResult.none) {
// phonenumber = prefs.getString('contact_number'); var result = await Get.to(NoInternet());
// OnBoard = prefs.getBool('OnBoard') ?? false; if (result != null && result) {
// if (OnBoard == false) { Timer(const Duration(seconds: 1), () async {
// Get.toNamed(RouteName.sliderscreen1); SharedPreferences prefs = await SharedPreferences.getInstance();
// } else { var token = prefs.getString('accessToken');
// if (token == null || token!.isEmpty) { // myusername = prefs.getString('name');
// Get.offAndToNamed(RouteName.loginScreen); // phonenumber = prefs.getString('contact_number');
// } else { // OnBoard = prefs.getBool('OnBoard') ?? false;
// GetProfile().GetProfileAPI().then((value) { // if (OnBoard == false) {
// Get.toNamed(RouteName.mainScreen, arguments: 0); // Get.toNamed(RouteName.sliderscreen1);
// }); // }
// } // else {
// } if (token == null || token!.isEmpty) {
// }); Get.offAndToNamed(RouteName.loginscreen);
// } } else {
// GetProfile().GetProfileAPI().then((value) {
// Get.toNamed(RouteName.mainScreen, arguments: 0);
// });
Get.toNamed(RouteName.mainscreen);
}
// }
});
}
} else {
Timer(const Duration(seconds: 2), () async {
SharedPreferences prefs = await SharedPreferences.getInstance();
var token = prefs.getString('accessToken');
// myusername = prefs.getString('name');
// phonenumber = prefs.getString('contact_number');
// OnBoard = prefs.getBool('OnBoard') ?? false;
// if (OnBoard == false) {
// Get.toNamed(RouteName.sliderscreen1);
// }
// else {
if (token == null || token!.isEmpty) {
Get.offAndToNamed(RouteName.loginscreen);
} else {
// GetProfile().GetProfileAPI().then((value) {
// Get.toNamed(RouteName.mainScreen, arguments: 0);
// });
Get.toNamed(RouteName.mainscreen);
}
// }
});
}
}); });
// for scaleTansition // for scaleTansition
_scaleController = AnimationController( _scaleController = AnimationController(
@@ -131,7 +136,8 @@ class _SplashScreenState extends State<SplashScreen>
scale: _scaleAnimation, scale: _scaleAnimation,
child: Text( child: Text(
"Traders Circuit", "Traders Circuit",
style: TextStyle(fontFamily: 'hiragino', style: TextStyle(
fontFamily: 'hiragino',
fontSize: 50, fontSize: 50,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Colors.white), color: Colors.white),

View File

@@ -3,10 +3,15 @@ import 'dart:developer';
import '../../Utils/api_urls.dart'; import '../../Utils/api_urls.dart';
import '../../Utils/base_manager.dart'; import '../../Utils/base_manager.dart';
import '../../data/network/network_api_services.dart'; import '../../data/network/network_api_services.dart';
import 'package:shared_preferences/shared_preferences.dart';
class FAQApi { class FAQApi {
Future<ResponseData<dynamic>> getFAQData() async { Future<ResponseData<dynamic>> getFAQData() async {
final response = await NetworkApiServices().getApi( SharedPreferences prefs = await SharedPreferences.getInstance();
String? token = prefs.getString('accessToken');
final response = await NetworkApiServices().postApi(
token == null || token.isEmpty ? {} : {"token": token},
ApiUrls.faqApi, ApiUrls.faqApi,
); );
log(response.data.toString()); log(response.data.toString());
@@ -22,4 +27,27 @@ class FAQApi {
} }
return response; return response;
} }
Future<ResponseData<dynamic>> updaeFAQLikeDisklikeData(
int faqId, int status) async {
final response = await NetworkApiServices().postApi(
{
"faq_id": faqId,
"status": status,
},
ApiUrls.faqLikeDislikeApi,
);
log(response.data.toString());
if (response.status == ResponseStatus.SUCCESS) {
Map<String, dynamic> responseData =
Map<String, dynamic>.from(response.data);
if (responseData['status'] == "success") {
return response;
} else {
return ResponseData<dynamic>(
responseData['message'], ResponseStatus.FAILED);
}
}
return response;
}
} }

View File

@@ -33,6 +33,22 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.11.0" version: "2.11.0"
audio_session:
dependency: transitive
description:
name: audio_session
sha256: a49af9981eec5d7cd73b37bacb6ee73f8143a6a9f9bd5b6021e6c346b9b6cf4e
url: "https://pub.dev"
source: hosted
version: "0.1.19"
audio_video_progress_bar:
dependency: "direct main"
description:
name: audio_video_progress_bar
sha256: ccc7d7b83d2a16c52d4a7fb332faabd1baa053fb0e4c16815aefd3945ab33b81
url: "https://pub.dev"
source: hosted
version: "2.0.2"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@@ -520,6 +536,30 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.7" version: "0.6.7"
just_audio:
dependency: "direct main"
description:
name: just_audio
sha256: b7cb6bbf3750caa924d03f432ba401ec300fd90936b3f73a9b33d58b1e96286b
url: "https://pub.dev"
source: hosted
version: "0.9.37"
just_audio_platform_interface:
dependency: transitive
description:
name: just_audio_platform_interface
sha256: c3dee0014248c97c91fe6299edb73dc4d6c6930a2f4f713579cd692d9e47f4a1
url: "https://pub.dev"
source: hosted
version: "4.2.2"
just_audio_web:
dependency: transitive
description:
name: just_audio_web
sha256: "134356b0fe3d898293102b33b5fd618831ffdc72bb7a1b726140abdf22772b70"
url: "https://pub.dev"
source: hosted
version: "0.4.9"
lints: lints:
dependency: transitive dependency: transitive
description: description:

View File

@@ -41,6 +41,8 @@ dependencies:
expansion_tile_group: ^1.2.4 expansion_tile_group: ^1.2.4
scgateway_flutter_plugin: ^2.3.1 scgateway_flutter_plugin: ^2.3.1
async: ^2.4.1 async: ^2.4.1
just_audio: ^0.9.37
audio_video_progress_bar: ^2.0.2
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: