Initial commit: Penyerahan final Source code Tugas Akhir

This commit is contained in:
ferdiakhh
2025-07-10 19:15:14 +07:00
commit e1f2206b8a
687 changed files with 80132 additions and 0 deletions

View File

@ -0,0 +1,72 @@
import 'package:flutter/material.dart';
import '../../../../theme.dart';
import '../../../../size_config.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:initial_folder/screens/splash/splash_screen_login.dart';
class Begin extends StatelessWidget {
const Begin({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
//EmailProvider emailProvider = Provider.of<EmailProvider>(context);
final user = FirebaseAuth.instance.currentUser;
return Row(
children: <Widget>[
Column(
children: <Widget>[
Container(
height: getProportionateScreenWidth(60),
width: getProportionateScreenWidth(60),
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
//border: Border.all(width: 2.0, color: Colors.white),
image: (Condition.loginFirebase == true)
? DecorationImage(
fit: BoxFit.fill,
image: NetworkImage(user!.photoURL!))
: DecorationImage(
image:
AssetImage('assets/images/Profile Image.png'))),
),
],
),
SizedBox(width: getProportionateScreenWidth(24)),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
//SizedBox(height: getProportionateScreenWidth(4)),
Row(
children: <Widget>[
Text(
"Hai,",
style: primaryTextStyle.copyWith(
fontSize: getProportionateScreenWidth(12),
fontWeight: reguler,
color: tenthColor,
),
textAlign: TextAlign.left,
),
],
),
SizedBox(height: getProportionateScreenWidth(7)),
Row(
children: <Widget>[
Text(
'Mau Upgrade Skill Apa?',
style: secondaryTextStyle.copyWith(
color: tenthColor,
fontWeight: semiBold,
fontSize: getProportionateScreenWidth(14),
),
textAlign: TextAlign.left,
),
],
),
],
),
],
);
}
}

View File

@ -0,0 +1,218 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:initial_folder/models/banners_model.dart';
import 'package:initial_folder/providers/banners_provider.dart';
import 'package:initial_folder/screens/detail_course/detail_course_screen.dart';
import 'package:initial_folder/theme.dart';
import 'package:initial_folder/widgets/custom_navigator.dart';
import 'package:initial_folder/widgets/terms_and_privacy.dart';
import 'package:provider/provider.dart';
import 'package:shimmer/shimmer.dart';
import '../../../../size_config.dart';
class CarouselWithIndicatorDemo extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _CarouselWithIndicatorState();
}
}
class _CarouselWithIndicatorState extends State<CarouselWithIndicatorDemo> {
int _current = 0;
@override
Widget build(BuildContext context) {
Widget listBannerPicture(BannersModel listBanner) {
return InkWell(
onTap: () {
String? idCourse;
if (listBanner.courseId.isNotEmpty) {
idCourse = listBanner.courseId;
} else {
if (listBanner.url!.isNotEmpty) {
if (listBanner.url!
.contains('https://vocasia-v4-develop.vercel.app/')) {
List<String> urlList = listBanner.url!.split('/');
try {
idCourse = urlList.last;
} on StateError {
idCourse = '0';
}
Navigator.of(context, rootNavigator: true).push(
CustomNavigator(
child: DetailCourseScreen(
idcourse: idCourse ?? '0',
),
),
);
} else {
Navigator.of(context, rootNavigator: true).push(
MaterialPageRoute(
builder: (context) => TermsAndCondition(
// url: 'https://vocasia.id/home/contact',
url: listBanner.url!,
),
),
);
}
}
}
},
splashColor: Colors.white10,
child: Container(
margin: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(16),
),
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(10)),
child: AspectRatio(
aspectRatio: 2,
child: CachedNetworkImage(
fadeInDuration: Duration(microseconds: 1),
imageUrl: listBanner.img.toString(),
fit: BoxFit.contain,
placeholder: (context, url) => Shimmer(
child: Container(
decoration: BoxDecoration(
color: ninthColor,
borderRadius: BorderRadius.circular(5),
),
),
gradient: LinearGradient(
stops: [0.2, 0.5, 0.6],
colors: [ninthColor, fourthColor, ninthColor])),
errorWidget: (context, url, error) => Icon(Icons.error),
),
),
),
),
);
}
return Container(
child: Consumer<BannersProvider>(builder: (context, state, _) {
if (state.state == ResultState.Loading) {
return Padding(
padding: const EdgeInsets.all(18.0),
child: Shimmer.fromColors(
baseColor: Colors.white,
highlightColor: Colors.grey,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white),
height: 210,
width: 50,
)),
);
} else if (state.state == ResultState.HasData) {
return Container(
child: Column(
children: [
CarouselSlider(
items: state.result
.map((banner) => listBannerPicture(banner))
.toList(),
options: CarouselOptions(
height: getProportionateScreenHeight(200),
disableCenter: true,
autoPlay: true,
autoPlayInterval: Duration(seconds: 10),
enlargeCenterPage: true,
viewportFraction: 1,
aspectRatio: 2,
onPageChanged: (index, reason) {
setState(() {
_current = index;
});
}),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: state.result.map((url) {
int index = state.result.indexOf(url);
return Container(
width: getProportionateScreenWidth(6.0),
height: getProportionateScreenWidth(6.0),
margin: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(3.0),
vertical: getProportionateScreenWidth(16)),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _current == index ? thirdColor : fourthColor,
),
);
}).toList()),
],
),
);
} else if (state.state == ResultState.NoData) {
final defaultBanners = [
'assets/images/deffault_banner.png',
'assets/images/default_banner_2.png'
];
return Column(
children: [
CarouselSlider.builder(
itemCount: defaultBanners.length,
itemBuilder: (context, index, realIndex) {
return Image.asset(
defaultBanners[index],
width: double.infinity,
);
},
options: CarouselOptions(
height: getProportionateScreenHeight(200),
autoPlay: true,
autoPlayInterval: Duration(seconds: 10),
enlargeCenterPage: true,
viewportFraction: 1,
aspectRatio: 2,
onPageChanged: (index, reason) {
setState(() {
_current = index;
});
},
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List.generate(defaultBanners.length, (index) {
return Container(
width: getProportionateScreenWidth(6.0),
height: getProportionateScreenWidth(6.0),
margin: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(3.0),
vertical: getProportionateScreenWidth(16),
),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _current == index ? thirdColor : fourthColor,
),
);
}),
),
],
);
} else if (state.state == ResultState.Error) {
return Padding(
padding: EdgeInsets.only(
left: getProportionateScreenWidth(76),
top: getProportionateScreenHeight(45),
),
child: Container(
width: getProportionateScreenWidth(480),
height: getProportionateScreenHeight(100),
color: Colors.transparent,
child: Text('Internet lemah, mohon muat ulang'),
),
);
} else {
return Center(child: Text(''));
}
}),
);
}
}

View File

@ -0,0 +1,164 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:initial_folder/screens/certificate/certificate.dart';
import 'package:initial_folder/screens/coupon/coupon_page.dart';
import 'package:initial_folder/screens/login/login_screen.dart';
import 'package:initial_folder/screens/login/login_with_email/login_email_screen.dart';
import 'package:initial_folder/screens/splash/splash_screen_login.dart';
import 'package:initial_folder/size_config.dart';
import 'package:initial_folder/theme.dart';
import 'package:initial_folder/widgets/custom_navigator_bottom.dart';
class CertificateVoucher extends StatelessWidget {
const CertificateVoucher({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
Future _showDialogNotLogin() {
return showDialog(
context: context,
builder: (context) => AlertDialog(
elevation: 0.0,
contentPadding: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(20),
vertical: getProportionateScreenHeight(20),
),
content: Text(
'Mohon login terlebih dahulu sebelum menukarkan kupon',
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(11)),
),
actions: [
GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
child: Text(
'Batal',
style: primaryTextStyle.copyWith(
fontSize: getProportionateScreenWidth(12),
letterSpacing: 1,
color: primaryColor),
),
),
SizedBox(
width: getProportionateScreenWidth(5),
),
GestureDetector(
onTap: () => Navigator.of(context).pushNamedAndRemoveUntil(
LoginEmail.routeName, (Route<dynamic> route) => false),
child: Text('Login',
style: primaryTextStyle.copyWith(
fontSize: getProportionateScreenWidth(12),
letterSpacing: 1,
color: primaryColor)),
),
],
),
);
}
return IntrinsicHeight(
child: Column(
children: [
SizedBox(height: getProportionateScreenHeight(20)),
Container(
height: getProportionateScreenHeight(44),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primaryContainer,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: -5,
blurRadius: 10,
offset: Offset(0, 3),
),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: () {
Navigator.of(context, rootNavigator: true).push(
CustomNavigatorBottom(
child: Certificate(),
),
);
},
child: Row(
children: [
SvgPicture.asset(
"assets/icons/certificate.svg",
color: Theme.of(context).colorScheme.onPrimary,
width: getProportionateScreenWidth(13),
),
SizedBox(width: getProportionateScreenWidth(5)),
Text(
'Sertifikat',
textAlign: TextAlign.start,
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(12),
fontWeight: reguler,
),
),
],
),
),
SizedBox(width: getProportionateScreenWidth(40)),
Container(
height: getProportionateScreenHeight(18),
child: VerticalDivider(
color: Theme.of(context).colorScheme.onPrimary,
thickness: 1),
),
SizedBox(width: getProportionateScreenWidth(40)),
GestureDetector(
onTap: () {
if (Condition.loginEmail || Condition.loginFirebase) {
showModalBottomSheet(
elevation: 0,
backgroundColor:
Theme.of(context).colorScheme.background,
context: context,
builder: (context) => ClipRect(child: CouponPage()),
isScrollControlled: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
),
);
} else if (!Condition.loginEmail ||
!Condition.loginFirebase) {
_showDialogNotLogin();
}
},
child: Row(
children: [
SvgPicture.asset(
"assets/icons/voucher.svg",
color: Theme.of(context).colorScheme.onPrimary,
width: getProportionateScreenWidth(13),
),
SizedBox(width: getProportionateScreenWidth(5)),
Text(
'Voucher',
textAlign: TextAlign.start,
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(12),
fontWeight: reguler,
),
),
],
),
),
],
),
)
],
),
);
}
}

View File

