EnakPromo: halaman promo dan detail promo

- Banner promo unggulan, info cara dapat, filter per tipe hadiah, daftar
  promo berlangsung dan segera hadir
- Detail promo: hadiah, periode, outlet, cara dapat, S&K, CTA ke Reward
  Saya atau daftar outlet
- Data contoh mengikuti bentuk campaign backend (POINTS/COINS/REWARD)
- Filter chip Reward Saya dipindah ke komponen bersama FilterBarDelegate

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
efrilm
2026-10-01 02:17:54 +07:00
co-authored by Claude Opus 5.5
parent bc751246d8
commit c35d0eedbe
12 changed files with 1685 additions and 358 deletions
@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import '../../../common/theme/theme.dart';
/// Chip filter berbentuk pil dengan jumlah item di sebelah label.
class AppFilterChip extends StatelessWidget {
const AppFilterChip({
super.key,
required this.label,
required this.count,
required this.isSelected,
required this.onTap,
});
final String label;
final int count;
final bool isSelected;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final foreground = isSelected ? AppColor.textWhite : AppColor.textPrimary;
return Material(
color: isSelected ? AppColor.primary : AppColor.white,
shape: StadiumBorder(
side: BorderSide(
color: isSelected ? AppColor.primary : AppColor.border,
),
),
child: InkWell(
customBorder: const StadiumBorder(),
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 14),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
label,
style: AppStyle.sm.copyWith(
color: foreground,
fontWeight: FontWeight.w600,
),
),
const SizedBox(width: 6),
Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),
decoration: BoxDecoration(
color: isSelected
? AppColor.white.withOpacity(0.2)
: AppColor.primary.withOpacity(0.08),
borderRadius: BorderRadius.circular(10),
),
child: Text(
'$count',
style: AppStyle.xs.copyWith(
color: isSelected ? AppColor.textWhite : AppColor.primary,
fontWeight: FontWeight.w700,
),
),
),
],
),
),
),
);
}
}
@@ -0,0 +1,62 @@
import 'package:flutter/material.dart';
import '../../../common/theme/theme.dart';
import '../chip/app_filter_chip.dart';
/// Baris [AppFilterChip] yang bisa di-scroll menyamping, untuk
/// [SliverPersistentHeader] yang menempel di atas daftar.
class FilterBarDelegate<T> extends SliverPersistentHeaderDelegate {
FilterBarDelegate({
required this.values,
required this.selected,
required this.labelOf,
required this.countOf,
required this.onSelected,
this.backgroundColor = AppColor.background,
});
final List<T> values;
final T selected;
final String Function(T value) labelOf;
final int Function(T value) countOf;
final ValueChanged<T> onSelected;
final Color backgroundColor;
static const double _height = 56;
@override
double get minExtent => _height;
@override
double get maxExtent => _height;
@override
Widget build(
BuildContext context,
double shrinkOffset,
bool overlapsContent,
) {
return Container(
color: backgroundColor,
child: ListView.separated(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
itemCount: values.length,
separatorBuilder: (_, _) => const SizedBox(width: 8),
itemBuilder: (context, index) {
final value = values[index];
return AppFilterChip(
label: labelOf(value),
count: countOf(value),
isSelected: value == selected,
onTap: () => onSelected(value),
);
},
),
);
}
@override
bool shouldRebuild(covariant FilterBarDelegate<T> oldDelegate) =>
oldDelegate.selected != selected || oldDelegate.values != values;
}