EnakNews: halaman berita dan detail berita
- Filter kategori, berita utama, dan daftar artikel terbaru - Detail artikel dengan sampul, penulis, isi, dan "Baca juga" - Data contoh 8 artikel; artikel tips mengikuti aturan di docs - Jumlah pada AppFilterChip kini opsional Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c35d0eedbe
commit
5ba60747a8
@@ -2,18 +2,19 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../common/theme/theme.dart';
|
||||
|
||||
/// Chip filter berbentuk pil dengan jumlah item di sebelah label.
|
||||
/// Chip filter berbentuk pil, dengan jumlah item di sebelah label bila
|
||||
/// [count] diisi.
|
||||
class AppFilterChip extends StatelessWidget {
|
||||
const AppFilterChip({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.count,
|
||||
this.count,
|
||||
required this.isSelected,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final int count;
|
||||
final int? count;
|
||||
final bool isSelected;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@@ -43,23 +44,28 @@ class AppFilterChip extends StatelessWidget {
|
||||
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,
|
||||
if (count != null) ...[
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -10,7 +10,7 @@ class FilterBarDelegate<T> extends SliverPersistentHeaderDelegate {
|
||||
required this.values,
|
||||
required this.selected,
|
||||
required this.labelOf,
|
||||
required this.countOf,
|
||||
this.countOf,
|
||||
required this.onSelected,
|
||||
this.backgroundColor = AppColor.background,
|
||||
});
|
||||
@@ -18,7 +18,9 @@ class FilterBarDelegate<T> extends SliverPersistentHeaderDelegate {
|
||||
final List<T> values;
|
||||
final T selected;
|
||||
final String Function(T value) labelOf;
|
||||
final int Function(T value) countOf;
|
||||
|
||||
/// Kosongkan bila chip tidak perlu menampilkan jumlah.
|
||||
final int Function(T value)? countOf;
|
||||
final ValueChanged<T> onSelected;
|
||||
final Color backgroundColor;
|
||||
|
||||
@@ -47,7 +49,7 @@ class FilterBarDelegate<T> extends SliverPersistentHeaderDelegate {
|
||||
final value = values[index];
|
||||
return AppFilterChip(
|
||||
label: labelOf(value),
|
||||
count: countOf(value),
|
||||
count: countOf?.call(value),
|
||||
isSelected: value == selected,
|
||||
onTap: () => onSelected(value),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user