74 lines
2.0 KiB
Dart
74 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../theme/app_theme.dart';
|
|
|
|
class BarTab {
|
|
final String label;
|
|
final IconData icon;
|
|
|
|
const BarTab(this.label, this.icon);
|
|
}
|
|
|
|
/// Tab strip that continues the dark app bar (Koledar/Stiki, Knjiga filters).
|
|
/// The selected tab is a white pill; [trailing] sits at the right end.
|
|
class BarTabs extends StatelessWidget {
|
|
final List<BarTab> tabs;
|
|
final int selected;
|
|
final ValueChanged<int> onSelect;
|
|
final Widget? trailing;
|
|
|
|
const BarTabs({
|
|
super.key,
|
|
required this.tabs,
|
|
required this.selected,
|
|
required this.onSelect,
|
|
this.trailing,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
color: AppTheme.bar,
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
|
child: Row(
|
|
children: [
|
|
for (int i = 0; i < tabs.length; i++) ...[
|
|
if (i > 0) const SizedBox(width: 6),
|
|
Expanded(child: _tab(tabs[i], i == selected, () => onSelect(i))),
|
|
],
|
|
if (trailing != null) trailing!,
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _tab(BarTab tab, bool active, VoidCallback onTap) {
|
|
final color = active ? Colors.black : Colors.grey[400];
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
|
decoration: BoxDecoration(
|
|
color: active ? Colors.white : Colors.transparent,
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(tab.icon, color: color, size: 18),
|
|
const SizedBox(width: 6),
|
|
Flexible(
|
|
child: Text(
|
|
tab.label,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: color),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|