Refactor UI components for improved layout and consistency

This commit is contained in:
wanghongenpin
2026-01-21 17:27:16 +08:00
parent ed6942eabd
commit 7008072a70
2 changed files with 19 additions and 28 deletions

View File

@@ -628,6 +628,7 @@ class _CryptoRuleDialogState extends State<CryptoRuleDialog> {
Row(children: [
Container(
height: 42,
width: 92,
padding: const EdgeInsets.symmetric(horizontal: 6),
decoration: BoxDecoration(
border: Border.all(color: Theme.of(context).dividerColor.withAlpha((0.12 * 255).round())),
@@ -647,7 +648,6 @@ class _CryptoRuleDialogState extends State<CryptoRuleDialog> {
),
),
const SizedBox(width: 12),
Expanded(
child: SizedBox(
child: TextFormField(
@@ -658,7 +658,6 @@ class _CryptoRuleDialogState extends State<CryptoRuleDialog> {
),
),
),
]),
const SizedBox(height: 12),
// Compact single-line IV controls for CBC
@@ -666,6 +665,7 @@ class _CryptoRuleDialogState extends State<CryptoRuleDialog> {
Row(children: [
Container(
height: 42,
constraints: const BoxConstraints(minWidth: 92),
padding: const EdgeInsets.symmetric(horizontal: 6),
decoration: BoxDecoration(
border: Border.all(color: Theme.of(context).dividerColor.withAlpha((0.12 * 255).round())),

View File

@@ -172,10 +172,8 @@ class _MobileRequestCryptoPageState extends State<MobileRequestCryptoPage> {
})),
const SizedBox(width: 20),
Expanded(
child: Text(
rule.urlPattern.isEmpty ? l10n.emptyMatchAll : rule.urlPattern,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 13))),
child: Text(rule.urlPattern.isEmpty ? l10n.emptyMatchAll : rule.urlPattern,
overflow: TextOverflow.ellipsis, style: const TextStyle(fontSize: 13))),
])));
}))
])),
@@ -214,9 +212,7 @@ class _MobileRequestCryptoPageState extends State<MobileRequestCryptoPage> {
icon: const Icon(Icons.share, size: 18),
label: Text(l10n.export, style: const TextStyle(fontSize: 14))),
TextButton.icon(
onPressed: selected.isEmpty
? null
: () => _removeSelected(),
onPressed: selected.isEmpty ? null : () => _removeSelected(),
icon: const Icon(Icons.delete, size: 18),
label: Text(l10n.delete, style: const TextStyle(fontSize: 14))),
TextButton.icon(
@@ -233,9 +229,7 @@ class _MobileRequestCryptoPageState extends State<MobileRequestCryptoPage> {
}
Future<void> _addRule(RequestCryptoManager manager) async {
Navigator.of(context)
.push(MaterialPageRoute(builder: (_) => const MobileCryptoRuleEditPage()))
.then((value) {
Navigator.of(context).push(MaterialPageRoute(builder: (_) => const MobileCryptoRuleEditPage())).then((value) {
if (value != null && mounted) {
setState(() {});
_refreshConfig(force: true);
@@ -245,9 +239,7 @@ class _MobileRequestCryptoPageState extends State<MobileRequestCryptoPage> {
Future<void> _editRule(RequestCryptoManager manager, int index) async {
final rule = manager.rules[index];
Navigator.of(context)
.push(MaterialPageRoute(builder: (_) => MobileCryptoRuleEditPage(rule: rule)))
.then((value) {
Navigator.of(context).push(MaterialPageRoute(builder: (_) => MobileCryptoRuleEditPage(rule: rule))).then((value) {
if (value != null && mounted) {
setState(() {});
_refreshConfig(force: true);
@@ -348,7 +340,8 @@ class _MobileRequestCryptoPageState extends State<MobileRequestCryptoPage> {
Future<void> _import(RequestCryptoManager manager) async {
try {
FilePickerResult? result = await FilePicker.platform.pickFiles(type: FileType.custom, allowedExtensions: ['json']);
FilePickerResult? result =
await FilePicker.platform.pickFiles(type: FileType.custom, allowedExtensions: ['json']);
final path = result?.files.single.path;
if (path == null) return;
final content = await File(path).readAsString();
@@ -385,7 +378,6 @@ class _MobileRequestCryptoPageState extends State<MobileRequestCryptoPage> {
}
}
/// Mobile editor page for a single crypto rule.
///
/// This mirrors the mobile rewrite editor pattern: push to a page, edit, and save.
@@ -635,12 +627,12 @@ class _MobileCryptoRuleEditPageState extends State<MobileCryptoRuleEditPage> {
Expanded(
child: ivSource == 'manual'
? TextFormField(
controller: ivController,
decoration: _decorate('IV'),
validator: (val) => (ivSource == 'manual' && (val == null || val.trim().isEmpty))
? l10n.cannotBeEmpty
: null,
)
controller: ivController,
decoration: _decorate('IV'),
validator: (val) => (ivSource == 'manual' && (val == null || val.trim().isEmpty))
? l10n.cannotBeEmpty
: null,
)
: _ivPrefixLengthEditor(),
),
],
@@ -691,11 +683,11 @@ class _MobileCryptoRuleEditPageState extends State<MobileCryptoRuleEditPage> {
}) {
return Container(
height: 40,
padding: const EdgeInsets.symmetric(horizontal: 10),
constraints: const BoxConstraints(minWidth: 95),
padding: const EdgeInsets.symmetric(horizontal: 6),
decoration: BoxDecoration(
border: Border.all(color: Theme.of(context).dividerColor.withValues(alpha: 0.25)),
borderRadius: BorderRadius.circular(8),
),
border: Border.all(color: Theme.of(context).dividerColor.withValues(alpha: 0.25)),
borderRadius: BorderRadius.circular(6)),
child: DropdownButtonHideUnderline(
child: DropdownButton<T>(
value: value,
@@ -785,4 +777,3 @@ class _MobileCryptoRuleEditPageState extends State<MobileCryptoRuleEditPage> {
Navigator.of(context).pop(updated);
}
}