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
+971
View File
@@ -0,0 +1,971 @@
import 'package:flutter/material.dart';
import '../services/app_settings.dart';
import '../theme/app_theme.dart';
// Building blocks of the V2 design. Screens use these instead of styling
// Material widgets one by one, so every screen looks alike.
/// Large page title of a tab ("Knjiga", "Streljanje"), with an optional
/// subtitle and a round action button on the right.
class PageHeader extends StatelessWidget {
final String title;
final String? subtitle;
final Widget? action;
const PageHeader({super.key, required this.title, this.subtitle, this.action});
@override
Widget build(BuildContext context) {
final c = Palette.current;
return Padding(
padding: EdgeInsets.fromLTRB(AppTheme.edge, MediaQuery.paddingOf(context).top + 14, 16, 12),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 30, fontWeight: FontWeight.w700, height: 1.15, letterSpacing: -0.4, color: c.ink)),
if (subtitle != null)
Padding(
padding: const EdgeInsets.only(top: 2),
child: Text(subtitle!, style: TextStyle(fontSize: 14, color: c.muted)),
),
],
),
),
if (action != null) Padding(padding: const EdgeInsets.only(top: 2), child: action!),
],
),
);
}
}
/// Header of a pushed screen: round back button, title and subtitle, actions.
/// [centered] puts the title in the middle (result screens).
class BackHeader extends StatelessWidget {
final String title;
final String? subtitle;
final List<Widget> actions;
final bool centered;
final VoidCallback? onBack;
final Color? background;
const BackHeader({
super.key,
required this.title,
this.subtitle,
this.actions = const [],
this.centered = false,
this.onBack,
this.background,
});
@override
Widget build(BuildContext context) {
final c = Palette.current;
final titles = Column(
crossAxisAlignment: centered ? CrossAxisAlignment.center : CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: centered ? 15 : 17, fontWeight: FontWeight.w700, color: c.ink)),
if (subtitle != null)
Text(subtitle!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 12, color: c.muted, fontFeatures: AppTheme.tnum)),
],
);
return Container(
color: background,
padding: EdgeInsets.fromLTRB(12, MediaQuery.paddingOf(context).top + 8, 12, 8),
child: SizedBox(
height: 44,
child: Row(
children: [
CircleButton(icon: Icons.chevron_left_rounded, size: 40, iconSize: 26, onTap: onBack ?? () => Navigator.maybePop(context)),
const SizedBox(width: 12),
Expanded(child: centered ? Center(child: titles) : titles),
if (centered && actions.isEmpty) const SizedBox(width: 52),
for (final a in actions) ...[const SizedBox(width: 8), a],
],
),
),
);
}
}
/// Round icon button on a tile background (header actions, back).
class CircleButton extends StatelessWidget {
final IconData icon;
final VoidCallback? onTap;
final double size;
final double iconSize;
final Color? color;
final Color? background;
final String? tooltip;
const CircleButton({
super.key,
required this.icon,
this.onTap,
this.size = 40,
this.iconSize = 20,
this.color,
this.background,
this.tooltip,
});
@override
Widget build(BuildContext context) {
final c = Palette.current;
final button = Material(
color: background ?? c.tile,
shape: const CircleBorder(),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: onTap,
child: SizedBox.square(dimension: size, child: Icon(icon, size: iconSize, color: color ?? c.ink)),
),
);
return tooltip == null ? button : Tooltip(message: tooltip!, child: button);
}
}
/// Rounded-square icon button (camera bars, share row).
class SquareButton extends StatelessWidget {
final IconData? icon;
final Widget? child;
final VoidCallback? onTap;
final double size;
final Color? color;
final Color? background;
final String? tooltip;
const SquareButton({super.key, this.icon, this.child, this.onTap, this.size = 48, this.color, this.background, this.tooltip});
@override
Widget build(BuildContext context) {
final c = Palette.current;
final button = Material(
color: background ?? c.tile,
borderRadius: BorderRadius.circular(14),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: onTap,
child: SizedBox.square(
dimension: size,
child: Center(child: child ?? Icon(icon, size: 22, color: color ?? c.ink)),
),
),
);
return tooltip == null ? button : Tooltip(message: tooltip!, child: button);
}
}
class SegmentItem {
final String label;
final IconData? icon;
const SegmentItem(this.label, [this.icon]);
}
/// Two or three equal segments in a card ("Statistika | Zgodovina").
class SegmentedTabs extends StatelessWidget {
final List<SegmentItem> items;
final int selected;
final ValueChanged<int> onSelect;
final double height;
final bool accentSelected; // selected segment filled with the accent
const SegmentedTabs({
super.key,
required this.items,
required this.selected,
required this.onSelect,
this.height = 44,
this.accentSelected = false,
});
@override
Widget build(BuildContext context) {
final c = Palette.current;
return Container(
height: height,
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: c.isDark ? c.card : c.tile,
borderRadius: BorderRadius.circular(14),
border: c.isDark ? Border.all(color: c.line) : null,
),
child: Row(
// The selected pill fills the bar's height
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
for (int i = 0; i < items.length; i++)
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => onSelect(i),
child: AnimatedContainer(
duration: const Duration(milliseconds: 180),
curve: Curves.easeOut,
decoration: BoxDecoration(
color: i == selected ? (accentSelected ? c.accent : (c.isDark ? c.tile : c.card)) : Colors.transparent,
borderRadius: BorderRadius.circular(10),
boxShadow: i == selected && !c.isDark ? c.shadow : null,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (items[i].icon != null) ...[
Icon(items[i].icon, size: 16, color: _fg(c, i)),
const SizedBox(width: 8),
],
Flexible(
child: Text(
items[i].label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: _fg(c, i)),
),
),
],
),
),
),
),
],
),
);
}
Color _fg(Palette c, int i) => i != selected ? c.muted : (accentSelected ? c.onAccent : c.ink);
}
/// Stadium chip: accent when selected ("Treningi", "Vse").
class ChoicePill extends StatelessWidget {
final String label;
final bool selected;
final VoidCallback? onTap;
final double height;
final EdgeInsets padding;
const ChoicePill({
super.key,
required this.label,
required this.selected,
this.onTap,
this.height = 32,
this.padding = const EdgeInsets.symmetric(horizontal: 14),
});
@override
Widget build(BuildContext context) {
final c = Palette.current;
return Material(
color: selected ? c.accent : c.tile,
shape: const StadiumBorder(),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: onTap,
child: Container(
height: height,
padding: padding,
alignment: Alignment.center,
child: Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: selected ? c.onAccent : (onTap == null ? c.faint : c.ink2),
),
),
),
),
);
}
}
/// Card surface: rounded, bordered on dark, shadowed on light.
class AppCard extends StatelessWidget {
final Widget child;
final EdgeInsetsGeometry padding;
final VoidCallback? onTap;
final VoidCallback? onLongPress;
final double radius;
final Color? color;
final Color? borderColor;
final bool dashed;
const AppCard({
super.key,
required this.child,
this.padding = const EdgeInsets.all(16),
this.onTap,
this.onLongPress,
this.radius = AppTheme.radius,
this.color,
this.borderColor,
this.dashed = false,
});
@override
Widget build(BuildContext context) {
final c = Palette.current;
final shape = RoundedRectangleBorder(
borderRadius: BorderRadius.circular(radius),
side: dashed ? BorderSide.none : BorderSide(color: borderColor ?? (c.isDark ? c.line2 : c.line2)),
);
Widget content = Padding(padding: padding, child: child);
if (onTap != null || onLongPress != null) {
content = InkWell(onTap: onTap, onLongPress: onLongPress, child: content);
}
Widget card = Material(
color: dashed ? Colors.transparent : (color ?? c.card),
shape: shape,
clipBehavior: Clip.antiAlias,
child: content,
);
if (dashed) {
card = CustomPaint(painter: _DashedBorder(color: c.line, radius: radius), child: card);
} else if (!c.isDark && color == null) {
card = DecoratedBox(
decoration: BoxDecoration(borderRadius: BorderRadius.circular(radius), boxShadow: c.shadow),
child: card,
);
}
return card;
}
}
class _DashedBorder extends CustomPainter {
final Color color;
final double radius;
const _DashedBorder({required this.color, required this.radius});
@override
void paint(Canvas canvas, Size size) {
final path = Path()
..addRRect(RRect.fromRectAndRadius(Offset.zero & size, Radius.circular(radius)).deflate(0.75));
final paint = Paint()
..color = color
..style = PaintingStyle.stroke
..strokeWidth = 1.5;
for (final m in path.computeMetrics()) {
for (double d = 0; d < m.length; d += 10) {
canvas.drawPath(m.extractPath(d, d + 5), paint);
}
}
}
@override
bool shouldRepaint(_DashedBorder old) => old.color != color;
}
/// Uppercase label: "TARČE", "ČLANI · 7".
class Kicker extends StatelessWidget {
final String text;
final Color? color;
final EdgeInsetsGeometry padding;
const Kicker(this.text, {super.key, this.color, this.padding = EdgeInsets.zero});
@override
Widget build(BuildContext context) {
final c = Palette.current;
return Padding(
padding: padding,
child: Text(text.toUpperCase(), style: AppTheme.kicker(c).copyWith(color: color)),
);
}
}
/// Main action of a screen: full width, accent fill, 52 high.
class PrimaryButton extends StatelessWidget {
final String label;
final IconData? icon;
final VoidCallback? onTap;
final Color? color;
final double height;
final bool busy;
const PrimaryButton({super.key, required this.label, this.icon, this.onTap, this.color, this.height = 52, this.busy = false});
@override
Widget build(BuildContext context) {
final c = Palette.current;
final fill = color ?? c.accent;
final fg = Palette.onColor(fill);
return Material(
color: onTap == null ? fill.withValues(alpha: 0.4) : fill,
borderRadius: BorderRadius.circular(14),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: busy ? null : onTap,
child: SizedBox(
height: height,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (busy)
SizedBox.square(dimension: 18, child: CircularProgressIndicator(strokeWidth: 2.5, color: fg))
else if (icon != null)
Icon(icon, size: 19, color: fg),
if (busy || icon != null) const SizedBox(width: 8),
Flexible(
child: Text(label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: fg, fontFeatures: AppTheme.tnum)),
),
],
),
),
),
);
}
}
/// Secondary action on a tile (or red-soft for destructive).
class SoftButton extends StatelessWidget {
final String label;
final IconData? icon;
final VoidCallback? onTap;
final bool destructive;
final double height;
const SoftButton({super.key, required this.label, this.icon, this.onTap, this.destructive = false, this.height = 44});
@override
Widget build(BuildContext context) {
final c = Palette.current;
final fg = destructive ? c.red : c.ink;
return Material(
color: destructive ? c.redSoft : c.tile,
borderRadius: BorderRadius.circular(12),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: onTap,
child: SizedBox(
height: height,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (icon != null) ...[Icon(icon, size: 17, color: fg), const SizedBox(width: 6)],
Flexible(
child: Text(label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: fg)),
),
],
),
),
),
);
}
}
/// Score tile: a small count on top ("3×") and the value.
/// [filled] uses [color] (the accent by default); otherwise a dim tile.
class ScoreTile extends StatelessWidget {
final String? top;
final String value;
final bool filled;
final Color? color;
final double height;
final VoidCallback? onTap;
final GestureTapDownCallback? onTapDown;
final VoidCallback? onTapEnd;
final bool outlined;
const ScoreTile({
super.key,
this.top,
required this.value,
this.filled = true,
this.color,
this.height = 64,
this.onTap,
this.onTapDown,
this.onTapEnd,
this.outlined = false,
});
@override
Widget build(BuildContext context) {
final c = Palette.current;
final fill = filled ? (color ?? c.accent) : c.tile;
final fg = filled ? Palette.onColor(fill) : c.faint;
return GestureDetector(
onTap: onTap,
onTapDown: onTapDown,
onTapUp: onTapEnd == null ? null : (_) => onTapEnd!(),
onTapCancel: onTapEnd,
child: AnimatedContainer(
duration: const Duration(milliseconds: 150),
height: height,
decoration: BoxDecoration(
color: fill,
borderRadius: BorderRadius.circular(14),
border: outlined ? Border.all(color: c.ink, width: 2) : null,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (top != null)
Text(top!,
style: TextStyle(
fontSize: 10, fontWeight: FontWeight.w600, color: fg.withValues(alpha: 0.7), fontFeatures: AppTheme.tnum)),
FittedBox(
fit: BoxFit.scaleDown,
child: Text(value,
style: TextStyle(
fontSize: 22, height: 1.15, fontWeight: FontWeight.w700, color: fg, fontFeatures: AppTheme.tnum)),
),
],
),
),
);
}
}
/// Small coloured label: "TRENING", "TEKMOVANJE", "V ŽIVO".
class StatusChip extends StatelessWidget {
final String label;
final Color color; // text and icon
final Color background;
final IconData? icon;
final bool dot;
const StatusChip({super.key, required this.label, required this.color, required this.background, this.icon, this.dot = false});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
decoration: BoxDecoration(color: background, borderRadius: BorderRadius.circular(20)),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (dot) ...[
Container(width: 6, height: 6, decoration: BoxDecoration(color: color, shape: BoxShape.circle)),
const SizedBox(width: 5),
] else if (icon != null) ...[
Icon(icon, size: 11, color: color),
const SizedBox(width: 4),
],
Text(label.toUpperCase(),
style: TextStyle(fontSize: 9.5, fontWeight: FontWeight.w700, letterSpacing: 0.6, color: color)),
],
),
);
}
}
/// Accent icon on a soft accent square (help rows, camera tiles).
class IconBadge extends StatelessWidget {
final IconData icon;
final double size;
final Color? color;
const IconBadge(this.icon, {super.key, this.size = 36, this.color});
@override
Widget build(BuildContext context) {
final c = Palette.current;
final fg = color ?? c.accent;
return Container(
width: size,
height: size,
decoration: BoxDecoration(color: fg.withValues(alpha: c.isDark ? 0.14 : 0.12), borderRadius: BorderRadius.circular(size * 0.28)),
child: Icon(icon, size: size * 0.52, color: fg),
);
}
}
/// Bottom sheet in the design: drag handle, 22 bold title, optional subtitle
/// and action. [clearBarrier] keeps the screen behind undimmed (camera).
Future<T?> showAppSheet<T>(
BuildContext context, {
String? title,
String? subtitle,
Widget? trailing,
required WidgetBuilder builder,
bool clearBarrier = false,
bool scrollable = true,
double maxHeightFactor = 0.85,
EdgeInsets padding = const EdgeInsets.fromLTRB(AppTheme.edge, 0, AppTheme.edge, 16),
}) {
return showModalBottomSheet<T>(
context: context,
isScrollControlled: true,
useSafeArea: true, // never under the status bar, so there is always room to tap outside
barrierColor: clearBarrier ? Colors.transparent : null,
builder: (sheet) {
// The title (and its close button) stays put; only the content scrolls
final header = title == null
? null
: Padding(
padding: EdgeInsets.fromLTRB(padding.left, 0, padding.right, 0),
child: SheetTitle(title, subtitle: subtitle, trailing: trailing),
);
final content = builder(sheet);
return SafeArea(
child: ConstrainedBox(
constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(sheet).height * maxHeightFactor),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (header != null) header,
Flexible(
child: scrollable
? SingleChildScrollView(padding: padding, child: content)
: Padding(padding: padding, child: content),
),
],
),
),
);
},
);
}
/// Title row of a sheet.
class SheetTitle extends StatelessWidget {
final String title;
final String? subtitle;
final Widget? trailing;
const SheetTitle(this.title, {super.key, this.subtitle, this.trailing});
@override
Widget build(BuildContext context) {
final c = Palette.current;
return Padding(
padding: const EdgeInsets.only(bottom: 16),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: TextStyle(fontSize: 22, fontWeight: FontWeight.w700, color: c.ink, height: 1.2)),
if (subtitle != null)
Padding(
padding: const EdgeInsets.only(top: 4),
child: Text(subtitle!, style: TextStyle(fontSize: 13, color: c.muted)),
),
],
),
),
if (trailing != null) trailing!,
],
),
);
}
}
/// Dialog body in the design: title, message, optional content and buttons
/// (text "cancel" on the left, filled action on the right).
class AppDialog extends StatelessWidget {
final String title;
final String? message;
final Widget? content;
final Widget? titleTrailing;
final List<Widget> actions;
const AppDialog({super.key, required this.title, this.message, this.content, this.titleTrailing, this.actions = const []});
@override
Widget build(BuildContext context) {
final c = Palette.current;
return Dialog(
insetPadding: const EdgeInsets.symmetric(horizontal: 24),
child: Padding(
padding: const EdgeInsets.fromLTRB(24, 22, 24, 20),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
children: [
Expanded(child: Text(title, style: TextStyle(fontSize: 20, fontWeight: FontWeight.w700, color: c.ink))),
if (titleTrailing != null) titleTrailing!,
],
),
if (message != null) ...[
const SizedBox(height: 8),
Text(message!, style: TextStyle(fontSize: 14, height: 1.4, color: c.muted)),
],
if (content != null) ...[const SizedBox(height: 18), content!],
if (actions.isNotEmpty) ...[
const SizedBox(height: 22),
Row(
children: [
for (int i = 0; i < actions.length; i++) ...[
if (i > 0) const SizedBox(width: 10),
Expanded(child: actions[i]),
],
],
),
],
],
),
),
);
}
}
/// Text button of a dialog ("Prekliči").
class DialogTextButton extends StatelessWidget {
final String label;
final VoidCallback? onTap;
const DialogTextButton(this.label, {super.key, this.onTap});
@override
Widget build(BuildContext context) {
final c = Palette.current;
return Material(
color: Colors.transparent,
borderRadius: BorderRadius.circular(12),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: onTap,
child: SizedBox(
height: 46,
child: Center(child: Text(label, style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: c.ink))),
),
),
);
}
}
/// Asks to confirm a deletion. Returns true when confirmed.
Future<bool> confirmDialog(
BuildContext context, {
required String title,
required String message,
required String confirm,
bool destructive = true,
}) async {
final s = AppSettings.instance;
final c = Palette.current;
final ok = await showDialog<bool>(
context: context,
builder: (dialog) => AppDialog(
title: title,
message: message,
actions: [
SoftButton(label: s.t('Cancel'), height: 46, onTap: () => Navigator.pop(dialog, false)),
PrimaryButton(
label: confirm,
height: 46,
color: destructive ? c.red : null,
onTap: () => Navigator.pop(dialog, true),
),
],
),
);
return ok == true;
}
/// One help line: icon badge and a sentence.
class HelpRow extends StatelessWidget {
final IconData icon;
final String text;
const HelpRow(this.icon, this.text, {super.key});
@override
Widget build(BuildContext context) {
final c = Palette.current;
return Padding(
padding: const EdgeInsets.only(bottom: 14),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
IconBadge(icon, size: 32),
const SizedBox(width: 14),
Expanded(
child: Padding(
padding: const EdgeInsets.only(top: 6),
child: Text(text, style: TextStyle(fontSize: 13.5, height: 1.35, color: c.ink2)),
),
),
],
),
);
}
}
/// Empty state: icon in a soft circle, a line and a hint.
class EmptyState extends StatelessWidget {
final IconData icon;
final String title;
final String? hint;
final Widget? action;
const EmptyState({super.key, required this.icon, required this.title, this.hint, this.action});
@override
Widget build(BuildContext context) {
final c = Palette.current;
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(color: c.accentSoft, shape: BoxShape.circle),
child: Icon(icon, size: 36, color: c.accent),
),
const SizedBox(height: 16),
Text(title, textAlign: TextAlign.center, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: c.ink)),
if (hint != null) ...[
const SizedBox(height: 6),
Text(hint!, textAlign: TextAlign.center, style: TextStyle(fontSize: 13.5, height: 1.35, color: c.muted)),
],
if (action != null) ...[const SizedBox(height: 18), action!],
],
);
}
}
/// − value + stepper in a row (timer, positions).
class Stepper3 extends StatelessWidget {
final String value;
final VoidCallback? onMinus;
final VoidCallback? onPlus;
final double valueWidth;
final double buttonSize;
final TextStyle? style;
const Stepper3({
super.key,
required this.value,
this.onMinus,
this.onPlus,
this.valueWidth = 56,
this.buttonSize = 36,
this.style,
});
@override
Widget build(BuildContext context) {
final c = Palette.current;
Widget btn(IconData icon, VoidCallback? onTap) => CircleButton(
icon: icon,
size: buttonSize,
iconSize: 20,
onTap: onTap,
color: onTap == null ? c.faint : c.ink,
background: c.isDark ? c.tile : c.card,
);
return Row(
mainAxisSize: MainAxisSize.min,
children: [
btn(Icons.remove_rounded, onMinus),
SizedBox(
width: valueWidth,
child: Text(value,
textAlign: TextAlign.center,
style: style ?? TextStyle(fontSize: 18, fontWeight: FontWeight.w700, color: c.ink, fontFeatures: AppTheme.tnum)),
),
btn(Icons.add_rounded, onPlus),
],
);
}
}
/// Icon, label, value and a slider under them (camera and image settings).
class LabeledSlider extends StatelessWidget {
final IconData icon;
final String label;
final String valueText;
final double value;
final double min;
final double max;
final ValueChanged<double> onChanged;
const LabeledSlider({
super.key,
required this.icon,
required this.label,
required this.valueText,
required this.value,
required this.min,
required this.max,
required this.onChanged,
});
@override
Widget build(BuildContext context) {
final c = Palette.current;
return Padding(
padding: const EdgeInsets.only(bottom: 6),
child: Column(
children: [
Row(
children: [
Icon(icon, size: 18, color: c.muted),
const SizedBox(width: 10),
Expanded(child: Text(label, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: c.ink))),
Text(valueText, style: TextStyle(fontSize: 13, color: c.ink2, fontFeatures: AppTheme.tnum)),
],
),
SliderTheme(
data: SliderTheme.of(context).copyWith(
overlayShape: const RoundSliderOverlayShape(overlayRadius: 16),
trackShape: const RoundedRectSliderTrackShape(),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 0),
child: SizedBox(
height: 32,
child: Slider(value: value.clamp(min, max), min: min, max: max, onChanged: onChanged),
),
),
),
],
),
);
}
}
/// A row on a card with an icon, a label and a trailing control (switch tile).
class ToggleRow extends StatelessWidget {
final IconData? icon;
final String label;
final bool value;
final ValueChanged<bool> onChanged;
final Widget? extra; // between label and switch
const ToggleRow({super.key, this.icon, required this.label, required this.value, required this.onChanged, this.extra});
@override
Widget build(BuildContext context) {
final c = Palette.current;
return AppCard(
color: c.isDark ? c.card2 : c.card,
padding: const EdgeInsets.fromLTRB(16, 8, 10, 8),
onTap: () => onChanged(!value),
child: SizedBox(
height: 40,
child: Row(
children: [
if (icon != null) ...[Icon(icon, size: 19, color: c.muted), const SizedBox(width: 12)],
Expanded(child: Text(label, style: TextStyle(fontSize: 14.5, fontWeight: FontWeight.w500, color: c.ink))),
if (extra != null) extra!,
Switch(value: value, onChanged: onChanged),
],
),
),
);
}
}