import 'package:flutter/material.dart';

import '../../../common/theme/theme.dart';

class CustomTabBar extends StatelessWidget {
  final List<String> tabTitles;
  final List<Widget> tabViews;

  const CustomTabBar({
    super.key,
    required this.tabTitles,
    required this.tabViews,
  });

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: tabTitles.length,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Material(
            elevation: 0,
            color: Colors.white,
            borderOnForeground: false,
            child: TabBar(
              isScrollable: true,
              tabAlignment: TabAlignment.start,
              labelColor: AppColor.primary,
              labelStyle: const TextStyle(fontWeight: FontWeight.bold),
              dividerColor: AppColor.border,
              unselectedLabelColor: AppColor.primary,
              indicatorSize: TabBarIndicatorSize.label,
              indicatorWeight: 4,
              indicatorColor: AppColor.primary,
              tabs: tabTitles
                  .map(
                    (title) => Padding(
                      padding: const EdgeInsets.symmetric(horizontal: 16),
                      child: Tab(text: title),
                    ),
                  )
                  .toList(),
            ),
          ),
          Expanded(
            // ✅ ini bagian penting
            child: TabBarView(children: tabViews),
          ),
        ],
      ),
    );
  }
}
