import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/store/store_view/store_info.dart'; import 'package:huixiang/union/union_view/union_coupon.dart'; import 'package:huixiang/union/union_view/vip.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/my_tab.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; class StoreOrderPage extends StatefulWidget { final Map arguments; StoreOrderPage({this.arguments}); @override State createState() { return _StoreOrderPage(); } } class _StoreOrderPage extends State with TickerProviderStateMixin/*, AutomaticKeepAliveClientMixin */{ TabController tabcontroller; ApiService apiService; StoreInfo storeInfo; RefreshController refreshController; @override void initState() { super.initState(); queryStoreInfo(); } queryStoreInfo() async { final SharedPreferences value = await SharedPreferences.getInstance(); apiService = ApiService( Dio(), context: context, token: value.getString('token'), ); BaseData baseData = await apiService .queryStoreInfo(widget.arguments["id"]) .catchError((error) { refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { refreshController.refreshCompleted(); storeInfo = StoreInfo.fromJson(baseData.data); if (mounted) { setState(() {}); } } else { refreshController.refreshFailed(); } } @override Widget build(BuildContext context) { return Column( children: [ Expanded( child: DefaultTabController( length: 2, child: SmartRefresher( controller: refreshController = RefreshController(initialRefresh: false), enablePullDown: true, enablePullUp: false, header: MyHeader(), physics: BouncingScrollPhysics(), onRefresh: () { queryStoreInfo(); }, child: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ SliverOverlapAbsorber( handle: NestedScrollView.sliverOverlapAbsorberHandleFor( context), sliver: SliverAppBar( title: Text( "百年川椒", style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 18.sp, ), ), expandedHeight: (storeInfo != null && storeInfo.couponVOList != null) ? 465.h : 365.h, floating: false, snap: false, leading: GestureDetector( onTap: () { Navigator.of(context).pop(); }, child: Container( alignment: Alignment.centerRight, margin: EdgeInsets.only(left: 10), padding: EdgeInsets.all(6), child: Icon( Icons.arrow_back_ios, color: Colors.black, size: 24, ), ), ), pinned: true, flexibleSpace: FlexibleSpaceBar( background: Stack( children: [ Positioned( child: Column( children: [ Image.asset( "assets/image/share_image_bg.png", fit: BoxFit.cover, width: MediaQuery.of(context).size.width, height: 180.h, ), Expanded( child: Container( color: Colors.transparent, ), flex: 1, ), ], ), top: 0, bottom: 0, left: 0, right: 0, ), Positioned( child: Container( child: Column( children: [ ///门店信息 StoreInfoView(storeInfo), ///门店对应优惠券 if (storeInfo != null && storeInfo.couponVOList != null) UnionCoupon( storeInfo, (a) {}, coupon: true, ), ///门店对应VIP信息 Vip(storeInfo, () {}, false), ], ), ), top: 110.h, bottom: 0, left: 0, right: 0, ), ], ), collapseMode: CollapseMode.pin, ), backgroundColor: Color(0xFFFAFAFA), centerTitle: false, elevation: 0, bottom: PreferredSize( preferredSize: Size( MediaQuery.of(context).size.width, 38.h, ), child: Container( padding: EdgeInsets.symmetric(horizontal: 10.w), width: MediaQuery.of(context).size.width, child: TabBar( controller: tabcontroller = TabController( length: 2, vsync: this, ), automaticIndicatorColorAdjustment: true, isScrollable: true, indicatorWeight: 1, indicatorColor: Color(0xFFFAFAFA), labelPadding: EdgeInsets.only(left: 8.w, right: 8.w), indicatorSize: TabBarIndicatorSize.label, unselectedLabelStyle: TextStyle( fontSize: 15.sp, fontWeight: FontWeight.w400, ), labelStyle: TextStyle( color: Colors.black, fontSize: 18.sp, fontWeight: FontWeight.bold, ), labelColor: Colors.black, tabs: [ MyTab(text: "点单"), MyTab(text: "星店活动"), ], ), ), ), ), ), ]; }, body: TabBarView( physics: BouncingScrollPhysics(), children: [ Container( color: Colors.white, width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.width, ), Container( color: Colors.white, width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.width, ), ], controller: tabcontroller, ), ), ), ), ), Container( height: 50.h, color: Colors.blue, ), ], ); } // @override // bool get wantKeepAlive => true; }