feat: merchant

This commit is contained in:
efrilm
2025-08-29 21:30:57 +07:00
parent 06cc7e3781
commit 89c94c796a
13 changed files with 153 additions and 223 deletions
@@ -1,26 +1,17 @@
import 'package:flutter/material.dart';
import '../../../../../../common/theme/theme.dart';
import '../../../../../../sample/sample_data.dart';
import '../../../../../components/image/image.dart';
class HomePopularMerchantCard extends StatelessWidget {
final String merchantName;
final String merchantImage;
final String category;
final double rating;
final String distance;
final bool isOpen;
final MerchantModel merchant;
final VoidCallback? onTap;
const HomePopularMerchantCard({
super.key,
required this.merchantName,
required this.merchantImage,
required this.category,
required this.rating,
required this.distance,
this.isOpen = true,
this.onTap,
required this.merchant,
});
@override
@@ -53,15 +44,25 @@ class HomePopularMerchantCard extends StatelessWidget {
),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.network(
merchantImage,
width: 60,
height: 60,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return ImagePlaceholder(width: 60, height: 60);
},
),
child: merchant.imageUrl.startsWith('http')
? Image.network(
merchant.imageUrl,
width: 60,
height: 60,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return ImagePlaceholder(width: 60, height: 60);
},
)
: Image.asset(
merchant.imageUrl,
width: 60,
height: 60,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return ImagePlaceholder(width: 60, height: 60);
},
),
),
),
@@ -73,7 +74,7 @@ class HomePopularMerchantCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
merchantName,
merchant.name,
style: AppStyle.md.copyWith(
fontWeight: FontWeight.w600,
height: 1.2,
@@ -85,31 +86,11 @@ class HomePopularMerchantCard extends StatelessWidget {
const SizedBox(height: 4),
Text(
category,
merchant.category,
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 6),
// Distance
Row(
children: [
Icon(
Icons.location_on,
size: 12,
color: AppColor.textSecondary,
),
const SizedBox(width: 2),
Text(
distance,
style: AppStyle.xs.copyWith(
color: AppColor.textSecondary,
),
),
],
),
],
),
),
@@ -127,11 +108,11 @@ class HomePopularMerchantCard extends StatelessWidget {
vertical: 2,
),
decoration: BoxDecoration(
color: isOpen ? AppColor.success : AppColor.error,
color: merchant.isOpen ? AppColor.success : AppColor.error,
borderRadius: BorderRadius.circular(6),
),
child: Text(
isOpen ? 'OPEN' : 'CLOSED',
merchant.isOpen ? 'OPEN' : 'CLOSED',
style: AppStyle.xs.copyWith(
color: AppColor.textWhite,
fontWeight: FontWeight.w600,
@@ -158,7 +139,7 @@ class HomePopularMerchantCard extends StatelessWidget {
Icon(Icons.star, size: 12, color: AppColor.warning),
const SizedBox(width: 2),
Text(
rating.toString(),
merchant.rating.toString(),
style: AppStyle.xs.copyWith(
fontWeight: FontWeight.w600,
color: AppColor.primary,
@@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import '../../../../../../common/theme/theme.dart';
import '../../../../../../sample/sample_data.dart';
import '../../../../../router/app_router.gr.dart';
import 'popular_merchant_card.dart';
@@ -44,38 +45,9 @@ class HomePopularMerchantSection extends StatelessWidget {
],
),
SizedBox(height: 16),
HomePopularMerchantCard(
merchantName: 'Warung Bu Sari',
merchantImage: 'https://via.placeholder.com/280x160',
category: 'Indonesian Food',
rating: 4.8,
distance: '0.5 km',
isOpen: true,
onTap: () {},
),
HomePopularMerchantCard(
merchantName: 'Pizza Corner',
merchantImage: 'https://via.placeholder.com/280x160',
category: 'Italian Food',
rating: 4.6,
distance: '1.2 km',
isOpen: false,
onTap: () {
print('Pizza Corner tapped');
},
),
HomePopularMerchantCard(
merchantName: 'Kopi Kenangan',
merchantImage: 'https://via.placeholder.com/280x160',
category: 'Coffee & Drinks',
rating: 4.9,
distance: '0.8 km',
isOpen: true,
onTap: () {
print('Kopi Kenangan tapped');
},
...List.generate(
merchants.length,
(index) => HomePopularMerchantCard(merchant: merchants[index]),
),
],
),
@@ -57,7 +57,7 @@ class VoucherCard extends StatelessWidget {
children: [
Text(
title,
style: AppStyle.lg.copyWith(
style: AppStyle.md.copyWith(
color: AppColor.textPrimary,
fontWeight: FontWeight.w600,
),
@@ -65,7 +65,7 @@ class VoucherCard extends StatelessWidget {
SizedBox(height: 4),
Text(
subtitle,
style: AppStyle.md.copyWith(
style: AppStyle.sm.copyWith(
color: AppColor.textSecondary,
),
),