685 lines
31 KiB
Dart
685 lines
31 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:game/network/NetworkConfig.dart';
|
|
|
|
import '../../beans/user_info_bean.dart';
|
|
import '../../common/EventBusUtil.dart';
|
|
import '../../common/func.dart';
|
|
import '../../dialog/exchange_dialog.dart';
|
|
import '../../dialog/sign_dialog.dart';
|
|
import 'me_model.dart';
|
|
|
|
class MyPage extends StatefulWidget {
|
|
const MyPage({super.key});
|
|
|
|
@override
|
|
State<MyPage> createState() => _MyPageState();
|
|
}
|
|
|
|
class _MyPageState extends State<MyPage> with AutomaticKeepAliveClientMixin {
|
|
late StreamSubscription subscription;
|
|
final MeModel _viewModel = MeModel();
|
|
late UserInfoBean userInfoBean;
|
|
late StreamSubscription<RefreshUserdata> _event;
|
|
|
|
bool _isInitialized = false;
|
|
|
|
late BuildContext exchangeContext;
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
|
|
_event = EventBusUtil.listen((event) {
|
|
_viewModel.getUserInfo();
|
|
});
|
|
|
|
subscription = _viewModel.streamController.stream.listen((event) {
|
|
String code = event['code'];
|
|
if (code.isNotEmpty) {
|
|
switch (code) {
|
|
case "getUserInfo":
|
|
EasyLoading.dismiss();
|
|
userInfoBean = event['data'];
|
|
_isInitialized = true;
|
|
break;
|
|
|
|
case "useRedemptionCode":
|
|
EasyLoading.dismiss();
|
|
EventBusUtil.fire(RefreshUserdata());
|
|
Navigator.pop(exchangeContext);
|
|
EasyLoading.showToast(event['data']);
|
|
break;
|
|
case "codeError":
|
|
EasyLoading.showToast(event['data']);
|
|
break;
|
|
case "sevenSignToday": //签到
|
|
EasyLoading.showToast(event['data']);
|
|
EventBusUtil.fire(RefreshUserdata());
|
|
_viewModel.getSevenSignList();
|
|
_viewModel.getUserInfo();
|
|
break;
|
|
|
|
default:
|
|
EasyLoading.showToast(event['data']);
|
|
break;
|
|
}
|
|
setState(() {});
|
|
}
|
|
});
|
|
|
|
FunctionUtil.loading();
|
|
_viewModel.getUserInfo();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// TODO: implement dispose
|
|
super.dispose();
|
|
subscription.cancel();
|
|
_event.cancel();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final size = MediaQuery.of(context).size;
|
|
final h282 = size.width / 1.2765957446808;
|
|
final t110 = size.width / 3.2727272727272;
|
|
final l14 = size.width / 25.714285714285;
|
|
final w57 = size.width / 6.31578947368;
|
|
final l85 = size.width / 4.235294117647;
|
|
final t147 = size.width / 2.4489795918367;
|
|
final s18 = size.width / 20;
|
|
final t203 = size.width / 1.7733990147783;
|
|
final w330 = size.width / 1.090909090909;
|
|
final h79 = size.width / 4.5569620253164;
|
|
final l23 = size.width / 15.652173913043;
|
|
final t22 = size.width / 16.363636363636;
|
|
final t41 = size.width / 8.780487804878;
|
|
final s16 = size.width / 22.5;
|
|
final w37 = size.width / 9.729729729729;
|
|
final t18 = size.width / 20;
|
|
final h60 = size.width / 6;
|
|
final w20 = size.width / 18;
|
|
final l11 = size.width / 32.727272727272;
|
|
final s14 = size.width / 25.714285714285;
|
|
final l4 = size.width / 90;
|
|
final h8 = size.width / 45;
|
|
|
|
return _isInitialized
|
|
? Scaffold(
|
|
backgroundColor: const Color(0xFF17181A),
|
|
body: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
SizedBox(
|
|
height: h282,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
top: 0,
|
|
child: Image(width: size.width, fit: BoxFit.fill, image: AssetImage('assets/images/me_bg.png')),
|
|
),
|
|
Positioned(
|
|
left: l14,
|
|
top: t110,
|
|
child: ClipOval(
|
|
child: CachedNetworkImage(
|
|
width: w57,
|
|
height: w57,
|
|
imageUrl: '${userInfoBean.userIcon}',
|
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
|
)),
|
|
),
|
|
Positioned(
|
|
left: l85,
|
|
top: t110,
|
|
child: Text(
|
|
"${userInfoBean.nickName}",
|
|
style: TextStyle(fontSize: s18, color: Colors.white),
|
|
)),
|
|
Positioned(
|
|
left: l85,
|
|
top: t147,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Navigator.pushNamed(context, "/EditInfoPage");
|
|
},
|
|
child: Row(
|
|
children: [
|
|
Text(
|
|
"编辑个人信息",
|
|
style: TextStyle(fontSize: l11, color: Color(0xFF909090)),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: l4),
|
|
child: Image(
|
|
width: l4,
|
|
height: h8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
Positioned(
|
|
top: t203,
|
|
child: !NetworkConfig.isChecking
|
|
? Container(
|
|
padding: EdgeInsets.only(left: l14, right: l14),
|
|
child: Container(
|
|
width: w330,
|
|
height: h79,
|
|
decoration: BoxDecoration(
|
|
gradient: const LinearGradient(
|
|
begin: Alignment.centerLeft,
|
|
end: Alignment.centerRight,
|
|
colors: [
|
|
Color(0xFF0978FF),
|
|
Color(0xFF39ADFE),
|
|
],
|
|
),
|
|
borderRadius: BorderRadius.all(Radius.circular(l11)),
|
|
),
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
left: l23,
|
|
top: t22,
|
|
child: Text(
|
|
"已游玩时长",
|
|
style: TextStyle(fontSize: l11, color: Color(0xFFE2F3FF)),
|
|
)),
|
|
Positioned(
|
|
left: l23,
|
|
top: t41,
|
|
child: Text(
|
|
"${userInfoBean.userPlayGameTime} 分钟",
|
|
style: TextStyle(fontSize: s16, color: Colors.white),
|
|
)),
|
|
Positioned(
|
|
right: l23,
|
|
child: Image(
|
|
width: w37,
|
|
height: w37,
|
|
image: const AssetImage('assets/images/ic_game_time.png'),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
)
|
|
: Container(),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: t18, left: l14, right: l14),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF202530),
|
|
borderRadius: BorderRadius.all(Radius.circular(l11)),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
///每日签到
|
|
!NetworkConfig.isChecking
|
|
? GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
FunctionUtil.popDialog2(
|
|
context,
|
|
SignDialog(
|
|
list: NetworkConfig.signData!.list!,
|
|
onTap: () {
|
|
if (NetworkConfig.signData!.isSign!) {
|
|
EasyLoading.showToast("今日已签到");
|
|
return;
|
|
}
|
|
FunctionUtil.loading();
|
|
_viewModel.sevenSignToday();
|
|
},
|
|
));
|
|
},
|
|
child: SizedBox(
|
|
height: h60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: l23),
|
|
child: Image(
|
|
width: w20,
|
|
height: w20,
|
|
image: const AssetImage('assets/images/ic_sign.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: l14),
|
|
child: Text(
|
|
"每日签到",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: l23),
|
|
child: Image(
|
|
width: l4,
|
|
height: h8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
: Container(),
|
|
|
|
///任务中心
|
|
// SizedBox(
|
|
// height: h60,
|
|
// child: Row(
|
|
// children: [
|
|
// Container(
|
|
// margin: EdgeInsets.only(left: l23),
|
|
// child: Image(
|
|
// width: w20,
|
|
// height: w20,
|
|
// image: AssetImage('assets/images/ic_task.png'),
|
|
// ),
|
|
// ),
|
|
// Container(
|
|
// margin: EdgeInsets.only(left: l14),
|
|
// child: const Text(
|
|
// "任务中心",
|
|
// style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
// ),
|
|
// ),
|
|
// Expanded(child: Container()),
|
|
// Container(
|
|
// margin: EdgeInsets.only(right: l23),
|
|
// child: const Image(
|
|
// width: 4,
|
|
// height: 8,
|
|
// image: AssetImage('assets/images/ic_arrow.png'),
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
],
|
|
),
|
|
),
|
|
|
|
///游玩历史
|
|
!NetworkConfig.isChecking
|
|
? GestureDetector(
|
|
onTap: () {
|
|
Navigator.pushNamed(context, "/GameHistoryPage");
|
|
},
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: t18, left: l14, right: l14),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF202530),
|
|
borderRadius: BorderRadius.all(Radius.circular(l11)),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
SizedBox(
|
|
height: h60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: l23),
|
|
child: Image(
|
|
width: w20,
|
|
height: w20,
|
|
image: AssetImage('assets/images/ic_play_history.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: l14),
|
|
child: Text(
|
|
"游玩历史",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: l23),
|
|
child: Image(
|
|
width: l4,
|
|
height: h8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
: Container(),
|
|
|
|
///包月卡
|
|
// Container(
|
|
// margin: EdgeInsets.only(top: t18, left: l14, right: l14),
|
|
// decoration: const BoxDecoration(
|
|
// color: Color(0xFF202530),
|
|
// borderRadius: BorderRadius.all(Radius.circular(11)),
|
|
// ),
|
|
// child: Column(
|
|
// children: [
|
|
// SizedBox(
|
|
// height: h60,
|
|
// child: Row(
|
|
// children: [
|
|
// Container(
|
|
// margin: EdgeInsets.only(left: l23),
|
|
// child: Image(
|
|
// width: w20,
|
|
// height: w20,
|
|
// image: const AssetImage('assets/images/ic_night.png'),
|
|
// ),
|
|
// ),
|
|
// Container(
|
|
// margin: EdgeInsets.only(left: l14),
|
|
// child: const Text(
|
|
// "包夜卡",
|
|
// style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
// ),
|
|
// ),
|
|
// Expanded(child: Container()),
|
|
// Container(
|
|
// margin: EdgeInsets.only(right: l23),
|
|
// child: const Image(
|
|
// width: 4,
|
|
// height: 8,
|
|
// image: AssetImage('assets/images/ic_arrow.png'),
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
|
|
Container(
|
|
margin: EdgeInsets.only(top: t18, left: l14, right: l14, bottom: w20),
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xFF202530),
|
|
borderRadius: BorderRadius.all(Radius.circular(11)),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
///资产记录
|
|
!NetworkConfig.isChecking
|
|
? GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
Navigator.pushNamed(context, "/PropertyPage");
|
|
},
|
|
child: SizedBox(
|
|
height: h60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: l23),
|
|
child: Image(
|
|
width: w20,
|
|
height: w20,
|
|
image: const AssetImage('assets/images/ic_property.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: l14),
|
|
child: Text(
|
|
"资产记录",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: l23),
|
|
child: Image(
|
|
width: l4,
|
|
height: h8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
: Container(),
|
|
|
|
///兑换码
|
|
!NetworkConfig.isChecking
|
|
? GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
showDialog(
|
|
context: context,
|
|
barrierDismissible: true,
|
|
builder: (BuildContext context) {
|
|
exchangeContext = context;
|
|
return ExchangeDialog(
|
|
onTap: (value) {
|
|
FunctionUtil.loading();
|
|
_viewModel.useRedemptionCode(value);
|
|
},
|
|
);
|
|
});
|
|
},
|
|
child: SizedBox(
|
|
height: h60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: l23),
|
|
child: Image(
|
|
width: w20,
|
|
height: w20,
|
|
image: const AssetImage('assets/images/ic_exchange.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: l14),
|
|
child: Text(
|
|
"兑换码",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: l23),
|
|
child: Image(
|
|
width: l4,
|
|
height: h8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
: Container(),
|
|
|
|
///反馈
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
Navigator.pushNamed(context, '/FeedbackPage');
|
|
},
|
|
child: SizedBox(
|
|
height: h60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: l23),
|
|
child: Image(
|
|
width: w20,
|
|
height: w20,
|
|
image: const AssetImage('assets/images/ic_feedback.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: l14),
|
|
child: Text(
|
|
"反馈",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: l23),
|
|
child: Image(
|
|
width: l4,
|
|
height: h8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
///我的收藏
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
Navigator.pushNamed(context, "/MyCollectPage");
|
|
},
|
|
child: SizedBox(
|
|
height: h60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: l23),
|
|
child: Image(
|
|
width: w20,
|
|
height: w20,
|
|
image: const AssetImage('assets/images/ic_collect.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: l14),
|
|
child: Text(
|
|
"我的收藏",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: l23),
|
|
child: Image(
|
|
width: l4,
|
|
height: h8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
///设置
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
Navigator.pushNamed(context, "/SettingPage");
|
|
},
|
|
child: SizedBox(
|
|
height: h60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: l23),
|
|
child: Image(
|
|
width: w20,
|
|
height: w20,
|
|
image: const AssetImage('assets/images/ic_set.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: l14),
|
|
child: Text(
|
|
"设置",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: l23),
|
|
child: Image(
|
|
width: l4,
|
|
height: h8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
///蓝牙手柄
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
Navigator.pushNamed(context, "/BtGamePadPage");
|
|
},
|
|
child: SizedBox(
|
|
height: h60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: l23),
|
|
child: Image(
|
|
width: w20,
|
|
height: w20,
|
|
image: const AssetImage('assets/images/ic_set.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: l14),
|
|
child: Text(
|
|
"蓝牙手柄",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: l23),
|
|
child: Image(
|
|
width: l4,
|
|
height: h8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
: Container();
|
|
}
|
|
|
|
@override
|
|
// TODO: implement wantKeepAlive
|
|
bool get wantKeepAlive => true;
|
|
}
|