UI fixes and league
This commit is contained in:
+86
-105
@@ -6,7 +6,6 @@ import '../services/app_settings.dart';
|
||||
import '../services/target_repository.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../utils/format.dart';
|
||||
import '../widgets/bar_tabs.dart';
|
||||
import '../widgets/ui.dart';
|
||||
import '../widgets/help_sheet.dart';
|
||||
import '../widgets/progress_chart.dart';
|
||||
@@ -289,8 +288,7 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
|
||||
|
||||
if (_view == _View.history) {
|
||||
return Column(children: [
|
||||
_buildTabs(),
|
||||
_buildHistoryBar(),
|
||||
_buildTabs(filters: _buildHistoryBar()),
|
||||
Expanded(child: _buildHistoryScreen()),
|
||||
]);
|
||||
}
|
||||
@@ -313,8 +311,7 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
_buildTabs(),
|
||||
_buildStatsBar(_formatCounts(typed.where(_inPeriod).toList()), shots),
|
||||
_buildTabs(filters: _buildStatsBar(_formatCounts(typed.where(_inPeriod).toList()), shots)),
|
||||
Expanded(
|
||||
child: _years.isEmpty
|
||||
? _centered(_buildEmpty())
|
||||
@@ -432,8 +429,8 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
|
||||
);
|
||||
}
|
||||
|
||||
// Title, then the two screens
|
||||
Widget _buildTabs() {
|
||||
// Title, then one card: the two screens over that screen's filters
|
||||
Widget _buildTabs({Widget? filters}) {
|
||||
final s = AppSettings.instance;
|
||||
return Column(
|
||||
children: [
|
||||
@@ -441,13 +438,21 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
|
||||
title: s.t('Book'),
|
||||
action: CircleButton(icon: Icons.info_outline_rounded, tooltip: s.t('Help'), onTap: () => showBookHelp(context)),
|
||||
),
|
||||
BarTabs(
|
||||
tabs: [
|
||||
BarTab(s.t('Statistics'), Icons.bar_chart_rounded),
|
||||
BarTab(s.t('History'), Icons.history_rounded),
|
||||
],
|
||||
selected: _view.index,
|
||||
onSelect: (i) => _change(() => _view = _View.values[i]),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(AppTheme.edge, 0, AppTheme.edge, 12),
|
||||
child: SegmentedCard(rows: [
|
||||
SegmentedTabs(
|
||||
bare: true,
|
||||
height: 40,
|
||||
items: [
|
||||
SegmentItem(s.t('Statistics'), Icons.bar_chart_rounded),
|
||||
SegmentItem(s.t('History'), Icons.history_rounded),
|
||||
],
|
||||
selected: _view.index,
|
||||
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
|
||||
Widget _buildHistoryBar() {
|
||||
final s = AppSettings.instance;
|
||||
final labels = {
|
||||
_HistoryFilter.all: s.t('All'),
|
||||
_HistoryFilter.training: s.t('Trainings'),
|
||||
_HistoryFilter.tournament: s.t('Tournaments'),
|
||||
};
|
||||
return Padding(
|
||||
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),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
return SegmentedTabs(
|
||||
bare: true,
|
||||
height: 36,
|
||||
items: [SegmentItem(s.t('All')), SegmentItem(s.t('Trainings')), SegmentItem(s.t('Tournaments'))],
|
||||
selected: _historyFilter.index,
|
||||
onSelect: (i) => _change(() => _historyFilter = _HistoryFilter.values[i]),
|
||||
);
|
||||
}
|
||||
|
||||
// Statistika: trainings or tournaments, then the shots-per-target format as
|
||||
// one chip with a menu. Shots are 1–5 (the capture limit); older saves above
|
||||
// 5 keep their own entry. Formats with no targets yet can't be picked.
|
||||
// Statistika: trainings or tournaments, and at the end of the same bar the
|
||||
// shots-per-target format as a menu. Shots are 1–5 (the capture limit);
|
||||
// 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) {
|
||||
final s = AppSettings.instance;
|
||||
final c = Palette.current;
|
||||
@@ -491,78 +482,68 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
|
||||
...counts.keys,
|
||||
}.toList()
|
||||
..sort((a, b) => b.compareTo(a));
|
||||
Widget kind(_Filter f, String label) => ChoicePill(
|
||||
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'),
|
||||
initialValue: selected,
|
||||
position: PopupMenuPosition.under,
|
||||
offset: const Offset(0, 6),
|
||||
color: c.isDark ? c.card2 : c.card,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
side: BorderSide(color: c.line),
|
||||
),
|
||||
onSelected: (n) => _change(() => _shots = n),
|
||||
itemBuilder: (_) => [
|
||||
for (final n in sorted)
|
||||
PopupMenuItem<int>(
|
||||
value: n,
|
||||
enabled: (counts[n] ?? 0) > 0,
|
||||
height: 44,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 22,
|
||||
child: n == selected ? Icon(Icons.check_rounded, size: 18, color: c.accent) : null,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(shotCount(n),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: n == selected ? FontWeight.w700 : FontWeight.w500,
|
||||
color: (counts[n] ?? 0) > 0 ? c.ink : c.faint)),
|
||||
const SizedBox(width: 16),
|
||||
const Spacer(),
|
||||
Text(targetCount(counts[n] ?? 0),
|
||||
style: TextStyle(fontSize: 12, color: c.muted, fontFeatures: AppTheme.tnum)),
|
||||
],
|
||||
),
|
||||
final shotsMenu = PopupMenuButton<int>(
|
||||
tooltip: s.t('Shots per target'),
|
||||
initialValue: selected,
|
||||
position: PopupMenuPosition.under,
|
||||
offset: const Offset(0, 6),
|
||||
color: c.isDark ? c.card2 : c.card,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
side: BorderSide(color: c.line),
|
||||
),
|
||||
onSelected: (n) => _change(() => _shots = n),
|
||||
itemBuilder: (_) => [
|
||||
for (final n in sorted)
|
||||
PopupMenuItem<int>(
|
||||
value: n,
|
||||
enabled: (counts[n] ?? 0) > 0,
|
||||
height: 44,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 22,
|
||||
child: n == selected ? Icon(Icons.check_rounded, size: 18, color: c.accent) : null,
|
||||
),
|
||||
],
|
||||
child: Container(
|
||||
height: 32,
|
||||
padding: const EdgeInsets.only(left: 12, right: 6),
|
||||
decoration: BoxDecoration(color: c.tile, borderRadius: BorderRadius.circular(16)),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(selected == null ? '–' : shotCount(selected),
|
||||
style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: c.ink2)),
|
||||
Icon(Icons.expand_more_rounded, size: 18, color: c.muted),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(shotCount(n),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: n == selected ? FontWeight.w700 : FontWeight.w500,
|
||||
color: (counts[n] ?? 0) > 0 ? c.ink : c.faint)),
|
||||
const SizedBox(width: 16),
|
||||
const Spacer(),
|
||||
Text(targetCount(counts[n] ?? 0),
|
||||
style: TextStyle(fontSize: 12, color: c.muted, fontFeatures: AppTheme.tnum)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 8, right: 2),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(selected == null ? '–' : shotCount(selected),
|
||||
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: c.ink)),
|
||||
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,
|
||||
);
|
||||
}
|
||||
|
||||
// Monday–Sunday week of [date], cut to its month: "6.–12. 10.", "27.–31. 10."
|
||||
|
||||
Reference in New Issue
Block a user