223 lines
7.1 KiB
Dart
223 lines
7.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:gap/gap.dart';
|
|
import 'package:iconsax_flutter/iconsax_flutter.dart';
|
|
import 'package:rijig_mobile/core/utils/guide.dart';
|
|
import 'package:rijig_mobile/features/home/components/product_card.dart';
|
|
import 'package:rijig_mobile/features/home/model/product.dart';
|
|
import 'package:rijig_mobile/widget/card_withicon.dart';
|
|
|
|
class HomeScreen extends StatefulWidget {
|
|
const HomeScreen({super.key});
|
|
|
|
@override
|
|
State<HomeScreen> createState() => _HomeScreenState();
|
|
}
|
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: whiteColor,
|
|
body: SafeArea(
|
|
child: SingleChildScrollView(
|
|
padding: PaddingCustom().paddingHorizontalVertical(16, 20),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"Rijig",
|
|
style: Tulisan.heading(color: primaryColor),
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
Icon(Iconsax.notification),
|
|
Gap(10),
|
|
Icon(Iconsax.message_2),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Gap(20),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
CardWithIcon(
|
|
icon: Icons.account_circle,
|
|
text: 'Users',
|
|
number: '245',
|
|
onTap: () {},
|
|
),
|
|
CardWithIcon(
|
|
icon: Icons.shopping_cart,
|
|
text: 'Orders',
|
|
number: '178',
|
|
onTap: () {},
|
|
),
|
|
],
|
|
),
|
|
Gap(20),
|
|
Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"Important!",
|
|
style: const TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const Gap(15),
|
|
SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: Row(
|
|
children: [
|
|
SpecialOfferCard(
|
|
image: "assets/image/Image Banner 2.png",
|
|
category: "Smartphone",
|
|
numOfBrands: 18,
|
|
press: () {},
|
|
),
|
|
Gap(10),
|
|
SpecialOfferCard(
|
|
image: "assets/image/Image Banner 3.png",
|
|
category: "Fashion",
|
|
numOfBrands: 24,
|
|
press: () {},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Gap(20),
|
|
Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"Artikel",
|
|
style: const TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: Row(
|
|
children: [
|
|
...List.generate(demoProducts.length, (index) {
|
|
if (demoProducts[index].isPopular) {
|
|
return Padding(
|
|
padding: const EdgeInsets.only(left: 20),
|
|
child: ProductCard(
|
|
product: demoProducts[index],
|
|
onPress: () {},
|
|
),
|
|
);
|
|
}
|
|
return const SizedBox.shrink();
|
|
}),
|
|
const SizedBox(width: 20),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class SpecialOfferCard extends StatelessWidget {
|
|
const SpecialOfferCard({
|
|
super.key,
|
|
required this.category,
|
|
required this.image,
|
|
required this.numOfBrands,
|
|
required this.press,
|
|
});
|
|
|
|
final String category, image;
|
|
final int numOfBrands;
|
|
final GestureTapCallback press;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: press,
|
|
child: SizedBox(
|
|
width: 242,
|
|
height: 100,
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(20),
|
|
child: Stack(
|
|
children: [
|
|
Image.asset(image, fit: BoxFit.cover),
|
|
Container(
|
|
decoration: const BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Colors.black54,
|
|
Colors.black38,
|
|
Colors.black26,
|
|
Colors.transparent,
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 15,
|
|
vertical: 10,
|
|
),
|
|
child: Text.rich(
|
|
TextSpan(
|
|
style: const TextStyle(color: Colors.white),
|
|
children: [
|
|
TextSpan(
|
|
text: "$category\n",
|
|
style: const TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
TextSpan(text: "$numOfBrands Brands"),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|