111 lines
3.2 KiB
Dart
111 lines
3.2 KiB
Dart
import 'package:chat/configs/app_colors.dart';
|
|
import 'package:chat/routes/user_routes.dart';
|
|
import 'package:chat/services/auth_service.dart';
|
|
import 'package:chat/utils/ui_tools.dart';
|
|
import 'package:chat/views/home/widgets/action_item.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
class UserSettingSafePage extends StatefulWidget {
|
|
const UserSettingSafePage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<UserSettingSafePage> createState() => _UserSettingSafePageState();
|
|
}
|
|
|
|
class _UserSettingSafePageState extends State<UserSettingSafePage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('安全设置'),
|
|
),
|
|
body: GetX<AuthService>(builder: (_) {
|
|
return Column(
|
|
children: [
|
|
ActionItem(
|
|
'导出助记词',
|
|
isFirst: true,
|
|
isLast: true,
|
|
onTap: _showMnemonic,
|
|
),
|
|
const SizedBox(height: 8),
|
|
ActionItem(
|
|
'绑定手机',
|
|
extend: _.userInfo.value.mobile ?? '未绑定',
|
|
isFirst: true,
|
|
onTap: () {
|
|
Get.toNamed(UserRoutes.settingSafeMobile);
|
|
},
|
|
),
|
|
ActionItem(
|
|
'绑定邮箱',
|
|
extend: _.userInfo.value.email ?? '未绑定',
|
|
isLast: true,
|
|
onTap: () {
|
|
Get.toNamed(UserRoutes.settingSafeEmail);
|
|
},
|
|
),
|
|
const SizedBox(height: 8),
|
|
ActionItem(
|
|
'开启两步验证',
|
|
extend: (_.userInfo.value.google2fa ?? false) ? '已开启' : '未开启',
|
|
isFirst: true,
|
|
isLast: true,
|
|
onTap: () {
|
|
Get.toNamed(UserRoutes.settingSafeGoogle);
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}),
|
|
);
|
|
}
|
|
|
|
void _showMnemonic() {
|
|
showModalBottomSheet(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
backgroundColor: AppColors.white,
|
|
shape: const RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(8)),
|
|
),
|
|
builder: (context) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const SizedBox(height: 16),
|
|
const Text('您的助记词'),
|
|
Container(
|
|
padding: const EdgeInsets.all(32),
|
|
child: Text(
|
|
AuthService.to.mnemonic,
|
|
style: const TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w500,
|
|
wordSpacing: 6,
|
|
height: 2,
|
|
),
|
|
),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
Clipboard.setData(
|
|
ClipboardData(
|
|
text: AuthService.to.mnemonic,
|
|
),
|
|
);
|
|
UiTools.toast('复制成功');
|
|
Get.back();
|
|
},
|
|
child: const Text('复制'),
|
|
),
|
|
const SizedBox(height: 16),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|