@ -0,0 +1,286 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:initial_folder/helper/validator.dart';
import 'package:initial_folder/providers/course_by_category_provider.dart';
import 'package:initial_folder/screens/detail_course/components/app_bar.dart';
import 'package:initial_folder/screens/detail_course/components/app_bar_filter.dart';
import 'package:initial_folder/screens/detail_course/detail_course_screen.dart';
import 'package:initial_folder/screens/home/components/body_comp/latest_course.dart';
import 'package:initial_folder/screens/home/components/body_comp/list_of_categories.dart';
import 'package:initial_folder/screens/home/components/body_comp/populer_course.dart';
import 'package:initial_folder/screens/home/components/body_comp/product_card/product_card.dart';
import 'package:initial_folder/services/course_by_category_service.dart';
import 'package:initial_folder/size_config.dart';
import 'package:initial_folder/theme.dart';
import 'package:initial_folder/widgets/custom_navigator.dart';
import 'package:provider/provider.dart';
class CourseByCategory extends StatefulWidget {
CourseByCategory({
Key? key,
required this.name,
required this.categoryId,
required this.subId,
this.homeCategories,
}) : super(key: key);
final String name;
final String categoryId;
final String subId;
final bool? homeCategories;
@override
State<CourseByCategory> createState() => _CourseByCategoryState();
}
class _CourseByCategoryState extends State<CourseByCategory> {
bool _isExpanded = false;
bool _buttonPressed = false;
final ScrollController _scrollController = ScrollController();
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: SingleChildScrollView(
controller: _scrollController,
child: ChangeNotifierProvider<CourseByCategoryProvider>(
create: (context) => CourseByCategoryProvider(
courseByCategoryService: CourseByCategoryService(),
id: widget.categoryId,
subId: widget.subId,
fetchBySubcategory: false,
),
child: Container(
child: Consumer<CourseByCategoryProvider>(
builder: (context, state, _) {
if (state.state == ResultState.Loading) {
return Center(
child: Padding(
padding: EdgeInsets.only(
top: getProportionateScreenHeight(300)),
child: CircularProgressIndicator(
color: secondaryColor,
strokeWidth: 2,
),
),
);
} else if (state.state == ResultState.HasData) {
return Stack(
children: [
GestureDetector(
child: Container(
color: Colors.transparent,
),
),
GestureDetector(
onTap: () {
setState(() {
_isExpanded = !_isExpanded;
_buttonPressed = !_buttonPressed;
});
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppBarHeader(),
SizedBox(height: getProportionateScreenHeight(23)),
Container(
margin: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(19)),
child: Text(
'${widget.name.replaceAll('&amp;', '&')}',
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(20),
letterSpacing: -0.5,
fontWeight: FontWeight.w600,
),
textAlign: TextAlign.start,
),
),
if (widget.homeCategories == null)
SizedBox(
height: getProportionateScreenHeight(65)),
if (widget.homeCategories == null)
PopulerCourse(text: 'Populer'),
if (widget.homeCategories == null)
LatestCourse(text: "New Release"),
if (widget.homeCategories == null)
SizedBox(
height: getProportionateScreenHeight(15)),
if (widget.homeCategories != null)
SizedBox(
height: getProportionateScreenHeight(25)),
if (widget.homeCategories == null)
Padding(
padding: EdgeInsets.only(
left: getProportionateScreenWidth(16),
bottom: getProportionateScreenHeight(28),
),
child: Text(
"${widget.name}",
textAlign: TextAlign.left,
style: thirdTextStyle.copyWith(
letterSpacing: 1,
fontSize: getProportionateScreenWidth(15),
fontWeight: semiBold,
),
),
),
GridView.builder(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(21),
left: getProportionateScreenWidth(7),
bottom: getProportionateScreenHeight(18),
),
physics: ScrollPhysics(),
shrinkWrap: true,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 2.8 / 4,
crossAxisSpacing: 16,
mainAxisSpacing: 14,
),
itemCount: state.result.length,
itemBuilder: (context, index) {
var courses = state.result[index];
int price = int.tryParse(
courses.price.replaceAll('.', '')) ??
0;
int discountPrice = int.tryParse(courses
.discountPrice
.replaceAll('.', '')) ??
0;
int calculatedPrice =
(courses.discountPrice != '0')
? price - discountPrice
: price;
String displayedPrice = (calculatedPrice == 0)
? courses.price
: calculatedPrice.toString();
return Container(
margin: EdgeInsets.only(
bottom: getProportionateScreenHeight(13)),
child: ProductCard(
totalDiscount: courses.totalDiscount ?? 0,
students: courses.students ?? '0',
id: courses.idCourse,
thumbnail: courses.thumbnail ??
'https://vocasia.id/uploads/thumbnails/course_thumbnails/course_thumbnail_default_63.jpg',
title: courses.title,
instructorName: courses.instructorName,
specificRating: double.parse(courses
.rating[0]!.avgRating !=
null
? '${courses.rating[0]!.avgRating}'
: '5.0')
.toString(),
rating: courses.rating[0]!.avgRating != null
? '${courses.rating[0]!.avgRating}'
: '5.0',
numberOfRatings:
courses.rating[0]!.totalReview ?? '0',
isTopCourse: '0',
price: (courses.discountPrice == '0')
? 'Gratis'
: numberFormat(displayedPrice),
realPrice: (courses.price == '0')
? ''
: numberFormat(courses.price),
press: () async {
Navigator.of(context, rootNavigator: true)
.push(
CustomNavigator(
child: DetailCourseScreen(
idcourse: courses.idCourse,
),
),
);
},
),
);
},
),
],
),
),
if (widget.homeCategories == null)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.topLeft,
widthFactor: 1,
heightFactor: 1,
child: Padding(
padding: EdgeInsets.only(
top: getProportionateScreenHeight(87)),
child: Categories(
selectedCategoryId: widget.categoryId,
key: UniqueKey(),
scrollController: _scrollController,
),
),
),
),
],
);
} else if (state.state == ResultState.NoData) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppBarHeader(),
Container(
margin: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(16)),
child: Text(
'${widget.name.replaceAll('&amp;', '&')}',
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(25),
letterSpacing: -0.5,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.start,
),
),
Categories(
selectedCategoryId: widget.categoryId,
key: UniqueKey(),
scrollController: _scrollController,
),
SizedBox(height: getProportionateScreenHeight(200)),
Center(
child: Text(
"Oops! Tidak ada kursus yang tersedia dalam kategori ini.",
textAlign: TextAlign.center,
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(14),
color: Colors.grey,
),
),
),
SizedBox(height: getProportionateScreenHeight(60)),
],
);
} else if (state.state == ResultState.Error) {
return Center(child: Text("No internet connections."));
} else {
return Center(child: Text(''));
}
}),
),
),
),
),
);
}
void _collapseSubcategories() {
_scrollController.animateTo(
0,
duration: Duration(milliseconds: 500),
curve: Curves.easeInOut,
);
}
}

View File

@ -0,0 +1,237 @@
import 'package:flutter/material.dart';
import 'package:initial_folder/helper/validator.dart';
import 'package:initial_folder/providers/course_by_category_provider.dart';
import 'package:initial_folder/screens/detail_course/components/app_bar.dart';
import 'package:initial_folder/screens/detail_course/components/app_bar_filter.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/services/course_by_category_service.dart';
import 'package:initial_folder/size_config.dart';
import 'package:initial_folder/theme.dart';
import 'package:initial_folder/widgets/custom_navigator.dart';
import 'package:provider/provider.dart';
class CourseBySubcategory extends StatefulWidget {
CourseBySubcategory({
Key? key,
required this.name,
required this.categoryId,
required this.subId,
}) : super(key: key);
final String name;
final String categoryId;
final String subId;
@override
State<CourseBySubcategory> createState() => _CourseBySubcategoryState();
}
class _CourseBySubcategoryState extends State<CourseBySubcategory> {
bool _isExpanded = false;
bool _buttonPressed = false;
final ScrollController _scrollController = ScrollController();
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: SingleChildScrollView(
controller: _scrollController,
child: ChangeNotifierProvider<CourseByCategoryProvider>(
create: (context) => CourseByCategoryProvider(
courseByCategoryService: CourseByCategoryService(),
id: widget.categoryId,
subId: widget.subId,
fetchBySubcategory: true,
),
child: Container(
child: Consumer<CourseByCategoryProvider>(
builder: (context, state, _) {
if (state.state == ResultState.Loading) {
return Center(
child: CircularProgressIndicator(
color: secondaryColor,
strokeWidth: 2,
),
);
} else if (state.state == ResultState.HasData) {
return GestureDetector(
onTap: () {
setState(() {
_isExpanded = !_isExpanded;
_buttonPressed = !_buttonPressed;
});
},
child: Stack(
children: [
GestureDetector(
child: Container(
color: Colors.transparent,
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppBarFilter(),
SizedBox(height: getProportionateScreenHeight(10)),
Container(
margin: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(16)),
child: Text(
'${widget.name}',
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(20),
letterSpacing: -0.5,
fontWeight: bold,
),
textAlign: TextAlign.start,
),
),
SizedBox(height: getProportionateScreenHeight(20)),
Container(
margin: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(16)),
child: Text(
"Semua Kursus ${widget.name}",
style:
thirdTextStyle.copyWith(fontWeight: bold),
),
),
SizedBox(height: getProportionateScreenHeight(20)),
GridView.builder(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(22),
left: getProportionateScreenWidth(7),
),
physics: ScrollPhysics(),
shrinkWrap: true,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 2.8 / 4,
crossAxisSpacing: 16,
mainAxisSpacing: 12,
),
itemCount: state.result.length,
itemBuilder: (context, index) {
var courses = state.result[index];
int price = int.tryParse(
courses.price.replaceAll('.', '')) ??
0;
int discountPrice = int.tryParse(courses
.discountPrice
.replaceAll('.', '')) ??
0;
int calculatedPrice =
(courses.discountPrice != '0')
? price - discountPrice
: price;
String displayedPrice = (calculatedPrice == 0)
? courses.price
: calculatedPrice.toString();
return Container(
margin: EdgeInsets.only(
bottom: getProportionateScreenHeight(17)),
child: ProductCard(
totalDiscount: courses.totalDiscount ?? 0,
students: courses.students ?? '0',
id: courses.idCourse,
thumbnail: courses.thumbnail ??
'https://vocasia.id/uploads/thumbnails/course_thumbnails/course_thumbnail_default_63.jpg',
title: courses.title,
instructorName: courses.instructorName,
specificRating: double.parse(courses
.rating[0]!.avgRating !=
null
? '${courses.rating[0]!.avgRating}'
: '5.0')
.toString(),
rating: courses.rating[0]!.avgRating != null
? '${courses.rating[0]!.avgRating}'
: '5.0',
numberOfRatings:
courses.rating[0]!.totalReview ?? '0',
isTopCourse: '0',
price: (courses.discountPrice == '0')
? 'Gratis'
: numberFormat(displayedPrice),
realPrice: (courses.price == '0')
? ''
: numberFormat(courses.price),
press: () async {
Navigator.of(context, rootNavigator: true)
.push(
CustomNavigator(
child: DetailCourseScreen(
idcourse: courses.idCourse,
),
),
);
},
),
);
},
),
],
),
],
),
);
} else if (state.state == ResultState.NoData) {
return Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppBarHeader(),
Container(
margin: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(16)),
child: Text(
'${widget.name.replaceAll('&amp;', '&')}',
style: secondaryTextStyle.copyWith(
fontSize: getProportionateScreenWidth(25),
letterSpacing: -0.5,
),
textAlign: TextAlign.start,
),
),
],
),
Center(
child: Padding(
padding: EdgeInsets.only(
top: getProportionateScreenHeight(300)),
child: Text(
"Sub kategori yang dipilih tidak memiliki kursus",
style: TextStyle(
fontSize: getProportionateScreenWidth(10)),
),
),
),
],
);
} else if (state.state == ResultState.Error) {
return Center(child: Text("Terjadi kesalahan."));
} else {
return Center(child: Text(''));
}
}),
),
),
),
),
);
}
void _collapseSubcategories() {
_scrollController.animateTo(
0,
duration: Duration(milliseconds: 500),
curve: Curves.easeInOut,
);
}
}

View File

