323 lines
11 KiB
Dart
323 lines
11 KiB
Dart
import 'dart:async';
|
||
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter/services.dart';
|
||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
import 'package:get/get.dart';
|
||
|
||
import '../../components/my_app_bar.dart';
|
||
import '../../util/util.dart';
|
||
import 'logic.dart';
|
||
|
||
class OffaccountPage extends StatefulWidget {
|
||
OffaccountPage({Key? key}) : super(key: key);
|
||
|
||
@override
|
||
_OffaccountState createState() => _OffaccountState();
|
||
}
|
||
|
||
class _OffaccountState extends State<OffaccountPage> {
|
||
int countdown = 10; // 初始倒计时时间
|
||
bool isButtonDisabled = false; // 按钮是否禁用
|
||
late Timer timer;
|
||
|
||
@override
|
||
void initState() {
|
||
super.initState();
|
||
startCountdown();
|
||
}
|
||
|
||
@override
|
||
void dispose() {
|
||
timer.cancel();
|
||
super.dispose();
|
||
}
|
||
|
||
void startCountdown() {
|
||
timer = Timer.periodic(const Duration(seconds: 1), (Timer t) {
|
||
setState(() {
|
||
if (countdown > 0) {
|
||
countdown--;
|
||
} else {
|
||
timer.cancel();
|
||
}
|
||
});
|
||
});
|
||
}
|
||
|
||
void handleLogout(OffaccountLogic logic) {
|
||
if(countdown > 0 ){
|
||
|
||
}else{
|
||
logic.offaccount();
|
||
// showToast(logic.state.photoController.text.toString()+"");
|
||
}
|
||
|
||
// 执行注销操作
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return GetBuilder<OffaccountLogic>(builder: (logic) {
|
||
|
||
return Container(
|
||
decoration: BoxDecoration(
|
||
image: DecorationImage(
|
||
image: AssetImage(getBaseImage("home_back")),
|
||
fit: BoxFit.cover,
|
||
),
|
||
),
|
||
child: Scaffold(
|
||
backgroundColor: Colors.transparent,
|
||
appBar: const MyAppBar(centerTitle: '注销账号'),
|
||
body: Scaffold(
|
||
backgroundColor: Colors.transparent,
|
||
body: SingleChildScrollView(
|
||
child: Container(
|
||
padding: EdgeInsets.all(16.sp),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
// 注销提示信息
|
||
Text(
|
||
"注销后,你的账号将",
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 16.sp,
|
||
),
|
||
),
|
||
SizedBox(height: 8.sp),
|
||
Text(
|
||
"1、无法登录app;",
|
||
style: TextStyle(
|
||
color: const Color(0xFFB7BECC),
|
||
fontSize: 12.sp,
|
||
),
|
||
),
|
||
Text(
|
||
"2、所有信息将被永远删除:身份信息、账户信息、会员、喊话、相册等内容;",
|
||
style: TextStyle(
|
||
color: const Color(0xFFB7BECC),
|
||
fontSize: 12.sp,
|
||
),
|
||
),
|
||
Text(
|
||
"3、您的好友无法与你取得联系(包括关注、粉丝等);",
|
||
style: TextStyle(
|
||
color: const Color(0xFFB7BECC),
|
||
fontSize: 12.sp,
|
||
),
|
||
),
|
||
Text(
|
||
"4、注销后,一个月内该手机号将无法注册新的账号。",
|
||
style: TextStyle(
|
||
color: const Color(0xFFB7BECC),
|
||
fontSize: 12.sp,
|
||
),
|
||
),
|
||
SizedBox(height: 10.sp),
|
||
|
||
// 输入手机号或邮箱
|
||
Text(
|
||
"请输入绑定的手机号",
|
||
style: TextStyle(
|
||
color: const Color(0xFF898F99),
|
||
fontSize: 10.sp,
|
||
),
|
||
),
|
||
SizedBox(height: 10.sp),
|
||
TextFormField(
|
||
controller: logic.state.photoController,
|
||
keyboardType: TextInputType.phone,
|
||
inputFormatters: [
|
||
FilteringTextInputFormatter.digitsOnly,
|
||
FilteringTextInputFormatter.deny(RegExp('[^0-9]')),
|
||
],
|
||
decoration: InputDecoration(
|
||
hintText: "请输入手机号",
|
||
hintStyle: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 14.sp,
|
||
),
|
||
filled: true,
|
||
fillColor: const Color(0xFF000000),
|
||
border: OutlineInputBorder(
|
||
borderRadius: BorderRadius.circular(4),
|
||
borderSide: BorderSide.none,
|
||
),
|
||
contentPadding: EdgeInsets.symmetric(horizontal: 16.sp),
|
||
),
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 14.sp,
|
||
),
|
||
// enabled: countdown == 0, // 当倒计时结束后才可编辑
|
||
),
|
||
SizedBox(height: 16.sp),
|
||
|
||
// 选择注销原因
|
||
Text(
|
||
"请选择你的注销原因",
|
||
style: TextStyle(
|
||
color: const Color(0xFF898F99),
|
||
fontSize: 10.sp,
|
||
),
|
||
),
|
||
SizedBox(height: 10.sp),
|
||
GestureDetector(onTap: () {
|
||
showBottomSheetDialog(context,logic);
|
||
},
|
||
child: Container(
|
||
width: double.infinity,
|
||
height: 40.sp,
|
||
margin: EdgeInsets.only(top: 10.sp),
|
||
decoration: BoxDecoration(
|
||
borderRadius: BorderRadius.circular(4.sp),
|
||
color: const Color(0xFF000000),
|
||
),
|
||
child: Row(
|
||
children: [
|
||
Expanded(
|
||
child: TextFormField(
|
||
enabled: false,
|
||
decoration: InputDecoration(
|
||
hintText: logic.state.offReasonMsg,
|
||
hintStyle: TextStyle(
|
||
color: const Color(0xFFF7FAFA),
|
||
fontSize: 14.sp,
|
||
),
|
||
border: InputBorder.none,
|
||
contentPadding: EdgeInsets.only(left: 16.sp),
|
||
),
|
||
style: TextStyle(
|
||
color: const Color(0xFFF7FAFA),
|
||
fontSize: 14.sp,
|
||
),
|
||
),
|
||
),
|
||
Image.asset(
|
||
getHomeImage("icon_in"),
|
||
width: 14.sp,
|
||
height: 14.sp,
|
||
),
|
||
],
|
||
),
|
||
),)
|
||
,
|
||
SizedBox(height: 42.sp),
|
||
|
||
// 注销按钮
|
||
GestureDetector(
|
||
behavior: HitTestBehavior.opaque,
|
||
onTap: () {
|
||
|
||
}, child: Align(
|
||
alignment: Alignment.bottomCenter,
|
||
child: SizedBox(
|
||
width: 160.sp,
|
||
child: ElevatedButton(
|
||
onPressed: (){
|
||
handleLogout(logic);
|
||
},
|
||
style: ButtonStyle(
|
||
backgroundColor: MaterialStateProperty.all<Color>(
|
||
countdown > 0 ? Colors.grey : const Color(0xFF21BEAB),
|
||
),
|
||
shape: MaterialStateProperty.all<OutlinedBorder>(
|
||
RoundedRectangleBorder(
|
||
borderRadius: BorderRadius.circular(17.sp),
|
||
),
|
||
),
|
||
),
|
||
child: Text(
|
||
countdown > 0 ? "注销($countdown s)" : "注销",
|
||
),
|
||
),
|
||
),
|
||
),)
|
||
,
|
||
],
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
);
|
||
});
|
||
}
|
||
|
||
|
||
void showBottomSheetDialog(BuildContext context,OffaccountLogic logic) {
|
||
showModalBottomSheet(
|
||
context: context,
|
||
backgroundColor: Colors.transparent,
|
||
builder: (BuildContext context) {
|
||
return Container(
|
||
decoration: BoxDecoration(
|
||
color: Colors.black.withOpacity(0.6),
|
||
borderRadius: BorderRadius.only(
|
||
topLeft: Radius.circular(20.sp),
|
||
topRight: Radius.circular(20.sp),
|
||
),
|
||
),
|
||
child: Column(
|
||
mainAxisSize: MainAxisSize.min,
|
||
children: [
|
||
buildOptionItem("体验太差", context,logic),
|
||
buildDivider(),
|
||
buildOptionItem("换平台了", context,logic),
|
||
buildDivider(),
|
||
buildOptionItem("担心隐私泄露", context,logic),
|
||
],
|
||
),
|
||
);
|
||
},
|
||
);
|
||
}
|
||
|
||
Widget buildOptionItem(String title, BuildContext context,OffaccountLogic logic) {
|
||
return GestureDetector(
|
||
behavior: HitTestBehavior.opaque,
|
||
onTap: () {
|
||
// 处理选项点击事件
|
||
Navigator.pop(context);
|
||
logic.state.offReasonMsg = title;
|
||
logic.update();
|
||
// 执行相应操作
|
||
// switch (title) {
|
||
// case "体验太差":
|
||
//
|
||
// // 执行体验操作
|
||
// break;
|
||
// case "换平台了":
|
||
// // 执行换平台操作
|
||
// break;
|
||
// case "担心隐私泄露":
|
||
// // 执行泄露隐私操作
|
||
// break;
|
||
// }
|
||
},
|
||
child: Container(
|
||
width: Get.width,
|
||
alignment: Alignment.center,
|
||
padding: EdgeInsets.symmetric(vertical: 16.sp),
|
||
child: Text(
|
||
title,
|
||
style: TextStyle(
|
||
fontSize: 16.sp,
|
||
color: Colors.white,
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget buildDivider() {
|
||
return Container(
|
||
height: 0.5.sp,
|
||
color: const Color(0xff2E2E3B),
|
||
margin: EdgeInsets.symmetric(horizontal: 16.sp),
|
||
);
|
||
}
|
||
|
||
} |