UI fixes and league

This commit is contained in:
Jan Pleterski
2026-11-28 12:22:02 +01:00
parent 2fc741a9f6
commit 258303deb8
118 changed files with 1439 additions and 537 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 339 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 372 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

+7 -2
View File
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// A holiday look (FigCraft Designs/holiday-themes/v2, themes.json): while a /// A holiday look (FigCraft Designs/holiday-themes/v3, themes.json): while a
/// holiday's window is on, the app shows its background, its target (locked) /// holiday's window is on, the app shows its background, its target (locked)
/// and its hit colour (until the user picks another one). Afterwards everything /// and its hit colour (until the user picks another one). Afterwards everything
/// is back to the user's own settings. Saved targets are never changed. /// is back to the user's own settings. Saved targets are never changed.
@@ -17,7 +17,12 @@ class HolidayTheme {
const HolidayTheme(this.id, this.name, this.targetId, this.color, {this.from, this.to, this.easter}); const HolidayTheme(this.id, this.name, this.targetId, this.color, {this.from, this.to, this.easter});
String background(bool dark) => 'assets/backgrounds/bg${id}_${dark ? 'dark' : 'light'}.webp'; String background(bool dark) => _background(id, dark);
/// The background when no holiday is on ("00 Privzeto").
static String everydayBackground(bool dark) => _background('00', dark);
static String _background(String id, bool dark) => 'assets/backgrounds/bg${id}_${dark ? 'dark' : 'light'}.webp';
/// In the order of themes.json: when windows overlap, the first one wins. /// In the order of themes.json: when windows overlap, the first one wins.
static const List<HolidayTheme> all = [ static const List<HolidayTheme> all = [
+29 -11
View File
@@ -3,13 +3,15 @@ import 'package:flutter/material.dart';
/// Where a target design comes from (only used to order and group the picker). /// Where a target design comes from (only used to order and group the picker).
enum TargetGroup { classic, design, holiday } enum TargetGroup { classic, design, holiday }
/// One target design of the v3 set (FigCraft Designs/target-designs/v3). /// One target design of the v5 set (FigCraft Designs/target-designs/v5).
/// ///
/// Every design has the same geometry in a 1200 × 1200 space: centre /// Every design has the same geometry in a 1200 × 1200 space: centre
/// (600, 600), ring 1 at r 510, the black at r 180; decoration and glow only /// (600, 600), ring 1 at r 510, the black at r 180; decoration and glow only
/// outside ring 1. Hits are stored in that space, so a hit lands on the same /// outside ring 1, transparent beyond. Each design comes with its own screen
/// ring whatever design is picked. The default ([id] 0) is drawn as vectors /// background (target-backgrounds/v3), shown on the target screens. Hits are stored in that space, so a hit lands on the same
/// (sharp at any zoom); the others are 1600 px WebP images with transparency. /// ring whatever design is picked. The default ([id] 0, "00 Privzeta") is
/// drawn as vectors (sharp at any zoom); the others are 1600 px WebP images
/// with transparency.
class TargetStyle { class TargetStyle {
final int id; // 1–35 are the old Target<id>.jpg, so saved choices carry over final int id; // 1–35 are the old Target<id>.jpg, so saved choices carry over
final String sl; final String sl;
@@ -21,10 +23,16 @@ class TargetStyle {
const TargetStyle(this.id, this.sl, this.en, this.de, this.group, this.glow); const TargetStyle(this.id, this.sl, this.en, this.de, this.group, this.glow);
bool get isDefault => id == 0; bool get isDefault => id == 0;
bool get isHoliday => group == TargetGroup.holiday; bool get isHoliday => group == TargetGroup.holiday;
/// Image asset; null for the vector default. /// Image asset; null for the vector default.
String? get asset => isDefault ? null : 'assets/targets/v3/t${id.toString().padLeft(2, '0')}.webp'; String? get asset => isDefault ? null : 'assets/targets/v5/t${id.toString().padLeft(2, '0')}.webp';
/// Its background on the target screens (target-backgrounds/v3, laid out
/// round the result screen's target), in dark or light.
String background(bool dark) => 'assets/backgrounds/t${id.toString().padLeft(2, '0')}_${dark ? 'dark' : 'light'}.webp';
String name(String language) => switch (language) { String name(String language) => switch (language) {
'Slovenian' => sl, 'Slovenian' => sl,
@@ -52,15 +60,25 @@ class TargetStyle {
TargetStyle(79, 'Dan državnosti', 'Statehood Day', 'Staatsfeiertag', TargetGroup.holiday, Color(0xFF1C4FA0)), TargetStyle(79, 'Dan državnosti', 'Statehood Day', 'Staatsfeiertag', TargetGroup.holiday, Color(0xFF1C4FA0)),
]; ];
/// The designs the app ships, in picker order. The rest of the v3 set /// The designs the app ships, in picker order (light to dark, then by
/// (FigCraft Designs/target-designs/v3) is not used for now; to bring one /// colour round the wheel: a 3 × 3 grid). The rest of the v5 set
/// back, add its line here and its webp to assets/targets/v3. /// (FigCraft Designs/target-designs/v5) is not used for now; to bring one
/// back, add its line here and its webp to assets/targets/v5.
static const List<TargetStyle> all = [ static const List<TargetStyle> all = [
fallback, fallback,
TargetStyle(1, 'Lovorov venec', 'Laurel wreath', 'Lorbeerkranz', TargetGroup.classic, Color(0xFF3E8A1E)),
TargetStyle(42, 'ISSF ecru', 'ISSF ecru', 'ISSF Ecru', TargetGroup.design, Color(0xFFE8D9B0)), TargetStyle(42, 'ISSF ecru', 'ISSF ecru', 'ISSF Ecru', TargetGroup.design, Color(0xFFE8D9B0)),
TargetStyle(5, 'Plameni', 'Flames', 'Flammen', TargetGroup.classic, Color(0xFFFF3D00)),
TargetStyle(8, 'Val', 'Wave', 'Welle', TargetGroup.classic, Color(0xFF0B8BD9)),
TargetStyle(7, 'Sončno rumena', 'Sunny yellow', 'Sonnengelb', TargetGroup.classic, Color(0xFFFFA000)), TargetStyle(7, 'Sončno rumena', 'Sunny yellow', 'Sonnengelb', TargetGroup.classic, Color(0xFFFFA000)),
TargetStyle(19, 'Oranžna', 'Orange', 'Orange', TargetGroup.classic, Color(0xFFFF5A00)),
TargetStyle(5, 'Plameni', 'Flames', 'Flammen', TargetGroup.classic, Color(0xFFFF3D00)),
TargetStyle(61, 'Cvetlice', 'Flowers', 'Blumen', TargetGroup.design, Color(0xFFFF6FB0)),
TargetStyle(18, 'Ledeni kristal', 'Ice crystal', 'Eiskristall', TargetGroup.classic, Color(0xFF00B8FF)),
TargetStyle(53, 'Kamuflaža', 'Camouflage', 'Tarnmuster', TargetGroup.design, Color(0xFF3E4A26)),
TargetStyle(1, 'Lovorov venec', 'Laurel wreath', 'Lorbeerkranz', TargetGroup.classic, Color(0xFF3E8A1E)),
]; ];
@override
bool operator ==(Object other) => other is TargetStyle && other.id == id;
@override
int get hashCode => id.hashCode;
} }
+42 -61
View File
@@ -6,7 +6,6 @@ import '../services/app_settings.dart';
import '../services/target_repository.dart'; import '../services/target_repository.dart';
import '../theme/app_theme.dart'; import '../theme/app_theme.dart';
import '../utils/format.dart'; import '../utils/format.dart';
import '../widgets/bar_tabs.dart';
import '../widgets/ui.dart'; import '../widgets/ui.dart';
import '../widgets/help_sheet.dart'; import '../widgets/help_sheet.dart';
import '../widgets/progress_chart.dart'; import '../widgets/progress_chart.dart';
@@ -289,8 +288,7 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
if (_view == _View.history) { if (_view == _View.history) {
return Column(children: [ return Column(children: [
_buildTabs(), _buildTabs(filters: _buildHistoryBar()),
_buildHistoryBar(),
Expanded(child: _buildHistoryScreen()), Expanded(child: _buildHistoryScreen()),
]); ]);
} }
@@ -313,8 +311,7 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
return Column( return Column(
children: [ children: [
_buildTabs(), _buildTabs(filters: _buildStatsBar(_formatCounts(typed.where(_inPeriod).toList()), shots)),
_buildStatsBar(_formatCounts(typed.where(_inPeriod).toList()), shots),
Expanded( Expanded(
child: _years.isEmpty child: _years.isEmpty
? _centered(_buildEmpty()) ? _centered(_buildEmpty())
@@ -432,8 +429,8 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
); );
} }
// Title, then the two screens // Title, then one card: the two screens over that screen's filters
Widget _buildTabs() { Widget _buildTabs({Widget? filters}) {
final s = AppSettings.instance; final s = AppSettings.instance;
return Column( return Column(
children: [ children: [
@@ -441,14 +438,22 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
title: s.t('Book'), title: s.t('Book'),
action: CircleButton(icon: Icons.info_outline_rounded, tooltip: s.t('Help'), onTap: () => showBookHelp(context)), action: CircleButton(icon: Icons.info_outline_rounded, tooltip: s.t('Help'), onTap: () => showBookHelp(context)),
), ),
BarTabs( Padding(
tabs: [ padding: const EdgeInsets.fromLTRB(AppTheme.edge, 0, AppTheme.edge, 12),
BarTab(s.t('Statistics'), Icons.bar_chart_rounded), child: SegmentedCard(rows: [
BarTab(s.t('History'), Icons.history_rounded), SegmentedTabs(
bare: true,
height: 40,
items: [
SegmentItem(s.t('Statistics'), Icons.bar_chart_rounded),
SegmentItem(s.t('History'), Icons.history_rounded),
], ],
selected: _view.index, selected: _view.index,
onSelect: (i) => _change(() => _view = _View.values[i]), onSelect: (i) => _change(() => _view = _View.values[i]),
), ),
if (filters != null) filters,
]),
),
], ],
); );
} }
@@ -456,33 +461,19 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
// Zgodovina: which sessions to list // Zgodovina: which sessions to list
Widget _buildHistoryBar() { Widget _buildHistoryBar() {
final s = AppSettings.instance; final s = AppSettings.instance;
final labels = { return SegmentedTabs(
_HistoryFilter.all: s.t('All'), bare: true,
_HistoryFilter.training: s.t('Trainings'), height: 36,
_HistoryFilter.tournament: s.t('Tournaments'), items: [SegmentItem(s.t('All')), SegmentItem(s.t('Trainings')), SegmentItem(s.t('Tournaments'))],
}; selected: _historyFilter.index,
return Padding( onSelect: (i) => _change(() => _historyFilter = _HistoryFilter.values[i]),
padding: const EdgeInsets.fromLTRB(AppTheme.edge, 0, AppTheme.edge, 12),
child: Row(
children: [
for (final f in _HistoryFilter.values) ...[
if (f.index > 0) const SizedBox(width: 8),
Expanded(
child: ChoicePill(
label: labels[f]!,
selected: f == _historyFilter,
onTap: () => _change(() => _historyFilter = f),
),
),
],
],
),
); );
} }
// Statistika: trainings or tournaments, then the shots-per-target format as // Statistika: trainings or tournaments, and at the end of the same bar the
// one chip with a menu. Shots are 1–5 (the capture limit); older saves above // shots-per-target format as a menu. Shots are 1–5 (the capture limit);
// 5 keep their own entry. Formats with no targets yet can't be picked. // older saves above 5 keep their own entry. Formats with no targets yet
// can't be picked.
Widget _buildStatsBar(Map<int, int> counts, int? selected) { Widget _buildStatsBar(Map<int, int> counts, int? selected) {
final s = AppSettings.instance; final s = AppSettings.instance;
final c = Palette.current; final c = Palette.current;
@@ -491,24 +482,7 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
...counts.keys, ...counts.keys,
}.toList() }.toList()
..sort((a, b) => b.compareTo(a)); ..sort((a, b) => b.compareTo(a));
Widget kind(_Filter f, String label) => ChoicePill( final shotsMenu = PopupMenuButton<int>(
label: s.t(label),
selected: f == _filter,
onTap: () => _change(() {
_filter = f;
_shots = null;
_chartAt = null;
}),
);
return Padding(
padding: const EdgeInsets.fromLTRB(AppTheme.edge, 0, AppTheme.edge, 12),
child: Row(
children: [
Expanded(child: kind(_Filter.training, 'Trainings')),
const SizedBox(width: 6),
Expanded(child: kind(_Filter.tournament, 'Tournaments')),
const SizedBox(width: 6),
PopupMenuButton<int>(
tooltip: s.t('Shots per target'), tooltip: s.t('Shots per target'),
initialValue: selected, initialValue: selected,
position: PopupMenuPosition.under, position: PopupMenuPosition.under,
@@ -546,22 +520,29 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
), ),
), ),
], ],
child: Container( child: Padding(
height: 32, padding: const EdgeInsets.only(left: 8, right: 2),
padding: const EdgeInsets.only(left: 12, right: 6),
decoration: BoxDecoration(color: c.tile, borderRadius: BorderRadius.circular(16)),
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text(selected == null ? '–' : shotCount(selected), Text(selected == null ? '–' : shotCount(selected),
style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: c.ink2)), style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: c.ink)),
Icon(Icons.expand_more_rounded, size: 18, color: c.muted), Icon(Icons.expand_more_rounded, size: 18, color: c.muted),
], ],
), ),
), ),
), );
], return SegmentedTabs(
), bare: true,
height: 36,
items: [SegmentItem(s.t('Trainings')), SegmentItem(s.t('Tournaments'))],
selected: _filter.index,
onSelect: (i) => _change(() {
_filter = _Filter.values[i];
_shots = null;
_chartAt = null;
}),
trailing: shotsMenu,
); );
} }
+8 -4
View File
@@ -10,6 +10,7 @@ import '../services/google_calendar_service.dart';
import '../services/notification_service.dart'; import '../services/notification_service.dart';
import '../widgets/section.dart'; import '../widgets/section.dart';
import '../widgets/ui.dart'; import '../widgets/ui.dart';
import 'league_view.dart';
import 'settings_screen.dart'; import 'settings_screen.dart';
enum EventType { enum EventType {
@@ -32,7 +33,7 @@ class _CalendarScreenState extends State<CalendarScreen> {
bool _isLoading = false; bool _isLoading = false;
List<CalendarEvent> _events = []; List<CalendarEvent> _events = [];
String? _errorMessage; String? _errorMessage;
bool _showContacts = false; int _tab = 0; // 0 calendar, 1 contacts, 2 league
String _query = ''; String _query = '';
List<Contact> get _contacts => AppSettings.instance.clubContacts; List<Contact> get _contacts => AppSettings.instance.clubContacts;
@@ -534,8 +535,10 @@ class _CalendarScreenState extends State<CalendarScreen> {
listenable: AppSettings.instance, listenable: AppSettings.instance,
builder: (context, _) { builder: (context, _) {
Widget body; Widget body;
if (_showContacts) { if (_tab == 1) {
body = _buildContactsList(); body = _buildContactsList();
} else if (_tab == 2) {
body = const LeagueView(); // loads each time the tab is opened
} else if (_isLoading && _events.isEmpty) { } else if (_isLoading && _events.isEmpty) {
body = const Center(child: CircularProgressIndicator()); body = const Center(child: CircularProgressIndicator());
} else if (_errorMessage != null && _events.isEmpty) { } else if (_errorMessage != null && _events.isEmpty) {
@@ -567,9 +570,10 @@ class _CalendarScreenState extends State<CalendarScreen> {
tabs: [ tabs: [
BarTab(_t('Calendar'), Icons.calendar_today_outlined), BarTab(_t('Calendar'), Icons.calendar_today_outlined),
BarTab(_t('Contacts'), Icons.person_add_alt_outlined), BarTab(_t('Contacts'), Icons.person_add_alt_outlined),
BarTab(_t('League'), Icons.emoji_events_outlined),
], ],
selected: _showContacts ? 1 : 0, selected: _tab,
onSelect: (i) => setState(() => _showContacts = i == 1), onSelect: (i) => setState(() => _tab = i),
), ),
Expanded(child: body), Expanded(child: body),
], ],
+305
View File
@@ -0,0 +1,305 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:url_launcher/url_launcher.dart';
import '../services/app_settings.dart';
import '../services/league_service.dart';
import '../theme/app_theme.dart';
import '../widgets/ui.dart';
import 'session_screen.dart' show targetCount, shotCount;
/// Koledar → Liga: the club league from liga.bl3kunja.top – which tournament
/// is open, the plan of all of them, and the live standings. Read when the
/// tab is opened (and on pull to refresh), never in the background.
class LeagueView extends StatefulWidget {
final LeagueService? service; // tests pass one with a fake client
const LeagueView({super.key, this.service});
@override
State<LeagueView> createState() => _LeagueViewState();
}
class _LeagueViewState extends State<LeagueView> {
static const String _ourClub = 'Kovinar'; // our shooters are highlighted
late final LeagueService _service = widget.service ?? LeagueService();
LeagueStandings? _data;
Object? _error;
bool _loading = true;
String _t(String key) => AppSettings.instance.t(key);
@override
void initState() {
super.initState();
_load();
}
@override
void dispose() {
_service.dispose();
super.dispose();
}
Future<void> _load() async {
setState(() => _loading = true);
try {
final data = await _service.standings();
if (!mounted) return;
setState(() {
_data = data;
_error = null;
_loading = false;
});
} catch (e) {
if (!mounted) return;
setState(() {
_error = e;
_loading = false;
});
}
}
Future<void> _openSite() =>
launchUrl(Uri.parse('${LeagueService.site}/lestvica'), mode: LaunchMode.externalApplication);
@override
Widget build(BuildContext context) {
final data = _data;
if (data == null) {
if (_loading) return const Center(child: CircularProgressIndicator());
return Center(
child: Padding(
padding: const EdgeInsets.all(32),
child: EmptyState(
icon: Icons.cloud_off_rounded,
title: _t('Could not load the league'),
hint: '$_error',
action: SizedBox(
width: 180,
child: PrimaryButton(label: _t('Retry'), icon: Icons.refresh_rounded, height: 46, onTap: _load),
),
),
),
);
}
return RefreshIndicator(
onRefresh: _load,
child: ListView(
padding: const EdgeInsets.fromLTRB(AppTheme.edge, 0, AppTheme.edge, 24),
children: [
_statusCard(data),
const SizedBox(height: 12),
_standingsCard(data),
const SizedBox(height: 12),
SoftButton(label: _t('Open the league website'), icon: Icons.open_in_new_rounded, onTap: _openSite),
],
),
);
}
// Which tournament is open (or next), the plan of all of them, the rules
Widget _statusCard(LeagueStandings data) {
final c = Palette.current;
final open = data.openRound;
final next = data.nextRound;
final day = DateFormat('d. M.');
final (String title, String? sub, Color dot) = open != null
? (
_t('{n}. tournament is open').replaceAll('{n}', '${open.number}'),
[
if (open.endsAt != null) _t('until {d}').replaceAll('{d}', day.format(open.endsAt!)),
_t('Entries: {n}').replaceAll('{n}', '${open.submissions}'),
].join(' · '),
c.pos,
)
: next != null
? (
_t('{n}. tournament').replaceAll('{n}', '${next.number}'),
next.startsAt == null ? null : _t('from {d}').replaceAll('{d}', day.format(next.startsAt!)),
c.muted,
)
: (_t('The league has finished'), null, c.faint);
return AppCard(
padding: const EdgeInsets.fromLTRB(16, 14, 16, 14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Kicker(data.league.name),
const SizedBox(height: 8),
Row(
children: [
Container(width: 9, height: 9, decoration: BoxDecoration(color: dot, shape: BoxShape.circle)),
const SizedBox(width: 8),
Expanded(child: Text(title, style: TextStyle(fontSize: 18, fontWeight: FontWeight.w700, color: c.ink))),
],
),
if (sub != null) ...[
const SizedBox(height: 2),
Padding(
padding: const EdgeInsets.only(left: 17),
child: Text(sub, style: TextStyle(fontSize: 13, color: c.muted)),
),
],
const SizedBox(height: 14),
Row(
children: [
for (int i = 0; i < data.rounds.length; i++) ...[
if (i > 0) const SizedBox(width: 6),
Expanded(child: _roundChip(data.rounds[i])),
],
],
),
const SizedBox(height: 12),
Text(
[
_t('Best {n} count').replaceAll('{n}', '${data.league.counted}'),
targetCount(data.league.targets),
shotCount(data.league.shots),
].join(' · '),
style: TextStyle(fontSize: 12, color: c.muted),
),
],
),
);
}
// One tournament of the plan: open in the accent, done ticked, to come faint
Widget _roundChip(LeagueRound r) {
final c = Palette.current;
final month = r.startsAt == null
? ''
: DateFormat('LLL', AppSettings.instance.dateLocale).format(r.startsAt!).replaceAll('.', '');
final fg = r.isOpen ? c.onAccent : (r.isDone ? c.ink2 : c.faint);
return Container(
height: 50,
decoration: BoxDecoration(
color: r.isOpen ? c.accent : (r.isDone ? c.tile : Colors.transparent),
borderRadius: BorderRadius.circular(12),
border: r.isUpcoming ? Border.all(color: c.line) : null,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
if (r.isDone) ...[Icon(Icons.check_rounded, size: 13, color: fg), const SizedBox(width: 2)],
Text('${r.number}.', style: TextStyle(fontSize: 15, fontWeight: FontWeight.w800, color: fg)),
],
),
Text(month, style: TextStyle(fontSize: 10.5, fontWeight: FontWeight.w600, color: fg.withValues(alpha: 0.8))),
],
),
);
}
Widget _standingsCard(LeagueStandings data) {
final c = Palette.current;
// Only tournaments that have started get a column, so early in the season
// names have room; the plan of all of them is in the status card
final rounds = data.rounds.where((r) => !r.isUpcoming).length.clamp(1, data.rounds.length);
return AppCard(
padding: const EdgeInsets.fromLTRB(12, 14, 12, 6),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.only(left: 4, bottom: 6),
child: Row(
children: [
Expanded(child: Kicker(_t('Standings'))),
for (int i = 1; i <= rounds; i++)
SizedBox(width: 30, child: Text('$i.', textAlign: TextAlign.center, style: AppTheme.kicker(c))),
SizedBox(width: 48, child: Text('Σ', textAlign: TextAlign.right, style: AppTheme.kicker(c))),
],
),
),
if (data.players.isEmpty)
Padding(
padding: const EdgeInsets.symmetric(vertical: 20),
child: Text(_t('No results yet'), textAlign: TextAlign.center, style: TextStyle(color: c.muted)),
),
for (final p in data.players) _playerRow(p, rounds),
],
),
);
}
Widget _playerRow(LeaguePlayer p, int rounds) {
final c = Palette.current;
final ours = p.club.contains(_ourClub);
// 1–3 in gold, silver and bronze
final medal = switch (p.rank) {
1 => c.gold,
2 => const Color(0xFFB8BEC6),
3 => const Color(0xFFCD8B4E),
_ => null,
};
return Container(
margin: const EdgeInsets.only(bottom: 4),
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 7),
decoration: BoxDecoration(
color: ours ? c.accentSoft : Colors.transparent,
borderRadius: BorderRadius.circular(10),
),
child: Row(
children: [
Container(
width: 26,
height: 26,
alignment: Alignment.center,
decoration: BoxDecoration(
color: medal?.withValues(alpha: 0.22) ?? c.tile,
shape: BoxShape.circle,
),
child: Text('${p.rank}',
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w800, color: medal ?? c.ink2, fontFeatures: AppTheme.tnum)),
),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(p.name,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w700, color: c.ink)),
Text(p.club,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 11.5, color: ours ? c.accent : c.muted, fontWeight: ours ? FontWeight.w600 : null)),
],
),
),
// Each tournament: counted ones plain, dropped ones struck through
for (int i = 0; i < rounds; i++)
SizedBox(
width: 30,
child: Text(
i < p.cells.length && p.cells[i] != null ? '${p.cells[i]!.score}' : '–',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 11.5,
fontWeight: FontWeight.w600,
fontFeatures: AppTheme.tnum,
color: i < p.cells.length && p.cells[i] != null ? (p.cells[i]!.counted ? c.ink2 : c.faint) : c.faint,
decoration: i < p.cells.length && p.cells[i] != null && !p.cells[i]!.counted ? TextDecoration.lineThrough : null,
),
),
),
SizedBox(
width: 48,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text('${p.finalScore}',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w800, color: c.ink, fontFeatures: AppTheme.tnum)),
Text('${p.tens}×10', style: TextStyle(fontSize: 10.5, color: c.muted, fontFeatures: AppTheme.tnum)),
],
),
),
],
),
);
}
}
+181 -83
View File
@@ -20,12 +20,27 @@ import 'yolo_detector.dart';
/// "Preveri zadetke": the detected hits on the chosen target design. Tap a /// "Preveri zadetke": the detected hits on the chosen target design. Tap a
/// tile to pick a hit, then hold and drag on the target to move it; add or /// tile to pick a hit, then hold and drag on the target to move it; add or
/// remove hits; choose where to save; save. /// remove hits; choose where to save; save.
///
/// [PreviewScreen.edit] opens a saved target the same way: its hits, no photo
/// and no folder choice; saving overwrites that target's file.
class PreviewScreen extends StatefulWidget { class PreviewScreen extends StatefulWidget {
final String imagePath; final String? imagePath;
final List<DetectionResult> detections; final List<DetectionResult> detections;
final int bulletCount; final int bulletCount;
final File? editFile; // the saved target being edited
final List<Offset> initialHits;
const PreviewScreen({super.key, required this.imagePath, required this.detections, required this.bulletCount}); const PreviewScreen({super.key, required String this.imagePath, required this.detections, required this.bulletCount})
: editFile = null,
initialHits = const [];
const PreviewScreen.edit({super.key, required File file, required List<Offset> hits, required this.bulletCount})
: imagePath = null,
detections = const [],
editFile = file,
initialHits = hits;
bool get isEdit => editFile != null;
@override @override
State<PreviewScreen> createState() => _PreviewScreenState(); State<PreviewScreen> createState() => _PreviewScreenState();
@@ -68,7 +83,11 @@ class _PreviewScreenState extends State<PreviewScreen> {
} }
Future<void> _load() async { Future<void> _load() async {
if (widget.isEdit) {
_hits = [...widget.initialHits];
} else {
await Future.wait([_loadFolders(), _runDetectionAndMapping()]); await Future.wait([_loadFolders(), _runDetectionAndMapping()]);
}
if (mounted) setState(() => _isLoading = false); if (mounted) setState(() => _isLoading = false);
} }
@@ -106,7 +125,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
Future<void> _runDetectionAndMapping() async { Future<void> _runDetectionAndMapping() async {
try { try {
final bytes = await File(widget.imagePath).readAsBytes(); final bytes = await File(widget.imagePath!).readAsBytes();
_photo = bytes; _photo = bytes;
_photoSize = await _imageSize(bytes); _photoSize = await _imageSize(bytes);
@@ -232,9 +251,8 @@ class _PreviewScreenState extends State<PreviewScreen> {
final i = _selected; final i = _selected;
if (i == null) return; if (i == null) return;
setState(() { setState(() {
final p = _hits[i] + delta; // Keep it within the target's square
// Keep it on the canvas _hits[i] = TargetScoring.shown(_hits[i] + delta);
_hits[i] = Offset(p.dx.clamp(0, TargetScoring.size), p.dy.clamp(0, TargetScoring.size));
}); });
} }
@@ -285,7 +303,30 @@ class _PreviewScreenState extends State<PreviewScreen> {
}); });
} }
// Edit: the same file with the new hits; everything else in it is kept
Future<void> _saveEdit() async {
final file = widget.editFile!;
if (_saving) return;
setState(() => _saving = true);
try {
final data = jsonDecode(await file.readAsString()) as Map<String, dynamic>;
final scores = [for (int i = 0; i < _hits.length; i++) _scoreAt(i)];
data['totalScore'] = scores.fold(0, (a, b) => a + b);
data['bulletCount'] = widget.bulletCount;
data['bullets'] = [for (final b in _hits) {'x': b.dx, 'y': b.dy}];
data['scores'] = scores;
await file.writeAsString(jsonEncode(data));
TargetRepository.notifyChanged();
if (!mounted) return;
Navigator.pop(context, true);
} catch (e) {
debugPrint('Error saving edited target: $e');
if (mounted) setState(() => _saving = false);
}
}
Future<void> _save() async { Future<void> _save() async {
if (widget.isEdit) return _saveEdit();
final to = _saveTo; final to = _saveTo;
if (to == null || _saving) return; if (to == null || _saving) return;
setState(() => _saving = true); setState(() => _saving = true);
@@ -327,8 +368,8 @@ class _PreviewScreenState extends State<PreviewScreen> {
showHelpSheet(context, t: _t, items: const [ showHelpSheet(context, t: _t, items: const [
(Icons.touch_app_outlined, 'Tap a value below to pick that hit; it gets a red border.'), (Icons.touch_app_outlined, 'Tap a value below to pick that hit; it gets a red border.'),
(Icons.open_with_rounded, 'Hold and drag on the target to move the picked hit; a magnifier shows where it is.'), (Icons.open_with_rounded, 'Hold and drag on the target to move the picked hit; a magnifier shows where it is.'),
(Icons.add_rounded, 'Add hit: for a shot that was not found. Remove hit: deletes the picked one.'), (Icons.add_box_outlined, '+ tile: for a shot that was not found. Bin: deletes the picked hit.'),
(Icons.folder_outlined, 'Save to: training or tournament, and which folder. The last one is chosen for you.'), (Icons.emoji_events_outlined, 'Button bottom left: training or tournament. The folder on top: where it is saved; the last one is chosen for you.'),
(Icons.photo_outlined, 'Photo icon: see the photo with what was detected.'), (Icons.photo_outlined, 'Photo icon: see the photo with what was detected.'),
]); ]);
} }
@@ -338,33 +379,30 @@ class _PreviewScreenState extends State<PreviewScreen> {
final s = AppSettings.instance; final s = AppSettings.instance;
final c = Palette.current; final c = Palette.current;
final found = widget.detections.where((r) => r.classId == 0).length; final found = widget.detections.where((r) => r.classId == 0).length;
return Scaffold( // The picked target's own background (a holiday's wins)
body: Column( return AppBackground(
target: true,
child: Scaffold(
// Laid out on the target background's zones: header and "save to" above
// its first line, the target in the window between the lines, the hits
// and buttons below the second one
body: Stack(
children: [ children: [
BackHeader( if (!_isLoading)
title: _t('Check hits'), TargetWindow(
subtitle: _t('{n} hits detected · correct them if needed').replaceAll('{n}', '${min(found, widget.bulletCount)}'),
actions: [CircleButton(icon: Icons.info_outline_rounded, onTap: _showHelp)],
),
if (_isLoading)
const Expanded(child: Center(child: CircularProgressIndicator()))
else ...[
Padding(
padding: const EdgeInsets.fromLTRB(AppTheme.edge, 4, AppTheme.edge, 0),
child: _saveCard(c),
),
Expanded(
child: Stack( child: Stack(
children: [ children: [
Positioned.fill(child: _showPhoto ? _photoView(c) : _targetView(s, c)), Positioned.fill(child: _showPhoto ? _photoView(c) : _targetView(s, c)),
// The photo with what the model saw, for checking // The photo with what the model saw, for checking (a saved
// target has no photo): the window's top right corner
if (!widget.isEdit)
Positioned( Positioned(
top: 8, top: 10,
right: AppTheme.edge, right: AppTheme.edge,
child: CircleButton( child: CircleButton(
icon: _showPhoto ? Icons.track_changes_rounded : Icons.photo_outlined, icon: _showPhoto ? Icons.track_changes_rounded : Icons.photo_outlined,
size: 36, size: 40,
iconSize: 18, iconSize: 19,
tooltip: _t(_showPhoto ? 'Show Mapped Target' : 'Show Camera Detections'), tooltip: _t(_showPhoto ? 'Show Mapped Target' : 'Show Camera Detections'),
onTap: () => setState(() => _showPhoto = !_showPhoto), onTap: () => setState(() => _showPhoto = !_showPhoto),
), ),
@@ -372,43 +410,87 @@ class _PreviewScreenState extends State<PreviewScreen> {
], ],
), ),
), ),
// The folder it is saved to sits on the target window's upper line
if (!_isLoading && !widget.isEdit)
Positioned.fill(
child: LayoutBuilder(builder: (context, box) {
// From under the header (60 + the status bar) down to just
// above the line: it grows with the room the screen has
final (line, _) = TargetWindow.lines(box.biggest);
final bottom = line - 12;
final top = min(MediaQuery.paddingOf(context).top + 60 + 6, bottom - 56);
return Stack(children: [
Positioned(left: AppTheme.edge, right: AppTheme.edge, top: top, height: bottom - top, child: _saveCard(c)),
]);
}),
),
Column(
children: [
BackHeader(
title: _t(widget.isEdit ? 'Edit target' : 'Check hits'),
subtitle: widget.isEdit
? widget.editFile!.parent.path.split('/').last
: _t('{n} hits detected').replaceAll('{n}', '${min(found, widget.bulletCount)}'),
actions: [
CircleButton(icon: Icons.info_outline_rounded, onTap: _showHelp),
],
),
if (_isLoading)
const Expanded(child: Center(child: CircularProgressIndicator()))
else ...[
const Spacer(),
Padding( Padding(
padding: const EdgeInsets.fromLTRB(AppTheme.edge, 0, AppTheme.edge, 0), padding: const EdgeInsets.fromLTRB(AppTheme.edge, 8, AppTheme.edge, 0),
child: _tiles(c), child: _tiles(c),
), ),
Padding( _actions(c),
padding: const EdgeInsets.fromLTRB(AppTheme.edge, 12, AppTheme.edge, 0), ],
child: Row( ],
children: [
Expanded(
child: SoftButton(
label: _t('Add hit'),
icon: Icons.add_rounded,
onTap: _hits.length < widget.bulletCount ? _addHit : null,
),
),
const SizedBox(width: 10),
Expanded(
child: SoftButton(
label: _t('Remove hit'),
icon: Icons.delete_outline_rounded,
destructive: _selected != null,
onTap: _selected == null ? null : _removeHit,
),
), ),
], ],
), ),
), ),
Padding( );
}
// Like the result page: a square button either side of the main one
Widget _actions(Palette c) {
return Padding(
padding: EdgeInsets.fromLTRB(AppTheme.edge, 16, AppTheme.edge, 12 + MediaQuery.paddingOf(context).bottom), padding: EdgeInsets.fromLTRB(AppTheme.edge, 16, AppTheme.edge, 12 + MediaQuery.paddingOf(context).bottom),
child: Row(
children: [
// Training or tournament: one tap switches (and the folder with it)
if (!widget.isEdit) ...[
SquareButton(
size: 52,
icon: _tournament ? Icons.emoji_events_outlined : Icons.track_changes_rounded,
color: _tournament ? c.gold : c.accent,
background: _tournament ? c.goldSoft : c.accentSoft,
tooltip: _t(_tournament ? 'Tournament' : 'Training'),
onTap: () {
HapticFeedback.selectionClick();
_setKind(!_tournament);
},
),
const SizedBox(width: 10),
],
Expanded(
child: PrimaryButton( child: PrimaryButton(
label: '${_t('Save target')} · $_total', label: '${_t(widget.isEdit ? 'Save changes' : 'Save target')} · $_total',
icon: Icons.check_rounded, icon: Icons.check_rounded,
busy: _saving, busy: _saving,
onTap: _save, onTap: _save,
), ),
), ),
], const SizedBox(width: 10),
SquareButton(
size: 52,
icon: Icons.delete_outline_rounded,
tooltip: _t('Remove hit'),
color: _selected == null ? c.faint : c.red,
background: _selected == null ? null : c.redSoft,
onTap: _selected == null ? null : _removeHit,
),
], ],
), ),
); );
@@ -423,50 +505,65 @@ class _PreviewScreenState extends State<PreviewScreen> {
: DateUtils.isSameDay(to.date, DateTime.now()) : DateUtils.isSameDay(to.date, DateTime.now())
? '${_t('today')} ${DateFormat('HH:mm').format(to.date!)}' ? '${_t('today')} ${DateFormat('HH:mm').format(to.date!)}'
: DateFormat('d. M.').format(to.date ?? DateTime.now()); : DateFormat('d. M.').format(to.date ?? DateTime.now());
return AppCard( // The folder, with the kind above its name (switched by the button
padding: const EdgeInsets.fromLTRB(12, 12, 12, 12), // bottom left); fills the room between the header and the line
child: Column( final tint = _tournament ? c.gold : c.accent;
crossAxisAlignment: CrossAxisAlignment.stretch, return Material(
children: [ color: c.card,
Kicker(_t('Save to'), padding: const EdgeInsets.only(left: 2, bottom: 8)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16), side: BorderSide(color: c.line)),
SegmentedTabs(
height: 40,
items: [SegmentItem(_t('Training')), SegmentItem(_t('Tournament'))],
selected: _tournament ? 1 : 0,
onSelect: (i) => _setKind(i == 1),
),
const SizedBox(height: 8),
Material(
color: c.isDark ? c.card : c.card,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12), side: BorderSide(color: c.line)),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: InkWell( child: InkWell(
onTap: _pickFolder, onTap: _pickFolder,
child: SizedBox( child: LayoutBuilder(builder: (context, box) {
height: 42, final roomy = box.maxHeight >= 76;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 14),
child: Row( child: Row(
children: [ children: [
Container(
width: roomy ? 48 : 34,
height: roomy ? 48 : 34,
decoration: BoxDecoration(
color: _tournament ? c.goldSoft : c.accentSoft,
borderRadius: BorderRadius.circular(roomy ? 14 : 10),
),
child: Icon(Icons.folder_outlined, size: roomy ? 24 : 18, color: tint),
),
const SizedBox(width: 12), const SizedBox(width: 12),
Icon(Icons.folder_outlined, size: 18, color: c.accent), Expanded(
const SizedBox(width: 10), child: Column(
Flexible( mainAxisAlignment: MainAxisAlignment.center,
child: Text(to?.name ?? '', crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('${_t('Save to')} · ${_t(_tournament ? 'Tournament' : 'Training')}'.toUpperCase(),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: c.ink)), style: AppTheme.kicker(c).copyWith(fontSize: roomy ? 10.5 : 9.5)),
), SizedBox(height: roomy ? 4 : 2),
Text(' · $when', style: TextStyle(fontSize: 12.5, color: c.muted)), Text(to?.name ?? '',
const Spacer(), maxLines: 1,
Icon(Icons.expand_more_rounded, size: 20, color: c.muted), overflow: TextOverflow.ellipsis,
const SizedBox(width: 8), style: TextStyle(fontSize: roomy ? 19 : 15, height: 1.15, fontWeight: FontWeight.w700, color: c.ink)),
if (roomy && when.isNotEmpty) ...[
const SizedBox(height: 3),
Text(when, maxLines: 1, style: TextStyle(fontSize: 12.5, color: c.muted)),
],
], ],
), ),
), ),
), if (!roomy && when.isNotEmpty) ...[Text(when, style: TextStyle(fontSize: 12, color: c.muted)), const SizedBox(width: 4)],
Container(
width: 32,
height: 32,
decoration: BoxDecoration(color: c.tile, shape: BoxShape.circle),
child: Icon(Icons.unfold_more_rounded, size: 18, color: c.ink2),
), ),
], ],
), ),
); );
}),
),
);
} }
// The target with the hits; hold and drag moves the picked hit // The target with the hits; hold and drag moves the picked hit
@@ -475,17 +572,18 @@ class _PreviewScreenState extends State<PreviewScreen> {
final side = min(box.maxWidth, box.maxHeight) - 8; final side = min(box.maxWidth, box.maxHeight) - 8;
if (side <= 0) return const SizedBox(); if (side <= 0) return const SizedBox();
final scale = side / TargetScoring.size; final scale = side / TargetScoring.size;
Offset toTarget(Offset screen) => screen / scale;
final i = _selected; final i = _selected;
final picked = i == null || i >= _hits.length ? null : _hits[i] * scale; final picked = i == null || i >= _hits.length ? null : TargetScoring.shown(_hits[i]) * scale;
return Center( return Center(
child: SizedBox.square( child: SizedBox.square(
dimension: side, dimension: side,
child: GestureDetector( child: GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTapUp: (d) => _pickAt(d.localPosition / scale), onTapUp: (d) => _pickAt(toTarget(d.localPosition)),
onPanStart: (d) { onPanStart: (d) {
// Starting on another hit picks that one // Starting on another hit picks that one
final near = _nearest(d.localPosition / scale); final near = _nearest(toTarget(d.localPosition));
if (near != null) _selected = near; if (near != null) _selected = near;
if (_selected == null) return; if (_selected == null) return;
HapticFeedback.selectionClick(); HapticFeedback.selectionClick();
@@ -544,7 +642,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
int? best; int? best;
var bestD = 60.0; // target units: a little more than a hit's radius var bestD = 60.0; // target units: a little more than a hit's radius
for (int i = 0; i < _hits.length; i++) { for (int i = 0; i < _hits.length; i++) {
final d = (_hits[i] - p).distance; final d = (TargetScoring.shown(_hits[i]) - p).distance; // where it is drawn
if (d < bestD) { if (d < bestD) {
bestD = d; bestD = d;
best = i; best = i;
+1
View File
@@ -168,6 +168,7 @@ class _SessionScreenState extends State<SessionScreen> {
style: s.target, style: s.target,
hits: _hits[target.file.path]?.bullets ?? const [], hits: _hits[target.file.path]?.bullets ?? const [],
hitColor: s.bulletColor, hitColor: s.bulletColor,
zoomToHits: true,
), ),
), ),
const SizedBox(width: 12), const SizedBox(width: 12),

Some files were not shown because too many files have changed in this diff Show More