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:
co-authored by
Claude Opus 5.5
parent
bc751246d8
commit
c35d0eedbe
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user