import 'package:flutter/material.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import '../../generated/l10n.dart'; import '../../retrofit/data/business_login_info.dart'; import '../../view_widget/classic_header.dart'; import '../../view_widget/my_footer.dart'; class SelectShop extends StatefulWidget { final arguments; SelectShop({this.arguments}); @override State createState() { return _SelectShop(); } } class _SelectShop extends State { final RefreshController refreshController = RefreshController(); BusinessLoginInfo businessLoginInfo; int selectIndex = 0; @override void initState() { super.initState(); businessLoginInfo = widget.arguments["businessLoginInfo"]; } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: MyAppBar( title: "选择门店", titleColor: Colors.black, background: Colors.white, leadingColor: Colors.black, brightness: Brightness.dark, ), body: SmartRefresher( controller: refreshController, enablePullDown: true, enablePullUp: false, header: MyHeader( color: Colors.white, ), footer: CustomFooter( builder: (context, mode) { return MyFooter(mode); }, ), onRefresh: () {}, physics: BouncingScrollPhysics(), scrollController: ScrollController(), child: Container( height: double.infinity, padding: EdgeInsets.only(top: 13.h, left: 16.w, right: 16.w), child: Column( children: [ Row( children: [ Image.asset( "assets/image/bs_switch_shop.webp", width: 24, height: 24, ), SizedBox( width: 4.w, ), Text( "门店切换", style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.semi_bold, color: Color(0xFF1A1A1A)), ), ], ), SizedBox( height: 20.h, ), Expanded( child: ListView.builder( padding: EdgeInsets.zero, itemCount: businessLoginInfo?.storeList?.length ?? 0, scrollDirection: Axis.vertical, shrinkWrap: true, physics: BouncingScrollPhysics(), itemBuilder: (context, position) { return GestureDetector( onTap: () { setState(() { selectIndex = position; }); }, child: shopsItem( businessLoginInfo?.storeList[position], position), ); }, )), GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { Navigator.of(context).pushReplacementNamed( '/router/business_page', arguments: { "selectStoreIndex": selectIndex, "businessLoginInfo": businessLoginInfo, }); }, child: Container( width: double.infinity, padding: EdgeInsets.symmetric(vertical: 16.h), margin: EdgeInsets.only(bottom: 34.h, top: 10.h), alignment: Alignment.center, decoration: BoxDecoration( color: Color(0xFF30415B), borderRadius: BorderRadius.circular(27.w), ), child: Text( S.of(context).queding, style: TextStyle( fontWeight: MyFontWeight.bold, fontSize: 16.sp, color: Colors.white, ), ), ), ), ], ), ), ), ); } Widget shopsItem(StoreList storeList, index) { return Container( height: 52.h, margin: EdgeInsets.only(bottom: 12), child: Stack( alignment: Alignment.bottomRight, children: [ Container( height: 52.h, width: double.infinity, decoration: BoxDecoration( color: selectIndex == index ? Color(0xFFEFF5FF) : Colors.white, borderRadius: BorderRadius.circular(4.w), border: Border.all( color: selectIndex == index ? Color(0xFF30415B) : Colors.white, width: selectIndex == index ? 1.w : 0, ), ), padding: EdgeInsets.only( top: 16.h, bottom: 16.h, left: 16.w, right: 17.w), child: Text( storeList?.name ?? "", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.medium, color: selectIndex == index ? Color(0xFF30415B) : Color(0xFF0D0D0D)), ), ), if (selectIndex == index) Image.asset( "assets/image/bs_shop.webp", width: 20, height: 20, fit: BoxFit.fill, ), ], ), ); } }