106 lines
3.5 KiB
Dart
106 lines
3.5 KiB
Dart
|
|
import 'package:fcs/domain/entities/setting.dart';
|
||
|
|
import 'package:fcs/helpers/theme.dart';
|
||
|
|
import 'package:fcs/pages/main/model/main_model.dart';
|
||
|
|
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
||
|
|
import 'package:flutter/material.dart';
|
||
|
|
import 'package:flutter_markdown/flutter_markdown.dart';
|
||
|
|
import 'package:provider/provider.dart';
|
||
|
|
|
||
|
|
import '../main/model/language_model.dart';
|
||
|
|
import '../main/util.dart';
|
||
|
|
import '../widgets/local_text.dart';
|
||
|
|
|
||
|
|
class AccountDelectionPage extends StatefulWidget {
|
||
|
|
final Function onlogout;
|
||
|
|
const AccountDelectionPage({Key? key, required this.onlogout})
|
||
|
|
: super(key: key);
|
||
|
|
@override
|
||
|
|
_AccountDelectionPageState createState() => _AccountDelectionPageState();
|
||
|
|
}
|
||
|
|
|
||
|
|
class _AccountDelectionPageState extends State<AccountDelectionPage> {
|
||
|
|
bool _isLoading = false;
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
bool isEng = Provider.of<LanguageModel>(context).isEng;
|
||
|
|
Setting? setting = Provider.of<MainModel>(context).setting;
|
||
|
|
String? text = isEng
|
||
|
|
? (setting!.deactivateTextEn ?? "")
|
||
|
|
: (setting!.deactivateTextMm ?? "");
|
||
|
|
|
||
|
|
return LocalProgress(
|
||
|
|
inAsyncCall: _isLoading,
|
||
|
|
child: Scaffold(
|
||
|
|
appBar: LocalAppBar(
|
||
|
|
labelKey: 'profile.delete.title',
|
||
|
|
backgroundColor: Colors.white,
|
||
|
|
labelColor: primaryColor,
|
||
|
|
arrowColor: primaryColor,
|
||
|
|
),
|
||
|
|
body: SafeArea(
|
||
|
|
child: ScrollConfiguration(
|
||
|
|
behavior: const ScrollBehavior().copyWith(overscroll: false),
|
||
|
|
child: ListView(
|
||
|
|
padding: const EdgeInsets.all(10),
|
||
|
|
children: [
|
||
|
|
Markdown(
|
||
|
|
shrinkWrap: true,
|
||
|
|
softLineBreak: true,
|
||
|
|
physics: const BouncingScrollPhysics(),
|
||
|
|
data: (text).replaceAll("\\n", '\n'),
|
||
|
|
styleSheet: MarkdownStyleSheet.fromTheme(ThemeData(
|
||
|
|
textTheme: TextTheme(
|
||
|
|
bodyMedium: TextStyle(
|
||
|
|
fontSize: isEng ? 15 : 14,
|
||
|
|
color: Colors.black87))))),
|
||
|
|
const SizedBox(
|
||
|
|
height: 50,
|
||
|
|
),
|
||
|
|
Container(
|
||
|
|
padding: const EdgeInsets.all(20),
|
||
|
|
child: TextButton(
|
||
|
|
style: TextButton.styleFrom(
|
||
|
|
foregroundColor: buttonColor,
|
||
|
|
backgroundColor: primaryColor,
|
||
|
|
shape: RoundedRectangleBorder(
|
||
|
|
borderRadius: BorderRadius.circular(30.0),
|
||
|
|
)),
|
||
|
|
onPressed: () {
|
||
|
|
showConfirmDialog(context, 'delete.confirm.label',
|
||
|
|
() {
|
||
|
|
_deactivate();
|
||
|
|
});
|
||
|
|
},
|
||
|
|
child: LocalText(context, "btn.delete",
|
||
|
|
fontSize: 15, color: buttonColor))),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
_deactivate() async {
|
||
|
|
try {
|
||
|
|
setState(() {
|
||
|
|
_isLoading = true;
|
||
|
|
});
|
||
|
|
|
||
|
|
// await context.read<MainModel>().deleteAccount();
|
||
|
|
// await widget.onlogout();
|
||
|
|
|
||
|
|
Navigator.pop(context, true);
|
||
|
|
} catch (e) {
|
||
|
|
showMsgDialog(context, "Error", e.toString());
|
||
|
|
} finally {
|
||
|
|
if (mounted) {
|
||
|
|
setState(() {
|
||
|
|
_isLoading = false;
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|