import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/goods_category.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/item_title.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class PointsGoodsTitle extends StatefulWidget { final ValueChanged onTap; final Function(int orderType, bool orderDesc) sortChange; final List gooodsCategorys; PointsGoodsTitle(this.gooodsCategorys, this.sortChange, this.onTap); @override State createState() { return _PointsGoodsTitle(); } } class _PointsGoodsTitle extends State { var _itemText = S.current.morenpaixu; List sortString = [ S.current.morenpaixu, S.current.jifengaodaodi, S.current.jifendidaogao, ]; @override Widget build(BuildContext context) { return Column( children: [ ItemTitle( text: S.of(context).jifenshangcheng, imgPath: "assets/image/icon_points_mall.png", moreText: _itemText, moreType: 1, items: sortString .map( (e) => DropdownMenuItem( value: e, child: Text( e, style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.medium, color: Color(0xff353535), ), ), ), ) .toList(), onChanged: _sortChange, ), Container( alignment: Alignment.centerLeft, child: DefaultTabController( length: widget.gooodsCategorys == null ? 0 : widget.gooodsCategorys.length, child: TabBar( isScrollable: true, //可滚动 indicatorColor: Color(0xff39B54A), labelColor: Color(0xff32A060), labelStyle: TextStyle( fontSize: 14.sp, fontWeight: FontWeight.bold, ), unselectedLabelStyle: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), // controller: tabController, //未选中文字颜色 unselectedLabelColor: Color(0xff4D4D4D), indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽 tabs: widget.gooodsCategorys == null ? [] : widget.gooodsCategorys .map((e) => Tab(text: e.name)) .toList(), onTap: widget.onTap, ), ), ), ], ); } _sortChange(item) { var index = sortString.indexOf(item); switch (index) { case 0: widget.sortChange(1, true); break; case 1: widget.sortChange(3, true); break; case 2: widget.sortChange(3, false); break; } setState(() { _itemText = item; }); } }