You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/new_views/common_widgets/tab_button.dart

76 lines
2.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/custom_badge.dart';
class TabButton extends StatelessWidget {
final String label;
final bool isSelected;
final int count;
final bool loading;
final VoidCallback onPressed;
const TabButton({
Key? key,
required this.label,
this.isSelected = false,
required this.count,
this.loading = false,
required this.onPressed,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onPressed,
child: count > 0 && isSelected && !loading
? CustomBadge(
value: count.toString(),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7),
color: isSelected ? AppColor.primary10 : AppColor.white30,
border: !isSelected ? Border.all(color: Colors.white54, width: 1) : null,
),
child: Center(
child: Text(
label,
style: AppTextStyles.bodyText.copyWith(
color: isSelected ? Colors.white : Colors.black,
),
)),
))
: Container(
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7),
color: isSelected ? AppColor.primary10 : AppColor.white30,
border: !isSelected ? Border.all(color: AppColor.white30, width: 1) : null,
),
child: Center(
child: Text(
label,
style: AppTextStyles.bodyText.copyWith(
color: isSelected ? Colors.white : Colors.black,
),
)),
),
);
}
}
class TabButtonData {
final String label;
final bool isSelected;
final int totalCount;
final VoidCallback onPressed;
TabButtonData({
required this.label,
required this.isSelected,
required this.totalCount,
required this.onPressed,
});
}