new UI + new targets.
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
class BarEntry {
|
||||
final String label;
|
||||
final double value;
|
||||
final String valueText;
|
||||
final bool highlight; // drawn in gold (best target, the 10s)
|
||||
final bool goldLabel;
|
||||
|
||||
const BarEntry(this.label, this.value, this.valueText, {this.highlight = false, this.goldLabel = false});
|
||||
}
|
||||
|
||||
/// Horizontal bars, one per row: label, bar on a track, value. Ticks along the
|
||||
/// bottom. The rows share the height they get.
|
||||
class BarList extends StatelessWidget {
|
||||
final List<BarEntry> entries;
|
||||
final double max;
|
||||
final List<double> ticks;
|
||||
final double labelWidth;
|
||||
final double valueWidth;
|
||||
final double scale; // text size factor (share image)
|
||||
final Palette? palette;
|
||||
|
||||
const BarList({
|
||||
super.key,
|
||||
required this.entries,
|
||||
required this.max,
|
||||
this.ticks = const [],
|
||||
this.labelWidth = 32,
|
||||
this.valueWidth = 40,
|
||||
this.scale = 1,
|
||||
this.palette,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = palette ?? Palette.current;
|
||||
String tick(double v) => v == v.roundToDouble() ? '${v.round()}' : v.toStringAsFixed(1);
|
||||
return LayoutBuilder(builder: (context, box) {
|
||||
final barWidth = box.maxWidth - labelWidth - valueWidth;
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
for (final e in entries)
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: labelWidth,
|
||||
child: Text(e.label,
|
||||
style: TextStyle(
|
||||
fontSize: 12 * scale,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: e.goldLabel ? c.gold : c.muted)),
|
||||
),
|
||||
SizedBox(
|
||||
width: barWidth,
|
||||
child: Stack(
|
||||
alignment: Alignment.centerLeft,
|
||||
children: [
|
||||
Container(
|
||||
height: 26 * scale,
|
||||
decoration: BoxDecoration(color: c.tile, borderRadius: BorderRadius.circular(7 * scale)),
|
||||
),
|
||||
FractionallySizedBox(
|
||||
widthFactor: max <= 0 ? 0 : (e.value / max).clamp(0.0, 1.0),
|
||||
child: Container(
|
||||
height: 26 * scale,
|
||||
decoration: BoxDecoration(
|
||||
color: e.highlight ? c.gold : c.accent,
|
||||
borderRadius: BorderRadius.circular(7 * scale),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: valueWidth,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 10 * scale),
|
||||
child: Text(e.valueText,
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontSize: 15 * scale,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: e.highlight ? c.gold : (e.value == 0 ? c.faint : c.ink),
|
||||
fontFeatures: AppTheme.tnum)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (ticks.isNotEmpty)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: labelWidth, right: valueWidth, top: 6 * scale),
|
||||
child: SizedBox(
|
||||
height: 14 * scale,
|
||||
child: Stack(
|
||||
children: [
|
||||
for (final t in ticks)
|
||||
Align(
|
||||
alignment: Alignment(max <= 0 ? -1 : (t / max) * 2 - 1, 0),
|
||||
child: Text(tick(t), style: TextStyle(fontSize: 10 * scale, color: c.faint, fontFeatures: AppTheme.tnum)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import 'ui.dart';
|
||||
|
||||
class BarTab {
|
||||
final String label;
|
||||
@@ -8,65 +9,28 @@ class BarTab {
|
||||
const BarTab(this.label, this.icon);
|
||||
}
|
||||
|
||||
/// Tab strip that continues the dark app bar (Koledar/Stiki, Knjiga filters).
|
||||
/// The selected tab is a white pill; [trailing] sits at the right end.
|
||||
/// The two views of a tab page (Statistika | Zgodovina, Koledar | Kontakti):
|
||||
/// a segmented control under the page title.
|
||||
class BarTabs extends StatelessWidget {
|
||||
final List<BarTab> tabs;
|
||||
final int selected;
|
||||
final ValueChanged<int> onSelect;
|
||||
final Widget? trailing;
|
||||
|
||||
const BarTabs({
|
||||
super.key,
|
||||
required this.tabs,
|
||||
required this.selected,
|
||||
required this.onSelect,
|
||||
this.trailing,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: AppTheme.bar,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||
child: Row(
|
||||
children: [
|
||||
for (int i = 0; i < tabs.length; i++) ...[
|
||||
if (i > 0) const SizedBox(width: 6),
|
||||
Expanded(child: _tab(tabs[i], i == selected, () => onSelect(i))),
|
||||
],
|
||||
if (trailing != null) trailing!,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _tab(BarTab tab, bool active, VoidCallback onTap) {
|
||||
final color = active ? Colors.black : Colors.grey[400];
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: active ? Colors.white : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(tab.icon, color: color, size: 18),
|
||||
const SizedBox(width: 6),
|
||||
Flexible(
|
||||
child: Text(
|
||||
tab.label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: color),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(AppTheme.edge, 0, AppTheme.edge, 12),
|
||||
child: SegmentedTabs(
|
||||
items: [for (final t in tabs) SegmentItem(t.label, t.icon)],
|
||||
selected: selected,
|
||||
onSelect: onSelect,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
+57
-18
@@ -1,10 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
class NavItem {
|
||||
final IconData icon;
|
||||
final IconData selectedIcon;
|
||||
final String label;
|
||||
const NavItem(this.icon, this.selectedIcon, this.label);
|
||||
}
|
||||
|
||||
/// Bottom navigation of the design: icon + label, the selected one on a soft
|
||||
/// accent pill. Paints the gesture-bar strip below it too (edge-to-edge).
|
||||
class BottomNavBar extends StatelessWidget {
|
||||
final int selectedIndex;
|
||||
final ValueChanged<int> onItemTapped;
|
||||
final List<BottomNavigationBarItem> items;
|
||||
final List<NavItem> items;
|
||||
|
||||
const BottomNavBar({
|
||||
super.key,
|
||||
@@ -15,29 +24,59 @@ class BottomNavBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Paint the gesture-bar strip below the nav too (edge-to-edge since targetSdk 35),
|
||||
// otherwise the target background color shows through as a thin line.
|
||||
return ColoredBox(
|
||||
color: AppTheme.bar,
|
||||
final c = Palette.current;
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: c.nav,
|
||||
border: Border(top: BorderSide(color: c.line2)),
|
||||
),
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
child: SizedBox(
|
||||
height: 80,
|
||||
child: BottomNavigationBar(
|
||||
backgroundColor: AppTheme.bar,
|
||||
currentIndex: selectedIndex,
|
||||
onTap: onItemTapped,
|
||||
showSelectedLabels: true,
|
||||
showUnselectedLabels: true,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
selectedFontSize: 12,
|
||||
unselectedFontSize: 12,
|
||||
selectedItemColor: Colors.white,
|
||||
unselectedItemColor: Colors.white70,
|
||||
items: items,
|
||||
height: 66,
|
||||
child: Row(
|
||||
children: [
|
||||
for (int i = 0; i < items.length; i++)
|
||||
Expanded(child: _item(c, items[i], i == selectedIndex, () => onItemTapped(i))),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _item(Palette c, NavItem item, bool selected, VoidCallback onTap) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
highlightColor: Colors.transparent,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeOut,
|
||||
width: 52,
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: selected ? c.accentSoft : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Icon(selected ? item.selectedIcon : item.icon, size: 22, color: selected ? c.accent : c.muted),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
item.label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: selected ? FontWeight.w700 : FontWeight.w500,
|
||||
color: selected ? c.ink : c.muted,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+84
-185
@@ -1,183 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import 'ui.dart';
|
||||
|
||||
/// Bottom sheet used by every menu on the camera stream: the live image stays
|
||||
/// Bottom sheet used by every menu on a camera screen: the live image stays
|
||||
/// visible and undimmed above it, so changes can be judged immediately.
|
||||
Future<T?> showCameraSheet<T>(BuildContext context,
|
||||
{required WidgetBuilder builder}) {
|
||||
return showModalBottomSheet<T>(
|
||||
context: context,
|
||||
barrierColor: Colors.transparent,
|
||||
backgroundColor: Colors.grey[900],
|
||||
isScrollControlled:
|
||||
true, // tall content (timer) may use more than half the screen
|
||||
builder: (sheet) => SafeArea(
|
||||
child: ConstrainedBox(
|
||||
constraints:
|
||||
BoxConstraints(maxHeight: MediaQuery.sizeOf(sheet).height * 0.75),
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(20, 0, 20, 16),
|
||||
child: builder(sheet),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Future<T?> showCameraSheet<T>(BuildContext context, {required WidgetBuilder builder}) =>
|
||||
showAppSheet<T>(context, clearBarrier: true, maxHeightFactor: 0.75, builder: builder);
|
||||
|
||||
/// Title (+ optional subtitle) on the left, optional action on the right.
|
||||
class CameraSheetHeader extends StatelessWidget {
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final IconData? icon;
|
||||
final Color? iconColor;
|
||||
final Widget? trailing;
|
||||
|
||||
const CameraSheetHeader({
|
||||
super.key,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
this.icon,
|
||||
this.iconColor,
|
||||
this.trailing,
|
||||
});
|
||||
const CameraSheetHeader({super.key, required this.title, this.subtitle, this.trailing});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 14),
|
||||
child: Row(
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(icon, color: iconColor ?? Colors.white, size: 22),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold)),
|
||||
if (subtitle != null)
|
||||
Text(subtitle!,
|
||||
style:
|
||||
const TextStyle(color: Colors.white54, fontSize: 12)),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trailing != null) trailing!,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
Widget build(BuildContext context) => SheetTitle(title, subtitle: subtitle, trailing: trailing);
|
||||
}
|
||||
|
||||
/// Icon, label, slider and current value in one row.
|
||||
class SheetSlider extends StatelessWidget {
|
||||
final IconData icon;
|
||||
/// "Ponastavi" pill in a sheet header.
|
||||
class ResetPill extends StatelessWidget {
|
||||
final String label;
|
||||
final String valueText;
|
||||
final double value;
|
||||
final double min;
|
||||
final double max;
|
||||
final Color accent;
|
||||
final ValueChanged<double> onChanged;
|
||||
|
||||
const SheetSlider({super.key,
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.valueText,
|
||||
required this.value,
|
||||
required this.min,
|
||||
required this.max,
|
||||
required this.accent,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(icon, color: Colors.white54, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(
|
||||
width: 72,
|
||||
child: Text(label,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 13)),
|
||||
),
|
||||
Expanded(
|
||||
child: Slider(
|
||||
value: value.clamp(min, max),
|
||||
min: min,
|
||||
max: max,
|
||||
activeColor: accent,
|
||||
inactiveColor: Colors.white24,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 46,
|
||||
child: Text(
|
||||
valueText,
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 13,
|
||||
fontFeatures: [FontFeature.tabularFigures()]),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Wide button that shows an on/off state with the accent color.
|
||||
class SheetToggle extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final bool active;
|
||||
final Color accent;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const SheetToggle({super.key,
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.active,
|
||||
required this.accent,
|
||||
required this.onTap,
|
||||
});
|
||||
const ResetPill({super.key, required this.label, required this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = Palette.current;
|
||||
return Material(
|
||||
color: active
|
||||
? accent.withValues(alpha: 0.18)
|
||||
: Colors.white.withValues(alpha: 0.06),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side:
|
||||
BorderSide(color: active ? accent : Colors.transparent, width: 1.5),
|
||||
),
|
||||
color: c.tile,
|
||||
shape: const StadiumBorder(),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 10),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: 18, color: active ? accent : Colors.white70),
|
||||
Icon(Icons.refresh_rounded, size: 16, color: c.ink),
|
||||
const SizedBox(width: 6),
|
||||
Flexible(
|
||||
child: Text(
|
||||
label,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: active ? Colors.white : Colors.white70),
|
||||
),
|
||||
),
|
||||
Text(label, style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: c.ink)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -186,50 +50,85 @@ class SheetToggle extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// Big number with − / + buttons, used for the bullet count.
|
||||
class SheetStepper extends StatelessWidget {
|
||||
final int value;
|
||||
final int min;
|
||||
final int max;
|
||||
final Color accent;
|
||||
final ValueChanged<int> onChanged;
|
||||
/// Icon, label, value and a slider.
|
||||
class SheetSlider 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 SheetStepper({
|
||||
const SheetSlider({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.valueText,
|
||||
required this.value,
|
||||
required this.min,
|
||||
required this.max,
|
||||
required this.accent,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget button(IconData icon, bool enabled, int next) => IconButton(
|
||||
onPressed: enabled ? () => onChanged(next) : null,
|
||||
icon: Icon(icon, color: Colors.white, size: 28),
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor:
|
||||
Colors.white.withValues(alpha: enabled ? 0.12 : 0.04),
|
||||
shape: const CircleBorder(),
|
||||
minimumSize: const Size(56, 56),
|
||||
),
|
||||
);
|
||||
Widget build(BuildContext context) => LabeledSlider(
|
||||
icon: icon, label: label, valueText: valueText, value: value, min: min, max: max, onChanged: onChanged);
|
||||
}
|
||||
|
||||
/// On/off row with a switch (flashlight).
|
||||
class SheetToggle extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final bool active;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const SheetToggle({super.key, required this.icon, required this.label, required this.active, required this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) =>
|
||||
ToggleRow(icon: icon, label: label, value: active, onChanged: (_) => onTap());
|
||||
}
|
||||
|
||||
/// The numbers [min]..[max] as big square buttons; the chosen one in the accent.
|
||||
class SheetStepper extends StatelessWidget {
|
||||
final int value;
|
||||
final int min;
|
||||
final int max;
|
||||
final ValueChanged<int> onChanged;
|
||||
|
||||
const SheetStepper({super.key, required this.value, required this.min, required this.max, required this.onChanged});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = Palette.current;
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
button(Icons.remove, value > min, value - 1),
|
||||
SizedBox(
|
||||
width: 120,
|
||||
child: Text(
|
||||
'$value',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 56, fontWeight: FontWeight.bold, color: accent),
|
||||
for (int n = min; n <= max; n++) ...[
|
||||
if (n > min) const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Material(
|
||||
color: n == value ? c.accent : c.tile,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: InkWell(
|
||||
onTap: () => onChanged(n),
|
||||
child: Center(
|
||||
child: Text('$n',
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: n == value ? c.onAccent : c.ink,
|
||||
fontFeatures: AppTheme.tnum,
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
button(Icons.add, value < max, value + 1),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
+10
-46
@@ -1,57 +1,21 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'ui.dart';
|
||||
|
||||
/// Help bottom sheet: one icon + sentence per control, close button at the end.
|
||||
/// Help bottom sheet: one icon + sentence per control.
|
||||
/// Shared by Knjiga, camera and stream so their info buttons look the same.
|
||||
void showHelpSheet(
|
||||
BuildContext context, {
|
||||
required List<(IconData, String)> items,
|
||||
required Color accent,
|
||||
required String Function(String) t,
|
||||
bool clearBarrier = false,
|
||||
}) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder: (sheet) => SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(24, 8, 24, 16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(t('Help'),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 16),
|
||||
for (final (icon, text) in items)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 14),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(icon, color: accent, size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(t(text),
|
||||
style: const TextStyle(
|
||||
color: Colors.white, fontSize: 14, height: 1.3)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: FilledButton(
|
||||
style: FilledButton.styleFrom(backgroundColor: accent),
|
||||
onPressed: () => Navigator.pop(sheet),
|
||||
child: Text(t('Close')),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
showAppSheet(
|
||||
context,
|
||||
title: t('Help'),
|
||||
clearBarrier: clearBarrier,
|
||||
builder: (sheet) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [for (final (icon, text) in items) HelpRow(icon, t(text))],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../utils/format.dart';
|
||||
import 'camera_sheet.dart';
|
||||
import 'ui.dart';
|
||||
|
||||
enum ImageFilterType { none, greyscale, invert, highContrast }
|
||||
|
||||
@@ -104,7 +107,6 @@ Future<void> showImageSettingsSheet(
|
||||
required ImageAdjustments initial,
|
||||
required String settingsId,
|
||||
required String cameraLabel,
|
||||
required Color accent,
|
||||
required String Function(String) t,
|
||||
required ValueChanged<ImageAdjustments> onChanged,
|
||||
}) {
|
||||
@@ -113,6 +115,7 @@ Future<void> showImageSettingsSheet(
|
||||
context,
|
||||
builder: (sheet) => StatefulBuilder(
|
||||
builder: (context, setSheetState) {
|
||||
final c = Palette.current;
|
||||
void update(ImageAdjustments next) {
|
||||
setSheetState(() => value = next);
|
||||
onChanged(next);
|
||||
@@ -121,37 +124,20 @@ Future<void> showImageSettingsSheet(
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
CameraSheetHeader(
|
||||
title: t('Image Settings'),
|
||||
subtitle: '$cameraLabel · ${t('Saved for this camera')}',
|
||||
trailing: TextButton.icon(
|
||||
style: TextButton.styleFrom(foregroundColor: Colors.white70),
|
||||
icon: const Icon(Icons.restart_alt_rounded, size: 18),
|
||||
label: Text(t('Reset')),
|
||||
onPressed: () => update(value.resetPicture()),
|
||||
),
|
||||
subtitle: '$cameraLabel · ${t('saved for this camera')}',
|
||||
trailing: ResetPill(label: t('Reset'), onTap: () => update(value.resetPicture())),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
for (final (f, icon, label) in [
|
||||
(ImageFilterType.none, Icons.image_outlined, 'None'),
|
||||
(
|
||||
ImageFilterType.greyscale,
|
||||
Icons.filter_b_and_w_rounded,
|
||||
'Greyscale'
|
||||
),
|
||||
(
|
||||
ImageFilterType.highContrast,
|
||||
Icons.contrast_rounded,
|
||||
'High contrast'
|
||||
),
|
||||
(
|
||||
ImageFilterType.invert,
|
||||
Icons.invert_colors_rounded,
|
||||
'Invert'
|
||||
),
|
||||
(ImageFilterType.greyscale, Icons.contrast_rounded, 'Greyscale'),
|
||||
(ImageFilterType.highContrast, Icons.wb_sunny_outlined, 'High contrast'),
|
||||
(ImageFilterType.invert, Icons.visibility_outlined, 'Invert'),
|
||||
]) ...[
|
||||
if (f != ImageFilterType.none) const SizedBox(width: 8),
|
||||
Expanded(
|
||||
@@ -159,43 +145,51 @@ Future<void> showImageSettingsSheet(
|
||||
icon: icon,
|
||||
label: t(label),
|
||||
selected: value.filter == f,
|
||||
accent: accent,
|
||||
onTap: () => update(value.copyWith(filter: f)),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
const SizedBox(height: 16),
|
||||
SheetSlider(
|
||||
icon: Icons.brightness_6_rounded,
|
||||
icon: Icons.light_mode_outlined,
|
||||
label: t('Brightness'),
|
||||
valueText:
|
||||
'${value.brightness >= 0 ? '+' : ''}${(value.brightness * 100).round()}',
|
||||
valueText: '${value.brightness >= 0 ? '+' : '−'}${(value.brightness.abs() * 100).round()}',
|
||||
value: value.brightness,
|
||||
min: -1,
|
||||
max: 1,
|
||||
accent: accent,
|
||||
onChanged: (v) => update(value.copyWith(brightness: v)),
|
||||
),
|
||||
SheetSlider(
|
||||
icon: Icons.tonality_rounded,
|
||||
icon: Icons.contrast_rounded,
|
||||
label: t('Contrast'),
|
||||
valueText: '${(value.contrast * 100).round()} %',
|
||||
valueText: dec(value.contrast, 1),
|
||||
value: value.contrast,
|
||||
min: 0.5,
|
||||
max: 2,
|
||||
accent: accent,
|
||||
onChanged: (v) => update(value.copyWith(contrast: v)),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SheetToggle(
|
||||
icon: Icons.rotate_90_degrees_cw_rounded,
|
||||
label: '${t('Rotate')} · ${value.quarterTurns * 90}°',
|
||||
active: value.quarterTurns != 0,
|
||||
accent: accent,
|
||||
onTap: () => update(
|
||||
value.copyWith(quarterTurns: (value.quarterTurns + 1) % 4)),
|
||||
AppCard(
|
||||
color: c.isDark ? c.card2 : c.card,
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 8, 8),
|
||||
onTap: () => update(value.copyWith(quarterTurns: (value.quarterTurns + 1) % 4)),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.rotate_right_rounded, size: 20, color: c.muted),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text('${t('Rotate')} · ${value.quarterTurns * 90}°',
|
||||
style: TextStyle(fontSize: 14.5, fontWeight: FontWeight.w500, color: c.ink)),
|
||||
),
|
||||
CircleButton(
|
||||
icon: Icons.rotate_right_rounded,
|
||||
size: 36,
|
||||
onTap: () => update(value.copyWith(quarterTurns: (value.quarterTurns + 1) % 4)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -208,46 +202,33 @@ class _FilterTile extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final bool selected;
|
||||
final Color accent;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _FilterTile({
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.selected,
|
||||
required this.accent,
|
||||
required this.onTap,
|
||||
});
|
||||
const _FilterTile({required this.icon, required this.label, required this.selected, required this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = Palette.current;
|
||||
return Material(
|
||||
color: selected
|
||||
? accent.withValues(alpha: 0.18)
|
||||
: Colors.white.withValues(alpha: 0.06),
|
||||
color: selected ? c.accentSoft : (c.isDark ? c.card2 : c.tile),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
side:
|
||||
BorderSide(color: selected ? accent : Colors.transparent, width: 2),
|
||||
side: BorderSide(color: selected ? c.accent : Colors.transparent, width: 1.5),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 4),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 2),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(icon, color: selected ? accent : Colors.white70, size: 26),
|
||||
const SizedBox(height: 4),
|
||||
Icon(icon, color: selected ? c.accent : c.muted, size: 22),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: selected ? Colors.white : Colors.white70,
|
||||
),
|
||||
style: TextStyle(fontSize: 10.5, fontWeight: FontWeight.w600, color: selected ? c.ink : c.muted),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -27,6 +27,9 @@ class ProgressChart extends StatefulWidget {
|
||||
final List<ChartSeries> series; // legend and tooltip order
|
||||
final Color textColor;
|
||||
final Color gridColor;
|
||||
final Color surfaceColor; // ring around points
|
||||
final Color tooltipColor;
|
||||
final Color tooltipTextColor;
|
||||
// true: the graph takes all the height its parent gives it (inside an
|
||||
// Expanded); false: a fixed 190 px
|
||||
final bool expand;
|
||||
@@ -37,6 +40,9 @@ class ProgressChart extends StatefulWidget {
|
||||
required this.series,
|
||||
required this.textColor,
|
||||
required this.gridColor,
|
||||
this.surfaceColor = Colors.white,
|
||||
this.tooltipColor = const Color(0xFF212121),
|
||||
this.tooltipTextColor = Colors.white,
|
||||
this.expand = false,
|
||||
});
|
||||
|
||||
@@ -97,6 +103,9 @@ class _ProgressChartState extends State<ProgressChart> {
|
||||
series: widget.series,
|
||||
textColor: widget.textColor,
|
||||
gridColor: widget.gridColor,
|
||||
surfaceColor: widget.surfaceColor,
|
||||
tooltipColor: widget.tooltipColor,
|
||||
tooltipTextColor: widget.tooltipTextColor,
|
||||
selected: _selected,
|
||||
),
|
||||
),
|
||||
@@ -120,9 +129,9 @@ class _ProgressChartState extends State<ProgressChart> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 14,
|
||||
height: 3,
|
||||
decoration: BoxDecoration(color: s.color, borderRadius: BorderRadius.circular(2)),
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: BoxDecoration(color: s.color, shape: BoxShape.circle),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(s.name, style: TextStyle(fontSize: 12, color: widget.textColor)),
|
||||
@@ -148,6 +157,9 @@ class _ChartPainter extends CustomPainter {
|
||||
final List<ChartSeries> series;
|
||||
final Color textColor;
|
||||
final Color gridColor;
|
||||
final Color surfaceColor;
|
||||
final Color tooltipColor;
|
||||
final Color tooltipTextColor;
|
||||
final int? selected;
|
||||
|
||||
_ChartPainter({
|
||||
@@ -155,6 +167,9 @@ class _ChartPainter extends CustomPainter {
|
||||
required this.series,
|
||||
required this.textColor,
|
||||
required this.gridColor,
|
||||
required this.surfaceColor,
|
||||
required this.tooltipColor,
|
||||
required this.tooltipTextColor,
|
||||
required this.selected,
|
||||
});
|
||||
|
||||
@@ -225,7 +240,7 @@ class _ChartPainter extends CustomPainter {
|
||||
for (int i = 0; i < n; i++) {
|
||||
final isSel = i == selected;
|
||||
final p = Offset(xAt(i), yAt(s.values[i], r));
|
||||
canvas.drawCircle(p, isSel ? 6 : 4.5, Paint()..color = Colors.white);
|
||||
canvas.drawCircle(p, isSel ? 6 : 4.5, Paint()..color = surfaceColor);
|
||||
canvas.drawCircle(p, isSel ? 4.5 : 3.5, Paint()..color = s.color);
|
||||
}
|
||||
}
|
||||
@@ -236,13 +251,13 @@ class _ChartPainter extends CustomPainter {
|
||||
canvas.drawLine(Offset(xAt(i), plot.top), Offset(xAt(i), plot.bottom), grid);
|
||||
final tp = TextPainter(
|
||||
text: TextSpan(
|
||||
style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white),
|
||||
style: TextStyle(fontFamily: 'Inter', fontSize: 12, fontWeight: FontWeight.w600, color: tooltipTextColor),
|
||||
children: [
|
||||
TextSpan(text: labels[i]),
|
||||
for (final s in series)
|
||||
TextSpan(
|
||||
text: ' ${s.format(s.values[i])}',
|
||||
style: TextStyle(color: Color.lerp(s.color, Colors.white, 0.35)),
|
||||
style: TextStyle(color: Color.lerp(s.color, tooltipTextColor, 0.25)),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -252,7 +267,7 @@ class _ChartPainter extends CustomPainter {
|
||||
final left = (xAt(i) - w / 2).clamp(0.0, size.width - w);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(Rect.fromLTWH(left, 2, w, 24), const Radius.circular(6)),
|
||||
Paint()..color = Colors.grey[900]!,
|
||||
Paint()..color = tooltipColor,
|
||||
);
|
||||
tp.paint(canvas, Offset(left + 8, 2 + (24 - tp.height) / 2));
|
||||
}
|
||||
@@ -260,7 +275,7 @@ class _ChartPainter extends CustomPainter {
|
||||
|
||||
void _text(Canvas canvas, String text, Offset at, double size, Color color, {bool alignRight = false}) {
|
||||
final tp = TextPainter(
|
||||
text: TextSpan(text: text, style: TextStyle(fontSize: size, color: color)),
|
||||
text: TextSpan(text: text, style: TextStyle(fontFamily: 'Inter', fontSize: size, color: color, fontFeatures: const [FontFeature.tabularFigures()])),
|
||||
textDirection: TextDirection.ltr,
|
||||
)..layout();
|
||||
tp.paint(canvas, alignRight ? at.translate(-tp.width, 0) : at);
|
||||
@@ -271,5 +286,6 @@ class _ChartPainter extends CustomPainter {
|
||||
old.labels != labels ||
|
||||
old.series != series ||
|
||||
old.selected != selected ||
|
||||
old.textColor != textColor;
|
||||
old.textColor != textColor ||
|
||||
old.surfaceColor != surfaceColor;
|
||||
}
|
||||
|
||||
+141
-242
@@ -1,45 +1,41 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import '../screens/target_view.dart' show BarChartPainter;
|
||||
import '../models/target_style.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../utils/format.dart';
|
||||
import 'bar_list.dart';
|
||||
import 'target_face.dart';
|
||||
import 'ui.dart';
|
||||
|
||||
/// Everything the share image shows, taken from the target view as it is.
|
||||
/// Everything the share image shows, taken from the result screen as it is.
|
||||
class ResultShareData {
|
||||
final String title; // session (folder) name
|
||||
final String date; // already formatted, e.g. 12.11.2026
|
||||
final String countsLine; // e.g. "7 tarč · 35 strelov"
|
||||
final String title; // "Trening 18" or "Tarča 3"
|
||||
final String subtitle; // date, counts
|
||||
final int total;
|
||||
final double? averagePerShot;
|
||||
final Uint8List targetImage; // the selected target design
|
||||
final Size targetImageSize;
|
||||
final List<Offset> bullets; // in targetImage pixels
|
||||
final double bulletDiameter; // in targetImage pixels
|
||||
final Color bulletColor;
|
||||
final Color targetBackground; // matches the target design
|
||||
final List<(String top, String bottom)> tiles; // e.g. ("6x", "10")
|
||||
final List<MapEntry<int, int>> chart; // bar label number -> points
|
||||
final bool chartPerShot; // bars are shots of one target, not targets of a session
|
||||
final TargetStyle style;
|
||||
final List<Offset> hits; // in target space
|
||||
final List<(String? top, String value, bool filled)> tiles;
|
||||
final String chartTitle;
|
||||
final List<BarEntry> bars;
|
||||
final double barMax;
|
||||
final String Function(String) t;
|
||||
|
||||
const ResultShareData({
|
||||
required this.title,
|
||||
required this.date,
|
||||
required this.countsLine,
|
||||
required this.subtitle,
|
||||
required this.total,
|
||||
required this.averagePerShot,
|
||||
required this.targetImage,
|
||||
required this.targetImageSize,
|
||||
required this.bullets,
|
||||
required this.bulletDiameter,
|
||||
required this.bulletColor,
|
||||
required this.targetBackground,
|
||||
required this.style,
|
||||
required this.hits,
|
||||
required this.tiles,
|
||||
required this.chart,
|
||||
required this.chartPerShot,
|
||||
required this.chartTitle,
|
||||
required this.bars,
|
||||
required this.barMax,
|
||||
required this.t,
|
||||
});
|
||||
}
|
||||
@@ -56,7 +52,8 @@ Future<void> shareResult(BuildContext context, ResultShareData data) async {
|
||||
OverlayEntry? entry;
|
||||
try {
|
||||
// Decode the target first so it is in the very first frame
|
||||
await precacheImage(MemoryImage(data.targetImage), context);
|
||||
final asset = data.style.asset;
|
||||
if (asset != null) await precacheImage(AssetImage(asset), context);
|
||||
|
||||
// Laid out and painted, but outside the screen
|
||||
entry = OverlayEntry(
|
||||
@@ -81,8 +78,7 @@ Future<void> shareResult(BuildContext context, ResultShareData data) async {
|
||||
entry = null;
|
||||
|
||||
final dir = await getTemporaryDirectory();
|
||||
final file = File(
|
||||
'${dir.path}/sdk_kovinar_${DateTime.now().millisecondsSinceEpoch}.png');
|
||||
final file = File('${dir.path}/sdk_kovinar_${DateTime.now().millisecondsSinceEpoch}.png');
|
||||
await file.writeAsBytes(png!.buffer.asUint8List());
|
||||
await SharePlus.instance.share(ShareParams(
|
||||
files: [XFile(file.path, mimeType: 'image/png')],
|
||||
@@ -97,8 +93,8 @@ Future<void> shareResult(BuildContext context, ResultShareData data) async {
|
||||
}
|
||||
}
|
||||
|
||||
/// The 960x540 image: header with the result, target with score tiles on the
|
||||
/// left, the bar chart with every value on the right.
|
||||
/// The 960×540 image: the result in the header, the target with its tiles on
|
||||
/// the left, the bar chart with every value on the right.
|
||||
class ResultShareCard extends StatelessWidget {
|
||||
static const Size size = Size(960, 540);
|
||||
final ResultShareData data;
|
||||
@@ -106,256 +102,159 @@ class ResultShareCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = Palette.current;
|
||||
final t = data.t;
|
||||
final accent = data.bulletColor;
|
||||
return SizedBox.fromSize(
|
||||
size: size,
|
||||
child: Material(
|
||||
color: const Color(0xFF1B1E21),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(28, 22, 28, 22),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// Header
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
color: c.bg,
|
||||
child: Stack(
|
||||
children: [
|
||||
// Faint rings behind the header, like a target in the corner
|
||||
Positioned(
|
||||
right: -260,
|
||||
top: -330,
|
||||
child: CustomPaint(size: const Size(700, 700), painter: _Rings(c.line2)),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(32, 26, 32, 32),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('SD KOVINAR',
|
||||
style: TextStyle(
|
||||
color: accent,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w800,
|
||||
letterSpacing: 2.5)),
|
||||
const SizedBox(height: 2),
|
||||
Text(data.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.w800)),
|
||||
const SizedBox(height: 2),
|
||||
Text('${data.date} · ${data.countsLine}',
|
||||
style: const TextStyle(
|
||||
color: Colors.white60, fontSize: 14)),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (data.averagePerShot != null)
|
||||
_HeaderFigure(
|
||||
label: t('Average per shot'),
|
||||
value: data.averagePerShot!.toStringAsFixed(2),
|
||||
size: 40),
|
||||
const SizedBox(width: 28),
|
||||
_HeaderFigure(
|
||||
label: t('Total score').replaceAll(':', ''),
|
||||
value: '${data.total}',
|
||||
size: 40,
|
||||
color: accent),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Expanded(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// Target and score tiles
|
||||
Container(
|
||||
width: 380,
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: data.targetBackground,
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('SD KOVINAR MUTA',
|
||||
style: TextStyle(color: c.accent, fontSize: 12, fontWeight: FontWeight.w800, letterSpacing: 2.2)),
|
||||
const SizedBox(height: 4),
|
||||
Text(data.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: c.ink, fontSize: 30, fontWeight: FontWeight.w700, height: 1.15)),
|
||||
const SizedBox(height: 4),
|
||||
Text(data.subtitle, style: TextStyle(color: c.muted, fontSize: 14)),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: AspectRatio(
|
||||
aspectRatio: data.targetImageSize.width /
|
||||
data.targetImageSize.height,
|
||||
child: _TargetWithHits(data: data),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
height: 58,
|
||||
child: Row(
|
||||
if (data.averagePerShot != null)
|
||||
_HeaderFigure(label: t('Average per shot'), value: dec(data.averagePerShot!), color: c.ink),
|
||||
const SizedBox(width: 40),
|
||||
_HeaderFigure(label: t('Total'), value: '${data.total}', color: c.accent),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Expanded(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 400,
|
||||
child: AppCard(
|
||||
padding: const EdgeInsets.fromLTRB(14, 10, 14, 14),
|
||||
child: Column(
|
||||
children: [
|
||||
for (final (top, bottom) in data.tiles)
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 3),
|
||||
child: _Tile(
|
||||
top: top,
|
||||
bottom: bottom,
|
||||
color: accent),
|
||||
),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: TargetFace(style: data.style, hits: data.hits, hitColor: c.accent),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
for (int i = 0; i < data.tiles.length; i++) ...[
|
||||
if (i > 0) const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: ScoreTile(
|
||||
top: data.tiles[i].$1,
|
||||
value: data.tiles[i].$2,
|
||||
filled: data.tiles[i].$3,
|
||||
height: 60,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
// Chart with every value
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(8, 8, 8, 4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
),
|
||||
child: CustomPaint(
|
||||
size: Size.infinite,
|
||||
painter: BarChartPainter(
|
||||
data: data.chart,
|
||||
maxScore: _chartMax(data),
|
||||
bulletColor: accent,
|
||||
isShotView: data.chartPerShot,
|
||||
backgroundColor: Colors.white,
|
||||
translateFunc: t,
|
||||
xAxisLabelKey: data.chartPerShot ? 'Points' : null,
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: AppCard(
|
||||
padding: const EdgeInsets.fromLTRB(20, 20, 20, 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Kicker(data.chartTitle, padding: const EdgeInsets.only(bottom: 14)),
|
||||
Expanded(
|
||||
child: BarList(
|
||||
entries: data.bars,
|
||||
max: data.barMax,
|
||||
ticks: [0, data.barMax / 2, data.barMax],
|
||||
labelWidth: 36,
|
||||
valueWidth: 56,
|
||||
scale: 1.1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static double _chartMax(ResultShareData d) {
|
||||
final max = d.chart.isEmpty
|
||||
? 0
|
||||
: d.chart.map((e) => e.value).reduce((a, b) => a > b ? a : b);
|
||||
return max <= 0 ? 1 : max.toDouble();
|
||||
class _Rings extends CustomPainter {
|
||||
final Color color;
|
||||
const _Rings(this.color);
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final p = Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1.5
|
||||
..color = color;
|
||||
for (double r = 80; r < size.width / 2; r += 55) {
|
||||
canvas.drawCircle(size.center(Offset.zero), r, p);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(_Rings old) => old.color != color;
|
||||
}
|
||||
|
||||
class _HeaderFigure extends StatelessWidget {
|
||||
final String label;
|
||||
final String value;
|
||||
final double size;
|
||||
final Color color;
|
||||
const _HeaderFigure(
|
||||
{required this.label,
|
||||
required this.value,
|
||||
required this.size,
|
||||
this.color = Colors.white});
|
||||
const _HeaderFigure({required this.label, required this.value, required this.color});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = Palette.current;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(label.toUpperCase(),
|
||||
style: const TextStyle(
|
||||
color: Colors.white54,
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 1.5)),
|
||||
Text(label.toUpperCase(), style: AppTheme.kicker(c).copyWith(letterSpacing: 1.5)),
|
||||
const SizedBox(height: 4),
|
||||
Text(value,
|
||||
style: TextStyle(
|
||||
color: color,
|
||||
fontSize: size,
|
||||
height: 1.05,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontFeatures: const [FontFeature.tabularFigures()])),
|
||||
color: color, fontSize: 44, height: 1.05, fontWeight: FontWeight.w800, fontFeatures: AppTheme.tnum)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _TargetWithHits extends StatelessWidget {
|
||||
final ResultShareData data;
|
||||
const _TargetWithHits({required this.data});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (context, c) {
|
||||
final scale = c.maxWidth / data.targetImageSize.width;
|
||||
final d = data.bulletDiameter * scale;
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Image.memory(data.targetImage,
|
||||
fit: BoxFit.fill, gaplessPlayback: true)),
|
||||
for (final b in data.bullets)
|
||||
Positioned(
|
||||
left: b.dx * scale - d / 2,
|
||||
top: b.dy * scale - d / 2,
|
||||
width: d,
|
||||
height: d,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: data.bulletColor.withValues(alpha: 0.85),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: Colors.black, width: 1),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class _Tile extends StatelessWidget {
|
||||
final String top;
|
||||
final String bottom;
|
||||
final Color color;
|
||||
const _Tile({required this.top, required this.bottom, required this.color});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 20,
|
||||
width: double.infinity,
|
||||
color: const Color(0xFF2C2F33),
|
||||
alignment: Alignment.center,
|
||||
child: FittedBox(
|
||||
child: Text(top,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700)),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
color: color.withValues(alpha: 0.9),
|
||||
alignment: Alignment.center,
|
||||
child: FittedBox(
|
||||
child: Text(bottom,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w800)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+130
-79
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/target_style.dart';
|
||||
import '../utils/target_scoring.dart';
|
||||
|
||||
/// A target design with hits on it, drawn in the shared 1200 × 1200 space and
|
||||
/// scaled to the space it gets (always square).
|
||||
///
|
||||
/// The default target is painted as vectors, so its rings and numbers stay
|
||||
/// sharp at any size or zoom; the other designs are their v3 images.
|
||||
class TargetFace extends StatelessWidget {
|
||||
final TargetStyle style;
|
||||
final List<Offset> hits; // in target space (0–1200)
|
||||
final Color hitColor;
|
||||
final Set<int> highlighted; // indexes of [hits] drawn with a ring
|
||||
final Set<int> dimmed; // indexes drawn faded (e.g. other values while one is pressed)
|
||||
final bool showScoring; // debug: the radii the scoring uses, over the design
|
||||
|
||||
const TargetFace({
|
||||
super.key,
|
||||
required this.style,
|
||||
this.hits = const [],
|
||||
this.hitColor = const Color(0xFF22C7E0),
|
||||
this.highlighted = const {},
|
||||
this.dimmed = const {},
|
||||
this.showScoring = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final asset = style.asset;
|
||||
return AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
if (asset == null)
|
||||
const RepaintBoundary(child: CustomPaint(painter: DefaultTargetPainter(glow: true)))
|
||||
else
|
||||
Image.asset(asset, fit: BoxFit.contain, filterQuality: FilterQuality.medium, gaplessPlayback: true),
|
||||
if (showScoring) const CustomPaint(painter: ScoringRingsPainter()),
|
||||
if (hits.isNotEmpty)
|
||||
CustomPaint(
|
||||
painter: HitsPainter(hits: hits, color: hitColor, highlighted: highlighted, dimmed: dimmed),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Small preview of a design, for the pickers and the settings row.
|
||||
class TargetThumb extends StatelessWidget {
|
||||
final TargetStyle style;
|
||||
final double size;
|
||||
|
||||
const TargetThumb(this.style, {super.key, required this.size});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final asset = style.asset;
|
||||
return SizedBox.square(
|
||||
dimension: size,
|
||||
child: asset == null
|
||||
? CustomPaint(painter: DefaultTargetPainter(glow: true, numbers: size >= 60))
|
||||
: Image.asset(
|
||||
asset,
|
||||
fit: BoxFit.contain,
|
||||
cacheWidth: (size * MediaQuery.devicePixelRatioOf(context)).round().clamp(64, 600),
|
||||
filterQuality: FilterQuality.medium,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The default target ("00 Privzeta · brez sijaja") in vectors: white paper
|
||||
/// ending on ring 1, black 7–10, numbers 1–8 on the four axes. [glow] adds a
|
||||
/// small glow (white rim, short light-blue halo).
|
||||
class DefaultTargetPainter extends CustomPainter {
|
||||
final bool glow;
|
||||
final bool numbers;
|
||||
|
||||
const DefaultTargetPainter({this.glow = false, this.numbers = true});
|
||||
|
||||
static const double _paper = 510;
|
||||
static const Color _glowOuter = Color(0xFF9FD8FF);
|
||||
|
||||
// Outer radius of score zone k (1–9); zone 10 is the centre dot
|
||||
static double ring(int k) => k == 10 ? 15 : 15 + 55 * (10 - k).toDouble();
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final s = size.shortestSide / TargetScoring.size;
|
||||
canvas.save();
|
||||
canvas.translate((size.width - size.shortestSide) / 2, (size.height - size.shortestSide) / 2);
|
||||
canvas.scale(s);
|
||||
const c = TargetScoring.center;
|
||||
|
||||
if (glow) {
|
||||
// figcraft drop-shadow "radius" is the blur; Flutter wants sigma ≈ blur / 2
|
||||
void blurDisc(double r, Color color, double blur) => canvas.drawCircle(
|
||||
c, r, Paint()..color = color..maskFilter = MaskFilter.blur(BlurStyle.normal, blur / 2));
|
||||
// A small glow: a short light-blue halo and a white rim
|
||||
blurDisc(_paper + 2, _glowOuter.withValues(alpha: 0.55), 40);
|
||||
blurDisc(_paper + 1, Colors.white.withValues(alpha: 0.7), 10);
|
||||
}
|
||||
|
||||
// Paper, then the black (zones 7–10)
|
||||
canvas.drawCircle(c, _paper, Paint()..color = Colors.white);
|
||||
canvas.drawCircle(c, ring(7), Paint()..color = Colors.black);
|
||||
|
||||
final line = Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..isAntiAlias = true;
|
||||
for (int k = 1; k <= 6; k++) {
|
||||
canvas.drawCircle(c, ring(k), line..color = Colors.black..strokeWidth = 3);
|
||||
}
|
||||
for (final k in [8, 9]) {
|
||||
canvas.drawCircle(c, ring(k), line..color = Colors.white..strokeWidth = 5);
|
||||
}
|
||||
canvas.drawCircle(c, ring(10), Paint()..color = Colors.white);
|
||||
|
||||
if (numbers) {
|
||||
for (int k = 1; k <= 8; k++) {
|
||||
final tp = TextPainter(
|
||||
text: TextSpan(
|
||||
text: '$k',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 33,
|
||||
fontWeight: FontWeight.w700,
|
||||
height: 1,
|
||||
color: k <= 6 ? Colors.black : Colors.white,
|
||||
),
|
||||
),
|
||||
textDirection: TextDirection.ltr,
|
||||
)..layout();
|
||||
final mid = ring(k) - 27.5;
|
||||
for (final d in const [Offset(-1, 0), Offset(1, 0), Offset(0, -1), Offset(0, 1)]) {
|
||||
final at = c + d * mid;
|
||||
// Centre the cap height (≈ 0.73 em of Inter) on the zone
|
||||
tp.paint(canvas, Offset(at.dx - tp.width / 2, at.dy - tp.height / 2 + 33 * 0.03));
|
||||
}
|
||||
}
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(DefaultTargetPainter old) => old.glow != glow || old.numbers != numbers;
|
||||
}
|
||||
|
||||
/// Hits in target space: a filled dot of [TargetScoring.bulletDiameter] with a
|
||||
/// dark rim, semi-transparent so overlapping hits stay visible. Highlighted
|
||||
/// ones are drawn on top with a red border on their own edge.
|
||||
class HitsPainter extends CustomPainter {
|
||||
final List<Offset> hits;
|
||||
final Color color;
|
||||
final Set<int> highlighted;
|
||||
final Set<int> dimmed;
|
||||
|
||||
static const Color selectedColor = Color(0xFFE5322D);
|
||||
|
||||
const HitsPainter({required this.hits, required this.color, this.highlighted = const {}, this.dimmed = const {}});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final s = size.shortestSide / TargetScoring.size;
|
||||
canvas.save();
|
||||
canvas.translate((size.width - size.shortestSide) / 2, (size.height - size.shortestSide) / 2);
|
||||
canvas.scale(s);
|
||||
const r = TargetScoring.bulletDiameter / 2;
|
||||
final rim = Color.lerp(color, Colors.black, 0.6)!;
|
||||
|
||||
// Highlighted last so they sit on top
|
||||
final order = [
|
||||
for (int i = 0; i < hits.length; i++)
|
||||
if (!highlighted.contains(i)) i,
|
||||
for (int i = 0; i < hits.length; i++)
|
||||
if (highlighted.contains(i)) i,
|
||||
];
|
||||
for (final i in order) {
|
||||
final p = hits[i];
|
||||
final selected = highlighted.contains(i);
|
||||
final faded = dimmed.contains(i);
|
||||
// Semi-transparent, so overlapping hits and the rings under them show through
|
||||
canvas.drawCircle(p + const Offset(0, 2), r,
|
||||
Paint()..color = Colors.black.withValues(alpha: faded ? 0.05 : 0.18)..maskFilter = const MaskFilter.blur(BlurStyle.normal, 3));
|
||||
canvas.drawCircle(p, r, Paint()..color = color.withValues(alpha: faded ? 0.25 : (selected ? 0.9 : 0.78)));
|
||||
canvas.drawCircle(
|
||||
p,
|
||||
r - 1.5,
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 3
|
||||
..color = rim.withValues(alpha: faded ? 0.2 : 0.8));
|
||||
// Selected: a red border on the hit's own edge, nothing around it
|
||||
if (selected) {
|
||||
canvas.drawCircle(
|
||||
p,
|
||||
r - 3,
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 6
|
||||
..color = selectedColor);
|
||||
}
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(HitsPainter old) =>
|
||||
old.hits != hits || old.color != color || old.highlighted != highlighted || old.dimmed != dimmed;
|
||||
}
|
||||
|
||||
/// Debug overlay: the outer edge of every score zone exactly as
|
||||
/// [TargetScoring] uses it, and the centre cross. The red's outer side is the
|
||||
/// edge: a hole whose edge touches it (or lies inside) scores that ring.
|
||||
class ScoringRingsPainter extends CustomPainter {
|
||||
const ScoringRingsPainter();
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final s = size.shortestSide / TargetScoring.size;
|
||||
canvas.save();
|
||||
canvas.translate((size.width - size.shortestSide) / 2, (size.height - size.shortestSide) / 2);
|
||||
canvas.scale(s);
|
||||
const c = TargetScoring.center;
|
||||
final line = Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1 / s // 1 screen pixel at any size
|
||||
..color = const Color(0xFFFF1744);
|
||||
// Drawn just inside each edge: the red's outer side is the exact scoring
|
||||
// edge, so it covers the printed line and nothing outside it
|
||||
for (final r in TargetScoring.rings) {
|
||||
canvas.drawCircle(c, r - line.strokeWidth / 2, line);
|
||||
}
|
||||
canvas.drawLine(c - const Offset(30, 0), c + const Offset(30, 0), line);
|
||||
canvas.drawLine(c - const Offset(0, 30), c + const Offset(0, 30), line);
|
||||
// Ring values just inside each edge, on the diagonal
|
||||
for (int i = 0; i < TargetScoring.rings.length; i++) {
|
||||
final r = TargetScoring.rings[i];
|
||||
if (r < 40) continue;
|
||||
final tp = TextPainter(
|
||||
text: TextSpan(
|
||||
text: '${10 - i}',
|
||||
style: const TextStyle(fontFamily: 'Inter', fontSize: 22, fontWeight: FontWeight.w800, color: Color(0xFFFF1744)),
|
||||
),
|
||||
textDirection: TextDirection.ltr,
|
||||
)..layout();
|
||||
final at = c + Offset(1, 1) / 1.41421 * (r - 16);
|
||||
tp.paint(canvas, at - Offset(tp.width / 2, tp.height / 2));
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(ScoringRingsPainter old) => false;
|
||||
}
|
||||
@@ -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')),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user