mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 16:18:22 +08:00
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:
@@ -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),
|
||||||
|
|||||||
@@ -737,57 +737,119 @@ 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) => AlertDialog(
|
builder: (context) => Builder(
|
||||||
title: const Text('选择账号mid, 为0时使用匿名'),
|
builder: (context) => AlertDialog(
|
||||||
titlePadding: const .only(left: 22, top: 16, right: 22),
|
title: Row(
|
||||||
contentPadding: const .symmetric(vertical: 5),
|
crossAxisAlignment: .start,
|
||||||
actionsPadding: const .only(left: 16, right: 16, bottom: 10),
|
mainAxisAlignment: .spaceBetween,
|
||||||
content: SingleChildScrollView(
|
children: [
|
||||||
child: Column(
|
Text.rich(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
style: const TextStyle(height: 1.5),
|
||||||
children: AccountType.values
|
TextSpan(
|
||||||
.map(
|
children: [
|
||||||
(e) => Builder(
|
const TextSpan(text: '账号切换'),
|
||||||
builder: (context) => RadioGroup(
|
TextSpan(
|
||||||
groupValue: selectAccount[e.index],
|
text: '\nmid 为0时使用匿名',
|
||||||
onChanged: (v) {
|
style: TextStyle(
|
||||||
selectAccount[e.index] = v!;
|
fontSize: 14,
|
||||||
(context as Element).markNeedsBuild();
|
color: ColorScheme.of(context).outline,
|
||||||
},
|
|
||||||
child: WrapRadioOptionsGroup<Account>(
|
|
||||||
groupTitle: e.title,
|
|
||||||
options: options,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
)
|
),
|
||||||
.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<Account>(
|
||||||
|
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<Account>(
|
||||||
|
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<Account>(
|
||||||
|
groupValue: selectAccount[e.index],
|
||||||
|
onChanged: (v) {
|
||||||
|
selectAccount[e.index] = v!;
|
||||||
|
(context as Element).markNeedsBuild();
|
||||||
|
},
|
||||||
|
child: WrapRadioOptionsGroup<Account>(
|
||||||
|
groupTitle: e.title,
|
||||||
|
options: options,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TextButton(
|
actions: [
|
||||||
onPressed: () {
|
TextButton(
|
||||||
for (final (i, v) in selectAccount.indexed) {
|
onPressed: Get.back,
|
||||||
if (v != Accounts.accountMode[i]) {
|
child: Text(
|
||||||
Accounts.set(AccountType.values[i], v);
|
'取消',
|
||||||
|
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('确定'),
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user