@ -0,0 +1,173 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:initial_folder/helper/validator.dart';
import 'package:initial_folder/providers/course_by_category_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/services/course_by_category_service.dart';
import 'package:initial_folder/size_config.dart';
import 'package:initial_folder/theme.dart';
import 'package:provider/provider.dart';
class CourseTerkait extends StatefulWidget {
CourseTerkait({
Key? key,
required this.name,
required this.categoryId,
required this.subId,
this.homeCategories,
}) : super(key: key);
final String name;
final String categoryId;
final String subId;
final bool? homeCategories;
@override
State<CourseTerkait> createState() => _CourseTerkaitState();
}
class _CourseTerkaitState extends State<CourseTerkait> {
final ScrollController _scrollController = ScrollController();
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
controller: _scrollController,
child: ChangeNotifierProvider<CourseByCategoryProvider>(
create: (context) => CourseByCategoryProvider(
courseByCategoryService: CourseByCategoryService(),
id: widget.categoryId,
subId: widget.subId,
fetchBySubcategory: false,
),
child: Container(
child: Consumer<CourseByCategoryProvider>(
builder: (context, state, _) {
if (state.state == ResultState.Loading) {
return Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 2,
),
);
} else if (state.state == ResultState.HasData) {
return Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
height: getProportionateScreenHeight(13)),
Text(
' Kursus Terkait',
style: thirdTextStyle.copyWith(
fontWeight: semiBold,
fontSize: getProportionateScreenWidth(15),
),
),
],
),
SizedBox(height: getProportionateScreenHeight(20)),
GridView.builder(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(21),
left: getProportionateScreenWidth(7),
bottom: getProportionateScreenHeight(18),
),
physics: BouncingScrollPhysics(),
shrinkWrap: true,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 2.8 / 4,
crossAxisSpacing: 16,
mainAxisSpacing: 14,
),
itemCount: state.result.length,
itemBuilder: (context, index) {
var courses = state.result[index];
int price = int.tryParse(
courses.price.replaceAll('.', '')) ??
0;
int discountPrice = int.tryParse(courses
.discountPrice
.replaceAll('.', '')) ??
0;
int calculatedPrice =
(courses.discountPrice != '0')
? price - discountPrice
: price;
String displayedPrice = (calculatedPrice == 0)
? courses.price
: calculatedPrice.toString();
return Container(
margin: EdgeInsets.only(
bottom: getProportionateScreenHeight(13)),
child: ProductCard(
totalDiscount: courses.totalDiscount ?? 0,
students: courses.students ?? '0',
id: courses.idCourse,
thumbnail: courses.thumbnail ??
'https://vocasia.id/uploads/thumbnails/course_thumbnails/course_thumbnail_default_63.jpg',
title: courses.title,
instructorName: courses.instructorName,
specificRating: double.parse(courses
.rating[0]!.avgRating !=
null
? '${courses.rating[0]!.avgRating}'
: '5.0')
.toString(),
rating: courses.rating[0]!.avgRating != null
? '${courses.rating[0]!.avgRating}'
: '5.0',
numberOfRatings:
courses.rating[0]!.totalReview ?? '0',
isTopCourse: '0',
price: (courses.discountPrice == '0')
? 'Gratis'
: numberFormat(displayedPrice),
realPrice: (courses.price == '0')
? ''
: numberFormat(courses.price),
press: () async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
DetailCourseScreen(
idcourse: courses.idCourse,
),
),
);
},
),
);
},
),
SizedBox(height: getProportionateScreenHeight(50)),
],
),
],
);
} else if (state.state == ResultState.NoData) {
return Center(child: Text("Tidak ada kursus terkait"));
} else if (state.state == ResultState.Error) {
return Center(child: Text("No internet connections."));
} else {
return Center(child: Text(''));
}
},
),
),
),
),
);
}
}

View File

@ -0,0 +1,256 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:initial_folder/providers/categories_provider.dart';
import 'package:initial_folder/screens/home/components/body_comp/course_by_category.dart';
import 'package:initial_folder/size_config.dart';
import 'package:initial_folder/theme.dart';
import 'package:provider/provider.dart';
import 'package:shimmer/shimmer.dart';
import 'package:initial_folder/widgets/custom_navigator.dart';
class HomeCategories extends StatelessWidget {
const HomeCategories({super.key});
@override
Widget build(BuildContext context) {
CategoriesProvider categoriesProvider =
Provider.of<CategoriesProvider>(context);
return Padding(
padding: EdgeInsets.only(left: getProportionateScreenWidth(17)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: getProportionateScreenHeight(15)),
Padding(
padding: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(16)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Kategori',
textAlign: TextAlign.left,
style: thirdTextStyle.copyWith(
letterSpacing: 1,
fontSize: getProportionateScreenWidth(15),
fontWeight: semiBold,
),
),
GestureDetector(
onTap: () =>
Navigator.pushNamed(context, '/lihatSemuaKategori'),
child: Text(
'Lihat Semua',
textAlign: TextAlign.left,
style: thirdTextStyle.copyWith(
letterSpacing: 1,
fontSize: getProportionateScreenWidth(11),
),
),
),
],
),
),
SizedBox(height: getProportionateScreenHeight(18)),
Stack(
children: [
Padding(
padding: EdgeInsets.only(
left: getProportionateScreenWidth(22),
right: getProportionateScreenWidth(14),
),
child: categoriesProvider.state == ResultState.Loading
? GridView.count(
crossAxisCount: 2,
childAspectRatio: 5 / 2,
mainAxisSpacing: 13,
crossAxisSpacing: 30,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
children: List.generate(4, (index) {
return Shimmer.fromColors(
baseColor: Colors.grey,
highlightColor: Colors.white,
child: SizedBox(
width: getProportionateScreenWidth(160),
child: Container(
padding: EdgeInsets.symmetric(
vertical: getProportionateScreenHeight(5),
horizontal: getProportionateScreenWidth(10),
),
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey,
),
borderRadius: BorderRadius.circular(15),
),
child: Padding(
padding: EdgeInsets.only(
left: getProportionateScreenWidth(18)),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Container(
color: Colors.white,
height:
getProportionateScreenHeight(10),
),
SizedBox(
height:
getProportionateScreenHeight(7)),
Container(
color: Colors.white,
height:
getProportionateScreenHeight(10),
),
],
),
),
),
),
);
}),
)
: GridView.count(
crossAxisCount: 2,
childAspectRatio: 5 / 2,
mainAxisSpacing: 13,
crossAxisSpacing: 30,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
children: List.generate(4, (index) {
return GestureDetector(
onTap: () {
Navigator.of(context).push(
CustomNavigator(
child: CourseByCategory(
name: categoriesProvider
.result[index].nameCategory! ??
'',
categoryId:
categoriesProvider.result[index].id!,
subId: "",
homeCategories: true,
),
),
);
},
child: SizedBox(
width: getProportionateScreenWidth(160),
child: Container(
padding: EdgeInsets.symmetric(
vertical: getProportionateScreenHeight(5),
horizontal: getProportionateScreenWidth(10),
),
decoration: BoxDecoration(
border: Border.all(
color: Theme.of(context).brightness ==
Brightness.dark
? baruTextutih
: Colors.grey,
),
borderRadius: BorderRadius.circular(15),
),
child: Padding(
padding: EdgeInsets.only(
left: getProportionateScreenWidth(18)),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
categoriesProvider
.result[index].nameCategory!.replaceAll('&amp;', '&'),
style: thirdTextStyle.copyWith(
fontSize:
getProportionateScreenWidth(10),
letterSpacing: 1,
fontWeight: bold,
),
),
],
),
),
),
),
);
}),
),
),
if (categoriesProvider.state != ResultState.Loading)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.topLeft,
widthFactor: 0.12,
heightFactor: 0.44,
child: SvgPicture.asset(
"assets/icons/category1.svg",
width: getProportionateScreenWidth(35),
height: getProportionateScreenHeight(35),
),
),
),
if (categoriesProvider.state != ResultState.Loading)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.topLeft,
widthFactor: 0.12,
heightFactor: 1.53,
child: SvgPicture.asset(
"assets/icons/category3.svg",
width: getProportionateScreenWidth(35),
height: getProportionateScreenHeight(35),
),
),
),
if (categoriesProvider.state != ResultState.Loading)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.topCenter,
widthFactor: 0.6,
heightFactor: 0.4,
child: Padding(
padding: EdgeInsets.only(
left: getProportionateScreenWidth(37),
top: getProportionateScreenHeight(7),
),
child: SvgPicture.asset(
"assets/icons/category2.svg",
width: getProportionateScreenWidth(35),
height: getProportionateScreenHeight(35),
),
),
),
),
if (categoriesProvider.state != ResultState.Loading)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.bottomCenter,
widthFactor: 0.53,
heightFactor: 0.39,
child: Padding(
padding: EdgeInsets.only(
left: getProportionateScreenWidth(37),
bottom: getProportionateScreenHeight(7),
),
child: SvgPicture.asset(
"assets/icons/category4.svg",
width: getProportionateScreenWidth(35),
height: getProportionateScreenHeight(35),
),
),
),
),
],
),
SizedBox(height: getProportionateScreenHeight(5)),
],
),
);
}
}

View File

@ -0,0 +1,485 @@
import 'package:flutter/material.dart';
import 'package:initial_folder/base_service.dart';
import 'package:initial_folder/helper/validator.dart';
import 'package:initial_folder/providers/latest_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_new.dart';
import 'package:initial_folder/widgets/custom_navigator.dart';
import 'package:provider/provider.dart';
import 'package:shimmer/shimmer.dart';
import '../../../../size_config.dart';
import '../../../../theme.dart';
class LatestCourse extends StatelessWidget {
const LatestCourse({Key? key, this.text}) : super(key: key);
final String? text;
@override
Widget build(BuildContext context) {
return Column(
children: [
SizedBox(height: getProportionateScreenHeight(20)),
Padding(
padding:
EdgeInsets.symmetric(horizontal: getProportionateScreenWidth(16)),
child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [
Text(
text.toString(),
textAlign: TextAlign.left,
style: thirdTextStyle.copyWith(
letterSpacing: 1,
fontSize: getProportionateScreenWidth(15),
fontWeight: semiBold,
),
),
]),
),
SizedBox(height: getProportionateScreenHeight(10)),
Consumer<LatestCourseProvider>(
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 text != "New Release"
? Container(
alignment: Alignment.centerLeft,
margin: EdgeInsets.only(
left: getProportionateScreenWidth(10)),
height: getProportionateScreenHeight(240),
child: ListView.builder(
scrollDirection: Axis.horizontal,
physics: const ScrollPhysics(),
shrinkWrap: true,
itemCount: state.result.length,
itemBuilder: (context, index) {
var latestCourse = state.result[index];
int price = int.tryParse(
latestCourse.price.replaceAll('.', '')) ??
0;
int discountPrice = int.tryParse(latestCourse
.discountPrice
.replaceAll('.', '')) ??
0;
int calculatedPrice =
(latestCourse.discountPrice != '0')
? price - discountPrice
: price;
String displayedPrice = (calculatedPrice == 0)
? latestCourse.price
: calculatedPrice.toString();
// var finalRating = double.parse(
// (topCourse.specificRating![0] / 20).toStringAsFixed(2));
return Container(
margin: EdgeInsets.only(
top: getProportionateScreenHeight(10),
bottom: getProportionateScreenHeight(10),
),
child: Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(18),
bottom: getProportionateScreenWidth(5),
),
child: ProductCardNew(
totalDiscount: latestCourse.totalDiscount ?? 0,
students: latestCourse.students ?? '0',
pad: 12,
// padRight: 12,
id: latestCourse.idCourse,
thumbnail: latestCourse.thumbnail ??
'$baseUrl/uploads/courses_thumbnail/course_thumbnail_default_57.jpg',
title: latestCourse.title,
instructorName: latestCourse.instructorName,
specificRating:
(latestCourse.rating.isNotEmpty &&
latestCourse.rating[0]?.avgRating !=
null)
? latestCourse.rating[0]!.avgRating
.toString()
: '0',
rating:
latestCourse.rating[0]!.avgRating != null
? '${latestCourse.rating[0]!.avgRating}'
: '5.0',
numberOfRatings: (latestCourse
.rating.isNotEmpty &&
latestCourse.rating[0]?.totalReview !=
null)
? latestCourse.rating[0]!.totalReview!
: '0',
isTopCourse: latestCourse.topCourse ?? '',
price: (latestCourse.price == '0')
? 'Gratis'
: (latestCourse.promoPrice != '0')
? numberFormat(latestCourse.promoPrice)
: numberFormat(displayedPrice),
realPrice: (latestCourse.price == '0')
? ''
: numberFormat(latestCourse.price),
press: () {
print(latestCourse.idCourse);
Navigator.of(context, rootNavigator: true)
.push(
CustomNavigator(
child: DetailCourseScreen(
idcourse: latestCourse.idCourse,
isPromo: latestCourse.promoPrice != '0'
? true
: null,
),
),
);
},
),
),
);
},
),
)
: GridView.builder(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(22),
left: getProportionateScreenWidth(7),
top: getProportionateScreenHeight(10),
),
physics: ScrollPhysics(),
shrinkWrap: true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 2.55 / 4,
crossAxisSpacing: 16,
mainAxisSpacing: 12,
),
itemCount: state.result.length,
itemBuilder: (context, index) {
var latestCourse = state.result[index];
int price = int.tryParse(
latestCourse.price.replaceAll('.', '')) ??
0;
int discountPrice = int.tryParse(latestCourse
.discountPrice
.replaceAll('.', '')) ??
0;
int calculatedPrice =
(latestCourse.discountPrice != '0')
? price - discountPrice
: price;
String displayedPrice = (calculatedPrice == 0)
? latestCourse.price
: calculatedPrice.toString();
return Container(
margin: EdgeInsets.only(
bottom: getProportionateScreenHeight(17)),
child: ProductCardNew(
totalDiscount: latestCourse.totalDiscount ?? 0,
students: latestCourse.students ?? '0',
id: latestCourse.idCourse,
thumbnail: latestCourse.thumbnail ??
'https://vocasia.id/uploads/thumbnails/course_thumbnails/course_thumbnail_default_63.jpg',
title: latestCourse.title,
instructorName: latestCourse.instructorName,
specificRating: double.parse(
latestCourse.rating[0]!.avgRating != null
? '${latestCourse.rating[0]!.avgRating}'
: '5.0')
.toString(),
rating: latestCourse.rating[0]!.avgRating != null
? '${latestCourse.rating[0]!.avgRating}'
: '5.0',
numberOfRatings:
latestCourse.rating[0]!.totalReview ?? '0',
isTopCourse: '0',
price: (latestCourse.discountPrice == '0')
? 'Gratis'
: numberFormat(displayedPrice),
realPrice: (latestCourse.price == '0')
? ''
: numberFormat(latestCourse.price),
press: () async {
// await Hive.openBox<Wishlist>("wishlist");
// await Hive.openBox('carts');
Navigator.of(context, rootNavigator: true).push(
CustomNavigator(
child: DetailCourseScreen(
idcourse: latestCourse.idCourse,
isPromo: latestCourse.promoPrice != '0'
? true
: null,
),
),
);
},
),
);
},
);
} else if (state.state == ResultState.NoData) {
return Center(child: Text(state.message));
} else if (state.state == ResultState.Error) {
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 {
return Center(child: Text(''));
}
},
)
],
);
}
// @override
// Widget build(BuildContext context) {
// return Column(
// children: [
// Padding(
// padding:
// EdgeInsets.symmetric(horizontal: getProportionateScreenWidth(16)),
// child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [
// Text('Kursus Terbaru',
// textAlign: TextAlign.left,
// style: secondaryTextStyle.copyWith(
// letterSpacing: 1,
// color: tenthColor,
// fontSize: getProportionateScreenWidth(14),
// fontWeight: semiBold)),
// ]),
// ),
// SizedBox(height: 20),
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Icon(Icons.construction_outlined),
// Text('Under Construction'),
// ],
// ),
// ],
// );
// }
}

