mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-06 17:08:29 +08:00
完善加载时的动画
This commit is contained in:
parent
5a3fc8753e
commit
18552f20d0
@ -11,6 +11,8 @@ class _SetHostDialogState extends State<_SetHostDialog> {
|
|||||||
final hostEditingController =
|
final hostEditingController =
|
||||||
TextEditingController(text: MaxKeyPersistent.instance.host);
|
TextEditingController(text: MaxKeyPersistent.instance.host);
|
||||||
|
|
||||||
|
bool isTesting = false;
|
||||||
|
|
||||||
/// true: 连接成功;false:链接失败
|
/// true: 连接成功;false:链接失败
|
||||||
bool testResult = true;
|
bool testResult = true;
|
||||||
String? testDesc;
|
String? testDesc;
|
||||||
@ -35,11 +37,17 @@ class _SetHostDialogState extends State<_SetHostDialog> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
TextButton(
|
TextButton.icon(
|
||||||
onPressed: () async {
|
onPressed: isTesting
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
setState(() {
|
||||||
|
isTesting = true;
|
||||||
|
});
|
||||||
final result = await MaxKey.instance
|
final result = await MaxKey.instance
|
||||||
.maxKeyNetworkTest(host: hostEditingController.text);
|
.maxKeyNetworkTest(host: hostEditingController.text);
|
||||||
setState(() {
|
setState(() {
|
||||||
|
isTesting = false;
|
||||||
testResult = result;
|
testResult = result;
|
||||||
testDesc = result
|
testDesc = result
|
||||||
? AppLocalizations.of(context)!
|
? AppLocalizations.of(context)!
|
||||||
@ -48,13 +56,22 @@ class _SetHostDialogState extends State<_SetHostDialog> {
|
|||||||
.settingsPageHostSettingDialogTestFail;
|
.settingsPageHostSettingDialogTestFail;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.settingsPageHostSettingDialogTestBtn),
|
icon: isTesting
|
||||||
|
? const SizedBox(
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
label: Text(AppLocalizations.of(context)!
|
||||||
|
.settingsPageHostSettingDialogTestBtn),
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: Navigator.of(context).pop,
|
onPressed: Navigator.of(context).pop,
|
||||||
child: Text(AppLocalizations.of(context)!.settingsPageHostSettingDialogCancleBtn),
|
child: Text(AppLocalizations.of(context)!
|
||||||
|
.settingsPageHostSettingDialogCancleBtn),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8.0),
|
const SizedBox(width: 8.0),
|
||||||
TextButton(
|
TextButton(
|
||||||
@ -66,7 +83,8 @@ class _SetHostDialogState extends State<_SetHostDialog> {
|
|||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.settingsPageHostSettingDialogConfirmBtn),
|
child: Text(AppLocalizations.of(context)!
|
||||||
|
.settingsPageHostSettingDialogConfirmBtn),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@ -34,7 +34,7 @@ class UserPage extends StatelessWidget {
|
|||||||
_UserCard(user: user!),
|
_UserCard(user: user!),
|
||||||
_UserPageButtonTile(
|
_UserPageButtonTile(
|
||||||
title: AppLocalizations.of(context)!.userPageUserInfoBtn,
|
title: AppLocalizations.of(context)!.userPageUserInfoBtn,
|
||||||
trailing: Icons.info,
|
trailing: const Icon(Icons.info),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final userInfo = await MaxKey.instance.usersService
|
final userInfo = await MaxKey.instance.usersService
|
||||||
.getFullUserInfo();
|
.getFullUserInfo();
|
||||||
@ -55,23 +55,13 @@ class UserPage extends StatelessWidget {
|
|||||||
const SizedBox(height: 8.0),
|
const SizedBox(height: 8.0),
|
||||||
_UserPageButtonTile(
|
_UserPageButtonTile(
|
||||||
title: AppLocalizations.of(context)!.userPageSettingsBtn,
|
title: AppLocalizations.of(context)!.userPageSettingsBtn,
|
||||||
trailing: Icons.settings,
|
trailing: const Icon(Icons.settings),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.push(RoutePath.settingsPage);
|
context.push(RoutePath.settingsPage);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8.0),
|
const SizedBox(height: 8.0),
|
||||||
_UserPageButtonTile(
|
const _LogoutBtn(),
|
||||||
title: AppLocalizations.of(context)!.userPageLogoutBtn,
|
|
||||||
trailing: Icons.logout,
|
|
||||||
onTap: () async {
|
|
||||||
await MaxKey.instance.authnService.logout();
|
|
||||||
|
|
||||||
if (context.mounted) {
|
|
||||||
context.pushReplacement(RoutePath.loginPage);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -79,17 +69,56 @@ class UserPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _LogoutBtn extends StatefulWidget {
|
||||||
|
const _LogoutBtn({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_LogoutBtn> createState() => _LogoutBtnState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LogoutBtnState extends State<_LogoutBtn> {
|
||||||
|
bool isLogouting = false;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return _UserPageButtonTile(
|
||||||
|
title: AppLocalizations.of(context)!.userPageLogoutBtn,
|
||||||
|
trailing: isLogouting
|
||||||
|
? const SizedBox(
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
|
)
|
||||||
|
: const Icon(Icons.logout),
|
||||||
|
onTap: isLogouting
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
setState(() {
|
||||||
|
isLogouting = true;
|
||||||
|
});
|
||||||
|
await MaxKey.instance.authnService.logout();
|
||||||
|
setState(() {
|
||||||
|
isLogouting = false;
|
||||||
|
});
|
||||||
|
if (context.mounted) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
context.pushReplacement(RoutePath.loginPage);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _UserPageButtonTile extends StatelessWidget {
|
class _UserPageButtonTile extends StatelessWidget {
|
||||||
const _UserPageButtonTile({
|
const _UserPageButtonTile({
|
||||||
super.key,
|
super.key,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.trailing,
|
required this.trailing,
|
||||||
required this.onTap,
|
this.onTap,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
final IconData trailing;
|
final Widget trailing;
|
||||||
final void Function() onTap;
|
final void Function()? onTap;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -100,7 +129,7 @@ class _UserPageButtonTile extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
tileColor: scheme.surfaceContainer,
|
tileColor: scheme.surfaceContainer,
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
trailing: Icon(trailing),
|
trailing: trailing,
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user