You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

259 lines
9.6 KiB

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/view_widget/coupon_widget.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:huixiang/view_widget/my_tab.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class MineCardPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _MineCardPage();
}
}
class _MineCardPage extends State<MineCardPage>
with SingleTickerProviderStateMixin{
RefreshController _refreshController;
RefreshController _refreshControllerOne;
RefreshController _refreshControllerTwo;
@override
void initState() {
super.initState();
tabController = TabController(length: 3, vsync: this);
_refreshController = RefreshController(initialRefresh: false);
_refreshControllerOne = RefreshController(initialRefresh: false);
_refreshControllerTwo = RefreshController(initialRefresh: false);
}
List<String> items = ["1", "2", "3", "4", "5", "6", "7", "8"];
void _onRefresh() async {
// monitor network fetch
await Future.delayed(Duration(milliseconds: 1000));
// if failed,use refreshFailed()
_refreshController.refreshCompleted();
_refreshControllerOne.refreshCompleted();
_refreshControllerTwo.refreshCompleted();
}
void _onLoading() async {
// monitor network fetch
await Future.delayed(Duration(milliseconds: 1000));
// if failed,use loadFailed(),if no data return,use LoadNodata()
items.add((items.length + 1).toString());
if (mounted) setState(() {});
_refreshController.loadComplete();
_refreshControllerOne.loadComplete();
_refreshControllerTwo.loadComplete();
}
TabController tabController;
@override
Widget build(BuildContext context) {
return DefaultTabController(
length:3,
child: Scaffold(
appBar: AppBar(
title: Text(
"卡包",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
centerTitle: false,
backgroundColor: Color(0xFFF7F7F7),
elevation: 0,
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,
),
),
),
titleSpacing: 2,
leadingWidth: 56,
bottom: TabBar(
// isScrollable: true, //可滚动
indicatorColor: Color(0xff39B54A),
labelColor: Colors.black,
labelStyle: TextStyle(fontSize: 17, fontWeight: FontWeight.bold),
unselectedLabelStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
),
controller: tabController,
//未选中文字颜色
unselectedLabelColor: Color(0xffA29E9E),
indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽
tabs: <Widget>[
Tab(text: S.of(context).dailingqu),
Tab(text: S.of(context).keshiyong),
Tab(text: S.of(context).yishixiao),
],
),
),
body:TabBarView(
controller: tabController,
children: <Widget>[
Container(
child: Container(
child: Column(
children: [
// ItemTitle(
// text: S.of(context).keyongyouhuiquan,
// imgPath: "assets/image/icon_card_coupon.png",
// moreText: S.of(context).chakanshixiaoquan,
// onTap: () {
// Navigator.of(context).pushNamed('/router/mine_card_invalid');
// },
// ),
Expanded(
flex: 1,
child: Container(
child: SmartRefresher(
enablePullDown: true,
enablePullUp: true,
header: ClassicHeader(),
footer: CustomFooter(
builder: (context, mode) {
Widget body;
if (mode == LoadStatus.idle) {
body = Text("pull up load");
} else if (mode == LoadStatus.loading) {
body = CupertinoActivityIndicator();
} else if (mode == LoadStatus.failed) {
body = Text("Load Failed!Click retry!");
} else if (mode == LoadStatus.canLoading) {
body = Text("release to load more");
} else {
body = Text(S.of(context).meiyougengduoyouhuiquan);
}
return Container(
height: 55.0,
child: Center(child: body),
);
},
),
controller: _refreshController,
onRefresh: _onRefresh,
onLoading: _onLoading,
child: ListView.builder(
itemBuilder: (c, i) {
return CouponWidget(true,true,(){
tabController.index = 1;
});
},
itemCount: items.length,
),
),
),
)
],
),
),
),
Container(
child: Container(
child: Column(
children: [
Expanded(
flex: 1,
child: Container(
child: SmartRefresher(
enablePullDown: true,
enablePullUp: true,
header: ClassicHeader(),
footer: CustomFooter(
builder: (context, mode) {
Widget body;
if (mode == LoadStatus.idle) {
body = Text("pull up load");
} else if (mode == LoadStatus.loading) {
body = CupertinoActivityIndicator();
} else if (mode == LoadStatus.failed) {
body = Text("Load Failed!Click retry!");
} else if (mode == LoadStatus.canLoading) {
body = Text("release to load more");
} else {
body = Text(S.of(context).meiyougengduoyouhuiquan);
}
return Container(
height: 55.0,
child: Center(child: body),
);
},
),
controller: _refreshControllerOne,
onRefresh: _onRefresh,
onLoading: _onLoading,
child: ListView.builder(
itemBuilder: (c, i) {
return CouponWidget(true,false,null);
},
itemCount: items.length,
),
),
),
)
],
),
),
),
Container(
child: SmartRefresher(
enablePullDown: true,
enablePullUp: true,
header: ClassicHeader(),
footer: CustomFooter(
builder: (context, mode) {
Widget body;
if (mode == LoadStatus.idle) {
body = Text("pull up load");
} else if (mode == LoadStatus.loading) {
body = CupertinoActivityIndicator();
} else if (mode == LoadStatus.failed) {
body = Text("Load Failed!Click retry!");
} else if (mode == LoadStatus.canLoading) {
body = Text("release to load more");
} else {
body = Text(S.of(context).meiyougengduoyouhuiquan);
}
return Container(
height: 55.0,
child: Center(child: body),
);
},
),
controller: _refreshControllerTwo,
onRefresh: _onRefresh,
onLoading: _onLoading,
child: ListView.builder(
itemBuilder: (c, i) {
return CouponWidget(false,false,null);
},
itemCount: items.length,
),
),
),
],
),
),
);
}
}