Initial commit: Penyerahan final Source code Tugas Akhir
This commit is contained in:
243
lib/screens/home/components/body_comp/populer_course_big.dart
Normal file
243
lib/screens/home/components/body_comp/populer_course_big.dart
Normal file
@ -0,0 +1,243 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_html/flutter_html.dart';
|
||||
import 'package:initial_folder/base_service.dart';
|
||||
import 'package:initial_folder/helper/validator.dart';
|
||||
import 'package:initial_folder/providers/top_course_provider.dart';
|
||||
import 'package:initial_folder/screens/detail_course/detail_course_screen.dart';
|
||||
import 'package:initial_folder/screens/home/components/body_comp/product_card/product_card.dart';
|
||||
import 'package:initial_folder/screens/home/components/body_comp/product_card/product_card_big.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
import '../../../../size_config.dart';
|
||||
import '../../../../theme.dart';
|
||||
|
||||
class PopulerCourseBig extends StatelessWidget {
|
||||
const PopulerCourseBig({Key? key, this.text}) : super(key: key);
|
||||
final String? text;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: getProportionateScreenWidth(16)),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
text!,
|
||||
textAlign: TextAlign.left,
|
||||
style: thirdTextStyle.copyWith(
|
||||
letterSpacing: 1,
|
||||
fontSize: getProportionateScreenWidth(15),
|
||||
fontWeight: semiBold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: getProportionateScreenHeight(10)),
|
||||
Consumer<TopCourseProvider>(
|
||||
builder: (context, state, _) {
|
||||
if (state.state == ResultState.Loading) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Shimmer.fromColors(
|
||||
baseColor: Colors.white,
|
||||
highlightColor: Colors.grey,
|
||||
child: Container(
|
||||
height: 105,
|
||||
width: 190,
|
||||
color: Colors.white,
|
||||
)),
|
||||
SizedBox(height: 10),
|
||||
Shimmer.fromColors(
|
||||
baseColor: Colors.white,
|
||||
highlightColor: Colors.grey,
|
||||
child: Container(
|
||||
height: 15,
|
||||
width: 85,
|
||||
color: Colors.white,
|
||||
)),
|
||||
SizedBox(height: 8),
|
||||
Shimmer.fromColors(
|
||||
baseColor: Colors.white,
|
||||
highlightColor: Colors.grey,
|
||||
child: Container(
|
||||
height: 15,
|
||||
width: 190,
|
||||
color: Colors.white,
|
||||
)),
|
||||
SizedBox(height: 10),
|
||||
Shimmer.fromColors(
|
||||
baseColor: Colors.white,
|
||||
highlightColor: Colors.grey,
|
||||
child: Container(
|
||||
height: 15,
|
||||
width: 120,
|
||||
color: Colors.white,
|
||||
)),
|
||||
SizedBox(height: 8),
|
||||
Shimmer.fromColors(
|
||||
baseColor: Colors.white,
|
||||
highlightColor: Colors.grey,
|
||||
child: Container(
|
||||
height: 15,
|
||||
width: 85,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Shimmer.fromColors(
|
||||
baseColor: Colors.white,
|
||||
highlightColor: Colors.grey,
|
||||
child: Container(
|
||||
height: 105,
|
||||
width: 190,
|
||||
color: Colors.white,
|
||||
)),
|
||||
SizedBox(height: 10),
|
||||
Shimmer.fromColors(
|
||||
baseColor: Colors.white,
|
||||
highlightColor: Colors.grey,
|
||||
child: Container(
|
||||
height: 15,
|
||||
width: 85,
|
||||
color: Colors.white,
|
||||
)),
|
||||
SizedBox(height: 8),
|
||||
Shimmer.fromColors(
|
||||
baseColor: Colors.white,
|
||||
highlightColor: Colors.grey,
|
||||
child: Container(
|
||||
height: 15,
|
||||
width: 190,
|
||||
color: Colors.white,
|
||||
)),
|
||||
SizedBox(height: 10),
|
||||
Shimmer.fromColors(
|
||||
baseColor: Colors.white,
|
||||
highlightColor: Colors.grey,
|
||||
child: Container(
|
||||
height: 15,
|
||||
width: 120,
|
||||
color: Colors.white,
|
||||
)),
|
||||
SizedBox(height: 8),
|
||||
Shimmer.fromColors(
|
||||
baseColor: Colors.white,
|
||||
highlightColor: Colors.grey,
|
||||
child: Container(
|
||||
height: 15,
|
||||
width: 85,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
} else if (state.state == ResultState.HasData) {
|
||||
return Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
margin: EdgeInsets.only(left: getProportionateScreenWidth(4)),
|
||||
height: getProportionateScreenHeight(270),
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics: ScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemCount: state.result.length,
|
||||
itemBuilder: (context, index) {
|
||||
var topCourse = state.result[index];
|
||||
// var finalRating = double.parse(
|
||||
// (topCourse.specificRating![0] / 20).toStringAsFixed(2));
|
||||
return Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: getProportionateScreenHeight(10),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: getProportionateScreenWidth(13),
|
||||
bottom: getProportionateScreenWidth(18),
|
||||
),
|
||||
child: ProductCardBig(
|
||||
totalDiscount: topCourse.totalDiscount ?? 0,
|
||||
students: topCourse.students ?? '0',
|
||||
pad: 12,
|
||||
id: topCourse.idCourse,
|
||||
thumbnail: topCourse.thumbnail ??
|
||||
'$baseUrl/uploads/courses_thumbnail/course_thumbnail_default_57.jpg',
|
||||
title: topCourse.title,
|
||||
instructorName: topCourse.instructorName,
|
||||
specificRating: (topCourse.rating.isNotEmpty &&
|
||||
topCourse.rating[0]?.avgRating != null)
|
||||
? topCourse.rating[0]!.avgRating.toString()
|
||||
: '0',
|
||||
rating: (topCourse.rating.isNotEmpty &&
|
||||
topCourse.rating[0]?.avgRating != null)
|
||||
? topCourse.rating[0]!.avgRating.toString()
|
||||
: '5.0',
|
||||
numberOfRatings: (topCourse.rating.isNotEmpty &&
|
||||
topCourse.rating[0]?.totalReview != null)
|
||||
? topCourse.rating[0]!.totalReview!
|
||||
: '0',
|
||||
isTopCourse: topCourse.topCourse!,
|
||||
price: (topCourse.discountPrice == '0')
|
||||
? 'Gratis'
|
||||
: numberFormat(topCourse.discountPrice),
|
||||
realPrice: (topCourse.price == '0')
|
||||
? ''
|
||||
: numberFormat(topCourse.price),
|
||||
press: () {
|
||||
print(topCourse.idCourse);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DetailCourseScreen(
|
||||
idcourse: topCourse.idCourse,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
} else if (state.state == ResultState.NoData) {
|
||||
return Center(child: Text(state.message));
|
||||
} else if (state.state == ResultState.Error) {
|
||||
return Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Text('Terjadi Kesalahan Coba Lagi'),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Center(child: Text(''));
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user