View File

@ -0,0 +1,273 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:initial_folder/providers/categories_provider.dart'
as categoriesProv;
import 'package:initial_folder/providers/others_course_provider.dart';
import 'package:initial_folder/screens/home/components/body_comp/course_by_category.dart';
import 'package:initial_folder/theme.dart';
import 'package:initial_folder/widgets/custom_navigator.dart';
import 'package:provider/provider.dart';
import '../../../../size_config.dart';
class LihatSemuaKategori extends StatefulWidget {
const LihatSemuaKategori({Key? key}) : super(key: key);
@override
State<LihatSemuaKategori> createState() => _LihatSemuaKategoriState();
}
class _LihatSemuaKategoriState extends State<LihatSemuaKategori> {
@override
Widget build(BuildContext context) {
categoriesProv.CategoriesProvider categoriesProvider =
Provider.of<categoriesProv.CategoriesProvider>(context);
return SafeArea(
child: Scaffold(
appBar: AppBar(
centerTitle: true,
scrolledUnderElevation: 0.0,
backgroundColor: Theme.of(context).colorScheme.background,
title: Text(
"Kategori",
style: thirdTextStyle.copyWith(
fontWeight: bold, fontSize: getProportionateScreenWidth(16)),
),
),
body: Padding(
padding: EdgeInsets.only(left: getProportionateScreenWidth(15)),
child: Stack(
children: [
Padding(
padding: EdgeInsets.only(
left: getProportionateScreenWidth(20),
right: getProportionateScreenWidth(14),
top: getProportionateScreenHeight(10),
),
child: categoriesProvider.state == ResultState.Loading
? Center(child: CircularProgressIndicator())
: GridView.count(
crossAxisCount: 2,
childAspectRatio: 4.3 / 2,
mainAxisSpacing: 13,
crossAxisSpacing: 30,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
children: List.generate(
categoriesProvider.result.length, (index) {
return GestureDetector(
onTap: () {
Navigator.of(context).push(
CustomNavigator(
child: CourseByCategory(
name: categoriesProvider
.result[index].nameCategory! ??
'',
categoryId:
categoriesProvider.result[index].id!,
subId: "",
homeCategories: true,
),
),
);
},
child: SizedBox(
width: getProportionateScreenWidth(160),
child: Container(
padding: EdgeInsets.symmetric(
vertical: getProportionateScreenHeight(5),
horizontal: getProportionateScreenWidth(10),
),
decoration: BoxDecoration(
border: Border.all(
color: Theme.of(context).brightness ==
Brightness.dark
? baruTextutih
: Colors.grey,
),
borderRadius: BorderRadius.circular(15),
),
child: Padding(
padding: EdgeInsets.only(
left: getProportionateScreenWidth(18)),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
categoriesProvider
.result[index].nameCategory!.replaceAll('&amp;', '&'),
style: thirdTextStyle.copyWith(
fontSize:
getProportionateScreenWidth(10),
fontWeight: bold,
),
),
],
),
),
),
),
);
}),
),
),
if (categoriesProvider.state != ResultState.Loading)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.topLeft,
widthFactor: 0.12,
heightFactor: 0.2,
child: Padding(
padding:
EdgeInsets.only(top: getProportionateScreenHeight(9)),
child: SvgPicture.asset(
"assets/icons/category1.svg",
width: getProportionateScreenWidth(35),
height: getProportionateScreenHeight(35),
),
),
),
),
if (categoriesProvider.state != ResultState.Loading)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.topLeft,
widthFactor: 0.12,
heightFactor: 0.59,
child: Padding(
padding:
EdgeInsets.only(top: getProportionateScreenHeight(9)),
child: SvgPicture.asset(
"assets/icons/category3.svg",
width: getProportionateScreenWidth(35),
height: getProportionateScreenHeight(35),
),
),
),
),
if (categoriesProvider.state != ResultState.Loading)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.topRight,
widthFactor: 0.51,
heightFactor: 0.2,
child: Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(133),
top: getProportionateScreenHeight(10),
),
child: SvgPicture.asset(
"assets/icons/category2.svg",
width: getProportionateScreenWidth(35),
height: getProportionateScreenHeight(35),
),
),
),
),
if (categoriesProvider.state != ResultState.Loading)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.topRight,
widthFactor: 0.51,
heightFactor: 0.6,
child: Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(133),
top: getProportionateScreenHeight(10),
),
child: SvgPicture.asset(
"assets/icons/category4.svg",
width: getProportionateScreenWidth(35),
height: getProportionateScreenHeight(35),
),
),
),
),
if (categoriesProvider.state != ResultState.Loading)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.centerLeft,
widthFactor: 0.12,
heightFactor: 0.7,
child: Padding(
padding:
EdgeInsets.only(top: getProportionateScreenHeight(9)),
child: SvgPicture.asset(
"assets/icons/category5.svg",
width: getProportionateScreenWidth(35),
height: getProportionateScreenHeight(35),
),
),
),
),
if (categoriesProvider.state != ResultState.Loading)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.bottomLeft,
widthFactor: 0.12,
heightFactor: 0.57,
child: SvgPicture.asset(
"assets/icons/category7.svg",
width: getProportionateScreenWidth(35),
height: getProportionateScreenHeight(35),
),
),
),
if (categoriesProvider.state != ResultState.Loading)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.centerRight,
widthFactor: 0.51,
heightFactor: 0.75,
child: Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(133),
top: getProportionateScreenHeight(10),
),
child: SvgPicture.asset(
"assets/icons/category6.svg",
width: getProportionateScreenWidth(35),
height: getProportionateScreenHeight(35),
),
),
),
),
if (categoriesProvider.state != ResultState.Loading)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.bottomRight,
widthFactor: 0.51,
heightFactor: 0.57,
child: Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(133)),
child: SvgPicture.asset(
"assets/icons/category8.svg",
width: getProportionateScreenWidth(35),
height: getProportionateScreenHeight(35),
),
),
),
),
if (categoriesProvider.state != ResultState.Loading)
Positioned.fill(
child: FractionallySizedBox(
alignment: Alignment.bottomLeft,
widthFactor: 0.12,
heightFactor: 0.17,
child: SvgPicture.asset(
"assets/icons/category9.svg",
width: getProportionateScreenWidth(35),
height: getProportionateScreenHeight(35),
),
),
),
],
),
),
),
);
}
}

View File

@ -0,0 +1,129 @@
import 'package:flutter/material.dart';
import 'package:initial_folder/helper/validator.dart';
import 'package:initial_folder/providers/others_course_provider.dart';
import 'package:initial_folder/screens/detail_course/components/app_bar.dart';
import 'package:initial_folder/screens/detail_course/detail_course_screen.dart';
import 'package:initial_folder/theme.dart';
import 'package:provider/provider.dart';
import 'others_course.dart';
import 'product_card/product_card.dart';
import '../../../../size_config.dart';
import 'section_title.dart';
import 'package:intl/intl.dart';
class LihatSemuaKursus extends StatefulWidget {
static String routeName = "/lihatKursus";
const LihatSemuaKursus({Key? key}) : super(key: key);
@override
State<LihatSemuaKursus> createState() => _LihatSemuaKursusState();
}
class _LihatSemuaKursusState extends State<LihatSemuaKursus> {
ScrollController _controller = ScrollController();
@override
void initState() {
_controller.addListener(() {
onScroll();
});
}
void onScroll() async {
double maxScroll = _controller.position.maxScrollExtent;
double currentScroll = _controller.position.pixels;
if (maxScroll == currentScroll) {
await Provider.of<OthersCourseProvider>(context, listen: false)
.getOthersCourses();
}
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (_controller.hasClients) {
if (_controller.position.pixels != _controller.position.maxScrollExtent) {
_controller.animateTo(0,
duration: Duration(milliseconds: 900), curve: Curves.linear);
}
}
return SafeArea(
child: Scaffold(
appBar: AppBar(
centerTitle: true,
scrolledUnderElevation: 0.0,
backgroundColor: Theme.of(context).colorScheme.background,
title: Text(
"Kursus Lainnya",
style: thirdTextStyle.copyWith(
fontWeight: bold, fontSize: getProportionateScreenWidth(16)),
),
),
body: Column(
children: [
Consumer<OthersCourseProvider>(builder: (context, state, _) {
if (state.state == ResultState.Loading) {
return Center(
child: CircularProgressIndicator(
color: secondaryColor,
strokeWidth: 2,
),
);
} else if (state.state == ResultState.HasData) {
return Expanded(
child: ListView(controller: _controller, children: [
OthersCourse(
key: PageStorageKey<String>('lihatKursus'),
showTitle: true,
),
Provider.of<OthersCourseProvider>(context).loading
? Center(
child: SizedBox(
height: 30,
width: 30,
child: CircularProgressIndicator(
color: secondaryColor,
strokeWidth: 2,
),
),
)
: SizedBox(height: 30),
SizedBox(height: 25),
]),
);
} 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',
style: thirdTextStyle,
),
],
));
} else {
return Center(child: Text(''));
}
})
],
),
),
);
}
}
// courseProvider.course
// .map(
// (product) => ProductCard(
// product: product,
// ),
// )
// .toList(),

