FreekakeApp/lib/components/tab_menu.dart
2025-04-15 13:38:24 +07:00

79 lines
2.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
class TabMenuButton extends StatelessWidget {
final String? label;
final String? icon;
final VoidCallback onPress;
final bool isSelected;
const TabMenuButton({
super.key,
this.label,
this.icon,
required this.onPress,
this.isSelected = false,
});
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
if (icon != null && icon!.isNotEmpty)
IconButton(
icon: SvgPicture.asset(
icon!,
width: 20,
height: 20,
colorFilter: ColorFilter.mode(
isSelected
? const Color.fromARGB(255, 10, 144, 16)
: Colors.white,
BlendMode.srcIn,
),
),
onPressed: onPress, // Semua aksi klik hanya lewat satu function
),
GestureDetector(
onTap: onPress, // Menggunakan satu event handler saja
child: Container(
width: 110,
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
decoration: BoxDecoration(
color:
isSelected
? const Color.fromARGB(255, 10, 144, 16).withOpacity(0)
: const Color.fromARGB(0, 0, 0, 0),
border:
isSelected
? const Border(
bottom: BorderSide(
color: Color.fromARGB(255, 255, 255, 255),
width: 2,
),
)
: null,
// borderRadius: BorderRadius.circular(20),
),
child: Center(
child: Text(
label ?? '',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color:
isSelected
? const Color.fromARGB(255, 255, 255, 255)
: const Color.fromARGB(255, 197, 194, 194),
),
),
),
),
),
],
);
}
}