SteamCloudGame/lib/tools/me/edit_info_page.dart
2024-12-29 14:27:28 +08:00

217 lines
6.9 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:game/common/EventBusUtil.dart';
import 'package:game/network/NetworkConfig.dart';
import '../../common/func.dart';
import '../../dialog/change_nickname_dialog.dart';
import 'me_model.dart';
class EditInfoPage extends StatefulWidget {
const EditInfoPage({super.key});
@override
State<EditInfoPage> createState() => _EditInfoPageState();
}
class _EditInfoPageState extends State<EditInfoPage> {
late StreamSubscription subscription;
final MeModel _viewModel = MeModel();
@override
void initState() {
// TODO: implement initState
super.initState();
subscription = _viewModel.streamController.stream.listen((event) {
String code = event['code'];
if (code.isNotEmpty) {
switch (code) {
case "updateUserNickName":
EasyLoading.showToast("修改成功");
EventBusUtil.fire(RefreshUserdata());
break;
}
}
});
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
subscription.cancel();
}
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final h50 = size.width / 7.2;
final s16 = size.width / 22.5;
final l14 = size.width / 25.71428571428571;
final w19 = size.width / 18.94736842105263;
final h26 = size.width / 13.84615384615385;
final h60 = size.width / 6;
final t18 = size.width / 20;
final l15 = size.width / 24;
final l23 = size.width / 15.65217391304348;
return Scaffold(
backgroundColor: const Color(0xFF17181A),
body: Column(
children: [
Container(
width: size.width,
height: h50,
margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
child: Stack(
alignment: Alignment.center,
children: [
Text(
"编辑个人信息",
style: TextStyle(fontSize: s16, color: const Color(0xFFD6D6D7)),
),
Positioned(
left: l14,
child: GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Image(
width: w19,
height: h26,
image: const AssetImage('assets/images/btn_fanhui.png'),
),
),
)
],
),
),
// Container(
// height: h60,
// margin: EdgeInsets.only(top: t18, left: l15, right: l15),
// decoration: const BoxDecoration(
// color: Color(0xFF202530),
// borderRadius: BorderRadius.all(Radius.circular(11)),
// ),
// child: Row(
// children: [
// 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(
// height: h60,
// margin: EdgeInsets.only(top: t18, left: l15, right: l15),
// decoration: const BoxDecoration(
// color: Color(0xFF202530),
// borderRadius: BorderRadius.all(Radius.circular(11)),
// ),
// child: Row(
// children: [
// 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'),
// ),
// ),
// ],
// ),
// ),
GestureDetector(
onTap: () {
FunctionUtil.popDialog(context, ChangeNicknameDialog(
onTap: (value) {
_viewModel.updateUserNickName(value);
},
));
},
child: Container(
height: h60,
margin: EdgeInsets.only(top: t18, left: l15, right: l15),
decoration: const BoxDecoration(
color: Color(0xFF202530),
borderRadius: BorderRadius.all(Radius.circular(11)),
),
child: Row(
children: [
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(
height: h60,
margin: EdgeInsets.only(top: t18, left: l15, right: l15),
decoration: const BoxDecoration(
color: Color(0xFF202530),
borderRadius: BorderRadius.all(Radius.circular(11)),
),
child: Row(
children: [
Container(
margin: EdgeInsets.only(left: l14),
child: const Text(
"ID",
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
),
),
Expanded(child: Container()),
Container(
margin: EdgeInsets.only(right: l23),
child: Text(
"${NetworkConfig.userInfoBean?.userId}",
style: const TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
),
),
],
),
),
],
),
);
}
}