tabBar static method

Widget tabBar({
  1. required List<String> tabs,
  2. required int selectedIndex,
  3. required dynamic onTabSelected(
    1. int
    ),
  4. GlassType type = GlassType.crystal,
})

Glass tab bar

Implementation

static Widget tabBar({
  required List<String> tabs,
  required int selectedIndex,
  required Function(int) onTabSelected,
  GlassType type = GlassType.crystal,
}) {
  return GlassContainer(
    type: type,
    padding: EdgeInsets.all(4.w),
    child: Row(
      children: tabs.asMap().entries.map((entry) {
        final index = entry.key;
        final tab = entry.value;
        final isSelected = index == selectedIndex;

        return Expanded(
          child: GestureDetector(
            onTap: () => onTabSelected(index),
            child: Container(
              padding: EdgeInsets.symmetric(vertical: 12.h),
              decoration: BoxDecoration(
                color: isSelected
                    ? Colors.white.withOpacity(0.3)
                    : Colors.transparent,
                borderRadius: BorderRadius.circular(8.r),
              ),
              child: Text(
                tab,
                style: AppTextThemes.bodyMedium(
                  color: Colors.white,
                  fontWeight:
                      isSelected ? FontWeight.bold : FontWeight.normal,
                ),
                textAlign: TextAlign.center,
              ),
            ),
          ),
        );
      }).toList(),
    ),
  );
}