new UI + new targets.

This commit is contained in:
Jan Pleterski
2026-11-27 14:37:44 +01:00
parent 5f9e2a3b86
commit 2fc741a9f6
113 changed files with 6861 additions and 7381 deletions
+65 -52
View File
@@ -1,14 +1,23 @@
import 'package:flutter/material.dart';
import '../services/app_settings.dart';
import '../theme/app_theme.dart';
import 'ui.dart';
/// Dark dialog with one text field. Returns the trimmed text, or null if cancelled.
/// [onReset] adds a secondary button ([resetLabel], default "Reset to Default") that closes the dialog.
/// Dialog with one text field. Returns the trimmed text, or null if cancelled.
/// [onReset] adds a secondary red text button ([resetLabel], default "Reset to
/// Default") that closes the dialog.
Future<String?> showTextPrompt(
BuildContext context, {
required String title,
String? message,
String initial = '',
String? hint,
String? note, // small text under the field
IconData? fieldIcon,
IconData? titleIcon,
IconData? confirmIcon,
bool obscure = false,
bool mono = false,
TextInputType keyboardType = TextInputType.text,
String? confirmLabel,
String? resetLabel,
@@ -19,60 +28,64 @@ Future<String?> showTextPrompt(
return showDialog<String>(
context: context,
builder: (dialog) => AlertDialog(
title: Text(title),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (message != null) ...[
Text(message),
const SizedBox(height: 16),
],
TextField(
controller: controller,
autofocus: true,
keyboardType: keyboardType,
autocorrect: false,
style: const TextStyle(color: Colors.white),
cursorColor: s.bulletColor,
decoration: InputDecoration(
hintText: hint,
hintStyle: const TextStyle(color: Colors.white38),
filled: true,
fillColor: Colors.white10,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
builder: (dialog) {
final c = Palette.current;
return AppDialog(
title: title,
message: message,
titleTrailing: titleIcon == null ? null : IconBadge(titleIcon, size: 40),
content: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextField(
controller: controller,
autofocus: true,
keyboardType: keyboardType,
autocorrect: false,
obscureText: obscure,
style: TextStyle(
color: c.ink,
fontSize: 15,
fontFamily: mono ? AppTheme.mono : null,
letterSpacing: mono ? 0.5 : null,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: s.bulletColor),
decoration: InputDecoration(
hintText: hint,
prefixIcon: fieldIcon == null ? null : Icon(fieldIcon, size: 19, color: c.muted),
),
onSubmitted: (v) => Navigator.pop(dialog, v.trim()),
),
onSubmitted: (v) => Navigator.pop(dialog, v.trim()),
if (note != null) ...[
const SizedBox(height: 10),
Text(note, style: TextStyle(fontSize: 12, height: 1.35, color: c.muted)),
],
if (onReset != null) ...[
const SizedBox(height: 6),
Align(
alignment: Alignment.centerLeft,
child: TextButton.icon(
style: TextButton.styleFrom(foregroundColor: c.red, padding: const EdgeInsets.symmetric(horizontal: 4)),
icon: const Icon(Icons.delete_outline_rounded, size: 18),
label: Text(resetLabel ?? s.t('Reset to Default')),
onPressed: () {
onReset();
Navigator.pop(dialog);
},
),
),
],
],
),
actions: [
DialogTextButton(s.t('Cancel'), onTap: () => Navigator.pop(dialog)),
PrimaryButton(
label: confirmLabel ?? s.t('Save'),
icon: confirmIcon,
height: 46,
onTap: () => Navigator.pop(dialog, controller.text.trim()),
),
],
),
actions: [
if (onReset != null)
TextButton(
onPressed: () {
onReset();
Navigator.pop(dialog);
},
child: Text(resetLabel ?? s.t('Reset to Default'), style: const TextStyle(color: Colors.white54)),
),
TextButton(
onPressed: () => Navigator.pop(dialog),
child: Text(s.t('Cancel'), style: const TextStyle(color: Colors.white70)),
),
FilledButton(
style: FilledButton.styleFrom(backgroundColor: s.bulletColor),
onPressed: () => Navigator.pop(dialog, controller.text.trim()),
child: Text(confirmLabel ?? s.t('Save')),
),
],
),
);
},
);
}