You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
diplomatic-quarter/lib/pages/learning/course_list.dart

170 lines
6.7 KiB
Dart

import 'dart:async';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/extensions/string_extensions.dart';
import 'package:diplomaticquarterapp/models/course/education_journey_list_model.dart' as model;
import 'package:diplomaticquarterapp/routes.dart';
import 'package:diplomaticquarterapp/services/course_service/course_service.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class CourseList extends StatefulWidget {
@override
State<CourseList> createState() => _CourseListState();
}
class _CourseListState extends State<CourseList> {
CourseServiceProvider? _courseServiceProvider;
@override
void initState() {
super.initState();
_courseServiceProvider = context.read<CourseServiceProvider>();
_courseServiceProvider!.getCourses(context);
}
@override
void dispose() {
_clearData();
super.dispose();
}
Future<void> _clearData() async {
await _courseServiceProvider!.clearData();
}
@override
Widget build(BuildContext context) {
return AppScaffold(
isShowAppBar: false,
isShowDecPage: false,
showNewAppBarTitle: true,
showNewAppBar: true,
appBarTitle: "Learning",
backgroundColor: Color(0xFFF7F7F7),
onTap: () {},
body: Consumer<CourseServiceProvider>(builder: (context, provider, child) {
if (provider.nabedJourneyResponse != null) {
return ListView.separated(
itemCount: provider.data!.length,
padding: EdgeInsets.zero,
itemBuilder: (context, index) {
List<model.ContentClass> conClass = provider.data![index].contentClasses!;
model.Datum data = provider.data![index];
return Card(
margin: EdgeInsets.only(left: 20, right: 20, top: 20),
shape: RoundedRectangleBorder(
side: BorderSide(width: 1, color: Color(0xFFEFEFEF)),
borderRadius: BorderRadius.circular(10.0), // Set your desired radius here
),
child: Padding(
padding: EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: CachedNetworkImage(
imageUrl: conClass.first.image!.thumbUrl!,
width: double.infinity,
height: MediaQuery.of(context).size.height * .25,
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover,
//colorFilter: ColorFilter.mode(Colors.red, BlendMode.colorBurn),
),
),
),
placeholder: (context, url) => Center(child: CircularProgressIndicator()),
errorWidget: (context, url, error) => Icon(Icons.error),
),
),
SizedBox(height: 20.0),
Text(
conClass.first.title ?? "",
// "Basics of Heart",
style: TextStyle(
fontSize: 16.0,
height: 24 / 16,
color: Color(0xFF2E303A),
fontWeight: FontWeight.w600,
),
),
SizedBox(height: 2.0),
Text(
//data.date!.toIso8601String(),
"Heart diseases include conditions like coronary and heart failure, often caused by factors ",
style: TextStyle(fontSize: 10.0, height: 15 / 10, color: Color(0xFF575757)),
),
SizedBox(height: 6.0),
Text(
conClass.first.readPercentage.toString() + " Hour Watched",
// "2 Hours",
style: TextStyle(
fontSize: 10.0,
height: 15 / 10,
color: Color(0xFF2E303A),
fontWeight: FontWeight.w600,
),
),
SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Row(
children: List.generate(5, (starIndex) {
return Icon(
Icons.star,
color: Color(0xFFD1272D),
size: 15.0,
);
}),
),
SizedBox(width: 8.0),
Text(
'540 reviews',
style: TextStyle(
fontSize: 10.0,
height: 15 / 10,
color: Color(0xFF2B353E),
fontWeight: FontWeight.w700,
),
),
],
),
Icon(
Icons.arrow_right_alt,
size: 18.0,
color: Color(0xFF2B353E),
),
],
),
],
),
),
).onTap(() {
provider.navigate(context, data.id!, onBack: (val) {
provider.uploadStats();
provider.clear();
});
});
},
separatorBuilder: (context, index) {
return SizedBox();
},
);
} else {
return SizedBox();
}
}),
);
}
}