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.

209 lines
5.7 KiB

3 years ago
import 'dart:convert';
3 years ago
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/utils/font_weight.dart';
3 years ago
import 'package:shared_preferences/shared_preferences.dart';
3 years ago
class PayMethod extends StatefulWidget {
3 years ago
final Function(int payChannel) payChannelCheck;
PayMethod(this.payChannelCheck);
3 years ago
@override
State<StatefulWidget> createState() {
return _PayMethod();
}
}
class _PayMethod extends State<PayMethod> {
3 years ago
String money = "0";
String balance = "0";
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
Map<String, dynamic> memberInfo =
jsonDecode(value.getString("minMember"));
balance = memberInfo["balance"];
money = memberInfo["money"];
setState(() {});
});
}
3 years ago
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
margin: EdgeInsets.only(
left: 16.w,
right: 16.w,
top: 12.h,
bottom: 4.h,
),
padding: EdgeInsets.only(
left: 16.w,
right: 16.w,
top: 20.h,
bottom: 20.h,
),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Color(0x000000).withAlpha(25),
offset: Offset(0, 1),
blurRadius: 12.0,
),
],
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(bottom: 16.h),
child: Text(
S.of(context).zhifufangshi,
style: TextStyle(
fontSize: 16.sp,
color: Colors.black,
fontWeight: MyFontWeight.regular,
),
),
),
GestureDetector(
onTap: () {
setState(() {
checkIndex = 1;
});
3 years ago
widget.payChannelCheck(4);
3 years ago
},
child: Row(
3 years ago
mainAxisAlignment: MainAxisAlignment.center,
3 years ago
crossAxisAlignment: CrossAxisAlignment.center,
3 years ago
children: [
checkView(1),
3 years ago
Expanded(
child: Container(),
flex: 1,
),
Text(
"¥$money",
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff353535),
fontWeight: MyFontWeight.semi_bold,
),
),
SizedBox(
width: 10,
),
3 years ago
Text(
S.of(context).pingtaiyue,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff353535),
3 years ago
fontWeight: MyFontWeight.semi_bold,
),
3 years ago
),
],
),
),
SizedBox(
height: 10,
),
GestureDetector(
onTap: () {
setState(() {
checkIndex = 2;
});
3 years ago
widget.payChannelCheck(3);
3 years ago
},
child: Row(
3 years ago
mainAxisAlignment: MainAxisAlignment.center,
3 years ago
crossAxisAlignment: CrossAxisAlignment.center,
3 years ago
children: [
checkView(2),
3 years ago
Expanded(
child: Container(),
flex: 1,
),
Text(
"¥$balance",
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff353535),
fontWeight: MyFontWeight.semi_bold,
),
),
SizedBox(
width: 10,
),
3 years ago
Text(
S.of(context).dianpuyue,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff353535),
fontWeight: MyFontWeight.semi_bold,
),
),
],
),
),
SizedBox(
height: 10,
),
GestureDetector(
onTap: () {
setState(() {
checkIndex = 3;
3 years ago
widget.payChannelCheck(1);
3 years ago
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
checkView(3),
Spacer(),
Image.asset("assets/image/icon_we_chat.png"),
Padding(
padding: EdgeInsets.only(left: 8.w),
child: Text(
S.of(context).weixinzhifu,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff353535),
fontWeight: MyFontWeight.semi_bold,
),
),
),
],
),
),
],
),
);
}
var checkIndex = 3;
3 years ago
Widget checkView(var index) {
return Container(
padding: EdgeInsets.only(right: 16.w),
alignment: Alignment.center,
child: Image.asset(
checkIndex != index
? "assets/image/icon_radio_unselected.png"
: "assets/image/icon_radio_selected.png",
width: 15.w,
height: 15.h,
),
);
}
3 years ago
}