import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class PersonalDetailTopBar extends StatefulWidget {
  final TabController controller;
  final ValueChanged<int>? onTap;
  final String customTimeStr;
  const PersonalDetailTopBar({Key? key,required this.controller, this.onTap, required this.customTimeStr}) : super(key: key);

  @override
  State<PersonalDetailTopBar> createState() => _PersonalDetailTopBarState();
}

class _PersonalDetailTopBarState extends State<PersonalDetailTopBar> {
   @override
   void initState(){
     super.initState();
   }

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.centerLeft,
      decoration: BoxDecoration(
          border: Border(bottom: BorderSide(width: 1.r,color: Color(0xFFCCCCCC)))
      ),
      child: TabBar(
        controller: widget.controller,
        unselectedLabelStyle: TextStyle(fontSize: 12.sp, color: const Color.fromRGBO(102, 102, 102, 1)),
        labelStyle: TextStyle(
          fontSize: 12.sp,
          fontWeight: FontWeight.bold,
          color: Color.fromRGBO(116, 145, 253, 1),
        ),
        isScrollable: true,
        labelColor: Color(0xFF6888FD),
        unselectedLabelColor: Color(0xFF666666),
        padding: EdgeInsets.symmetric(horizontal: 14.r),
        // indicatorSize: TabBarIndicatorSize.label, // 设置指示器高度和标签一样高
        onTap: widget.onTap,
        tabs: <Widget>[
          const Tab(text: '全部'),
          const Tab(text: '近一周'),
          const Tab(text: '近一月'),
          Tab(text: widget.customTimeStr),
        ],
      ),
    );
  }
}