View File

@ -0,0 +1,239 @@
import 'dart:ui';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:initial_folder/models/subcategories_model.dart';
import 'package:initial_folder/providers/categories_provider.dart';
import 'package:initial_folder/screens/home/components/body_comp/course_by_subcategory.dart';
import 'package:initial_folder/size_config.dart';
import 'package:initial_folder/theme.dart';
import 'package:initial_folder/widgets/custom_navigator.dart';
import 'package:provider/provider.dart';
class Categories extends StatefulWidget {
const Categories({
Key? key,
this.scrollable = false,
required this.selectedCategoryId,
required this.scrollController,
}) : super(key: key);
final bool scrollable;
final String selectedCategoryId;
final ScrollController scrollController;
@override
State<Categories> createState() => _CategoriesState();
}
class _CategoriesState extends State<Categories> {
bool _isExpanded = false;
bool _buttonPressed = false;
final GlobalKey<_CategoriesState> _categoriesKey =
GlobalKey<_CategoriesState>();
@override
void initState() {
super.initState();
widget.scrollController.addListener(_scrollListener);
}
@override
void dispose() {
widget.scrollController.removeListener(_scrollListener);
super.dispose();
}
void _scrollListener() {
if (_isExpanded) {
setState(() {
_isExpanded = false;
_buttonPressed = false;
});
}
}
void toggleExpansion(bool expanded) {
setState(() {
_isExpanded = expanded;
_buttonPressed = expanded;
});
if (!expanded) {
widget.scrollController.animateTo(
0,
duration: Duration(milliseconds: 500),
curve: Curves.easeInOut,
);
}
}
@override
Widget build(BuildContext context) {
return Container(
child: Consumer<CategoriesProvider>(builder: (context, state, _) {
if (state.state == ResultState.Loading) {
return Center(
child: CircularProgressIndicator(
color: secondaryColor,
strokeWidth: 2,
),
);
} else if (state.state == ResultState.HasData) {
final List<SubCategoryModel> filteredResult = state.result
.where((category) => category.id == widget.selectedCategoryId)
.map((category) => category.subCategories!)
.expand((element) => element)
.toList();
final bool showExpandIcon = filteredResult.length > 3;
return Container(
margin: EdgeInsets.symmetric(
vertical: getProportionateScreenHeight(10)),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
boxShadow: [
BoxShadow(
color: Theme.of(context).brightness == Brightness.dark
? Colors.grey.withOpacity(0.6)
: Colors.black.withOpacity(0.2),
spreadRadius: -10,
blurRadius: 12,
offset: Offset(0, 9),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
...filteredResult
.take(_buttonPressed ? 2 : 2)
.map<Widget>((subcategory) {
return Padding(
padding: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(17)),
child: GestureDetector(
onTap: () {
Navigator.push(
context,
CustomNavigator(
child: CourseBySubcategory(
categoryId: widget.selectedCategoryId,
subId: subcategory.subId,
name: subcategory.nameSubCategory,
),
),
);
},
child: Text(
subcategory.nameSubCategory.isNotEmpty
? subcategory.nameSubCategory.replaceAll('&amp;', '&')
: 'No subcategories available',
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(11.5),
fontWeight: FontWeight.w600,
),
),
),
);
}).toList(),
if (showExpandIcon)
IconButton(
icon: Transform.rotate(
angle: _isExpanded ? pi / 2 : 0,
child: Icon(
Icons.arrow_forward_ios,
size: getProportionateScreenWidth(16),
),
),
onPressed: () {
setState(() {
_isExpanded = !_isExpanded;
_buttonPressed = !_buttonPressed;
});
},
),
],
),
if (_isExpanded)
Padding(
padding: EdgeInsets.only(
top: getProportionateScreenHeight(8)),
child: Container(
color: Theme.of(context).colorScheme.background,
height: 160,
child: ListView(
shrinkWrap: true,
physics: AlwaysScrollableScrollPhysics(),
children: filteredResult
.skip(2)
.map<Widget>((subcategory) {
return Padding(
padding: EdgeInsets.symmetric(
horizontal:
getProportionateScreenWidth(17)),
child: GestureDetector(
onTap: () {
Navigator.push(
context,
CustomNavigator(
child: CourseBySubcategory(
categoryId:
widget.selectedCategoryId,
subId: subcategory.subId,
name: subcategory.nameSubCategory,
),
),
);
},
child: Padding(
padding: EdgeInsets.only(
bottom:
getProportionateScreenHeight(10)),
child: Padding(
padding: EdgeInsets.only(
bottom:
getProportionateScreenHeight(
9)),
child: Text(
subcategory.nameSubCategory.isNotEmpty
? subcategory.nameSubCategory.replaceAll('&amp;', '&')
: 'No subcategories available',
style: thirdTextStyle.copyWith(
fontSize:
getProportionateScreenWidth(
11.5),
fontWeight: FontWeight.w600,
),
),
),
),
),
);
}).toList(),
),
),
),
],
),
),
],
),
key: _categoriesKey,
);
} else if (state.state == ResultState.NoData) {
return Center(child: Text("No subcategories available"));
} else if (state.state == ResultState.Error) {
return Center(child: Text("No internet connections."));
} else {
print(state.result.length);
return Center(child: Text(''));
}
}),
);
}
}

View File

@ -0,0 +1,368 @@
import 'package:flutter/material.dart';
import 'package:initial_folder/base_service.dart';
import 'package:initial_folder/helper/validator.dart';
import 'package:initial_folder/providers/others_course_provider.dart';
import 'package:initial_folder/screens/detail_course/detail_course_screen.dart';
import 'package:initial_folder/screens/home/components/body_comp/lihat_semua_kursus_page.dart';
import 'package:initial_folder/theme.dart';
import 'package:initial_folder/widgets/custom_navigator.dart';
import 'package:provider/provider.dart';
import 'package:shimmer/shimmer.dart';
import 'product_card/product_card.dart';
import '../../../../size_config.dart';
import 'section_title.dart';
class OthersCourse extends StatelessWidget {
final bool? showTitle;
const OthersCourse({Key? key, this.showTitle}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
children: [
Padding(
padding: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(16)),
child: (showTitle == null)
? SectionTitle(
title: "Kursus Lainnya",
press: () {
Navigator.push(
context,
CustomNavigator(
child: LihatSemuaKursus(),
),
);
},
)
: SizedBox()),
SizedBox(height: getProportionateScreenHeight(30)),
Consumer<OthersCourseProvider>(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) {
// state.result.shuffle();
return GridView.builder(
// controller: _controller,
padding: EdgeInsets.only(
right: getProportionateScreenWidth(23),
left: getProportionateScreenWidth(8),
),
physics: ScrollPhysics(),
shrinkWrap: true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 2.6 / 4,
crossAxisSpacing: 15,
mainAxisSpacing: 10,
),
itemCount: state.result.length,
itemBuilder: (context, index) {
var othersCourse = state.result[index];
int price =
int.tryParse(othersCourse.price.replaceAll('.', '')) ?? 0;
int discountPrice = int.tryParse(
othersCourse.discountPrice.replaceAll('.', '')) ??
0;
int calculatedPrice = (othersCourse.discountPrice != '0')
? price - discountPrice
: price;
String displayedPrice = (calculatedPrice == 0)
? othersCourse.price
: calculatedPrice.toString();
// var finalRating = double.parse(
// (othersCourse.specificRating![0] / 20).toStringAsFixed(2));
return Padding(
padding:
EdgeInsets.only(bottom: getProportionateScreenHeight(8)),
child: Container(
margin: EdgeInsets.only(
bottom: getProportionateScreenHeight(12)),
child: ProductCard(
totalDiscount: othersCourse.totalDiscount ?? 0,
students: othersCourse.students ?? '0',
id: othersCourse.idCourse,
thumbnail: othersCourse.thumbnail ??
'$baseUrl/uploads/courses_thumbnail/course_thumbnail_default_57.jpg',
title: othersCourse.title,
instructorName: othersCourse.instructorName,
specificRating: (othersCourse.rating.isNotEmpty &&
othersCourse.rating[0]?.avgRating != null)
? othersCourse.rating[0]!.avgRating.toString()
: '0',
rating: (othersCourse.rating.isNotEmpty &&
othersCourse.rating[0]?.avgRating != null)
? othersCourse.rating[0]!.avgRating.toString()
: '5.0',
numberOfRatings: (othersCourse.rating.isNotEmpty &&
othersCourse.rating[0]?.totalReview != null)
? othersCourse.rating[0]!.totalReview!
: '0',
isTopCourse: othersCourse.topCourse ?? '',
price: (othersCourse.price == '0')
? 'Gratis'
: (othersCourse.promoPrice != '0')
? numberFormat(othersCourse.promoPrice)
: numberFormat(displayedPrice),
realPrice: (othersCourse.price == '0')
? ''
: numberFormat(othersCourse.price),
press: () {
Navigator.of(context, rootNavigator: true).push(
CustomNavigator(
child: DetailCourseScreen(
idcourse: othersCourse.idCourse,
isPromo:
othersCourse.promoPrice != "0" ? true : null,
),
),
);
},
),
),
);
},
);
} else if (state.state == ResultState.NoData) {
return Center(child: Text(state.message));
} else if (state.state == ResultState.Error) {
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 {
return Center(child: Text(''));
}
})
],
);
}
}
// courseProvider.course
// .map(
// (product) => ProductCard(
// product: product,
// ),
// )
// .toList(),

View File

@ -0,0 +1,361 @@
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/widgets/custom_navigator.dart';
import 'package:provider/provider.dart';
import 'package:shimmer/shimmer.dart';
import '../../../../size_config.dart';
import '../../../../theme.dart';
class PopulerCourse extends StatelessWidget {
const PopulerCourse({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.toString(),
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(10)),
height: getProportionateScreenHeight(220),
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));
int price =
int.tryParse(topCourse.price.replaceAll('.', '')) ?? 0;
int discountPrice = int.tryParse(
topCourse.discountPrice.replaceAll('.', '')) ??
0;
int calculatedPrice = (topCourse.discountPrice != '0')
? price - discountPrice
: price;
String displayedPrice = (calculatedPrice == 0)
? topCourse.price
: calculatedPrice.toString();
return Container(
margin: EdgeInsets.only(
top: getProportionateScreenHeight(10),
),
child: Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(18),
bottom: getProportionateScreenWidth(18),
),
child: ProductCard(
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.price == '0')
? 'Gratis'
: (topCourse.promoPrice != '0')
? numberFormat(topCourse.promoPrice)
: numberFormat(displayedPrice),
realPrice: (topCourse.price == '0')
? ''
: numberFormat(topCourse.price),
press: () {
print(topCourse.idCourse);
Navigator.of(context, rootNavigator: true).push(
CustomNavigator(
child: DetailCourseScreen(
idcourse: topCourse.idCourse,
),
),
);
},
),
),
);
},
),
);
} else if (state.state == ResultState.NoData) {
return Center(child: Text(state.message));
} else if (state.state == ResultState.Error) {
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 {
return Center(child: Text(''));
}
},
)
],
);
}
}

View 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(''));
}
},
)
],
);
}
}

View File

