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 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"). The /// selected pill hops over to a newly picked segment (a slide with a slight /// overshoot). [trailing] sits at the end of the same bar, after a thin line /// (e.g. a menu); [bare] leaves out the bar's own card, for several rows in /// one card (see [SegmentedCard]). class SegmentedTabs extends StatelessWidget { final List items; final int selected; final ValueChanged onSelect; final double height; final bool accentSelected; // selected segment filled with the accent final Widget? trailing; final bool bare; const SegmentedTabs({ super.key, required this.items, required this.selected, required this.onSelect, this.height = 44, this.accentSelected = false, this.trailing, this.bare = false, }); static const Duration _hop = Duration(milliseconds: 380); // Slides past its target a little and settles back: a hop, not a fade static const Curve _hopCurve = Cubic(0.3, 1.3, 0.5, 1); static BoxDecoration track(Palette c) => BoxDecoration( color: c.isDark ? c.card : c.tile, borderRadius: BorderRadius.circular(14), border: c.isDark ? Border.all(color: c.line) : null, ); @override Widget build(BuildContext context) { final c = Palette.current; final segments = LayoutBuilder(builder: (context, box) { final w = box.maxWidth / items.length; return Stack( children: [ // The pill, under the labels if (selected >= 0 && selected < items.length) AnimatedPositioned( duration: _hop, curve: _hopCurve, left: w * selected, top: 0, bottom: 0, width: w, child: AnimatedContainer( duration: const Duration(milliseconds: 180), decoration: BoxDecoration( color: accentSelected ? c.accent : (c.isDark ? c.tile : c.card), borderRadius: BorderRadius.circular(10), boxShadow: !c.isDark ? c.shadow : null, ), ), ), Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ for (int i = 0; i < items.length; i++) Expanded( child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () => onSelect(i), child: TweenAnimationBuilder( tween: ColorTween(end: _fg(c, i)), duration: const Duration(milliseconds: 220), builder: (context, fg, _) => Row( mainAxisAlignment: MainAxisAlignment.center, children: [ if (items[i].icon != null) ...[ Icon(items[i].icon, size: 16, color: fg), const SizedBox(width: 8), ], Flexible( child: Text( items[i].label, maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: fg), ), ), ], ), ), ), ), ], ), ], ); }); final bar = trailing == null ? segments : Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Expanded(child: segments), Container(width: 1, margin: const EdgeInsets.symmetric(horizontal: 4, vertical: 6), color: c.isDark ? c.line : c.line2), trailing!, ], ); return Container( height: height, padding: bare ? EdgeInsets.zero : const EdgeInsets.all(4), decoration: bare ? null : track(c), child: bar, ); } Color _fg(Palette c, int i) => i != selected ? c.muted : (accentSelected ? c.onAccent : c.ink); } /// Several [SegmentedTabs] rows (built [bare]) in one card, a thin line /// between them: "Statistika | Zgodovina" over its filters. class SegmentedCard extends StatelessWidget { final List rows; const SegmentedCard({super.key, required this.rows}); @override Widget build(BuildContext context) { final c = Palette.current; return Container( padding: const EdgeInsets.all(4), decoration: SegmentedTabs.track(c), child: Column( mainAxisSize: MainAxisSize.min, children: [ for (int i = 0; i < rows.length; i++) ...[ if (i > 0) Container(height: 1, margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), color: c.isDark ? c.line : c.line2), rows[i], ], ], ), ); } } /// 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 double borderWidth; final bool dashed; final Color? glow; // a soft halo in this colour round the card 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.borderWidth = 1, this.dashed = false, this.glow, }); @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), width: borderWidth), ); 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 (glow != null) { card = DecoratedBox( decoration: BoxDecoration( borderRadius: BorderRadius.circular(radius), boxShadow: [BoxShadow(color: glow!.withValues(alpha: c.isDark ? 0.28 : 0.22), blurRadius: 14)], ), 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; // Without an action it is visibly off, so it never looks like it does nothing final fg = (destructive ? c.red : c.ink).withValues(alpha: onTap == null ? 0.35 : 1); 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; final double radius; 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, this.radius = 14, }); @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(radius), border: outlined ? Border.all(color: c.ink, width: 2) : null, ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ if (top != null) FittedBox( fit: BoxFit.scaleDown, child: 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)), ), ], ), ), ); } } /// A centred row of equal tiles. Each is as wide as if there were at least /// [minSlots], so one or two tiles don't stretch across the whole width. class TileRow extends StatelessWidget { final List children; final double gap; final int minSlots; const TileRow({super.key, required this.children, this.gap = 10, this.minSlots = 6}); @override Widget build(BuildContext context) { return LayoutBuilder(builder: (context, box) { final slots = children.length < minSlots ? minSlots : children.length; final w = (box.maxWidth - gap * (slots - 1)) / slots; return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ for (int i = 0; i < children.length; i++) ...[ if (i > 0) SizedBox(width: gap), SizedBox(width: w, child: children[i]), ], ], ); }); } } /// 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 showAppSheet( 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( 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 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 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( 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 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 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), ], ), ), ); } }