|
|
|
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:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:huixiang/view_widget/item_title.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_tab.dart';
|
|
|
|
|
|
|
|
class PointsGoodsTitle extends StatefulWidget {
|
|
|
|
final ValueChanged<int> onTap;
|
|
|
|
final Function(int orderType, bool orderDesc) sortChange;
|
|
|
|
final List<GoodsCategory> gooodsCategorys;
|
|
|
|
|
|
|
|
PointsGoodsTitle(
|
|
|
|
this.gooodsCategorys,
|
|
|
|
this.sortChange,
|
|
|
|
this.onTap,
|
|
|
|
);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _PointsGoodsTitle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _PointsGoodsTitle extends State<PointsGoodsTitle>
|
|
|
|
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin{
|
|
|
|
var _itemText = S.current.morenpaixu;
|
|
|
|
List<String> sortString = [
|
|
|
|
S.current.morenpaixu,
|
|
|
|
S.current.jifengaodaodi,
|
|
|
|
S.current.jifendidaogao,
|
|
|
|
];
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
// ItemTitle(
|
|
|
|
// text: S.of(context).jifenshangcheng,
|
|
|
|
// imgPath: "assets/image/icon_points_mall.webp",
|
|
|
|
// ),
|
|
|
|
ItemTitle(
|
|
|
|
text: S.of(context).jifenshangcheng,
|
|
|
|
// imgPath: "assets/image/icon_points_mall.webp",
|
|
|
|
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: Theme(
|
|
|
|
data: ThemeData(
|
|
|
|
splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明
|
|
|
|
highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明
|
|
|
|
),
|
|
|
|
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) => MyTab(text: e.name))
|
|
|
|
.toList(),
|
|
|
|
onTap: widget.onTap,
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
// Container(
|
|
|
|
// width: 124.w,
|
|
|
|
// height: 32.h,
|
|
|
|
// margin: EdgeInsets.only(left: 20.w, top: 10),
|
|
|
|
// color: Colors.white,
|
|
|
|
// child: Stack(
|
|
|
|
// alignment: Alignment.center,
|
|
|
|
// children: [
|
|
|
|
// Container(
|
|
|
|
// width: 104.w,
|
|
|
|
// height: 32.h,
|
|
|
|
// color: Colors.white,
|
|
|
|
// ),
|
|
|
|
// Container(
|
|
|
|
// padding: EdgeInsets.symmetric(horizontal: 10.w),
|
|
|
|
// child: DropdownButton(
|
|
|
|
// items: sortString
|
|
|
|
// .map(
|
|
|
|
// (e) => DropdownMenuItem(
|
|
|
|
// value: e,
|
|
|
|
// child: Text(
|
|
|
|
// e,
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 12.sp,
|
|
|
|
// fontWeight: MyFontWeight.medium,
|
|
|
|
// color: Color(0xff353535),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// .toList(),
|
|
|
|
// value: _itemText,
|
|
|
|
// itemHeight: 50,
|
|
|
|
// onChanged: _sortChange,
|
|
|
|
// style: TextStyle(),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_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;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool get wantKeepAlive => true;
|
|
|
|
}
|