@ -0,0 +1,328 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:initial_folder/providers/theme_provider.dart';
import 'package:provider/provider.dart';
import 'package:shimmer/shimmer.dart';
import '../../../../../theme.dart';
import '../../../../../size_config.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
class ProductCard extends StatelessWidget {
const ProductCard({
Key? key,
this.width = 120,
this.pad = 16,
this.padRight = 0,
this.isHome,
required this.thumbnail,
required this.id,
required this.isTopCourse,
required this.title,
required this.instructorName,
required this.rating,
required this.specificRating,
required this.numberOfRatings,
required this.price,
required this.realPrice,
required this.press,
required this.students,
required this.totalDiscount,
}) : super(key: key);
final double width;
final double pad, padRight;
final String thumbnail,
title,
instructorName,
price,
realPrice,
rating,
specificRating,
numberOfRatings,
id,
isTopCourse;
final String students;
final VoidCallback press;
final int totalDiscount;
final bool? isHome;
// final VoidCallback? whislistPress;
// final Widget? iconWishlist;
@override
Widget build(BuildContext context) {
//CourseProvider courseProvider = Provider.of<CourseProvider>(context);
// final formatCurrency =
// new NumberFormat.simpleCurrency(decimalDigits: 0, locale: 'id_ID');
bool isRatingValid = int.tryParse(rating) != null;
bool isStudentsValid = int.tryParse(students) != null;
final themeProvider = Provider.of<ThemeProvider>(context);
bool isPopular = false;
if (isRatingValid && isStudentsValid) {
int ratingValue = int.parse(rating);
int studentsValue = int.parse(students);
bool isSpecificRatingValid = int.tryParse(specificRating) != null;
bool isNumberOfRatingsValid = int.tryParse(numberOfRatings) != null;
if (isSpecificRatingValid && isNumberOfRatingsValid) {
int specificRatingValue = int.parse(specificRating);
int numberOfRatingsValue = int.parse(numberOfRatings);
isPopular = ratingValue > 4 &&
studentsValue > 19 &&
specificRatingValue > 4 &&
numberOfRatingsValue > 4;
}
}
return Stack(
children: [
Container(
width: getProportionateScreenWidth(155),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
spreadRadius: 1,
blurRadius: 1,
offset: Offset(7, 17),
),
],
),
padding: EdgeInsets.only(
left: getProportionateScreenWidth(pad),
right: getProportionateScreenWidth(padRight),
),
child: InkWell(
onTap: press,
child: Container(
width: getProportionateScreenWidth(40),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.primaryContainer,
spreadRadius: 11,
blurRadius: 0,
offset: Offset(0, 3),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AspectRatio(
aspectRatio: 1.7,
child: CachedNetworkImage(
imageUrl: thumbnail,
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.vertical(top: Radius.circular(5)),
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover,
),
),
),
placeholder: (context, url) => Shimmer(
child: Container(
decoration: BoxDecoration(
color: ninthColor,
borderRadius:
BorderRadius.vertical(top: Radius.circular(5)),
),
),
gradient: LinearGradient(
stops: [0.2, 0.5, 0.6],
colors: [ninthColor, fourthColor, ninthColor]),
),
errorWidget: (context, url, error) => Icon(Icons.error),
fadeInDuration: Duration(milliseconds: 1),
fadeOutDuration: Duration(milliseconds: 1),
),
),
SizedBox(height: getProportionateScreenWidth(4)),
Container(
padding: EdgeInsets.only(left: 2),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: thirdTextStyle.copyWith(
letterSpacing: 1,
fontSize: getProportionateScreenWidth(12),
fontWeight: bold),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
SizedBox(height: getProportionateScreenWidth(6)),
// Row(
// children: [product.description],
// ),
RichText(
text: new TextSpan(
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(10),
color: Theme.of(context).dividerColor,
),
children: <TextSpan>[
new TextSpan(
text: '',
style: TextStyle(
fontWeight: bold,
),
),
new TextSpan(
text: instructorName,
style: TextStyle(fontWeight: bold),
),
],
),
),
SizedBox(height: getProportionateScreenWidth(6)),
Row(
children: [
Text(
specificRating,
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(10),
fontWeight: bold,
),
),
SizedBox(
width: getProportionateScreenWidth(2),
),
RatingBarIndicator(
itemSize: getProportionateScreenWidth(11),
rating: double.parse(rating),
direction: Axis.horizontal,
itemCount: 5,
itemBuilder: (context, _) => FaIcon(
FontAwesomeIcons.solidStar,
color: thirteenColor,
),
),
SizedBox(width: getProportionateScreenWidth(3)),
Text(
'(' + numberOfRatings + ')',
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(10),
fontWeight: bold,
),
),
],
),
SizedBox(height: getProportionateScreenWidth(6)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
price,
style: thirdTextStyle.copyWith(
letterSpacing: 0.5,
fontSize: SizeConfig.blockHorizontal! * 3,
fontWeight: bold,
),
),
],
),
SizedBox(height: getProportionateScreenWidth(6)),
if (realPrice.isNotEmpty && realPrice != price)
Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(10)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
realPrice,
style: primaryTextStyle.copyWith(
decoration: TextDecoration.lineThrough,
fontSize: getProportionateScreenWidth(10),
fontWeight: reguler,
),
),
// IconButton(onPressed: whislistPress, icon: iconWishlist)
],
),
)
else
SizedBox.shrink(),
if (isPopular)
Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(10),
),
child: Container(
alignment: Alignment.center,
width: getProportionateScreenWidth(48),
height: getProportionateScreenHeight(17),
child: Text(
'Populer',
style: thirdTextStyle.copyWith(
letterSpacing: 0.5,
color: Colors.white,
fontSize: SizeConfig.blockHorizontal! * 2.5,
fontWeight: bold,
),
),
decoration: BoxDecoration(
color:themeProvider.themeData == ThemeClass.darkmode
?primaryColor : primaryColorligtmode,
borderRadius: BorderRadius.circular(5),
),
),
)
else
SizedBox.shrink(),
],
),
)
],
),
),
),
),
if (totalDiscount != 0)
Padding(
padding: EdgeInsets.only(top: getProportionateScreenHeight(7)),
child: Container(
height: 20,
alignment: Alignment.center,
width: getProportionateScreenWidth(35),
child: Text(
'${totalDiscount.toString()}%',
style: thirdTextStyle.copyWith(
letterSpacing: 0.5,
color: baruTextutih,
fontSize: SizeConfig.blockHorizontal! * 2.5,
fontWeight: light,
),
),
decoration: BoxDecoration(
color: themeProvider.themeData == ThemeClass.darkmode
?primaryColor : primaryColorligtmode,
borderRadius: BorderRadius.only(
topRight: Radius.circular(4),
bottomRight: Radius.circular(4),
),
),
),
)
else
SizedBox.shrink(),
],
);
}
}
// Shimmer(
// child: Container(
// color: Colors.black,
// ),
// gradient: LinearGradient(
// stops: [0.2, 0.5, 0.6],
// colors: [ninthColor, fourthColor, ninthColor])),

View File

@ -0,0 +1,329 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:shimmer/shimmer.dart';
import '../../../../../theme.dart';
import '../../../../../size_config.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
class ProductCardBig extends StatelessWidget {
const ProductCardBig({
Key? key,
this.width = 120,
this.pad = 16,
this.padRight = 0,
required this.thumbnail,
required this.id,
required this.isTopCourse,
required this.title,
required this.instructorName,
required this.rating,
required this.specificRating,
required this.numberOfRatings,
required this.price,
required this.realPrice,
required this.press,
required this.students,
required this.totalDiscount,
}) : super(key: key);
final double width;
final double pad, padRight;
final String thumbnail,
title,
instructorName,
price,
realPrice,
rating,
specificRating,
numberOfRatings,
id,
isTopCourse;
final String students;
final VoidCallback press;
final int totalDiscount;
// final VoidCallback? whislistPress;
// final Widget? iconWishlist;
@override
Widget build(BuildContext context) {
//CourseProvider courseProvider = Provider.of<CourseProvider>(context);
// final formatCurrency =
// new NumberFormat.simpleCurrency(decimalDigits: 0, locale: 'id_ID');
bool isRatingValid = int.tryParse(rating) != null;
bool isStudentsValid = int.tryParse(students) != null;
bool isPopular = false;
if (isRatingValid && isStudentsValid) {
int ratingValue = int.parse(rating);
int studentsValue = int.parse(students);
bool isSpecificRatingValid = int.tryParse(specificRating) != null;
bool isNumberOfRatingsValid = int.tryParse(numberOfRatings) != null;
if (isSpecificRatingValid && isNumberOfRatingsValid) {
int specificRatingValue = int.parse(specificRating);
int numberOfRatingsValue = int.parse(numberOfRatings);
isPopular = ratingValue > 4 &&
studentsValue > 19 &&
specificRatingValue > 4 &&
numberOfRatingsValue > 4;
}
}
return Stack(
children: [
Container(
height: getProportionateScreenHeight(500),
width: getProportionateScreenWidth(250),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
spreadRadius: 1,
blurRadius: 1,
offset: Offset(7, 17),
),
],
),
padding: EdgeInsets.only(
left: getProportionateScreenWidth(pad),
right: getProportionateScreenWidth(padRight),
),
child: InkWell(
onTap: press,
child: Container(
width: getProportionateScreenWidth(40),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.primaryContainer,
spreadRadius: 11,
blurRadius: 0,
offset: Offset(0, 3),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AspectRatio(
aspectRatio: 1.7,
child: CachedNetworkImage(
imageUrl: thumbnail,
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.vertical(top: Radius.circular(5)),
image: DecorationImage(
image: imageProvider,
fit: BoxFit.fill,
),
),
),
placeholder: (context, url) => Shimmer(
child: Container(
decoration: BoxDecoration(
color: ninthColor,
borderRadius:
BorderRadius.vertical(top: Radius.circular(5)),
),
),
gradient: LinearGradient(
stops: [0.2, 0.5, 0.6],
colors: [ninthColor, fourthColor, ninthColor]),
),
errorWidget: (context, url, error) => Icon(Icons.error),
fadeInDuration: Duration(milliseconds: 1),
fadeOutDuration: Duration(milliseconds: 1),
),
),
SizedBox(height: getProportionateScreenWidth(4)),
Container(
padding: EdgeInsets.only(left: 2),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: thirdTextStyle.copyWith(
letterSpacing: 1,
fontSize: getProportionateScreenWidth(13),
fontWeight: bold),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
SizedBox(height: getProportionateScreenWidth(6)),
// Row(
// children: [product.description],
// ),
RichText(
text: new TextSpan(
style: primaryTextStyle.copyWith(
fontSize: getProportionateScreenWidth(11),
color: Theme.of(context).dividerColor,
),
children: [
new TextSpan(
text: '',
style: thirdTextStyle.copyWith(
fontWeight: reguler,
),
),
new TextSpan(
text: instructorName,
style: TextStyle(fontWeight: bold),
),
],
),
),
SizedBox(height: getProportionateScreenWidth(6)),
Row(
children: [
Text(
specificRating,
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(11),
fontWeight: bold,
),
),
SizedBox(
width: getProportionateScreenWidth(2),
),
RatingBarIndicator(
itemSize: getProportionateScreenWidth(12),
rating: double.parse(rating),
direction: Axis.horizontal,
itemCount: 1,
itemBuilder: (context, _) => FaIcon(
FontAwesomeIcons.solidStar,
color: thirteenColor,
),
),
SizedBox(
width: getProportionateScreenWidth(3),
),
Text(
'(' + numberOfRatings + ' Reviews)',
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(11),
fontWeight: light,
),
),
],
),
SizedBox(
height: getProportionateScreenWidth(6),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
price,
style: thirdTextStyle.copyWith(
letterSpacing: 0.5,
fontSize: SizeConfig.blockHorizontal! * 3,
fontWeight: bold,
),
),
],
),
SizedBox(height: getProportionateScreenWidth(6)),
(realPrice != price)
? Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(10)),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
realPrice,
style: thirdTextStyle.copyWith(
decoration: TextDecoration.lineThrough,
fontSize:
getProportionateScreenWidth(10),
fontWeight: reguler,
),
),
// IconButton(
// onPressed: whislistPress,
// icon: iconWishlist)
],
),
)
: SizedBox(height: 13, width: 1),
if (isPopular)
Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(10)),
child: Container(
alignment: Alignment.center,
width: getProportionateScreenWidth(48),
height: getProportionateScreenHeight(17),
child: Text(
'Populer',
style: thirdTextStyle.copyWith(
letterSpacing: 0.5,
color: Colors.white,
fontSize: SizeConfig.blockHorizontal! * 2.5,
fontWeight: bold,
),
),
decoration: BoxDecoration(
color: primaryColor,
borderRadius: BorderRadius.circular(5),
),
),
)
else
SizedBox(height: 0, width: 0),
],
),
)
],
),
),
),
),
if (totalDiscount != 0)
Padding(
padding: EdgeInsets.only(top: getProportionateScreenHeight(7)),
child: Container(
height: 20,
alignment: Alignment.center,
width: getProportionateScreenWidth(35),
child: Text(
'${totalDiscount.toString()}%',
style: thirdTextStyle.copyWith(
letterSpacing: 0.5,
color: baruTextutih,
fontSize: SizeConfig.blockHorizontal! * 2.5,
fontWeight: light,
),
),
decoration: BoxDecoration(
color: primaryColor,
borderRadius: BorderRadius.only(
topRight: Radius.circular(4),
bottomRight: Radius.circular(4),
),
),
),
)
else
SizedBox(height: 0, width: 0),
],
);
}
}
// Shimmer(
// child: Container(
// color: Colors.black,
// ),
// gradient: LinearGradient(
// stops: [0.2, 0.5, 0.6],
// colors: [ninthColor, fourthColor, ninthColor])),

