import 'package:flutter/material.dart'; 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'; 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: CustomBadge( value: loading ? 0 : !isSelected ? 0 : count, child: Container( padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 8), decoration: BoxDecoration( borderRadius: BorderRadius.circular(7), color: isSelected ? AppColor.primary10 : AppColor.background(context), border: !isSelected ? Border.all(color: AppColor.white936.withOpacity(.03), width: 1) : null, ), alignment: Alignment.center, child: Text( label, style: AppTextStyles.bodyText2.copyWith( //AppColor.background(context) color: isSelected ? Colors.white : AppColor.textColor(context), ), ), ), ), ).toShimmer(isShow: loading && isSelected, radius: 7, context: context); } } class RequestTypeButton extends StatelessWidget { final String label; final String icon; final Color iconColor; final bool isSelected; final int count; final bool loading; final VoidCallback onPressed; const RequestTypeButton({Key? key, required this.label, required this.icon, required this.iconColor, this.isSelected = false, required this.count, this.loading = false, required this.onPressed}) : super(key: key); @override Widget build(BuildContext context) { // InkWell( // onTap: onPressed, // child: CustomBadge( // value: loading // ? 0 // : !isSelected // ? 0 // : count, // child: Container( // padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 8), // decoration: BoxDecoration( // borderRadius: BorderRadius.circular(7), // color: isSelected ? AppColor.primary10 : AppColor.background(context), // border: !isSelected ? Border.all(color: AppColor.white936.withOpacity(.03), width: 1) : null, // ), // alignment: Alignment.center, // child: Text( // label, // style: AppTextStyles.bodyText2.copyWith( // //AppColor.background(context) // color: isSelected ? Colors.white : AppColor.textColor(context), // ), // ), // ), // ), // ).toShimmer(isShow: loading && isSelected, radius: 7, context: context); return CustomBadge( value: loading ? 0 : count, positionR: -4, positionT: -4, child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.end, spacing: 0, children: [ icon.toSvgAsset(height: 26, width: 26, color: iconColor).toShimmer(isShow: loading, context: context).center.expanded, Text( label, textAlign: TextAlign.center, style: AppTextStyles.textStyle9.copyWith(color: AppColor.headingTextColor(context)), ).toShimmer(isShow: loading, context: context), ], ).toShadowContainer(context, borderColor: isSelected ? AppColor.primary10 : null, borderRadius: 16, paddingObject: const EdgeInsets.symmetric(horizontal: 12, vertical: 12)), ).onPress(onPressed).paddingOnly(end: 4, top: 4); } }