import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/orders_page/models/order_page_style_model.dart';
import 'package:zhiying_base_widget/widgets/search/widget/my_tab.dart';
import 'package:zhiying_comm/util/extension/color.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

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

  const OrderTabbarWidget(
    this.model,
    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: false,
                indicatorSize: TabBarIndicatorSize.label,
                // tabs: widgets,
                indicatorColor:
                    HexColor.fromHex(model?.appActivateColor ?? '#ff4242'),
                labelColor:
                    HexColor.fromHex(model?.appActivateColor ?? '#ff4242'),
                unselectedLabelColor: Color(0xff999999),

                tabs: titles.map((item) {
                  return MyTab(
                    // icon: CachedNetworkImage(imageUrl: item?.with_icon_color ?? '', width: 14,),
                    text: item,
                  );
                }).toList(),
              ),
            ),
            GestureDetector(
              behavior: HitTestBehavior.opaque,
              child: Container(
                width: 40,
                height: 40,
                padding: EdgeInsets.all(10),
                child: CachedNetworkImage(
                  imageUrl: model?.filter?.icon ?? '',
                  fit: BoxFit.contain,
                ),
              ),
              onTap: () {
                if (onMoreClick != null) {
                  onMoreClick();
                }
              },
            )
          ],
        ));
  }
}