View File

@ -0,0 +1,320 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:shimmer/shimmer.dart';
import '../../../../../theme.dart';
import '../../../../../size_config.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
class ProductCardCoupon extends StatelessWidget {
const ProductCardCoupon({
Key? key,
this.width = 120,
this.pad = 16,
this.padRight = 0,
required this.thumbnail,
required this.id,
required this.isTopCourse,
required this.title,
required this.instructorName,
required this.rating,
required this.specificRating,
required this.numberOfRatings,
required this.price,
required this.realPrice,
required this.press,
required this.students,
required this.totalDiscount,
}) : super(key: key);
final double width;
final double pad, padRight;
final String thumbnail,
title,
instructorName,
price,
realPrice,
rating,
specificRating,
numberOfRatings,
id,
isTopCourse;
final String students;
final VoidCallback press;
final int totalDiscount;
// final VoidCallback? whislistPress;
// final Widget? iconWishlist;
@override
Widget build(BuildContext context) {
//CourseProvider courseProvider = Provider.of<CourseProvider>(context);
// final formatCurrency =
// new NumberFormat.simpleCurrency(decimalDigits: 0, locale: 'id_ID');
bool isRatingValid = int.tryParse(rating) != null;
bool isStudentsValid = int.tryParse(students) != null;
bool isPopular = false;
if (isRatingValid && isStudentsValid) {
int ratingValue = int.parse(rating);
int studentsValue = int.parse(students);
bool isSpecificRatingValid = int.tryParse(specificRating) != null;
bool isNumberOfRatingsValid = int.tryParse(numberOfRatings) != null;
if (isSpecificRatingValid && isNumberOfRatingsValid) {
int specificRatingValue = int.parse(specificRating);
int numberOfRatingsValue = int.parse(numberOfRatings);
isPopular = ratingValue > 4 &&
studentsValue > 19 &&
specificRatingValue > 4 &&
numberOfRatingsValue > 4;
}
}
return Stack(
children: [
Container(
width: getProportionateScreenWidth(165),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
spreadRadius: 1,
blurRadius: 1,
offset: Offset(7, 17),
),
],
),
padding: EdgeInsets.only(
left: getProportionateScreenWidth(pad),
right: getProportionateScreenWidth(padRight),
),
child: InkWell(
onTap: press,
child: Container(
width: getProportionateScreenWidth(40),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.primaryContainer,
spreadRadius: 11,
blurRadius: 0,
offset: Offset(0, 3),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AspectRatio(
aspectRatio: 1.7,
child: CachedNetworkImage(
imageUrl: thumbnail,
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.vertical(top: Radius.circular(5)),
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover,
),
),
),
placeholder: (context, url) => Shimmer(
child: Container(
decoration: BoxDecoration(
color: ninthColor,
borderRadius:
BorderRadius.vertical(top: Radius.circular(5)),
),
),
gradient: LinearGradient(
stops: [0.2, 0.5, 0.6],
colors: [ninthColor, fourthColor, ninthColor]),
),
errorWidget: (context, url, error) => Icon(Icons.error),
fadeInDuration: Duration(milliseconds: 1),
fadeOutDuration: Duration(milliseconds: 1),
),
),
SizedBox(height: getProportionateScreenWidth(4)),
Container(
padding: EdgeInsets.only(left: 2),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: thirdTextStyle.copyWith(
letterSpacing: 1,
fontSize: getProportionateScreenWidth(12),
fontWeight: bold),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
SizedBox(height: getProportionateScreenWidth(6)),
// Row(
// children: [product.description],
// ),
RichText(
text: new TextSpan(
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(10),
color: Theme.of(context).dividerColor,
),
children: <TextSpan>[
new TextSpan(
text: '',
style: TextStyle(
fontWeight: bold,
),
),
new TextSpan(
text: instructorName,
style: TextStyle(fontWeight: bold),
),
],
),
),
SizedBox(height: getProportionateScreenWidth(6)),
Row(
children: [
Text(
specificRating,
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(10),
fontWeight: bold,
),
),
SizedBox(
width: getProportionateScreenWidth(2),
),
RatingBarIndicator(
itemSize: getProportionateScreenWidth(11),
rating: double.parse(rating),
direction: Axis.horizontal,
itemCount: 5,
itemBuilder: (context, _) => FaIcon(
FontAwesomeIcons.solidStar,
color: thirteenColor,
),
),
SizedBox(width: getProportionateScreenWidth(3)),
Text(
'(' + numberOfRatings + ')',
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(10),
fontWeight: bold,
),
),
],
),
SizedBox(height: getProportionateScreenWidth(6)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
price,
style: thirdTextStyle.copyWith(
letterSpacing: 0.5,
fontSize: SizeConfig.blockHorizontal! * 3,
fontWeight: bold,
),
),
],
),
SizedBox(height: getProportionateScreenWidth(6)),
if (realPrice.isNotEmpty && realPrice != price)
Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(10)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
realPrice,
style: primaryTextStyle.copyWith(
decoration: TextDecoration.lineThrough,
fontSize: getProportionateScreenWidth(10),
fontWeight: reguler,
),
),
// IconButton(onPressed: whislistPress, icon: iconWishlist)
],
),
)
else
SizedBox.shrink(),
if (isPopular)
Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(10)),
child: Container(
alignment: Alignment.center,
width: getProportionateScreenWidth(48),
height: getProportionateScreenHeight(17),
child: Text(
'Populer',
style: thirdTextStyle.copyWith(
letterSpacing: 0.5,
color: Colors.white,
fontSize: SizeConfig.blockHorizontal! * 2.5,
fontWeight: bold,
),
),
decoration: BoxDecoration(
color: primaryColor,
borderRadius: BorderRadius.circular(5),
),
),
)
else
SizedBox(height: 0, width: 0),
],
),
)
],
),
),
),
),
if (totalDiscount != 0)
Padding(
padding: EdgeInsets.only(top: getProportionateScreenHeight(7)),
child: Container(
height: 20,
alignment: Alignment.center,
width: getProportionateScreenWidth(35),
child: Text(
'${totalDiscount.toString()}%',
style: thirdTextStyle.copyWith(
letterSpacing: 0.5,
color: baruTextutih,
fontSize: SizeConfig.blockHorizontal! * 2.5,
fontWeight: light,
),
),
decoration: BoxDecoration(
color: primaryColor,
borderRadius: BorderRadius.only(
topRight: Radius.circular(4),
bottomRight: Radius.circular(4),
),
),
),
)
else
SizedBox(height: 0, width: 0),
],
);
}
}
// Shimmer(
// child: Container(
// color: Colors.black,
// ),
// gradient: LinearGradient(
// stops: [0.2, 0.5, 0.6],
// colors: [ninthColor, fourthColor, ninthColor])),

View File

