import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/search/widget/my_tab.dart';

class OrderTabbarWidget extends StatelessWidget {
  final TabController controller;
  final List<String> titles;
  final VoidCallback onMoreClick;

  const OrderTabbarWidget(
    this.controller,
    this.titles, {
    Key key,
    this.onMoreClick,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
        width: double.infinity,
        height: 40,
        color: Colors.white,
        child: Row(
          children: <Widget>[
            Expanded(
              child: TabBar(
                controller: controller,
                isScrollable: true,
                indicatorSize: TabBarIndicatorSize.label,
                // tabs: widgets,
                indicatorColor: Color(0xffff4242),
                labelColor: Color(0xffff4242),
                unselectedLabelColor: Color(0xff999999),
                tabs: titles.map((item) {
                  return MyTab(
                    // icon: CachedNetworkImage(imageUrl: item?.with_icon_color ?? '', width: 14,),
                    text: item,
                  );
                }).toList(),
              ),
            ),
            GestureDetector(
              child: Container(
                width: 40,
                height: 40,
                child: Icon(
                  Icons.filter_4,
                  size: 14,
                ),
              ),
              onTap: () {
                if (onMoreClick != null) {
                  onMoreClick();
                }
              },
            )
          ],
        ));
  }
}

class OrderTabbarItemWidget extends StatelessWidget {
  final String title;
  final bool isSelected;

  const OrderTabbarItemWidget({Key key, this.title, this.isSelected = false})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 26,
      child: Text(
        title,
        style: TextStyle(
            color: isSelected ? Color(0xFFFF4242) : Color(0xff999999)),
      ),
    );
  }
}
