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.
85 lines
2.8 KiB
Dart
85 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:badges/badges.dart' as badges;
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
import 'package:test_sa/new_views/app_style/app_color.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,
|
|
@required this.loading = false,
|
|
@required this.onPressed,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return InkWell(
|
|
onTap: onPressed,
|
|
child: count != null && count > 0 && isSelected && !loading
|
|
? badges.Badge(
|
|
badgeContent: Text(
|
|
count.toString(),
|
|
style: const TextStyle(
|
|
color: AppColor.white20,
|
|
fontWeight: FontWeight.normal,
|
|
),
|
|
),
|
|
badgeStyle: const badges.BadgeStyle(padding: EdgeInsets.symmetric(horizontal: 5, vertical: 3), badgeColor: AppColor.red50),
|
|
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,
|
|
),
|
|
)),
|
|
).toShimmer(isShow: loading, radius: 7),
|
|
)
|
|
: 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,
|
|
),
|
|
)),
|
|
).toShimmer(isShow: loading, radius: 7),
|
|
);
|
|
}
|
|
}
|
|
|
|
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,
|
|
});
|
|
}
|