手机号显示开关添加提示

master
laiiihz 4 years ago
parent c4fe7d6cf6
commit 6a84d9fdd5

@ -57,14 +57,7 @@ class _AccountAndSafetyPageState extends State<AccountAndSafetyPage> {
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 6.w), padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 6.w),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () async { onPressed: () async {
final cancel = ReToast.loading(text: '修改中'); await _updateSwitchState();
secureValue = !secureValue;
await HttpManager.post(
APIV2.userAPI.securePhone,
{'secure': secureValue ? 1 : 0},
);
cancel();
setState(() {});
}, },
child: Row( child: Row(
children: [ children: [
@ -83,12 +76,7 @@ class _AccountAndSafetyPageState extends State<AccountAndSafetyPage> {
value: secureValue, value: secureValue,
trackColor: Color(0xFFDB2D2D), trackColor: Color(0xFFDB2D2D),
onChanged: (state) async { onChanged: (state) async {
final cancel = ReToast.loading(text: '修改中'); await _updateSwitchState();
secureValue = !secureValue;
await HttpManager.post(APIV2.userAPI.securePhone,
{'secure': secureValue ? 1 : 0});
cancel();
setState(() {});
}, },
), ),
], ],
@ -99,6 +87,18 @@ class _AccountAndSafetyPageState extends State<AccountAndSafetyPage> {
); );
} }
_updateSwitchState() async {
final cancel = ReToast.loading(text: '修改中');
secureValue = !secureValue;
await HttpManager.post(
APIV2.userAPI.securePhone,
{'secure': secureValue ? 1 : 0},
);
cancel();
ReToast.success(text: '修改成功');
setState(() {});
}
_backButton(context) { _backButton(context) {
if (Navigator.canPop(context)) { if (Navigator.canPop(context)) {
return IconButton( return IconButton(

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:recook/widgets/alert.dart';
import 'package:recook/widgets/progress/loading_dialog.dart'; import 'package:recook/widgets/progress/loading_dialog.dart';
@ -24,6 +25,17 @@ class ReToast {
); );
} }
static Function success({String text}) {
return BotToast.showCustomText(
toastBuilder: (func) {
return StatusDialog(
status: Status.success,
text: text ?? '',
);
},
);
}
static Function raw(Widget child) => BotToast.showCustomLoading( static Function raw(Widget child) => BotToast.showCustomLoading(
toastBuilder: (func) => child, toastBuilder: (func) => child,
enableKeyboardSafeArea: false, enableKeyboardSafeArea: false,

Loading…
Cancel
Save