diff --git a/lib/common/widgets/radio_widget.dart b/lib/common/widgets/radio_widget.dart index 7f9a35c4a..852437c81 100644 --- a/lib/common/widgets/radio_widget.dart +++ b/lib/common/widgets/radio_widget.dart @@ -1,3 +1,4 @@ +import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:flutter/material.dart'; class RadioWidget extends StatefulWidget { @@ -61,17 +62,13 @@ class RadioWidgetState extends State> with RadioClient { final child = Row( mainAxisSize: widget.mainAxisSize, children: [ - Focus( - parentNode: focusNode, - canRequestFocus: false, - skipTraversal: true, - includeSemantics: true, - descendantsAreFocusable: false, - descendantsAreTraversable: false, + ExcludeFocus( child: Radio( value: radioValue, groupRegistry: _radioRegistry, - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + materialTapTargetSize: PlatformUtils.isDesktop + ? .padded + : .shrinkWrap, ), ), Text(widget.title), diff --git a/lib/pages/login/controller.dart b/lib/pages/login/controller.dart index 5debcee03..a2a1496d2 100644 --- a/lib/pages/login/controller.dart +++ b/lib/pages/login/controller.dart @@ -737,57 +737,119 @@ class LoginPageController extends GetxController (k, v) => MapEntry(v, k as String), ), }; + bool quickSelect = selectAccount.every((e) => e == selectAccount.first); return showDialog( context: context, - builder: (context) => AlertDialog( - title: const Text('选择账号mid, 为0时使用匿名'), - titlePadding: const .only(left: 22, top: 16, right: 22), - contentPadding: const .symmetric(vertical: 5), - actionsPadding: const .only(left: 16, right: 16, bottom: 10), - content: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: AccountType.values - .map( - (e) => Builder( - builder: (context) => RadioGroup( - groupValue: selectAccount[e.index], - onChanged: (v) { - selectAccount[e.index] = v!; - (context as Element).markNeedsBuild(); - }, - child: WrapRadioOptionsGroup( - groupTitle: e.title, - options: options, + builder: (context) => Builder( + builder: (context) => AlertDialog( + title: Row( + crossAxisAlignment: .start, + mainAxisAlignment: .spaceBetween, + children: [ + Text.rich( + style: const TextStyle(height: 1.5), + TextSpan( + children: [ + const TextSpan(text: '账号切换'), + TextSpan( + text: '\nmid 为0时使用匿名', + style: TextStyle( + fontSize: 14, + color: ColorScheme.of(context).outline, ), ), - ), - ) - .toList(), - ), - ), - actions: [ - TextButton( - onPressed: Get.back, - child: Text( - '取消', - style: TextStyle( - color: Theme.of(context).colorScheme.outline, + ], + ), ), + TextButton( + onPressed: () { + quickSelect = !quickSelect; + (context as Element).markNeedsBuild(); + }, + child: const Text('切换'), + ), + ], + ), + titlePadding: const .only(left: 22, top: 16, right: 22, bottom: 3), + contentPadding: const .symmetric(vertical: 5), + actionsPadding: const .only(left: 16, right: 16, bottom: 10), + content: SingleChildScrollView( + child: AnimatedSize( + curve: Curves.easeIn, + alignment: .topCenter, + duration: const Duration(milliseconds: 200), + child: quickSelect + ? Builder( + builder: (context) => RadioGroup( + groupValue: selectAccount[0], + onChanged: (v) { + for (int i = 0; i < selectAccount.length; i++) { + selectAccount[i] = v!; + } + (context as Element).markNeedsBuild(); + }, + child: Column( + crossAxisAlignment: .start, + children: options.entries + .map( + (entry) => RadioWidget( + value: entry.key, + title: entry.value, + mainAxisSize: .max, + padding: const .only(left: 12), + ), + ) + .toList(), + ), + ), + ) + : Column( + crossAxisAlignment: .start, + children: AccountType.values + .map( + (e) => Builder( + builder: (context) => RadioGroup( + groupValue: selectAccount[e.index], + onChanged: (v) { + selectAccount[e.index] = v!; + (context as Element).markNeedsBuild(); + }, + child: WrapRadioOptionsGroup( + groupTitle: e.title, + options: options, + ), + ), + ), + ) + .toList(), + ), ), ), - TextButton( - onPressed: () { - for (final (i, v) in selectAccount.indexed) { - if (v != Accounts.accountMode[i]) { - Accounts.set(AccountType.values[i], v); + actions: [ + TextButton( + onPressed: Get.back, + child: Text( + '取消', + style: TextStyle(color: ColorScheme.of(context).outline), + ), + ), + TextButton( + onPressed: () { + Get.back(); + for (final type in AccountType.values) { + final index = type.index; + final account = quickSelect + ? selectAccount.first + : selectAccount[index]; + if (account != Accounts.accountMode[index]) { + Accounts.set(type, account); + } } - } - Get.back(); - }, - child: const Text('确定'), - ), - ], + }, + child: const Text('确定'), + ), + ], + ), ), ); }