604 lines
25 KiB
Dart
604 lines
25 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> {
|
|
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":
|
|
userInfoBean = event['data'];
|
|
_isInitialized = true;
|
|
break;
|
|
|
|
case "useRedemptionCode":
|
|
Navigator.pop(exchangeContext);
|
|
EasyLoading.showToast(event['data']);
|
|
break;
|
|
case "codeError":
|
|
EasyLoading.showToast(event['data']);
|
|
break;
|
|
case "sevenSignToday": //签到
|
|
EasyLoading.showToast(event['data']);
|
|
_viewModel.getSevenSignList();
|
|
_viewModel.getUserInfo();
|
|
break;
|
|
|
|
default:
|
|
EasyLoading.showToast(event['data']);
|
|
break;
|
|
}
|
|
setState(() {});
|
|
}
|
|
});
|
|
_viewModel.getUserInfo();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// TODO: implement dispose
|
|
subscription.cancel();
|
|
_Event.cancel();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final size = MediaQuery.of(context).size;
|
|
return _isInitialized
|
|
? Scaffold(
|
|
backgroundColor: const Color(0xFF17181A),
|
|
body: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
SizedBox(
|
|
height: 282,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
top: 0,
|
|
child: Image(width: size.width, image: AssetImage('assets/images/me_bg.png')),
|
|
),
|
|
Positioned(
|
|
left: 14,
|
|
top: 110,
|
|
child: ClipOval(
|
|
child: CachedNetworkImage(
|
|
width: 57,
|
|
height: 57,
|
|
imageUrl: '${userInfoBean.userIcon}',
|
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
|
)),
|
|
),
|
|
Positioned(
|
|
left: 85,
|
|
top: 110,
|
|
child: Text(
|
|
"${userInfoBean.nickName}",
|
|
style: TextStyle(fontSize: 18, color: Colors.white),
|
|
)),
|
|
Positioned(
|
|
left: 85,
|
|
top: 147,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Navigator.pushNamed(context, "/EditInfoPage");
|
|
},
|
|
child: Row(
|
|
children: [
|
|
Text(
|
|
"编辑个人资料",
|
|
style: TextStyle(fontSize: 11, color: Color(0xFF909090)),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 4),
|
|
child: Image(
|
|
width: 4,
|
|
height: 8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
Positioned(
|
|
top: 203,
|
|
child: Container(
|
|
padding: EdgeInsets.only(left: 15, right: 15),
|
|
child: Container(
|
|
width: 330,
|
|
height: 79,
|
|
decoration: const BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.centerLeft,
|
|
end: Alignment.centerRight,
|
|
colors: [
|
|
Color(0xFF0978FF),
|
|
Color(0xFF39ADFE),
|
|
],
|
|
),
|
|
borderRadius: BorderRadius.all(Radius.circular(11)),
|
|
),
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
left: 23,
|
|
top: 22,
|
|
child: Text(
|
|
"我的游戏时长",
|
|
style: TextStyle(fontSize: 11, color: Color(0xFFE2F3FF)),
|
|
)),
|
|
Positioned(
|
|
left: 23,
|
|
top: 41,
|
|
child: Text(
|
|
"${userInfoBean.totalGamingTime} 分钟",
|
|
style: TextStyle(fontSize: 16, color: Colors.white),
|
|
)),
|
|
Positioned(
|
|
right: 23,
|
|
child: Image(
|
|
width: 37,
|
|
height: 37,
|
|
image: AssetImage('assets/images/ic_game_time.png'),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 18, left: 15, right: 15),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF202530),
|
|
borderRadius: BorderRadius.all(Radius.circular(11)),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
///每日签到
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
FunctionUtil.popDialog2(
|
|
context,
|
|
SignDialog(
|
|
list: NetworkConfig.signData!.list!,
|
|
onTap: () {
|
|
EasyLoading.show(status: "加载中");
|
|
_viewModel.sevenSignToday();
|
|
},
|
|
));
|
|
},
|
|
child: SizedBox(
|
|
height: 60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: 23),
|
|
child: Image(
|
|
width: 20,
|
|
height: 20,
|
|
image: AssetImage('assets/images/ic_sign.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 14),
|
|
child: Text(
|
|
"每日签到",
|
|
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: 23),
|
|
child: Image(
|
|
width: 4,
|
|
height: 8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
///任务中心
|
|
SizedBox(
|
|
height: 60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: 23),
|
|
child: Image(
|
|
width: 20,
|
|
height: 20,
|
|
image: AssetImage('assets/images/ic_task.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 14),
|
|
child: Text(
|
|
"任务中心",
|
|
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: 23),
|
|
child: Image(
|
|
width: 4,
|
|
height: 8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
///游玩历史
|
|
GestureDetector(
|
|
onTap: () {
|
|
Navigator.pushNamed(context, "/GameHistoryPage");
|
|
},
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 18, left: 15, right: 15),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF202530),
|
|
borderRadius: BorderRadius.all(Radius.circular(11)),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
SizedBox(
|
|
height: 60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: 23),
|
|
child: Image(
|
|
width: 20,
|
|
height: 20,
|
|
image: AssetImage('assets/images/ic_play_history.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 14),
|
|
child: Text(
|
|
"游玩历史",
|
|
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: 23),
|
|
child: Image(
|
|
width: 4,
|
|
height: 8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
///包月卡
|
|
Container(
|
|
margin: EdgeInsets.only(top: 18, left: 15, right: 15),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF202530),
|
|
borderRadius: BorderRadius.all(Radius.circular(11)),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
SizedBox(
|
|
height: 60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: 23),
|
|
child: Image(
|
|
width: 20,
|
|
height: 20,
|
|
image: AssetImage('assets/images/ic_night.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 14),
|
|
child: Text(
|
|
"包夜卡",
|
|
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: 23),
|
|
child: Image(
|
|
width: 4,
|
|
height: 8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
Container(
|
|
margin: EdgeInsets.only(top: 18, left: 15, right: 15, bottom: 20),
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xFF202530),
|
|
borderRadius: BorderRadius.all(Radius.circular(11)),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
///资产记录
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
Navigator.pushNamed(context, "/PropertyPage");
|
|
},
|
|
child: SizedBox(
|
|
height: 60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: 23),
|
|
child: const Image(
|
|
width: 20,
|
|
height: 20,
|
|
image: AssetImage('assets/images/ic_property.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 14),
|
|
child: Text(
|
|
"资产记录",
|
|
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: 23),
|
|
child: Image(
|
|
width: 4,
|
|
height: 8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
///兑换码
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
// FunctionUtil.popDialog(context, ExchangeDialog(
|
|
// onTap: (value) {
|
|
// _viewModel.useRedemptionCode(value);
|
|
// },
|
|
// ));
|
|
|
|
showDialog(
|
|
context: context,
|
|
barrierDismissible: true,
|
|
builder: (BuildContext context) {
|
|
exchangeContext = context;
|
|
return ExchangeDialog(
|
|
onTap: (value) {
|
|
_viewModel.useRedemptionCode(value);
|
|
},
|
|
);
|
|
});
|
|
},
|
|
child: SizedBox(
|
|
height: 60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: 23),
|
|
child: Image(
|
|
width: 20,
|
|
height: 20,
|
|
image: AssetImage('assets/images/ic_exchange.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 14),
|
|
child: Text(
|
|
"兑换码",
|
|
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: 23),
|
|
child: Image(
|
|
width: 4,
|
|
height: 8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
///反馈
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
Navigator.pushNamed(context, '/FeedbackPage');
|
|
},
|
|
child: SizedBox(
|
|
height: 60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: 23),
|
|
child: Image(
|
|
width: 20,
|
|
height: 20,
|
|
image: AssetImage('assets/images/ic_feedback.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 14),
|
|
child: Text(
|
|
"反馈",
|
|
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: 23),
|
|
child: Image(
|
|
width: 4,
|
|
height: 8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
///我的收藏
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
Navigator.pushNamed(context, "/MyCollectPage");
|
|
},
|
|
child: SizedBox(
|
|
height: 60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: 23),
|
|
child: Image(
|
|
width: 20,
|
|
height: 20,
|
|
image: AssetImage('assets/images/ic_collect.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 14),
|
|
child: Text(
|
|
"我的收藏",
|
|
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: 23),
|
|
child: Image(
|
|
width: 4,
|
|
height: 8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
///设置
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
Navigator.pushNamed(context, "/SettingPage");
|
|
},
|
|
child: SizedBox(
|
|
height: 60,
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(left: 23),
|
|
child: Image(
|
|
width: 20,
|
|
height: 20,
|
|
image: AssetImage('assets/images/ic_set.png'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 14),
|
|
child: Text(
|
|
"设置",
|
|
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(right: 23),
|
|
child: Image(
|
|
width: 4,
|
|
height: 8,
|
|
image: AssetImage('assets/images/ic_arrow.png'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
: Container();
|
|
}
|
|
}
|