|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/pages/my/store_wine_manage/wine_in_store_item.dart';
|
|
|
|
import 'package:one_key/pages/my/store_wine_manage/wine_out_store_item.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../../../provider/store_wine_provider.dart';
|
|
|
|
import '../../../res/colors.dart';
|
|
|
|
import '../../../route/navigator_util.dart';
|
|
|
|
import '../../../utils/event_bus.dart';
|
|
|
|
import '../../../utils/utils.dart';
|
|
|
|
import '../../../widgets/custom_tab_indicator.dart';
|
|
|
|
import '../../../widgets/round_button.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* 存酒首页
|
|
|
|
*/
|
|
|
|
|
|
|
|
class StoreWineManageHomePage extends StatefulWidget {
|
|
|
|
StoreWineManageHomePage({Key key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_StoreWineManageHomePageState createState() =>
|
|
|
|
_StoreWineManageHomePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _StoreWineManageHomePageState extends State<StoreWineManageHomePage>
|
|
|
|
with TickerProviderStateMixin {
|
|
|
|
StoreWineProvider storeWineProvider;
|
|
|
|
|
|
|
|
TextEditingController searchC = TextEditingController(); //搜索框控制器
|
|
|
|
List _tabBarTitle;
|
|
|
|
TabController tabController;
|
|
|
|
int index = 0;
|
|
|
|
ScrollController listInStoreC = ScrollController();
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
_tabBarTitle = ['全部在店', '取酒记录'];
|
|
|
|
super.initState();
|
|
|
|
tabController = TabController(length: 2, vsync: this);
|
|
|
|
tabController.index = 0;
|
|
|
|
|
|
|
|
tabController.addListener(() {
|
|
|
|
if (tabController.index == tabController.animation.value) {
|
|
|
|
if (index == tabController.index) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
print(tabController.index);
|
|
|
|
index = tabController.index;
|
|
|
|
|
|
|
|
// _getContantData(first: true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
|
|
index = tabController.index;
|
|
|
|
|
|
|
|
// _getContantData(first: first);
|
|
|
|
});
|
|
|
|
// bus.on("refresh_guest_list_my", (arg) {
|
|
|
|
// _getContantData();
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 搜索框
|
|
|
|
Widget _searchWidget() {
|
|
|
|
return Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(40),
|
|
|
|
),
|
|
|
|
height: ScreenUtil().setWidth(45 * 2),
|
|
|
|
// alignment: Alignment.center,
|
|
|
|
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: ScreenUtil().setWidth(20 * 2),
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
borderRadius:
|
|
|
|
BorderRadius.circular(ScreenUtil().setWidth(24 * 2)),
|
|
|
|
border: Border.all(color: Color.fromRGBO(228, 228, 228, 1)),
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Color.fromRGBO(220, 220, 220, 1), //投影颜色
|
|
|
|
offset: Offset(2, 3), //x,y轴
|
|
|
|
blurRadius: ScreenUtil().setWidth(6) //投影距离
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
child: Row(children: [
|
|
|
|
Expanded(
|
|
|
|
child: TextField(
|
|
|
|
maxLines: 1,
|
|
|
|
controller: searchC,
|
|
|
|
// focusNode: _focusNode,
|
|
|
|
// autofocus: true,
|
|
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_333333,
|
|
|
|
fontSize: ScreenUtil().setSp(26)),
|
|
|
|
// textAlignVertical: TextAlignVertical.center,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
hintText: "输入手机号或姓名",
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(26),
|
|
|
|
),
|
|
|
|
// isCollapsed:
|
|
|
|
// true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
// 左边图标设置
|
|
|
|
icon: Image.asset(
|
|
|
|
Utils.getImgPath('search'),
|
|
|
|
width: ScreenUtil().setWidth(30),
|
|
|
|
),
|
|
|
|
//右边图标设置
|
|
|
|
// suffixIcon:
|
|
|
|
),
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
textInputAction: TextInputAction.done,
|
|
|
|
|
|
|
|
onChanged: (value) {
|
|
|
|
// _getContantData(showLoading: false);
|
|
|
|
},
|
|
|
|
onEditingComplete: () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
// _getContantData(showLoading: false);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Offstage(
|
|
|
|
offstage: searchC.text == '',
|
|
|
|
child: GestureDetector(
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(40),
|
|
|
|
vertical: ScreenUtil().setWidth(20),
|
|
|
|
),
|
|
|
|
// color: Colors.orange,
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath('clear'),
|
|
|
|
width: ScreenUtil().setWidth(30),
|
|
|
|
height: ScreenUtil().setWidth(30),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onTap: () {
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback(((_) {
|
|
|
|
searchC.clear();
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
// _getContantData(showLoading: false);
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
// Offstage(
|
|
|
|
// offstage: false,
|
|
|
|
// child: GestureDetector(
|
|
|
|
// child: Container(
|
|
|
|
// padding: EdgeInsets.only(
|
|
|
|
// right: ScreenUtil().setWidth(30),
|
|
|
|
// bottom: ScreenUtil().setWidth(20),
|
|
|
|
// top: ScreenUtil().setWidth(20),
|
|
|
|
// ),
|
|
|
|
// child: Text(
|
|
|
|
// '搜索',
|
|
|
|
// style: TextStyle(
|
|
|
|
// color: MyColours.color_199095,
|
|
|
|
// fontSize: ScreenUtil().setSp(28)),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// onTap: () {
|
|
|
|
// customerProvider.searchData(
|
|
|
|
// customerProvider.controller.text);
|
|
|
|
// },
|
|
|
|
// ))
|
|
|
|
])));
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _menuWidget() {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(40),
|
|
|
|
vertical: ScreenUtil().setWidth(20)),
|
|
|
|
decoration: BoxDecoration(color: MyColours.color_ffffff, boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
// color: Colors.red,
|
|
|
|
color: Color.fromRGBO(220, 220, 220, 1), //投影颜色
|
|
|
|
offset: Offset(2, 2), //x,y轴
|
|
|
|
blurRadius: ScreenUtil().setWidth(6) //投影距离
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(10)),
|
|
|
|
margin:
|
|
|
|
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(30)),
|
|
|
|
child: TabBar(
|
|
|
|
controller: tabController,
|
|
|
|
// isScrollable: true,
|
|
|
|
indicator: CustomTabIndicator(
|
|
|
|
radius: 0,
|
|
|
|
),
|
|
|
|
indicatorColor: MyColours.color_199095,
|
|
|
|
indicatorSize: TabBarIndicatorSize.tab,
|
|
|
|
// indicatorPadding: EdgeInsets.symmetric(
|
|
|
|
// horizontal: ScreenUtil().setWidth(12)),
|
|
|
|
labelColor: MyColours.color_199095,
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
labelPadding: EdgeInsets.zero,
|
|
|
|
unselectedLabelStyle: TextStyle(
|
|
|
|
fontWeight: FontWeight.normal,
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
),
|
|
|
|
unselectedLabelColor: MyColours.color_999999,
|
|
|
|
tabs: _tabBarTitle.map((value) {
|
|
|
|
return Tab(
|
|
|
|
child: Text(value),
|
|
|
|
);
|
|
|
|
}).toList()),
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
storeWineProvider = Provider.of<StoreWineProvider>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
appBar: SystemAppBar(
|
|
|
|
'存酒管理',
|
|
|
|
onTap: () {
|
|
|
|
EventBus().emit('changeStatusColor');
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
body: WillPopScope(
|
|
|
|
onWillPop: () async {
|
|
|
|
EventBus().emit('changeStatusColor');
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
child: SafeArea(
|
|
|
|
child: Column(children: [
|
|
|
|
_searchWidget(), _menuWidget(),
|
|
|
|
Expanded(
|
|
|
|
child: TabBarView(controller: tabController,
|
|
|
|
// physics: NeverScrollableScrollPhysics(),
|
|
|
|
children: [
|
|
|
|
ListView.builder(
|
|
|
|
itemCount: 100,
|
|
|
|
controller: listInStoreC,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return WineInStoreItem(
|
|
|
|
controller: listInStoreC,
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
ListView.builder(
|
|
|
|
itemCount: 100,
|
|
|
|
controller: listInStoreC,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return WineOutStoreItem(
|
|
|
|
controller: listInStoreC,
|
|
|
|
);
|
|
|
|
})
|
|
|
|
])),
|
|
|
|
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(91 * 2),
|
|
|
|
width: double.infinity,
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: ScreenUtil().setWidth(12 * 2),
|
|
|
|
bottom: ScreenUtil().setWidth(25 * 2),
|
|
|
|
left: ScreenUtil().setWidth(45 * 2),
|
|
|
|
right: ScreenUtil().setWidth(45 * 2),
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
spreadRadius: ScreenUtil().setWidth(2),
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.1),
|
|
|
|
offset: Offset(0, ScreenUtil().setWidth(-2)),
|
|
|
|
blurRadius: ScreenUtil().setWidth(8))
|
|
|
|
],
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
Radius.circular(ScreenUtil().setWidth(16)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: RoundButton(
|
|
|
|
text: '新建存酒',
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
isBold: true,
|
|
|
|
fontSize: 32,
|
|
|
|
textColor: MyColours.color_F8F9FD,
|
|
|
|
onPressed: () async {
|
|
|
|
// UserModel userModel =
|
|
|
|
// Provider.of<UserModel>(context, listen: false);
|
|
|
|
// if (userModel.user.role_name == '管理员' ||
|
|
|
|
// userModel.user.role_name == '店长') {
|
|
|
|
NavigatorUtil.goCreateStoreWinePage(context);
|
|
|
|
// } else {
|
|
|
|
// bool needRefresh =
|
|
|
|
// await NavigatorUtil.goCouponEditPage(context);
|
|
|
|
// print(needRefresh);
|
|
|
|
// if (needRefresh != null && needRefresh) {
|
|
|
|
// bus.emit('refresh_coupon_list_f');
|
|
|
|
// //刷新页面数据
|
|
|
|
// // _controller.callRefresh();
|
|
|
|
// // _couponNetworkData(tabController.index);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
// _searchWidget(),
|
|
|
|
// Positioned(
|
|
|
|
// top: 0,
|
|
|
|
// left: ScreenUtil().setWidth(40),
|
|
|
|
// right: ScreenUtil().setWidth(40),
|
|
|
|
// child: _filterWidget())
|
|
|
|
// ],
|
|
|
|
])),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|