optimization of the detection algorithem.

BOOK update.
This commit is contained in:
Jan Pleterski
2026-11-27 09:43:25 +01:00
parent b22d7987e3
commit 5f9e2a3b86
11 changed files with 1209 additions and 542 deletions
+477 -216
View File
@@ -12,13 +12,20 @@ import '../widgets/section.dart';
import 'session_screen.dart';
import 'target_view.dart';
enum _View { stats, history }
enum _Filter { training, tournament }
enum _HistoryFilter { all, training, tournament }
enum _Period { month, threeMonths, year, all, custom }
/// Knjiga: one summary card with the shooter's form, records and progress graph,
/// then their sessions. One period filter drives the card and the list, so they
/// always agree; the graph has its own month/year navigation.
/// Knjiga, two screens:
/// * Statistika: the summary card (form, records) and the progress graph for
/// one kind of session and one number of shots per target, so averages
/// compare like with like. The graph has its own month/year navigation.
/// * Zgodovina: every session of the chosen kind, whatever its shot count.
/// One period filter drives the card and the list, so they always agree.
class BookScreen extends StatefulWidget {
const BookScreen({super.key});
@@ -31,7 +38,9 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
List<Session>? _sessions; // all sessions; null while loading
List<int> _years = []; // years with sessions, newest first
_Filter _filter = _Filter.training;
_View _view = _View.stats;
_Filter _filter = _Filter.training; // Statistika: trainings or tournaments
_HistoryFilter _historyFilter = _HistoryFilter.all; // Zgodovina
int? _shots; // shots per target shown; null = pick the most common one
bool _sortByScore = false;
_Period _period = _Period.year;
@@ -63,7 +72,9 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
final end = p.getInt('${_prefix}customEnd');
if (!mounted) return;
setState(() {
_view = pick(_View.values, 'view', _view);
_filter = pick(_Filter.values, 'filter', _filter);
_historyFilter = pick(_HistoryFilter.values, 'historyFilter', _historyFilter);
_period = pick(_Period.values, 'period', _period);
_shots = p.getInt('${_prefix}shots');
_sortByScore = p.getBool('${_prefix}sortByScore') ?? _sortByScore;
@@ -80,7 +91,9 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
Future<void> _saveSettings() async {
final p = await SharedPreferences.getInstance();
await p.setInt('${_prefix}view', _view.index);
await p.setInt('${_prefix}filter', _filter.index);
await p.setInt('${_prefix}historyFilter', _historyFilter.index);
await p.setInt('${_prefix}period', _period.index);
if (_shots == null) {
await p.remove('${_prefix}shots');
@@ -262,8 +275,17 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
]);
}
// Statistics only compare like with like: one tab, one shots-per-target
// format. The card and the list use the period; the graph its own month/year.
if (_view == _View.history) {
return Column(children: [
_buildTabs(),
_buildHistoryBar(),
Expanded(child: _buildHistoryScreen()),
]);
}
// Statistics only compare like with like: one kind of session, one
// shots-per-target format. The card uses the period; the graph its own
// month/year.
final typed = _filtered;
final formats = _formats(typed.where(_inPeriod).toList());
final shots = formats.contains(_shots)
@@ -280,23 +302,18 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
return Column(
children: [
_buildTabs(),
_buildFilterBar(formats, shots),
_buildStatsBar(formats, shots),
Expanded(
child: RefreshIndicator(
onRefresh: _load,
child: ListView(
padding: const EdgeInsets.fromLTRB(16, 16, 16, 32),
children: [
if (_years.isEmpty)
_buildEmpty()
else ...[
if (stats.targets > 0) _buildSummary(format, stats),
..._buildHistory(sessions,
stats.sessions > 1 ? stats.averagePerShot : null),
],
],
),
),
child: _years.isEmpty
? _centered(_buildEmpty())
: stats.targets == 0
? Column(children: [
Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
child: _periodRow()),
Expanded(child: _centered(_noSessions())),
])
: _buildStats(format, stats),
),
],
);
@@ -304,43 +321,205 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
);
}
// Filters continue the dark app bar, like Koledar/Stiki
// An empty state in the middle of the free space; pull-to-refresh still works
Widget _centered(Widget child) {
return RefreshIndicator(
onRefresh: _load,
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverFillRemaining(
hasScrollBody: false,
child: Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: child,
),
),
),
],
),
);
}
// Nothing in the chosen period or filter (there are sessions elsewhere)
Widget _noSessions() {
final s = AppSettings.instance;
final surf = Surfaces.current;
return Padding(
padding: const EdgeInsets.only(bottom: 48), // a little above the middle
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.event_busy_rounded, size: 40, color: surf.textSecondary),
const SizedBox(height: 10),
Text(s.t('No sessions in this period'),
textAlign: TextAlign.center,
style: TextStyle(fontSize: 15, color: surf.textSecondary)),
],
),
);
}
// Full-width "Obdobje … To leto ▾" button: says what it changes and that it
// can be tapped. Opens the period sheet; Statistika and Zgodovina share it.
Widget _periodRow() {
final s = AppSettings.instance;
final surf = Surfaces.current;
return Material(
color: surf.card,
borderRadius: BorderRadius.circular(14),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: _pickPeriod,
child: Padding(
padding: const EdgeInsets.fromLTRB(14, 10, 8, 10),
child: Row(
children: [
Icon(Icons.date_range_rounded, size: 20, color: s.bulletColor),
const SizedBox(width: 10),
Text(s.t('Period'),
style: TextStyle(fontSize: 13, color: surf.textSecondary)),
const SizedBox(width: 12),
Expanded(
child: Text(
_periodLabel(_period),
textAlign: TextAlign.right,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w700,
color: surf.textPrimary),
),
),
Icon(Icons.expand_more_rounded, color: surf.textSecondary),
],
),
),
),
);
}
// Zgodovina: every session of the chosen kind in the period, any shot count
Widget _buildHistoryScreen() {
if (_years.isEmpty) return _centered(_buildEmpty());
final sessions = [
for (final x in _sessions!)
if (_inPeriod(x) &&
switch (_historyFilter) {
_HistoryFilter.all => true,
_HistoryFilter.training => !x.isTournament,
_HistoryFilter.tournament => x.isTournament,
})
x,
];
// Average per shot over the listed sessions, for each card's difference
final shots = sessions.fold(0, (a, x) => a + x.shots);
final average = sessions.length > 1 && shots > 0
? sessions.fold(0, (a, x) => a + x.totalScore) / shots
: null;
if (sessions.isEmpty) {
return Column(children: [
Padding(
padding: const EdgeInsets.fromLTRB(16, 4, 16, 0),
child: _historyHeader()),
Expanded(child: _centered(_noSessions())),
]);
}
return RefreshIndicator(
onRefresh: _load,
child: ListView(
padding: const EdgeInsets.fromLTRB(16, 4, 16, 32),
children: _buildHistory(sessions, average),
),
);
}
// The two screens; filters continue the dark app bar, like Koledar/Stiki
Widget _buildTabs() {
final s = AppSettings.instance;
return BarTabs(
tabs: [
BarTab(s.t('Trainings'), Icons.track_changes_rounded),
BarTab(s.t('Tournaments'), Icons.emoji_events_rounded),
BarTab(s.t('Statistics'), Icons.insights_rounded),
BarTab(s.t('History'), Icons.history_rounded),
],
selected: _filter.index,
onSelect: (i) => _change(() {
_filter = _Filter.values[i];
_shots = null;
_chartAt = null;
}),
selected: _view.index,
onSelect: (i) => _change(() => _view = _View.values[i]),
);
}
// Second dark row under the tabs: shots-per-target pills across the width
// Always 1–5 (the capture limit); older saves above 5 keep their own pill.
// Formats with no targets yet are dimmed and can't be picked.
Widget _buildFilterBar(List<int> formats, int? selected) {
// Zgodovina's dark row: which sessions to list
Widget _buildHistoryBar() {
final s = AppSettings.instance;
final labels = {
_HistoryFilter.all: s.t('All'),
_HistoryFilter.training: s.t('Trainings'),
_HistoryFilter.tournament: s.t('Tournaments'),
};
return Container(
color: AppTheme.bar,
padding: const EdgeInsets.fromLTRB(12, 4, 12, 10),
child: Row(
children: [
for (final f in _HistoryFilter.values) ...[
if (f.index > 0) const SizedBox(width: 6),
Expanded(
child: _BarPill(
label: labels[f]!,
selected: f == _historyFilter,
empty: false,
onTap: () => _change(() => _historyFilter = f),
),
),
],
],
),
);
}
// Statistika's dark row: trainings or tournaments, then shots per target.
// Shots are always 1–5 (the capture limit); older saves above 5 keep their
// own pill. Formats with no targets yet are dimmed and can't be picked.
Widget _buildStatsBar(List<int> formats, int? selected) {
final s = AppSettings.instance;
final sorted = {
for (int n = AppSettings.minBullets; n <= AppSettings.maxBullets; n++) n,
...formats,
}.toList()
..sort();
Widget kind(_Filter f, String label) => Expanded(
flex: 5,
child: _BarPill(
label: s.t(label),
selected: f == _filter,
empty: false,
onTap: () => _change(() {
_filter = f;
_shots = null;
_chartAt = null;
}),
),
);
return Container(
color: AppTheme.bar,
padding: const EdgeInsets.fromLTRB(12, 4, 12, 10),
// Pills share the full width equally
child: Row(
children: [
Text(AppSettings.instance.t('Shots'),
style: const TextStyle(fontSize: 12, color: Colors.white60)),
kind(_Filter.training, 'Trainings'),
const SizedBox(width: 6),
kind(_Filter.tournament, 'Tournaments'),
// Divider between the two groups
Container(
width: 1,
height: 22,
margin: const EdgeInsets.symmetric(horizontal: 8),
color: Colors.white24),
for (final n in sorted) ...[
const SizedBox(width: 6),
if (n != sorted.first) const SizedBox(width: 4),
Expanded(
flex: 2,
child: _BarPill(
label: '$n',
selected: n == selected,
@@ -355,6 +534,7 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
);
}
// Monday–Sunday week of [date], cut to its month: "6.–12. 10.", "27.–31. 10."
static String _weekLabel(DateTime date) {
final day = DateTime(date.year, date.month, date.day);
@@ -427,105 +607,143 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
s.isLightBackground ? Colors.black : Colors.white, amount)!;
}
// Hero on the card surface (follows light/dark like the rest of Knjiga): the
// period's average per shot with its trend, counts and best session.
// The graph below gets every loaded session of the format, [all], and picks
// its own month or year.
Widget _buildSummary(List<Session> all, ShooterStats stats) {
// Statistika as cards: one with the period's average per shot and its trend
// beside three counts; the graph; the best session. It fits
// the screen without scrolling, the graph taking the height that is left;
// on a screen too small for that it scrolls with a fixed-height graph.
// The graph gets every loaded session of the format, [all], and picks its
// own month or year.
Widget _buildStats(List<Session> all, ShooterStats stats) {
final s = AppSettings.instance;
final bestSession = stats.bestSession;
final tournaments = _filter == _Filter.tournament;
const gap = SizedBox(height: 12);
// One card: the average on the left, the three counts on the right
final surf = Surfaces.current;
final top = _BookCard(
padding: const EdgeInsets.symmetric(vertical: 14),
child: IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(flex: 11, child: _averageContent(stats)),
VerticalDivider(width: 1, thickness: 1, color: surf.divider),
Expanded(
flex: 9,
child: Padding(
padding: const EdgeInsets.only(left: 14, right: 12),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_CountLine(
value: '${stats.sessions}',
label: s.t(tournaments ? 'Tournaments' : 'Trainings')),
_CountLine(
value: '${stats.targets}', label: s.t('Targets')),
_CountLine(
value: stats.averageTarget!.toStringAsFixed(1),
label: s.t('Average target')),
],
),
),
),
],
),
),
);
// Best session; tap to see its targets
final best = bestSession != null && stats.sessions > 1
? _HeroRecord(
label: s.t(tournaments ? 'Best tournament' : 'Best training'),
value: bestSession.averagePerShot!.toStringAsFixed(2),
caption:
'${DateFormat('d. M.').format(bestSession.date)} · ${bestSession.name}',
onTap: () => _openTargets(bestSession),
)
: null;
return LayoutBuilder(builder: (context, box) {
// Room for the cards above plus a graph that is still worth reading
if (box.maxHeight >= 560) {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
child: Column(
children: [
_periodRow(),
const SizedBox(height: 8),
top,
gap,
Expanded(child: _BookCard(child: _buildChart(all, stats, fill: true))),
if (best != null) ...[gap, best],
],
),
);
}
return RefreshIndicator(
onRefresh: _load,
child: ListView(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 32),
children: [
_periodRow(),
const SizedBox(height: 8),
top,
gap,
_BookCard(child: _buildChart(all, stats)),
if (best != null) ...[gap, best],
],
),
);
});
}
Widget _averageContent(ShooterStats stats) {
final s = AppSettings.instance;
final surf = Surfaces.current;
final trend = stats.trend;
final bestSession = stats.bestSession;
return ClipRRect(
borderRadius: BorderRadius.circular(20),
child: ColoredBox(
color: surf.card,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(18, 16, 18, 14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.t('Average per shot').toUpperCase(),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.bold,
letterSpacing: 1.2,
color: surf.textSecondary)),
Text(
stats.averagePerShot?.toStringAsFixed(2) ?? '–',
style: TextStyle(
fontSize: 44,
fontWeight: FontWeight.w800,
color: surf.textPrimary,
height: 1.1),
),
if (trend != null)
Text(
'${trend >= 0 ? '▲' : '▼'} ${trend.abs().toStringAsFixed(2)} ${s.t('vs earlier')}',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: _deltaColor(trend)),
),
],
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
_HeroCount(
value: '${stats.sessions}',
label: s.t(_filter == _Filter.tournament
? 'Tournaments'
: 'Trainings')),
_HeroCount(
value: '${stats.targets}', label: s.t('Targets')),
_HeroCount(
value: stats.averageTarget!.toStringAsFixed(1),
label: s.t('Average target')),
],
),
],
),
// Best session; tap to see its targets
if (bestSession != null && stats.sessions > 1) ...[
const SizedBox(height: 14),
_HeroRecord(
label: s.t(_filter == _Filter.tournament
? 'Best tournament'
: 'Best training'),
value: bestSession.averagePerShot!.toStringAsFixed(2),
caption:
'${DateFormat('d. M.').format(bestSession.date)} · ${bestSession.name}',
onTap: () => _openTargets(bestSession),
),
],
],
),
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(s.t('Average per shot').toUpperCase(),
maxLines: 2,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.bold,
letterSpacing: 1.2,
color: surf.textSecondary)),
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
stats.averagePerShot?.toStringAsFixed(2) ?? '–',
style: TextStyle(
fontSize: 48,
fontWeight: FontWeight.w800,
color: surf.textPrimary,
height: 1.1),
),
Divider(height: 1, thickness: 1, color: surf.divider),
_buildChart(all, stats),
],
),
),
if (trend != null)
Text(
'${trend >= 0 ? '▲' : '▼'} ${trend.abs().toStringAsFixed(2)} ${s.t('vs earlier')}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: _deltaColor(trend)),
),
],
),
);
}
// Shot average and points per session, each on its own scale.
Widget _buildChart(List<Session> all, ShooterStats stats) {
// [fill]: the graph takes all the height the card gets (inside an Expanded)
Widget _buildChart(List<Session> all, ShooterStats stats, {bool fill = false}) {
final s = AppSettings.instance;
final surf = Surfaces.current;
final scored = all.where((x) => x.shots > 0).toList();
@@ -594,23 +812,32 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
],
),
if (shown.isEmpty)
Padding(
padding: const EdgeInsets.symmetric(vertical: 40),
child: Text(s.t('No sessions in this period'),
style: TextStyle(color: surf.textSecondary)),
_fillIf(
fill,
Padding(
padding: const EdgeInsets.symmetric(vertical: 40),
child: Center(
child: Text(s.t('No sessions in this period'),
style: TextStyle(color: surf.textSecondary)),
),
),
)
else ...[
const SizedBox(height: 4),
ProgressChart(
labels: data.labels,
series: [
ChartSeries(s.t('Shot average'), s.bulletColor, data.perShot,
axis: ChartAxis.left),
ChartSeries(s.t('Number of points'), _tint(0.55), data.total,
decimals: 0, axis: ChartAxis.right),
],
textColor: surf.textSecondary,
gridColor: surf.divider,
_fillIf(
fill,
ProgressChart(
expand: fill,
labels: data.labels,
series: [
ChartSeries(s.t('Shot average'), s.bulletColor, data.perShot,
axis: ChartAxis.left),
ChartSeries(s.t('Number of points'), _tint(0.55), data.total,
decimals: 0, axis: ChartAxis.right),
],
textColor: surf.textSecondary,
gridColor: surf.divider,
),
),
],
],
@@ -618,6 +845,9 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
);
}
static Widget _fillIf(bool fill, Widget child) =>
fill ? Expanded(child: child) : child;
List<Widget> _buildHistory(List<Session> sessions, double? average) {
// Average per shot, so sessions with more targets don't win by volume
final ordered = _sortByScore
@@ -627,59 +857,53 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
return [
_historyHeader(),
for (final x in ordered) _sessionCard(x, average),
if (sessions.isEmpty)
Padding(
padding: const EdgeInsets.all(24),
child: Center(
child: Text(AppSettings.instance.t('No sessions in this period'),
style: TextStyle(color: Surfaces.current.textSecondary)),
),
),
];
}
// Section title, then the period chip (drives the card above too) and the sort toggle
// Period selector (shared with Statistika) and the sort order, both labelled
Widget _historyHeader() {
final s = AppSettings.instance;
final surf = Surfaces.current;
return Padding(
padding: const EdgeInsets.fromLTRB(4, 12, 0, 4),
child: Row(
// With the list's 4 px this starts 8 px under the bar, like Statistika
padding: const EdgeInsets.only(top: 4, bottom: 8),
// Same height for both buttons
child: IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: Text(
s.t(_sortByScore ? 'Best results' : 'History').toUpperCase(),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
letterSpacing: 1.4,
color: surf.textSecondary,
Expanded(child: _periodRow()),
const SizedBox(width: 8),
// Each tap switches between date and score order
Material(
color: surf.card,
borderRadius: BorderRadius.circular(14),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: () => _change(() => _sortByScore = !_sortByScore),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
child: Row(
children: [
Icon(
_sortByScore
? Icons.leaderboard_rounded
: Icons.event_rounded,
size: 20,
color: s.bulletColor),
const SizedBox(width: 6),
Text(s.t(_sortByScore ? 'Sort by Score' : 'Sort by Date'),
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: surf.textPrimary)),
],
),
),
),
),
ActionChip(
avatar: Icon(Icons.date_range_rounded,
size: 16, color: surf.textSecondary),
label: Text(_periodLabel(_period)),
labelStyle: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: surf.textPrimary),
backgroundColor: surf.card,
side: BorderSide.none,
shape: const StadiumBorder(),
visualDensity: VisualDensity.compact,
onPressed: _pickPeriod,
),
// Each tap switches between date and score order
IconButton(
tooltip: s.t(_sortByScore ? 'Sort by Score' : 'Sort by Date'),
icon: Icon(
_sortByScore ? Icons.leaderboard_rounded : Icons.event_rounded,
color: surf.textSecondary),
onPressed: () => _change(() => _sortByScore = !_sortByScore),
),
],
),
),
);
}
@@ -789,14 +1013,24 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
final s = AppSettings.instance;
final surf = Surfaces.current;
return Container(
padding: const EdgeInsets.symmetric(vertical: 48, horizontal: 24),
width: double.infinity,
margin: const EdgeInsets.only(bottom: 48), // a little above the middle
padding: const EdgeInsets.symmetric(vertical: 36, horizontal: 24),
decoration: BoxDecoration(
color: surf.card, borderRadius: BorderRadius.circular(20)),
color: surf.card, borderRadius: BorderRadius.circular(24)),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.track_changes_rounded,
size: 48, color: surf.textSecondary),
const SizedBox(height: 12),
Container(
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
color: s.bulletColor.withValues(alpha: 0.15),
shape: BoxShape.circle,
),
child: Icon(Icons.track_changes_rounded,
size: 44, color: s.bulletColor),
),
const SizedBox(height: 16),
Text(
s.t('No saved target data found'),
textAlign: TextAlign.center,
@@ -821,6 +1055,10 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
void showBookHelp(BuildContext context) {
final s = AppSettings.instance;
showHelpSheet(context, accent: s.bulletColor, t: s.t, items: const [
(
Icons.insights_rounded,
'Statistics / History: your form and progress graph, or the list of all your sessions.'
),
(
Icons.emoji_events_rounded,
'Trainings / Tournaments: choose which sessions the statistics count.'
@@ -843,7 +1081,11 @@ void showBookHelp(BuildContext context) {
),
(
Icons.date_range_rounded,
'Period (next to History): this month, last 3 months, this year, all or your own dates. The top card and the list both use it.'
'Period: this month, last 3 months, this year, all or your own dates. Statistics and History both use it.'
),
(
Icons.filter_list_rounded,
'History: All / Trainings / Tournaments chooses which sessions are listed, with any number of shots.'
),
(
Icons.sort_rounded,
@@ -851,7 +1093,7 @@ void showBookHelp(BuildContext context) {
),
(
Icons.touch_app_rounded,
'Tap a session to see all its targets with the selected number of shots on one target.'
'Tap a session to see all its targets on one target.'
),
(
Icons.more_vert_rounded,
@@ -860,36 +1102,55 @@ void showBookHelp(BuildContext context) {
]);
}
/// "12 Trainings" line on the hero, value first.
class _HeroCount extends StatelessWidget {
final String value;
final String label;
/// A rounded card on the page, the same surface as the history cards.
class _BookCard extends StatelessWidget {
final Widget child;
final EdgeInsetsGeometry padding;
const _HeroCount({required this.value, required this.label});
const _BookCard({required this.child, this.padding = EdgeInsets.zero});
@override
Widget build(BuildContext context) {
final surf = Surfaces.current;
return Padding(
padding: const EdgeInsets.only(top: 2),
child: Text.rich(
TextSpan(children: [
TextSpan(
text: value,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w800,
color: surf.textPrimary)),
TextSpan(
text: ' $label',
style: TextStyle(fontSize: 12, color: surf.textSecondary)),
]),
),
return Container(
padding: padding,
decoration: BoxDecoration(
color: Surfaces.current.card,
borderRadius: BorderRadius.circular(20)),
child: child,
);
}
}
/// Record on the hero: label and date left, value right. Tappable.
/// One count in the summary card: number, then its label, on one line.
class _CountLine extends StatelessWidget {
final String value;
final String label;
const _CountLine({required this.value, required this.label});
@override
Widget build(BuildContext context) {
final surf = Surfaces.current;
return Row(
children: [
Text(value,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w800,
color: surf.textPrimary)),
const SizedBox(width: 8),
Expanded(
child: Text(label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 12, color: surf.textSecondary)),
),
],
);
}
}
/// Best-session card: label and date left, value right. Tappable.
class _HeroRecord extends StatelessWidget {
final String label;
final String value;
@@ -906,13 +1167,13 @@ class _HeroRecord extends StatelessWidget {
Widget build(BuildContext context) {
final surf = Surfaces.current;
return Material(
color: surf.textPrimary.withValues(alpha: 0.06),
borderRadius: BorderRadius.circular(12),
color: surf.card,
borderRadius: BorderRadius.circular(20),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.fromLTRB(12, 8, 6, 8),
padding: const EdgeInsets.fromLTRB(16, 14, 10, 14),
child: Row(
children: [
Icon(Icons.emoji_events_rounded,