opt select account (#1815)

* feat: switchAccountDialog pages simple-detaile

* update

Signed-off-by: dom <githubaccount56556@proton.me>

---------

Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
систем
2026-01-29 22:06:10 +08:00
committed by GitHub
parent 058ff44e39
commit 9442b17d63
2 changed files with 110 additions and 51 deletions

View File

@@ -1,3 +1,4 @@
import 'package:PiliPlus/utils/platform_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class RadioWidget<T> extends StatefulWidget { class RadioWidget<T> extends StatefulWidget {
@@ -61,17 +62,13 @@ class RadioWidgetState<T> extends State<RadioWidget<T>> with RadioClient<T> {
final child = Row( final child = Row(
mainAxisSize: widget.mainAxisSize, mainAxisSize: widget.mainAxisSize,
children: [ children: [
Focus( ExcludeFocus(
parentNode: focusNode,
canRequestFocus: false,
skipTraversal: true,
includeSemantics: true,
descendantsAreFocusable: false,
descendantsAreTraversable: false,
child: Radio<T>( child: Radio<T>(
value: radioValue, value: radioValue,
groupRegistry: _radioRegistry, groupRegistry: _radioRegistry,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: PlatformUtils.isDesktop
? .padded
: .shrinkWrap,
), ),
), ),
Text(widget.title), Text(widget.title),

View File

@@ -737,20 +737,78 @@ class LoginPageController extends GetxController
(k, v) => MapEntry(v, k as String), (k, v) => MapEntry(v, k as String),
), ),
}; };
bool quickSelect = selectAccount.every((e) => e == selectAccount.first);
return showDialog( return showDialog(
context: context, context: context,
builder: (context) => Builder(
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
title: const Text('选择账号mid, 为0时使用匿名'), title: Row(
titlePadding: const .only(left: 22, top: 16, right: 22), 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,
),
),
],
),
),
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), contentPadding: const .symmetric(vertical: 5),
actionsPadding: const .only(left: 16, right: 16, bottom: 10), actionsPadding: const .only(left: 16, right: 16, bottom: 10),
content: SingleChildScrollView( content: SingleChildScrollView(
child: AnimatedSize(
curve: Curves.easeIn,
alignment: .topCenter,
duration: const Duration(milliseconds: 200),
child: quickSelect
? Builder(
builder: (context) => RadioGroup<Account>(
groupValue: selectAccount[0],
onChanged: (v) {
for (int i = 0; i < selectAccount.length; i++) {
selectAccount[i] = v!;
}
(context as Element).markNeedsBuild();
},
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: .start,
children: options.entries
.map(
(entry) => RadioWidget<Account>(
value: entry.key,
title: entry.value,
mainAxisSize: .max,
padding: const .only(left: 12),
),
)
.toList(),
),
),
)
: Column(
crossAxisAlignment: .start,
children: AccountType.values children: AccountType.values
.map( .map(
(e) => Builder( (e) => Builder(
builder: (context) => RadioGroup( builder: (context) => RadioGroup<Account>(
groupValue: selectAccount[e.index], groupValue: selectAccount[e.index],
onChanged: (v) { onChanged: (v) {
selectAccount[e.index] = v!; selectAccount[e.index] = v!;
@@ -766,29 +824,33 @@ class LoginPageController extends GetxController
.toList(), .toList(),
), ),
), ),
),
actions: [ actions: [
TextButton( TextButton(
onPressed: Get.back, onPressed: Get.back,
child: Text( child: Text(
'取消', '取消',
style: TextStyle( style: TextStyle(color: ColorScheme.of(context).outline),
color: Theme.of(context).colorScheme.outline,
),
), ),
), ),
TextButton( TextButton(
onPressed: () { onPressed: () {
for (final (i, v) in selectAccount.indexed) {
if (v != Accounts.accountMode[i]) {
Accounts.set(AccountType.values[i], v);
}
}
Get.back(); 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);
}
}
}, },
child: const Text('确定'), child: const Text('确定'),
), ),
], ],
), ),
),
); );
} }
} }