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
+130 -79
View File
@@ -4,21 +4,20 @@ import '../theme/app_theme.dart';
/// Small uppercase label above a group, e.g. "OBVESTILA".
class SectionHeader extends StatelessWidget {
final String label;
final Widget? trailing;
const SectionHeader(this.label, {super.key});
const SectionHeader(this.label, {super.key, this.trailing});
@override
Widget build(BuildContext context) {
final c = Palette.current;
return Padding(
padding: const EdgeInsets.fromLTRB(4, 20, 4, 8),
child: Text(
label.toUpperCase(),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
letterSpacing: 1.4,
color: Surfaces.current.textSecondary,
),
padding: const EdgeInsets.fromLTRB(0, 22, 0, 10),
child: Row(
children: [
Expanded(child: Text(label.toUpperCase(), style: AppTheme.kicker(c))),
if (trailing != null) trailing!,
],
),
);
}
@@ -27,20 +26,26 @@ class SectionHeader extends StatelessWidget {
/// Rounded group of rows with thin dividers between them.
class GroupCard extends StatelessWidget {
final List<Widget> children;
final bool indentDividers;
const GroupCard({super.key, required this.children});
const GroupCard({super.key, required this.children, this.indentDividers = true});
@override
Widget build(BuildContext context) {
final s = Surfaces.current;
return ClipRRect(
borderRadius: BorderRadius.circular(14),
final c = Palette.current;
return DecoratedBox(
decoration: BoxDecoration(borderRadius: BorderRadius.circular(AppTheme.radius), boxShadow: c.shadow),
child: Material(
color: s.card,
color: c.card,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppTheme.radius),
side: BorderSide(color: c.line2),
),
clipBehavior: Clip.antiAlias,
child: Column(
children: [
for (int i = 0; i < children.length; i++) ...[
if (i > 0) Divider(height: 1, thickness: 1, indent: 16, color: s.divider),
if (i > 0) Divider(height: 1, thickness: 1, indent: indentDividers ? 16 : 0, endIndent: indentDividers ? 16 : 0, color: c.line2),
children[i],
],
],
@@ -50,50 +55,65 @@ class GroupCard extends StatelessWidget {
}
}
/// One settings row: title (+ optional subtitle) on the left, current value and
/// a chevron on the right. Pass [trailing] to replace value + chevron (e.g. a Switch).
/// One settings row: icon, title (+ subtitle) on the left, current value and a
/// chevron on the right. [trailing] replaces value + chevron (e.g. a switch).
class SettingsTile extends StatelessWidget {
final String title;
final String? subtitle;
final IconData? icon;
final Color? iconColor;
final Widget? leading;
final String? value;
final Color? valueColor;
final Widget? valueLeading;
final Widget? trailing;
final VoidCallback? onTap;
final bool mono; // value in the monospace font (IP addresses)
final bool showChevron;
final IconData chevron;
final Color? titleColor;
const SettingsTile({
super.key,
required this.title,
this.subtitle,
this.icon,
this.iconColor,
this.leading,
this.value,
this.valueColor,
this.valueLeading,
this.trailing,
this.onTap,
this.mono = false,
this.showChevron = true,
this.chevron = Icons.chevron_right_rounded,
this.titleColor,
});
@override
Widget build(BuildContext context) {
final s = Surfaces.current;
final c = Palette.current;
return InkWell(
onTap: onTap,
child: ConstrainedBox(
constraints: const BoxConstraints(minHeight: 52),
constraints: const BoxConstraints(minHeight: 56),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
padding: const EdgeInsets.fromLTRB(16, 9, 12, 9),
child: Row(
children: [
if (leading != null) ...[leading!, const SizedBox(width: 12)],
if (leading != null) ...[leading!, const SizedBox(width: 14)]
else if (icon != null) ...[Icon(icon, size: 21, color: iconColor ?? c.muted), const SizedBox(width: 14)],
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(title, style: TextStyle(fontSize: 15, color: s.textPrimary)),
Text(title, style: TextStyle(fontSize: 15.5, fontWeight: FontWeight.w500, color: titleColor ?? c.ink)),
if (subtitle != null)
Padding(
padding: const EdgeInsets.only(top: 2),
child: Text(subtitle!, style: TextStyle(fontSize: 12, color: s.textSecondary)),
child: Text(subtitle!, style: TextStyle(fontSize: 12, color: c.muted)),
),
],
),
@@ -104,14 +124,22 @@ class SettingsTile extends StatelessWidget {
if (valueLeading != null) ...[valueLeading!, const SizedBox(width: 8)],
if (value != null)
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 170),
constraints: const BoxConstraints(maxWidth: 190),
child: Text(
value!,
style: TextStyle(fontSize: 14, color: s.textSecondary),
style: TextStyle(
fontSize: mono ? 13 : 14,
fontFamily: mono ? AppTheme.mono : null,
color: valueColor ?? c.muted,
fontFeatures: AppTheme.tnum,
),
overflow: TextOverflow.ellipsis,
),
),
if (onTap != null) Icon(Icons.chevron_right, color: s.textSecondary),
if (onTap != null && showChevron) ...[
const SizedBox(width: 4),
Icon(chevron, size: 20, color: c.faint),
],
],
],
),
@@ -124,68 +152,87 @@ class SettingsTile extends StatelessWidget {
/// Settings row with a switch on the right; tapping the row toggles it.
class SettingsSwitchTile extends StatelessWidget {
final String title;
final IconData? icon;
final bool value;
final ValueChanged<bool> onChanged;
final Color activeColor;
const SettingsSwitchTile({
super.key,
required this.title,
this.icon,
required this.value,
required this.onChanged,
required this.activeColor,
});
@override
Widget build(BuildContext context) {
return SettingsTile(
title: title,
icon: icon,
onTap: () => onChanged(!value),
trailing: SizedBox(
height: 32,
child: FittedBox(
child: Switch(
value: value,
onChanged: onChanged,
activeTrackColor: activeColor,
activeThumbColor: Colors.white,
),
),
),
trailing: SizedBox(height: 32, child: FittedBox(child: Switch(value: value, onChanged: onChanged))),
);
}
}
/// Row used inside dark bottom-sheet pickers, with a check on the selected one.
/// Row of a picker sheet, with a check on the selected one.
class SheetOption extends StatelessWidget {
final String label;
final String? subtitle;
final Widget? leading;
final bool selected;
final Color selectedColor;
final VoidCallback onTap;
final bool showDivider;
const SheetOption({
super.key,
required this.label,
this.subtitle,
this.leading,
required this.selected,
required this.selectedColor,
required this.onTap,
this.showDivider = true,
});
@override
Widget build(BuildContext context) {
return ListTile(
final c = Palette.current;
return InkWell(
onTap: onTap,
leading: leading,
title: Text(
label,
style: TextStyle(
color: Colors.white,
fontWeight: selected ? FontWeight.bold : FontWeight.normal,
borderRadius: BorderRadius.circular(12),
child: Container(
constraints: const BoxConstraints(minHeight: 56),
padding: const EdgeInsets.symmetric(vertical: 10),
decoration: BoxDecoration(
border: showDivider ? Border(top: BorderSide(color: c.line2)) : null,
),
child: Row(
children: [
if (leading != null) ...[leading!, const SizedBox(width: 12)],
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(label, style: TextStyle(fontSize: 15.5, fontWeight: selected ? FontWeight.w600 : FontWeight.w500, color: c.ink)),
if (subtitle != null)
Padding(
padding: const EdgeInsets.only(top: 3),
child: Text(subtitle!, style: TextStyle(fontSize: 12, color: c.muted)),
),
],
),
),
if (selected)
Container(
width: 24,
height: 24,
decoration: BoxDecoration(color: c.accent, shape: BoxShape.circle),
child: Icon(Icons.check_rounded, size: 16, color: c.onAccent),
),
],
),
),
trailing: selected ? Icon(Icons.check_rounded, color: selectedColor) : null,
);
}
}
@@ -200,24 +247,22 @@ class StatTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
final s = Surfaces.current;
return Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 12, 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label, style: TextStyle(fontSize: 12, color: s.textSecondary)),
const SizedBox(height: 2),
Text(value, style: TextStyle(fontSize: 26, fontWeight: FontWeight.bold, color: s.textPrimary)),
if (caption != null)
Text(caption!, style: TextStyle(fontSize: 11, color: s.textSecondary), maxLines: 1, overflow: TextOverflow.ellipsis),
],
),
final c = Palette.current;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label, style: TextStyle(fontSize: 12, color: c.muted)),
const SizedBox(height: 2),
Text(value,
style: TextStyle(fontSize: 28, fontWeight: FontWeight.w800, height: 1.15, color: c.ink, fontFeatures: AppTheme.tnum)),
if (caption != null)
Text(caption!, style: TextStyle(fontSize: 11.5, color: c.muted), maxLines: 1, overflow: TextOverflow.ellipsis),
],
);
}
}
/// Grid of [StatTile]s, two per row, on one card.
/// [StatTile]s two per row, each on its own card.
class StatGrid extends StatelessWidget {
final List<StatTile> tiles;
@@ -225,24 +270,30 @@ class StatGrid extends StatelessWidget {
@override
Widget build(BuildContext context) {
final s = Surfaces.current;
final c = Palette.current;
final rows = <Widget>[];
for (int i = 0; i < tiles.length; i += 2) {
if (i > 0) rows.add(Divider(height: 1, thickness: 1, color: s.divider));
rows.add(IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(child: tiles[i]),
VerticalDivider(width: 1, thickness: 1, color: s.divider),
Expanded(child: i + 1 < tiles.length ? tiles[i + 1] : const SizedBox()),
if (i > 0) rows.add(const SizedBox(height: 10));
rows.add(Row(
children: [
for (final t in [tiles[i], if (i + 1 < tiles.length) tiles[i + 1]]) ...[
if (t != tiles[i]) const SizedBox(width: 10),
Expanded(
child: Container(
padding: const EdgeInsets.fromLTRB(14, 12, 12, 12),
decoration: BoxDecoration(
color: c.card,
borderRadius: BorderRadius.circular(AppTheme.radius),
border: Border.all(color: c.line2),
boxShadow: c.shadow,
),
child: t,
),
),
],
),
],
));
}
return ClipRRect(
borderRadius: BorderRadius.circular(14),
child: ColoredBox(color: s.card, child: Column(children: rows)),
);
return Column(children: rows);
}
}