@ -0,0 +1,328 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import 'package:shimmer/shimmer.dart';
import '../../../../../providers/theme_provider.dart';
import '../../../../../theme.dart';
import '../../../../../size_config.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
class ProductCardNew extends StatelessWidget {
const ProductCardNew({
Key? key,
this.width = 120,
this.pad = 16,
this.padRight = 0,
required this.thumbnail,
required this.id,
required this.isTopCourse,
required this.title,
required this.instructorName,
required this.rating,
required this.specificRating,
required this.numberOfRatings,
required this.price,
required this.realPrice,
required this.press,
required this.students,
required this.totalDiscount,
}) : super(key: key);
final double width;
final double pad, padRight;
final String thumbnail,
title,
instructorName,
price,
realPrice,
rating,
specificRating,
numberOfRatings,
id,
isTopCourse;
final String students;
final VoidCallback press;
final int totalDiscount;
// final VoidCallback? whislistPress;
// final Widget? iconWishlist;
@override
Widget build(BuildContext context) {
//CourseProvider courseProvider = Provider.of<CourseProvider>(context);
// final formatCurrency =
// new NumberFormat.simpleCurrency(decimalDigits: 0, locale: 'id_ID');
bool isRatingValid = int.tryParse(rating) != null;
bool isStudentsValid = int.tryParse(students) != null;
final themeProvider = Provider.of<ThemeProvider>(context);
bool isPopular = false;
if (isRatingValid && isStudentsValid) {
int ratingValue = int.parse(rating);
int studentsValue = int.parse(students);
bool isSpecificRatingValid = int.tryParse(specificRating) != null;
bool isNumberOfRatingsValid = int.tryParse(numberOfRatings) != null;
if (isSpecificRatingValid && isNumberOfRatingsValid) {
int specificRatingValue = int.parse(specificRating);
int numberOfRatingsValue = int.parse(numberOfRatings);
isPopular = ratingValue > 4 &&
studentsValue > 19 &&
specificRatingValue > 4 &&
numberOfRatingsValue > 4;
}
}
return Stack(
children: [
Container(
width: getProportionateScreenWidth(155),
height: getProportionateScreenHeight(200),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
spreadRadius: 1,
blurRadius: 1,
offset: Offset(7, 17),
),
],
),
padding: EdgeInsets.only(
left: getProportionateScreenWidth(pad),
right: getProportionateScreenWidth(padRight),
),
child: InkWell(
onTap: press,
child: Container(
width: getProportionateScreenWidth(40),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.primaryContainer,
spreadRadius: 11,
blurRadius: 0,
offset: Offset(0, 3),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AspectRatio(
aspectRatio: 1.7,
child: CachedNetworkImage(
imageUrl: thumbnail,
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.vertical(top: Radius.circular(5)),
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover,
),
),
),
placeholder: (context, url) => Shimmer(
child: Container(
decoration: BoxDecoration(
color: ninthColor,
borderRadius:
BorderRadius.vertical(top: Radius.circular(5)),
),
),
gradient: LinearGradient(
stops: [0.2, 0.5, 0.6],
colors: [ninthColor, fourthColor, ninthColor]),
),
errorWidget: (context, url, error) => Icon(Icons.error),
fadeInDuration: Duration(milliseconds: 1),
fadeOutDuration: Duration(milliseconds: 1),
),
),
SizedBox(height: getProportionateScreenWidth(4)),
Container(
padding: EdgeInsets.only(left: 2),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: thirdTextStyle.copyWith(
letterSpacing: 1,
fontSize: getProportionateScreenWidth(12),
fontWeight: bold),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
SizedBox(height: getProportionateScreenWidth(6)),
// Row(
// children: [product.description],
// ),
RichText(
text: new TextSpan(
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(10),
color: Theme.of(context).dividerColor,
),
children: <TextSpan>[
new TextSpan(
text: '',
style: TextStyle(
fontWeight: bold,
),
),
new TextSpan(
text: instructorName,
style: TextStyle(fontWeight: bold),
),
],
),
),
SizedBox(height: getProportionateScreenWidth(6)),
Row(
children: [
if (specificRating.isNotEmpty && specificRating != '0') ...[
Text(
specificRating,
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(10),
fontWeight: bold,
),
),
SizedBox(
width: getProportionateScreenWidth(2),
),],
RatingBarIndicator(
itemSize: getProportionateScreenWidth(11),
rating: (rating.isEmpty || double.tryParse(rating) == 0)
? 5.0
: double.parse(rating), // Jika rating kosong atau 0, tampilkan bintang 5
direction: Axis.horizontal,
itemCount: 5,
itemBuilder: (context, _) => FaIcon(
FontAwesomeIcons.solidStar,
color: thirteenColor,
),
),
SizedBox(width: getProportionateScreenWidth(3)),
if (numberOfRatings.isNotEmpty && numberOfRatings != '0') ...[
Text(
'(' + numberOfRatings + ')',
style: thirdTextStyle.copyWith(
fontSize: getProportionateScreenWidth(10),
fontWeight: bold,
),
),
],
],
),
SizedBox(height: getProportionateScreenWidth(6)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
price,
style: thirdTextStyle.copyWith(
letterSpacing: 0.5,
fontSize: SizeConfig.blockHorizontal! * 3,
fontWeight: bold,
),
),
],
),
SizedBox(height: getProportionateScreenWidth(6)),
if (realPrice.isNotEmpty && realPrice != price)
Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(10)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
realPrice,
style: primaryTextStyle.copyWith(
decoration: TextDecoration.lineThrough,
fontSize: getProportionateScreenWidth(10),
fontWeight: reguler,
),
),
// IconButton(onPressed: whislistPress, icon: iconWishlist)
],
),
)
else
SizedBox.shrink(),
Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(10)),
child: Container(
alignment: Alignment.center,
width: getProportionateScreenWidth(48),
height: getProportionateScreenHeight(17),
child: Text(
'NEW',
style: thirdTextStyle.copyWith(
letterSpacing: 0.5,
color: Colors.white,
fontSize: SizeConfig.blockHorizontal! * 3,
fontWeight: reguler,
),
),
decoration: BoxDecoration(
color: themeProvider.themeData == ThemeClass.darkmode
?primaryColor : primaryColorligtmode,
borderRadius: BorderRadius.circular(5),
),
),
),
],
),
)
],
),
),
),
),
if (totalDiscount != 0)
Padding(
padding: EdgeInsets.only(top: getProportionateScreenHeight(7)),
child: Container(
height: 20,
alignment: Alignment.center,
width: getProportionateScreenWidth(35),
child: Text(
'${totalDiscount.toString()}%',
style: thirdTextStyle.copyWith(
letterSpacing: 0.5,
color: baruTextutih,
fontSize: SizeConfig.blockHorizontal! * 2.5,
fontWeight: light,
),
),
decoration: BoxDecoration(
color: themeProvider.themeData == ThemeClass.darkmode
?primaryColor : primaryColorligtmode,
borderRadius: BorderRadius.only(
topRight: Radius.circular(4),
bottomRight: Radius.circular(4),
),
),
),
)
else
SizedBox(height: 0, width: 0),
],
);
}
}
// Shimmer(
// child: Container(
// color: Colors.black,
// ),
// gradient: LinearGradient(
// stops: [0.2, 0.5, 0.6],
// colors: [ninthColor, fourthColor, ninthColor])),

View File

@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'package:initial_folder/models/ProductProgram.dart';
import '../../../../../theme.dart';
import '../../../../../size_config.dart';
class ProductCardProgram extends StatelessWidget {
const ProductCardProgram({
Key? key,
this.width = 150,
this.aspectRetio = 1.02,
required this.product,
}) : super(key: key);
final double width, aspectRetio;
final ProductProgram product;
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.fromLTRB(0, getProportionateScreenWidth(10),
getProportionateScreenWidth(10), getProportionateScreenWidth(10)),
child: SizedBox(
width: getProportionateScreenWidth(width),
child: GestureDetector(
onTap: () {},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AspectRatio(
aspectRatio: 1.7,
child: Container(
decoration: BoxDecoration(
color: tenthColor.withOpacity(0),
borderRadius: BorderRadius.circular(15),
),
child: Hero(
tag: product.id.toString(),
child: Image.asset(product.images[0], scale: 0.000000001),
),
),
),
],
),
),
),
);
}
}

View File

@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'product_card/product_card_program.dart';
import 'package:initial_folder/models/ProductProgram.dart';
import '../../../../size_config.dart';
import '../../../../theme.dart';
class Program extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
Padding(
padding:
EdgeInsets.symmetric(horizontal: getProportionateScreenWidth(20)),
child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [
Text('Promo Terkini',
textAlign: TextAlign.left,
style: secondaryTextStyle.copyWith(
letterSpacing: 1,
color: tenthColor,
fontSize: getProportionateScreenWidth(14),
fontWeight: semiBold)),
]),
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(20)),
child: Row(
children: [
...List.generate(
demoProducts.length,
(index) => ProductCardProgram(product: demoProducts[index]),
),
],
),
),
)
],
);
}
}

View File

@ -0,0 +1,364 @@
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/promo_course_provider.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/widgets/custom_navigator.dart';
import 'package:provider/provider.dart';
import 'package:shimmer/shimmer.dart';
import '../../../../size_config.dart';
import '../../../../theme.dart';
class PromoCourse extends StatelessWidget {
const PromoCourse({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.toString(),
textAlign: TextAlign.left,
style: thirdTextStyle.copyWith(
letterSpacing: 1,
fontSize: getProportionateScreenWidth(15),
fontWeight: semiBold,
),
),
],
),
),
SizedBox(height: getProportionateScreenHeight(10)),
Consumer<PromoCourseProvider>(
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(10)),
height: getProportionateScreenHeight(220),
child: ListView.builder(
scrollDirection: Axis.horizontal,
physics: ScrollPhysics(),
shrinkWrap: true,
itemCount: state.result.length,
itemBuilder: (context, index) {
var promoCourse = state.result[index];
// var finalRating = double.parse(
// (promoCourse.specificRating![0] / 20).toStringAsFixed(2));
int price =
int.tryParse(promoCourse.price.replaceAll('.', '')) ??
0;
int discountPrice = int.tryParse(
promoCourse.discountPrice.replaceAll('.', '')) ??
0;
int calculatedPrice = (promoCourse.discountPrice != '0')
? price - discountPrice
: price;
String displayedPrice = (calculatedPrice == 0)
? promoCourse.price
: calculatedPrice.toString();
return Container(
margin: EdgeInsets.only(
top: getProportionateScreenHeight(10),
),
child: Padding(
padding: EdgeInsets.only(
right: getProportionateScreenWidth(18),
bottom: getProportionateScreenWidth(18),
),
child: ProductCard(
totalDiscount: promoCourse.totalDiscount ?? 0,
students: promoCourse.students ?? '0',
pad: 12,
id: promoCourse.idCourse,
thumbnail: promoCourse.thumbnail ??
'$baseUrl/uploads/courses_thumbnail/course_thumbnail_default_57.jpg',
title: promoCourse.title,
instructorName: promoCourse.instructorName,
specificRating: (promoCourse.rating.isNotEmpty &&
promoCourse.rating[0]?.avgRating != null)
? promoCourse.rating[0]!.avgRating.toString()
: '0',
rating: (promoCourse.rating.isNotEmpty &&
promoCourse.rating[0]?.avgRating != null)
? promoCourse.rating[0]!.avgRating.toString()
: '5.0',
numberOfRatings: (promoCourse.rating.isNotEmpty &&
promoCourse.rating[0]?.totalReview != null)
? promoCourse.rating[0]!.totalReview!
: '0',
isTopCourse: promoCourse.topCourse!,
price: (promoCourse.price == '0')
? 'Gratis'
: (promoCourse.promoPrice != '0')
? numberFormat(promoCourse.promoPrice)
: numberFormat(displayedPrice),
realPrice: (promoCourse.price == '0')
? ''
: numberFormat(promoCourse.price),
press: () {
print(promoCourse.idCourse);
Navigator.of(context, rootNavigator: true).push(
CustomNavigator(
child: DetailCourseScreen(
isPromo: true,
idcourse: promoCourse.idCourse,
),
),
);
},
),
),
);
},
),
);
} else if (state.state == ResultState.NoData) {
return Center(child: Text(state.message));
} else if (state.state == ResultState.Error) {
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 {
return Center(child: Text(''));
}
},
)
],
);
}
}

View File

@ -0,0 +1,41 @@
// import 'package:flutter/material.dart';
// import 'product_card/product_card.dart';
// import 'package:initial_folder/models/Product.dart';
// import '../../../../size_config.dart';
// import 'section_title.dart';
// class Recommendation extends StatelessWidget {
// @override
// Widget build(BuildContext context) {
// return Column(
// children: [
// Padding(
// padding:
// EdgeInsets.symmetric(horizontal: getProportionateScreenWidth(20)),
// child: SectionTitle(title: "Rekomendasi Khusus", press: () {}),
// ),
// SizedBox(height: 10),
// SingleChildScrollView(
// scrollDirection: Axis.horizontal,
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// ...List.generate(
// demoProducts.length,
// (index) {
// if (demoProducts[index].isPopular)
// return ProductCard(product: demoProducts[index]);
// return SizedBox
// .shrink(); // here by default width and height is 0
// },
// ),
// SizedBox(width: getProportionateScreenWidth(200)),
// ],
// ),
// )
// ],
// );
// }
// }

View File

@ -0,0 +1,61 @@
import 'package:flutter/material.dart';
import 'package:initial_folder/widgets/search_and_filter_course.dart';
import '../../../../theme.dart';
import '../../../../size_config.dart';
class SearchField extends StatelessWidget {
const SearchField({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
// width: SizeConfig.screenWidth * 0.9,
// height: 33,
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(15),
// border: Border.all(
// color: kSecondaryColor.withOpacity(0.5),
// width: 2,
//print(SizeConfig.screenWidth);
return GestureDetector(
onTap: () => Navigator.push(context,
MaterialPageRoute(builder: (context) => SearchAndFilterCourse())),
child: Container(
margin:
EdgeInsets.symmetric(horizontal: getProportionateScreenWidth(16)),
height: 35,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: secondaryColor)),
child: Column(
children: [
Expanded(
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(left: 13),
child: Icon(
Icons.search,
size: 20,
color: secondaryColor,
),
),
SizedBox(
width: getProportionateScreenWidth(10),
),
Text(
'Cari kursus',
style: secondaryTextStyle.copyWith(
color: secondaryColor, fontSize: 12),
)
],
),
),
],
),
),
);
}
}

View File

@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import '../../../../size_config.dart';
import '../../../../theme.dart';
class SectionTitle extends StatelessWidget {
const SectionTitle({
Key? key,
required this.title,
required this.press,
}) : super(key: key);
final String title;
final GestureTapCallback press;
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: thirdTextStyle.copyWith(
letterSpacing: 1,
fontSize: getProportionateScreenWidth(15),
fontWeight: semiBold),
),
GestureDetector(
onTap: press,
child: Text(
"Lihat Semua",
style: thirdTextStyle.copyWith(
letterSpacing: 0.5,
fontSize: getProportionateScreenWidth(11),
fontWeight: reguler),
),
),
],
);
}
}