|
@@ -0,0 +1,172 @@
|
|
|
|
|
+import 'package:flutter/material.dart';
|
|
|
|
|
+import '../styles/colors.dart';
|
|
|
|
|
+
|
|
|
|
|
+class ShoppingMall extends StatefulWidget {
|
|
|
|
|
+ @override
|
|
|
|
|
+ ShoppingMallState createState() => ShoppingMallState();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+class ShoppingMallState extends State<ShoppingMall> {
|
|
|
|
|
+ final List<Tab> myTabs = <Tab>[Tab(text: '金币充值'), Tab(text: '会员充值')];
|
|
|
|
|
+
|
|
|
|
|
+ @override
|
|
|
|
|
+ Widget build(BuildContext context) {
|
|
|
|
|
+ return DefaultTabController(
|
|
|
|
|
+ length: myTabs.length,
|
|
|
|
|
+ child: Scaffold(
|
|
|
|
|
+ appBar: AppBar(
|
|
|
|
|
+ backgroundColor: PRIMARY_COLOR,
|
|
|
|
|
+ title: Padding(
|
|
|
|
|
+ padding: EdgeInsets.only(right: 56),
|
|
|
|
|
+ child: TabBar(
|
|
|
|
|
+ tabs: myTabs,
|
|
|
|
|
+ indicatorColor: Colors.white,
|
|
|
|
|
+ labelColor: Colors.white,
|
|
|
|
|
+ indicatorSize: TabBarIndicatorSize.label,
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ body: TabBarView(
|
|
|
|
|
+ children: <Widget>[Recharge(
|
|
|
|
|
+ type:0
|
|
|
|
|
+ ), Recharge(
|
|
|
|
|
+ type: 1,
|
|
|
|
|
+ )],
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+class Recharge extends StatefulWidget {
|
|
|
|
|
+ Recharge({Key key, this.type}) : super(key: key);
|
|
|
|
|
+final int type;//类型 0 金币 1 会员
|
|
|
|
|
+ @override
|
|
|
|
|
+ RechargeState createState() => RechargeState();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+class RechargeState extends State<Recharge> {
|
|
|
|
|
+ List moneyList = [100, 300, 500, 1000, 2000, 5000];
|
|
|
|
|
+ List vipList = [{
|
|
|
|
|
+ "name":'VIP1',
|
|
|
|
|
+ "value":100
|
|
|
|
|
+ },{
|
|
|
|
|
+ "name":'VIP2',
|
|
|
|
|
+ "value":300
|
|
|
|
|
+ },{
|
|
|
|
|
+ "name":'VIP3',
|
|
|
|
|
+ "value":500
|
|
|
|
|
+ },{
|
|
|
|
|
+ "name":'VIP4',
|
|
|
|
|
+ "value":1000
|
|
|
|
|
+ },{
|
|
|
|
|
+ "name":'VIP5',
|
|
|
|
|
+ "value":2000
|
|
|
|
|
+ },{
|
|
|
|
|
+ "name":'VIP6',
|
|
|
|
|
+ "value":5000
|
|
|
|
|
+ }];
|
|
|
|
|
+ int chooseMoney = 100;
|
|
|
|
|
+ @override
|
|
|
|
|
+ void initState() {
|
|
|
|
|
+ // TODO: implement initState
|
|
|
|
|
+ super.initState();
|
|
|
|
|
+ print(widget.type);
|
|
|
|
|
+ }
|
|
|
|
|
+ @override
|
|
|
|
|
+ Widget build(BuildContext context) {
|
|
|
|
|
+ return Scaffold(
|
|
|
|
|
+ body: Container(
|
|
|
|
|
+ color: BG_COLOR,
|
|
|
|
|
+ child: ListView.builder(
|
|
|
|
|
+ itemCount: widget.type==0?moneyList.length:vipList.length,
|
|
|
|
|
+ itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
+ bool isChoose=false;
|
|
|
|
|
+ if(widget.type==0){
|
|
|
|
|
+ if(moneyList[index]==chooseMoney){
|
|
|
|
|
+ isChoose=true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ if(vipList[index]['value']==chooseMoney){
|
|
|
|
|
+ isChoose=true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return Container(
|
|
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 15),
|
|
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
|
|
+ height: 60,
|
|
|
|
|
+ child: FlatButton(
|
|
|
|
|
+ color: Color(0xFF222335),
|
|
|
|
|
+ padding: EdgeInsets.all(0),
|
|
|
|
|
+ shape: Border.all(
|
|
|
|
|
+ color: isChoose
|
|
|
|
|
+ ? Color(0xFFC2524D)
|
|
|
|
|
+ : Colors.transparent,
|
|
|
|
|
+ width: 1),
|
|
|
|
|
+ disabledColor: Color(0xFF222335),
|
|
|
|
|
+ child: Container(
|
|
|
|
|
+ child: Stack(
|
|
|
|
|
+ children: <Widget>[
|
|
|
|
|
+ Center(
|
|
|
|
|
+ child: Row(
|
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
+ children: <Widget>[
|
|
|
|
|
+ Text(widget.type==0?(moneyList[index].toString() + "金币"):vipList[index]['name'],
|
|
|
|
|
+ style: TextStyle(
|
|
|
|
|
+ color: Color(0xFFFFFFFF),
|
|
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
|
|
+ fontSize: 15)),
|
|
|
|
|
+ Container(
|
|
|
|
|
+ width: 10,
|
|
|
|
|
+ ),
|
|
|
|
|
+ Text(
|
|
|
|
|
+ widget.type==0?("¥"+moneyList[index].toString()):("¥"+vipList[index]['value'].toString()),
|
|
|
|
|
+ style: TextStyle(
|
|
|
|
|
+ color: Color(0xFF727785),
|
|
|
|
|
+ fontWeight: FontWeight.w400,
|
|
|
|
|
+ fontSize: 14),
|
|
|
|
|
+ )
|
|
|
|
|
+ ],
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ Positioned(
|
|
|
|
|
+ right: 0,
|
|
|
|
|
+ bottom: 0,
|
|
|
|
|
+ child: isChoose
|
|
|
|
|
+ ? Image.asset('images/icon_xuanzhong.png',
|
|
|
|
|
+ width: 36)
|
|
|
|
|
+ : Container(),
|
|
|
|
|
+ )
|
|
|
|
|
+ ],
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ onPressed: isChoose
|
|
|
|
|
+ ? null
|
|
|
|
|
+ : () {
|
|
|
|
|
+
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ chooseMoney = widget.type==0?moneyList[index]:vipList[index]['value'];
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ ),
|
|
|
|
|
+ );
|
|
|
|
|
+ }),
|
|
|
|
|
+ ),
|
|
|
|
|
+ floatingActionButton: Container(
|
|
|
|
|
+ width: double.infinity,
|
|
|
|
|
+ padding: EdgeInsets.symmetric(horizontal:15),
|
|
|
|
|
+ height: 48,
|
|
|
|
|
+ child: FlatButton(
|
|
|
|
|
+ color: PRIMARY_COLOR,
|
|
|
|
|
+ textColor: Colors.white,
|
|
|
|
|
+ child: Text('立即充值'),
|
|
|
|
|
+ onPressed: (){
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ floatingActionButtonLocation:FloatingActionButtonLocation.centerFloat,
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+}
|