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

BIN
assets/images/bakso343.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
assets/images/tumulu.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
assets/images/woku.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@ -14,6 +14,10 @@ import 'package:flutter/widgets.dart';
class $AssetsImagesGen { class $AssetsImagesGen {
const $AssetsImagesGen(); const $AssetsImagesGen();
/// File path: assets/images/bakso343.jpeg
AssetGenImage get bakso343 =>
const AssetGenImage('assets/images/bakso343.jpeg');
/// File path: assets/images/launcher.png /// File path: assets/images/launcher.png
AssetGenImage get launcher => AssetGenImage get launcher =>
const AssetGenImage('assets/images/launcher.png'); const AssetGenImage('assets/images/launcher.png');
@ -33,13 +37,27 @@ class $AssetsImagesGen {
AssetGenImage get onboarding3 => AssetGenImage get onboarding3 =>
const AssetGenImage('assets/images/onboarding3.png'); const AssetGenImage('assets/images/onboarding3.png');
/// File path: assets/images/ramenmulu.jpeg
AssetGenImage get ramenmulu =>
const AssetGenImage('assets/images/ramenmulu.jpeg');
/// File path: assets/images/tumulu.jpeg
AssetGenImage get tumulu => const AssetGenImage('assets/images/tumulu.jpeg');
/// File path: assets/images/woku.jpeg
AssetGenImage get woku => const AssetGenImage('assets/images/woku.jpeg');
/// List of all assets /// List of all assets
List<AssetGenImage> get values => [ List<AssetGenImage> get values => [
bakso343,
launcher, launcher,
logo, logo,
onboarding1, onboarding1,
onboarding2, onboarding2,
onboarding3, onboarding3,
ramenmulu,
tumulu,
woku,
]; ];
} }

View File

@ -1,26 +1,17 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../../../../common/theme/theme.dart'; import '../../../../../../common/theme/theme.dart';
import '../../../../../../sample/sample_data.dart';
import '../../../../../components/image/image.dart'; import '../../../../../components/image/image.dart';
class HomePopularMerchantCard extends StatelessWidget { class HomePopularMerchantCard extends StatelessWidget {
final String merchantName; final MerchantModel merchant;
final String merchantImage;
final String category;
final double rating;
final String distance;
final bool isOpen;
final VoidCallback? onTap; final VoidCallback? onTap;
const HomePopularMerchantCard({ const HomePopularMerchantCard({
super.key, super.key,
required this.merchantName,
required this.merchantImage,
required this.category,
required this.rating,
required this.distance,
this.isOpen = true,
this.onTap, this.onTap,
required this.merchant,
}); });
@override @override
@ -53,15 +44,25 @@ class HomePopularMerchantCard extends StatelessWidget {
), ),
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
child: Image.network( child: merchant.imageUrl.startsWith('http')
merchantImage, ? Image.network(
width: 60, merchant.imageUrl,
height: 60, width: 60,
fit: BoxFit.cover, height: 60,
errorBuilder: (context, error, stackTrace) { fit: BoxFit.cover,
return ImagePlaceholder(width: 60, height: 60); 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, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
merchantName, merchant.name,
style: AppStyle.md.copyWith( style: AppStyle.md.copyWith(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
height: 1.2, height: 1.2,
@ -85,31 +86,11 @@ class HomePopularMerchantCard extends StatelessWidget {
const SizedBox(height: 4), const SizedBox(height: 4),
Text( Text(
category, merchant.category,
style: AppStyle.sm.copyWith(color: AppColor.textSecondary), style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, 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, vertical: 2,
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isOpen ? AppColor.success : AppColor.error, color: merchant.isOpen ? AppColor.success : AppColor.error,
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
), ),
child: Text( child: Text(
isOpen ? 'OPEN' : 'CLOSED', merchant.isOpen ? 'OPEN' : 'CLOSED',
style: AppStyle.xs.copyWith( style: AppStyle.xs.copyWith(
color: AppColor.textWhite, color: AppColor.textWhite,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@ -158,7 +139,7 @@ class HomePopularMerchantCard extends StatelessWidget {
Icon(Icons.star, size: 12, color: AppColor.warning), Icon(Icons.star, size: 12, color: AppColor.warning),
const SizedBox(width: 2), const SizedBox(width: 2),
Text( Text(
rating.toString(), merchant.rating.toString(),
style: AppStyle.xs.copyWith( style: AppStyle.xs.copyWith(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: AppColor.primary, color: AppColor.primary,

View File

@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../../../../common/theme/theme.dart'; import '../../../../../../common/theme/theme.dart';
import '../../../../../../sample/sample_data.dart';
import '../../../../../router/app_router.gr.dart'; import '../../../../../router/app_router.gr.dart';
import 'popular_merchant_card.dart'; import 'popular_merchant_card.dart';
@ -44,38 +45,9 @@ class HomePopularMerchantSection extends StatelessWidget {
], ],
), ),
SizedBox(height: 16), SizedBox(height: 16),
HomePopularMerchantCard( ...List.generate(
merchantName: 'Warung Bu Sari', merchants.length,
merchantImage: 'https://via.placeholder.com/280x160', (index) => HomePopularMerchantCard(merchant: merchants[index]),
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');
},
), ),
], ],
), ),

View File

@ -57,7 +57,7 @@ class VoucherCard extends StatelessWidget {
children: [ children: [
Text( Text(
title, title,
style: AppStyle.lg.copyWith( style: AppStyle.md.copyWith(
color: AppColor.textPrimary, color: AppColor.textPrimary,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),
@ -65,7 +65,7 @@ class VoucherCard extends StatelessWidget {
SizedBox(height: 4), SizedBox(height: 4),
Text( Text(
subtitle, subtitle,
style: AppStyle.md.copyWith( style: AppStyle.sm.copyWith(
color: AppColor.textSecondary, color: AppColor.textSecondary,
), ),
), ),

View File

@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../common/theme/theme.dart'; import '../../../common/theme/theme.dart';
import '../../../sample/sample_data.dart';
import '../../components/field/field.dart'; import '../../components/field/field.dart';
import '../../router/app_router.gr.dart'; import '../../router/app_router.gr.dart';
import 'widgets/empty_merchant_card.dart'; import 'widgets/empty_merchant_card.dart';
@ -113,7 +114,7 @@ class _MerchantPageState extends State<MerchantPage> {
Padding( Padding(
padding: const EdgeInsets.only(right: 8), padding: const EdgeInsets.only(right: 8),
child: FilterChip( child: FilterChip(
label: const Text('All'), label: const Text('Semua'),
selected: _selectedCategory == null, selected: _selectedCategory == null,
onSelected: (selected) { onSelected: (selected) {
_onCategorySelected(null); _onCategorySelected(null);
@ -193,89 +194,6 @@ class _MerchantPageState extends State<MerchantPage> {
} }
static List<MerchantModel> _generateMockMerchants() { static List<MerchantModel> _generateMockMerchants() {
return [ return merchants;
MerchantModel(
id: '1',
name: 'Warung Makan Sederhana',
category: 'Food & Beverage',
rating: 4.5,
isOpen: true,
imageUrl: 'https://via.placeholder.com/150',
),
MerchantModel(
id: '2',
name: 'Toko Elektronik',
category: 'Electronics',
rating: 4.2,
isOpen: true,
imageUrl: 'https://via.placeholder.com/150',
),
MerchantModel(
id: '3',
name: 'Apotek Sehat',
category: 'Healthcare',
rating: 4.8,
isOpen: false,
imageUrl: 'https://via.placeholder.com/150',
),
MerchantModel(
id: '4',
name: 'Fashion Store',
category: 'Clothing',
rating: 4.1,
isOpen: true,
imageUrl: 'https://via.placeholder.com/150',
),
MerchantModel(
id: '5',
name: 'Bengkel Motor',
category: 'Automotive',
rating: 4.3,
isOpen: true,
imageUrl: 'https://via.placeholder.com/150',
),
MerchantModel(
id: '6',
name: 'Minimarket 24',
category: 'Retail',
rating: 4.0,
isOpen: true,
imageUrl: 'https://via.placeholder.com/150',
),
MerchantModel(
id: '7',
name: 'Salon Kecantikan',
category: 'Beauty',
rating: 4.6,
isOpen: false,
imageUrl: 'https://via.placeholder.com/150',
),
MerchantModel(
id: '8',
name: 'Laundry Express',
category: 'Service',
rating: 4.4,
isOpen: true,
imageUrl: 'https://via.placeholder.com/150',
),
];
} }
} }
class MerchantModel {
final String id;
final String name;
final String category;
final double rating;
final bool isOpen;
final String imageUrl;
MerchantModel({
required this.id,
required this.name,
required this.category,
required this.rating,
required this.isOpen,
required this.imageUrl,
});
}

View File

@ -1,7 +1,7 @@
import 'package:auto_route/auto_route.dart'; import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../../../common/theme/theme.dart'; import '../../../../../common/theme/theme.dart';
import '../../merchant_page.dart'; import '../../../../../sample/sample_data.dart';
// Models // Models
class ProductCategory { class ProductCategory {
@ -295,9 +295,9 @@ class _MerchantDetailPageState extends State<MerchantDetailPage> {
], ],
), ),
child: Center( child: Center(
child: Text( child: ClipRRect(
_getCategoryIcon(widget.merchant.category), borderRadius: BorderRadius.circular(12),
style: TextStyle(fontSize: 36), child: Image.asset(widget.merchant.imageUrl),
), ),
), ),
), ),
@ -596,29 +596,6 @@ class _MerchantDetailPageState extends State<MerchantDetailPage> {
), ),
); );
} }
String _getCategoryIcon(String category) {
switch (category.toLowerCase()) {
case 'food & beverage':
return '🍽️';
case 'electronics':
return '📱';
case 'healthcare':
return '⚕️';
case 'clothing':
return '👕';
case 'automotive':
return '🚗';
case 'retail':
return '🛍️';
case 'beauty':
return '💄';
case 'service':
return '🔧';
default:
return '🏪';
}
}
} }
// Custom delegate for pinned category bar // Custom delegate for pinned category bar

View File

@ -1,8 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../../common/theme/theme.dart'; import '../../../../common/theme/theme.dart';
import '../../../../sample/sample_data.dart';
import '../../../components/image/image.dart'; import '../../../components/image/image.dart';
import '../merchant_page.dart';
class MerchantCard extends StatelessWidget { class MerchantCard extends StatelessWidget {
final MerchantModel merchant; final MerchantModel merchant;
@ -44,35 +44,44 @@ class MerchantCard extends StatelessWidget {
topLeft: Radius.circular(8), topLeft: Radius.circular(8),
topRight: Radius.circular(8), topRight: Radius.circular(8),
), ),
child: Image.network( child: merchant.imageUrl.startsWith('assets')
merchant.imageUrl, ? Image.asset(
width: double.infinity, merchant.imageUrl,
fit: BoxFit.cover, fit: BoxFit.fill,
loadingBuilder: (context, child, loadingProgress) { errorBuilder: (context, error, stackTrace) {
if (loadingProgress == null) return child; return ImagePlaceholder(width: 60, height: 60);
return Center( },
child: SizedBox( )
width: 20, : Image.network(
height: 20, merchant.imageUrl,
child: CircularProgressIndicator( width: double.infinity,
strokeWidth: 2, fit: BoxFit.cover,
color: AppColor.primary, loadingBuilder: (context, child, loadingProgress) {
value: loadingProgress.expectedTotalBytes != null if (loadingProgress == null) return child;
? loadingProgress.cumulativeBytesLoaded / return Center(
loadingProgress.expectedTotalBytes! child: SizedBox(
: null, width: 20,
), height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
color: AppColor.primary,
value:
loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes!
: null,
),
),
);
},
errorBuilder: (context, error, stackTrace) {
return ImagePlaceholder(
width: double.infinity,
height: 100,
showBorderRadius: false,
);
},
), ),
);
},
errorBuilder: (context, error, stackTrace) {
return ImagePlaceholder(
width: double.infinity,
height: 100,
showBorderRadius: false,
);
},
),
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),

View File

@ -49,6 +49,7 @@ import 'package:enaklo/presentation/pages/reward/reward_page.dart' as _i21;
import 'package:enaklo/presentation/pages/splash/splash_page.dart' as _i22; import 'package:enaklo/presentation/pages/splash/splash_page.dart' as _i22;
import 'package:enaklo/presentation/pages/voucher/voucher_detail/voucher_detail_page.dart' import 'package:enaklo/presentation/pages/voucher/voucher_detail/voucher_detail_page.dart'
as _i23; as _i23;
import 'package:enaklo/sample/sample_data.dart' as _i27;
import 'package:flutter/material.dart' as _i26; import 'package:flutter/material.dart' as _i26;
/// generated route for /// generated route for
@ -173,7 +174,7 @@ class MainRoute extends _i25.PageRouteInfo<void> {
class MerchantDetailRoute extends _i25.PageRouteInfo<MerchantDetailRouteArgs> { class MerchantDetailRoute extends _i25.PageRouteInfo<MerchantDetailRouteArgs> {
MerchantDetailRoute({ MerchantDetailRoute({
_i26.Key? key, _i26.Key? key,
required _i8.MerchantModel merchant, required _i27.MerchantModel merchant,
List<_i25.PageRouteInfo>? children, List<_i25.PageRouteInfo>? children,
}) : super( }) : super(
MerchantDetailRoute.name, MerchantDetailRoute.name,
@ -197,7 +198,7 @@ class MerchantDetailRouteArgs {
final _i26.Key? key; final _i26.Key? key;
final _i8.MerchantModel merchant; final _i27.MerchantModel merchant;
@override @override
String toString() { String toString() {

View File

@ -0,0 +1,54 @@
import '../presentation/components/assets/assets.gen.dart';
class MerchantModel {
final String id;
final String name;
final String category;
final double rating;
final bool isOpen;
final String imageUrl;
MerchantModel({
required this.id,
required this.name,
required this.category,
required this.rating,
required this.isOpen,
required this.imageUrl,
});
}
List<MerchantModel> merchants = [
MerchantModel(
id: 'hsjdhaj12',
name: 'Bakso 343',
category: 'Restaurant',
rating: 5,
isOpen: true,
imageUrl: Assets.images.bakso343.path,
),
MerchantModel(
id: 'ahjs7812',
name: 'Tumulu Coffee',
category: 'Coffe Shop',
rating: 5,
isOpen: true,
imageUrl: Assets.images.tumulu.path,
),
MerchantModel(
id: 'ahjs7812',
name: 'Ramenmulu',
category: 'Ramen',
rating: 5,
isOpen: true,
imageUrl: Assets.images.ramenmulu.path,
),
MerchantModel(
id: '178271bjas',
name: 'Woku Pedas',
category: 'Restaurant',
rating: 5,
isOpen: true,
imageUrl: Assets.images.woku.path,
),
];