169 lines
5.7 KiB
Dart
169 lines
5.7 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
import 'package:yumi/app_localizations.dart';
|
|
import 'package:yumi/ui_kit/components/text/sc_text.dart';
|
|
import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
|
|
|
|
import 'package:yumi/ui_kit/components/appbar/socialchat_appbar.dart';
|
|
import 'package:yumi/ui_kit/components/dialog/dialog_base.dart';
|
|
|
|
import '../../../../../app/constants/sc_global_config.dart';
|
|
|
|
///删除账户
|
|
class DeleteAccountPage extends StatefulWidget {
|
|
@override
|
|
_DeleteAccountPageState createState() => _DeleteAccountPageState();
|
|
}
|
|
|
|
class _DeleteAccountPageState extends State<DeleteAccountPage> {
|
|
int delay = 30;
|
|
bool canClick = false;
|
|
String btnText = "";
|
|
Timer? _timer;
|
|
BuildContext? ct;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_timer = Timer.periodic(Duration(seconds: 1), (timer) {
|
|
if (delay == 0) {
|
|
canClick = true;
|
|
_timer?.cancel();
|
|
btnText = SCAppLocalizations.of(ct!)!.deleteAccount;
|
|
} else {
|
|
delay--;
|
|
btnText = SCAppLocalizations.of(ct!)!.deleteAccount2("$delay");
|
|
}
|
|
setState(() {});
|
|
});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_timer?.cancel();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
ct = context;
|
|
return Stack(
|
|
children: [
|
|
Image.asset(
|
|
SCGlobalConfig.businessLogicStrategy.getRechargePageBackgroundImage(),
|
|
width: ScreenUtil().screenWidth,
|
|
fit: BoxFit.fill,
|
|
),
|
|
|
|
Scaffold(
|
|
backgroundColor: Colors.transparent,
|
|
resizeToAvoidBottomInset: false,
|
|
appBar: SocialChatStandardAppBar(
|
|
title: SCAppLocalizations.of(context)!.deleteAccount,
|
|
actions: [],
|
|
),
|
|
body: SafeArea(
|
|
top: false,
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 10.w),
|
|
text(
|
|
SCAppLocalizations.of(context)!.accountDeletionNotice,
|
|
fontSize: 14.sp,
|
|
textColor: Colors.white38,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 10.w),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 10.w),
|
|
Expanded(
|
|
child: text(
|
|
SCAppLocalizations.of(context)!.deleteAccountTips,
|
|
fontSize: 12.sp,
|
|
maxLines: 30,
|
|
textColor: Colors.white,
|
|
),
|
|
),
|
|
SizedBox(width: 10.w),
|
|
],
|
|
),
|
|
SizedBox(height: 10.w),
|
|
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 10.w),
|
|
Expanded(
|
|
child: text(
|
|
SCAppLocalizations.of(context)!.deleteAccountTips2,
|
|
fontSize: 12.sp,
|
|
maxLines: 30,
|
|
textColor: Colors.white38,
|
|
),
|
|
),
|
|
SizedBox(width: 10.w),
|
|
],
|
|
),
|
|
SizedBox(height: 35.w),
|
|
GestureDetector(
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(25),
|
|
color: !canClick ? Colors.black26 : Colors.red,
|
|
),
|
|
width: 275.w,
|
|
height: 46.w,
|
|
child: text(
|
|
btnText.isEmpty
|
|
? SCAppLocalizations.of(
|
|
context,
|
|
)!.deleteAccount2("30")
|
|
: btnText,
|
|
fontSize: 15.sp,
|
|
textColor: Colors.white,
|
|
),
|
|
),
|
|
onTap: () {
|
|
if (canClick) {
|
|
SmartDialog.show(
|
|
tag: "showConfirmDialog",
|
|
alignment: Alignment.center,
|
|
debounce: true,
|
|
animationType: SmartAnimationType.fade,
|
|
builder: (_) {
|
|
return MsgDialog(
|
|
title: SCAppLocalizations.of(context)!.tips,
|
|
msg:
|
|
SCAppLocalizations.of(
|
|
context,
|
|
)!.areYouSureYouWantToDeleteYourAccount,
|
|
btnText: SCAppLocalizations.of(context)!.delete,
|
|
onEnsure: () {
|
|
AccountStorage().logout(context);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|