small updates

This commit is contained in:
2026-10-27 14:03:31 +01:00
parent 3b50cb0fe9
commit 9d9e0c77f2
8 changed files with 391 additions and 356 deletions
+201 -173
View File
@@ -4,6 +4,7 @@ import '../services/app_settings.dart';
import '../services/target_repository.dart';
import '../theme/app_theme.dart';
import '../widgets/bar_tabs.dart';
import '../widgets/help_sheet.dart';
import '../widgets/progress_chart.dart';
import '../widgets/section.dart';
import 'session_screen.dart';
@@ -125,12 +126,15 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
..sort((a, b) => counts[b]!.compareTo(counts[a]!));
}
Future<void> _openSession(Session session) async {
// Open the full session, not the copy limited to one format
final full = _sessions!
.firstWhere((s) => s.name == session.name, orElse: () => session);
await Navigator.push(context,
MaterialPageRoute(builder: (_) => SessionScreen(session: full)));
// The full session, not the copy limited to one format
Session _full(Session session) => _sessions!
.firstWhere((s) => s.name == session.name, orElse: () => session);
Future<void> _openDetails(Session session) async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (_) => SessionScreen(session: _full(session))));
_load();
}
@@ -188,7 +192,7 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
);
}
// Filters continue the dark app bar, like Koledar/Stiki; sort toggle at the end
// Filters continue the dark app bar, like Koledar/Stiki
Widget _buildTabs() {
final s = AppSettings.instance;
return BarTabs(
@@ -201,19 +205,18 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
_filter = _Filter.values[i];
_shots = null;
}),
trailing: IconButton(
tooltip: _sortByScore ? s.t('Sort by Score') : s.t('Sort by Date'),
icon: Icon(
_sortByScore ? Icons.leaderboard_rounded : Icons.event_rounded,
color: Colors.white),
onPressed: () => setState(() => _sortByScore = !_sortByScore),
),
);
}
// Second dark row under the tabs: shots-per-target pills left, year right
// 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) {
final sorted = [...formats]..sort();
final sorted = {
for (int n = AppSettings.minBullets; n <= AppSettings.maxBullets; n++) n,
...formats,
}.toList()
..sort();
return Container(
color: AppTheme.bar,
padding: const EdgeInsets.fromLTRB(12, 0, 4, 8),
@@ -224,11 +227,18 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
scrollDirection: Axis.horizontal,
child: Row(
children: [
Text(AppSettings.instance.t('Shots'),
style:
const TextStyle(fontSize: 12, color: Colors.white60)),
const SizedBox(width: 8),
for (final n in sorted) ...[
_BarPill(
label: shotCount(n),
label: '$n',
selected: n == selected,
onTap: () => setState(() => _shots = n)),
empty: !formats.contains(n),
onTap: formats.contains(n)
? () => setState(() => _shots = n)
: null),
const SizedBox(width: 6),
],
],
@@ -286,15 +296,7 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
.toList()
.reversed
.toList(); // oldest first
// Last session's average per shot compared with the overall average
final last =
chartSessions.isNotEmpty ? chartSessions.last.averagePerShot : null;
final delta = (last != null &&
stats.averagePerShot != null &&
chartSessions.length > 1)
? last - stats.averagePerShot!
: null;
const divider = VerticalDivider(width: 1, color: Colors.white24);
return ClipRRect(
borderRadius: BorderRadius.circular(20),
@@ -303,77 +305,56 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Dark header: headline number left, trend right
// Dark header: all four numbers in equal columns
Container(
color: AppTheme.bar,
padding: const EdgeInsets.fromLTRB(20, 14, 16, 14),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.t('Average per shot'),
style: const TextStyle(
fontSize: 13, color: Colors.white60)),
Text(
stats.averagePerShot?.toStringAsFixed(2) ?? '–',
style: const TextStyle(
fontSize: 40,
fontWeight: FontWeight.w800,
color: Colors.white,
height: 1.15),
),
],
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 14),
child: IntrinsicHeight(
child: Row(
children: [
Expanded(
child: _MiniStat(
label: s.t('Average per shot'),
value: stats.averagePerShot?.toStringAsFixed(2) ?? '–',
),
),
),
if (delta != null)
_TrendBadge(delta: delta, label: s.t('last training')),
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (chartSessions.length > 1) ...[
const SizedBox(height: 4),
ProgressChart(
points: _chartPoints(chartSessions),
color: s.bulletColor,
textColor: surf.textSecondary,
gridColor: surf.divider,
divider,
Expanded(
child: _MiniStat(
label: s.t('Best target'),
value: '${stats.best!.score}',
),
),
divider,
Expanded(
child: _MiniStat(
label: s.t('Average target'),
value: stats.averageTarget!.toStringAsFixed(1),
),
),
divider,
Expanded(
child: _MiniStat(
label: s.t(_filter == _Filter.tournament
? 'Tournaments'
: 'Trainings'),
value: '${stats.sessions}',
),
),
],
const SizedBox(height: 12),
Divider(height: 1, color: surf.divider),
const SizedBox(height: 14),
Row(
children: [
Expanded(
child: _MiniStat(
label: s.t('Best target'),
value: '${stats.best!.score}',
),
),
Expanded(
child: _MiniStat(
label: s.t('Average target'),
value: stats.averageTarget!.toStringAsFixed(1),
),
),
Expanded(
child: _MiniStat(
label: s.t('Targets'),
value: '${stats.targets}',
),
),
],
),
],
),
),
),
if (chartSessions.length > 1)
Padding(
padding: const EdgeInsets.fromLTRB(12, 12, 12, 12),
child: ProgressChart(
points: _chartPoints(chartSessions),
color: s.bulletColor,
textColor: surf.textSecondary,
gridColor: surf.divider,
),
),
],
),
),
@@ -385,25 +366,29 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
final surf = Surfaces.current;
final widgets = <Widget>[];
String monthOf(Session x) =>
DateFormat('LLLL yyyy', _locale).format(x.date).toUpperCase();
if (_sortByScore) {
final ranked = [...sessions]
..sort((a, b) => b.totalScore.compareTo(a.totalScore));
widgets.add(_monthHeader(s.t('Best results')));
// Average per shot, so sessions with more targets don't win by volume
final ranked = [...sessions]..sort(
(a, b) => (b.averagePerShot ?? 0).compareTo(a.averagePerShot ?? 0));
widgets.add(_sortBar(s.t('Best results').toUpperCase()));
widgets.addAll(ranked.map(_sessionCard));
return widgets;
}
String? month;
for (final session in sessions) {
final m =
DateFormat('LLLL yyyy', _locale).format(session.date).toUpperCase();
final m = monthOf(session);
if (m != month) {
widgets.add(_monthHeader(m));
// The first month header shares its row with the sort toggle
widgets.add(month == null ? _sortBar(m) : _monthHeader(m));
month = m;
}
widgets.add(_sessionCard(session));
}
if (widgets.isEmpty) {
if (sessions.isEmpty) {
widgets.add(Padding(
padding: const EdgeInsets.all(24),
child: Text(s.t('No saved target data found'),
@@ -413,6 +398,53 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
return widgets;
}
// Sort choice sits right above the list it sorts
Widget _sortBar(String title) {
final s = AppSettings.instance;
final surf = Surfaces.current;
return Padding(
padding: const EdgeInsets.fromLTRB(4, 16, 0, 4),
child: Row(
children: [
Expanded(
child: Text(
title,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
letterSpacing: 1.4,
color: surf.textSecondary,
),
),
),
SegmentedButton<bool>(
showSelectedIcon: false,
style: SegmentedButton.styleFrom(
visualDensity: VisualDensity.compact,
selectedBackgroundColor: s.bulletColor,
selectedForegroundColor: Colors.white,
foregroundColor: surf.textSecondary,
textStyle:
const TextStyle(fontSize: 12, fontWeight: FontWeight.w600),
),
segments: [
ButtonSegment(
value: false,
icon: const Icon(Icons.event_rounded, size: 16),
label: Text(s.t('Sort by Date'))),
ButtonSegment(
value: true,
icon: const Icon(Icons.leaderboard_rounded, size: 16),
label: Text(s.t('Sort by Score'))),
],
selected: {_sortByScore},
onSelectionChanged: (v) => setState(() => _sortByScore = v.first),
),
],
),
);
}
Widget _monthHeader(String text) {
return Padding(
padding: const EdgeInsets.fromLTRB(4, 24, 4, 10),
@@ -428,14 +460,12 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
);
}
// Same build as the calendar cards: date block on the left, content in the
// middle (opens the training), action strip on the right (opens all targets).
// Date block on the left like the calendar cards. Tap shows this session's
// targets of the selected format on one target; the menu opens details/edit.
Widget _sessionCard(Session session) {
final s = AppSettings.instance;
final surf = Surfaces.current;
final avg = session.averagePerShot;
final full = _sessions!
.firstWhere((x) => x.name == session.name, orElse: () => session);
return Padding(
padding: const EdgeInsets.only(bottom: 10),
@@ -461,9 +491,10 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: () => _openSession(session),
onTap: () => _openTargets(session),
onLongPress: () => _openDetails(session),
child: Padding(
padding: const EdgeInsets.fromLTRB(14, 12, 12, 12),
padding: const EdgeInsets.fromLTRB(14, 12, 4, 12),
child: Row(
children: [
Expanded(
@@ -516,16 +547,10 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
),
),
),
Material(
color: AppTheme.bar,
child: InkWell(
onTap: () => _openAllTargets(full),
child: const SizedBox(
width: 56,
child: Icon(Icons.visibility_rounded,
color: Colors.white, size: 22),
),
),
IconButton(
tooltip: s.t('Details'),
icon: Icon(Icons.more_vert_rounded, color: surf.textSecondary),
onPressed: () => _openDetails(session),
),
],
),
@@ -534,7 +559,7 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
);
}
Future<void> _openAllTargets(Session session) async {
Future<void> _openTargets(Session session) async {
if (session.targets.isEmpty) return;
await Navigator.push(
context,
@@ -580,50 +605,39 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
}
}
/// ▲/▼ difference with an icon, so the direction never depends on color alone.
class _TrendBadge extends StatelessWidget {
final double delta;
final String label;
const _TrendBadge({required this.delta, required this.label});
@override
Widget build(BuildContext context) {
final up = delta >= 0;
final color = up ? Colors.green[700]! : Colors.red[700]!;
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
decoration: BoxDecoration(
color: color, borderRadius: BorderRadius.circular(12)),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
up
? Icons.arrow_upward_rounded
: Icons.arrow_downward_rounded,
size: 14,
color: Colors.white),
const SizedBox(width: 2),
Text(
delta.abs().toStringAsFixed(2),
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Colors.white),
),
],
),
),
const SizedBox(height: 2),
Text(label,
style: const TextStyle(fontSize: 11, color: Colors.white60)),
],
);
}
/// What Knjiga shows and where to tap; opened from the info button in the app bar.
void showBookHelp(BuildContext context) {
final s = AppSettings.instance;
showHelpSheet(context, accent: s.bulletColor, t: s.t, items: const [
(
Icons.emoji_events_rounded,
'Trainings / Tournaments: choose which sessions the statistics count.'
),
(
Icons.filter_5_rounded,
'Shots 1–5: statistics only compare targets with the same number of shots. Grey numbers have no targets yet.'
),
(
Icons.calendar_month_rounded,
'Year (top right): choose which year to show.'
),
(
Icons.show_chart_rounded,
'Graph: average per shot over time. Tap or drag on it to see each value.'
),
(
Icons.leaderboard_rounded,
'By date / By score: sort the list by date or by best average per shot.'
),
(
Icons.touch_app_rounded,
'Tap a session to see all its targets with the selected number of shots on one target.'
),
(
Icons.more_vert_rounded,
'Three dots on the right or long press: session details, single targets, rename and delete.'
),
]);
}
class _MiniStat extends StatelessWidget {
@@ -632,19 +646,27 @@ class _MiniStat extends StatelessWidget {
const _MiniStat({required this.label, required this.value});
// White on the dark header; labels get two lines since four share the width
@override
Widget build(BuildContext context) {
final surf = Surfaces.current;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(value,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: surf.textPrimary)),
Text(label, style: TextStyle(fontSize: 12, color: surf.textSecondary)),
],
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Column(
children: [
Text(value,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.w800,
color: Colors.white)),
const SizedBox(height: 2),
Text(label,
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 11, color: Colors.white60, height: 1.2)),
],
),
);
}
}
@@ -697,10 +719,14 @@ class _DateBlock extends StatelessWidget {
class _BarPill extends StatelessWidget {
final String label;
final bool selected;
final VoidCallback onTap;
final bool empty; // no targets with this many shots
final VoidCallback? onTap; // null = not selectable
const _BarPill(
{required this.label, required this.selected, required this.onTap});
{required this.label,
required this.selected,
this.empty = false,
required this.onTap});
@override
Widget build(BuildContext context) {
@@ -712,13 +738,15 @@ class _BarPill extends StatelessWidget {
customBorder: const StadiumBorder(),
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6),
child: Text(
label,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: selected ? Colors.black : Colors.white70,
color: selected
? Colors.black
: (empty ? Colors.white30 : Colors.white70),
),
),
),
+20 -71
View File
@@ -7,7 +7,9 @@ import 'yolo_detector.dart';
import 'preview_screen.dart';
import '../utils/translations.dart';
import '../utils/target_colors.dart';
import '../services/app_settings.dart';
import '../widgets/camera_sheet.dart';
import '../widgets/help_sheet.dart';
class CameraScreen extends StatefulWidget {
const CameraScreen({super.key});
@@ -113,8 +115,9 @@ class _CameraScreenState extends State<CameraScreen> {
Future<void> _loadBulletCount() async {
final prefs = await SharedPreferences.getInstance();
setState(() {
_numberOfBullets = prefs.getInt('bulletCount') ??
5; // Load stored bullet count, default to 5
// Older versions allowed up to 10
_numberOfBullets = (prefs.getInt('bulletCount') ?? AppSettings.maxBullets)
.clamp(AppSettings.minBullets, AppSettings.maxBullets);
});
}
@@ -203,11 +206,13 @@ class _CameraScreenState extends State<CameraScreen> {
mainAxisSize: MainAxisSize.min,
children: [
CameraSheetHeader(
title: _t('Select the number of bullets'), subtitle: '1 – 10'),
title: _t('Select the number of bullets'),
subtitle:
'${AppSettings.minBullets} – ${AppSettings.maxBullets}'),
SheetStepper(
value: _numberOfBullets,
min: 1,
max: 10,
min: AppSettings.minBullets,
max: AppSettings.maxBullets,
accent: _bulletColor,
onChanged: (n) {
_selectBulletCount(n);
@@ -222,71 +227,15 @@ class _CameraScreenState extends State<CameraScreen> {
}
void _showHelpDialog() {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Colors.grey[900],
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_t('Help'),
style: const TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
_buildHelpItem(Icons.camera_alt,
_t('Tap camera button to capture and detect bullets')),
const SizedBox(height: 12),
_buildHelpItem(Icons.filter_9_plus,
_t('Bottom left number: Set expected bullet count (1-5)')),
const SizedBox(height: 12),
_buildHelpItem(Icons.tune,
_t('Settings icon: exposure, zoom and flashlight')),
const SizedBox(height: 12),
_buildHelpItem(Icons.crop_square,
_t('Align target inside the square frame')),
const SizedBox(height: 20),
Center(
child: ElevatedButton(
onPressed: () => Navigator.of(context).pop(),
style: ElevatedButton.styleFrom(
backgroundColor: _bulletColor,
foregroundColor: Colors.white,
),
child: Text(_t('Got it!')),
),
),
],
),
),
);
},
);
}
Widget _buildHelpItem(IconData icon, String text) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(icon, color: _bulletColor, size: 20),
const SizedBox(width: 12),
Expanded(
child: Text(
text,
style: const TextStyle(color: Colors.white, fontSize: 14),
),
),
],
);
showHelpSheet(context, accent: _bulletColor, t: _t, items: const [
(Icons.crop_square, 'Align the target inside the square frame.'),
(
Icons.camera_alt,
'Camera button: take a photo. Bullets are detected and you can check and save the result.'
),
(Icons.filter_5_rounded, 'Number bottom left: shots per target (1–5).'),
(Icons.tune, 'Settings icon: exposure, zoom and flashlight.'),
]);
}
void _showCameraControls() {
@@ -406,7 +355,7 @@ class _CameraScreenState extends State<CameraScreen> {
centerTitle: true,
actions: [
IconButton(
icon: const Icon(Icons.help_outline, color: Colors.white),
icon: const Icon(Icons.info_outline_rounded, color: Colors.white),
onPressed: _showHelpDialog,
),
const SizedBox(width: 16),
+6
View File
@@ -93,6 +93,12 @@ class _HomeScreenState extends State<HomeScreen> {
automaticallyImplyLeading: false,
scrolledUnderElevation: 0, // For Material 3 (Flutter 3.7+)
actions: [
if (_selected == AppTab.book)
IconButton(
tooltip: settings.t('Help'),
icon: const Icon(Icons.info_outline_rounded, color: Colors.white),
onPressed: () => showBookHelp(context),
),
if (_selected == AppTab.shooting)
IconButton(
icon: const Icon(Icons.visibility_rounded, color: Colors.white),
-3
View File
@@ -31,7 +31,6 @@ class SettingsScreen extends StatelessWidget {
SectionHeader(t('Language')),
GroupCard(children: [
SettingsTile(
leading: Text(language['flag']!, style: const TextStyle(fontSize: 22)),
title: t(language['name']!),
subtitle: s.followSystemLanguage ? t('Automatic (phone language)') : null,
onTap: () => _pickLanguage(context),
@@ -213,7 +212,6 @@ class SettingsScreen extends StatelessWidget {
children: [
_SheetTitle(s.t('Select Language')),
SheetOption(
leading: const Text('📱', style: TextStyle(fontSize: 22)),
label: '${s.t('Automatic (phone language)')} · ${s.t(AppSettings.systemLanguage)}',
selected: s.followSystemLanguage,
selectedColor: s.bulletColor,
@@ -224,7 +222,6 @@ class SettingsScreen extends StatelessWidget {
),
for (final lang in AppSettings.languages)
SheetOption(
leading: Text(lang['flag']!, style: const TextStyle(fontSize: 22)),
label: s.t(lang['name']!),
selected: !s.followSystemLanguage && lang['name'] == s.language,
selectedColor: s.bulletColor,
+32 -74
View File
@@ -12,7 +12,9 @@ import 'yolo_detector.dart';
import 'preview_screen.dart';
import 'package:wakelock_plus/wakelock_plus.dart';
import '../utils/translations.dart';
import '../services/app_settings.dart';
import '../widgets/camera_sheet.dart';
import '../widgets/help_sheet.dart';
import '../widgets/image_settings.dart';
import '../services/wifi_binding.dart';
@@ -128,7 +130,9 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
final waitOn = prefs.getBool('timerWaitEnabled') ?? false;
setState(() {
_selectedLanguage = prefs.getString('language') ?? 'English';
_numberOfBullets = prefs.getInt('bulletCount') ?? 5;
// Older versions allowed up to 10
_numberOfBullets = (prefs.getInt('bulletCount') ?? AppSettings.maxBullets)
.clamp(AppSettings.minBullets, AppSettings.maxBullets);
_image = image;
_bulletColor =
_getColorFromName(prefs.getString('bulletColor') ?? 'Blue');
@@ -396,7 +400,8 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
builder: (sheet) => StatefulBuilder(
builder: (context, setSheetState) {
Future<void> setCount(int count) async {
final clamped = count.clamp(1, 10);
final clamped =
count.clamp(AppSettings.minBullets, AppSettings.maxBullets);
setState(() => _numberOfBullets = clamped);
setSheetState(() {});
final prefs = await SharedPreferences.getInstance();
@@ -408,12 +413,13 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
children: [
CameraSheetHeader(
title: _t('Select the number of bullets'),
subtitle: '1 – 10',
subtitle:
'${AppSettings.minBullets} – ${AppSettings.maxBullets}',
),
SheetStepper(
value: _numberOfBullets,
min: 1,
max: 10,
min: AppSettings.minBullets,
max: AppSettings.maxBullets,
accent: _bulletColor,
onChanged: setCount,
),
@@ -426,74 +432,26 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
}
void _showHelpDialog() {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Colors.grey[900],
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_t('Help'),
style: const TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
_buildHelpItem(Icons.timer,
_t('Timer icon: Configure shoot/wait timer and start session')),
const SizedBox(height: 12),
_buildHelpItem(Icons.filter_9_plus,
_t('Bottom left number: Set expected bullet count (1-5)')),
const SizedBox(height: 12),
_buildHelpItem(Icons.brightness_6,
_t('Sun icon: Adjust brightness and contrast for better visibility')),
const SizedBox(height: 12),
_buildHelpItem(Icons.filter_alt,
_t('Filter icon: Apply color filters (None, Greyscale, Invert)')),
const SizedBox(height: 12),
_buildHelpItem(
Icons.pinch, _t('Pinch to zoom on the camera stream')),
const SizedBox(height: 20),
Center(
child: ElevatedButton(
onPressed: () => Navigator.of(context).pop(),
style: ElevatedButton.styleFrom(
backgroundColor: _bulletColor,
foregroundColor: Colors.white,
),
child: Text(_t('Got it!')),
),
),
],
),
),
);
},
);
}
Widget _buildHelpItem(IconData icon, String text) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(icon, color: _bulletColor, size: 20),
const SizedBox(width: 12),
Expanded(
child: Text(
text,
style: const TextStyle(color: Colors.white, fontSize: 14),
),
),
],
);
showHelpSheet(context, accent: _bulletColor, t: _t, items: const [
(Icons.pinch, 'Pinch to zoom on the camera stream'),
(Icons.filter_5_rounded, 'Number bottom left: shots per target (1–5).'),
(
Icons.timer,
'Timer icon: set shoot, reload and wait times. While the timer runs, tap it to stop.'
),
(
Icons.play_arrow,
'Play / pause / stop in the middle: control the timer.'
),
(
Icons.circle_outlined,
'Circle icon: shot counter. Tap + after each shot; when the target is full you get a "Change target!" warning.'
),
(
Icons.tune,
'Settings icon: brightness, contrast, filters and rotation, saved for each camera.'
),
]);
}
@override
@@ -1324,7 +1282,7 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
),
actions: [
IconButton(
icon: const Icon(Icons.help_outline, color: Colors.white),
icon: const Icon(Icons.info_outline_rounded, color: Colors.white),
onPressed: _showHelpDialog,
),
const SizedBox(width: 16),
+3
View File
@@ -19,6 +19,9 @@ class AppSettings extends ChangeNotifier {
static final AppSettings instance = AppSettings._();
static const String defaultTarget = 'assets/target.png';
// Shots per target, same limit for camera and stream capture
static const int minBullets = 1;
static const int maxBullets = 5;
static const List<int> reminderHourOptions = [1, 2, 3, 6, 12, 24, 48];
static const List<Map<String, String>> languages = [
+72 -35
View File
@@ -657,40 +657,49 @@ class AppTranslations {
'English': 'Help',
'Slovenian': 'Pomoč',
},
'Tap camera button to capture and detect bullets': {
'English': 'Tap camera button to capture and detect bullets',
'Slovenian': 'Tapnite gumb kamere za zajem in zaznavanje zadetkov',
},
'Timer icon: Configure shoot/wait timer and start session': {
'English': 'Timer icon: Configure shoot/wait timer and start session',
'Slovenian': 'Ikona časovnika: Nastavi časovnik strela/čakanja in začni serijo',
},
'Bottom left number: Set expected bullet count (1-5)': {
'English': 'Bottom left number: Set expected bullet count (1-5)',
'Slovenian': 'Spodaj levo številka: Nastavite število zadetkov (1-5)',
},
'Sun icon: Adjust brightness and contrast for better visibility': {
'English':
'Sun icon: Adjust brightness and contrast for better visibility',
'Slovenian':
'Ikona sonca: Prilagodite svetlost in kontrast za boljšo vidljivost',
},
'Filter icon: Apply color filters (None, Greyscale, Invert)': {
'English': 'Filter icon: Apply color filters (None, Greyscale, Invert)',
'Slovenian':
'Ikona filtra: Uporabite barvne filtre (Brez, Sivine, Inverzno)',
},
'Pinch to zoom on the camera stream': {
'English': 'Pinch to zoom on the camera stream',
'Slovenian': 'Povečajte s prstoma na video pretoku',
'English': 'Pinch to zoom on the camera stream.',
'Slovenian': 'Z dvema prstoma povečaš sliko kamere.',
},
'Align target inside the square frame': {
'English': 'Align target inside the square frame',
'Slovenian': 'Poravnajte tarčo znotraj kvadratnega okvirja',
'Align the target inside the square frame.': {
'English': 'Align the target inside the square frame.',
'Slovenian': 'Poravnaj tarčo znotraj kvadratnega okvirja.',
},
'Got it!': {
'English': 'Got it!',
'Slovenian': 'Razumem!',
'Camera button: take a photo. Bullets are detected and you can check and save the result.': {
'English':
'Camera button: take a photo. Bullets are detected and you can check and save the result.',
'Slovenian':
'Gumb kamere: posnemi tarčo. Zadetki se zaznajo, rezultat pa lahko preveriš in shraniš.',
},
'Number bottom left: shots per target (1–5).': {
'English': 'Number bottom left: shots per target (1–5).',
'Slovenian': 'Številka spodaj levo: število strelov na tarčo (1–5).',
},
'Settings icon: exposure, zoom and flashlight.': {
'English': 'Settings icon: exposure, zoom and flashlight.',
'Slovenian': 'Ikona nastavitev: osvetlitev, povečava in svetilka.',
},
'Timer icon: set shoot, reload and wait times. While the timer runs, tap it to stop.': {
'English':
'Timer icon: set shoot, reload and wait times. While the timer runs, tap it to stop.',
'Slovenian':
'Ikona časovnika: nastavi čas streljanja, polnjenja in čakanja. Ko časovnik teče, ga s tapom ustaviš.',
},
'Play / pause / stop in the middle: control the timer.': {
'English': 'Play / pause / stop in the middle: control the timer.',
'Slovenian': 'Predvajaj / premor / ustavi na sredini: upravljanje časovnika.',
},
'Circle icon: shot counter. Tap + after each shot; when the target is full you get a "Change target!" warning.': {
'English':
'Circle icon: shot counter. Tap + after each shot; when the target is full you get a "Change target!" warning.',
'Slovenian':
'Ikona kroga: števec strelov. Po vsakem strelu tapni +; ko je tarča polna, se prikaže opozorilo za menjavo tarče.',
},
'Settings icon: brightness, contrast, filters and rotation, saved for each camera.': {
'English':
'Settings icon: brightness, contrast, filters and rotation, saved for each camera.',
'Slovenian':
'Ikona nastavitev: svetlost, kontrast, filtri in vrtenje, shranjeno za vsako kamero.',
},
// Brightness & Contrast dialog translations
@@ -1184,6 +1193,10 @@ class AppTranslations {
'English': 'vs. last training',
'Slovenian': 'zadnji trening',
},
'Details': {
'English': 'Details',
'Slovenian': 'Podrobnosti',
},
'shot': {
'English': 'shot',
'Slovenian': 'strel',
@@ -1196,6 +1209,34 @@ class AppTranslations {
'English': 'Saved targets and your statistics will appear here',
'Slovenian': 'Tukaj se bodo prikazale shranjene tarče in tvoja statistika',
},
'Trainings / Tournaments: choose which sessions the statistics count.': {
'English': 'Trainings / Tournaments: choose which sessions the statistics count.',
'Slovenian': 'Treningi / Tekmovanja: izberi, katere seje šteje statistika.',
},
'Shots 1–5: statistics only compare targets with the same number of shots. Grey numbers have no targets yet.': {
'English': 'Shots 1–5: statistics only compare targets with the same number of shots. Grey numbers have no targets yet.',
'Slovenian': 'Streli 1–5: statistika primerja le tarče z enakim številom strelov. Sive številke še nimajo tarč.',
},
'Year (top right): choose which year to show.': {
'English': 'Year (top right): choose which year to show.',
'Slovenian': 'Leto (desno zgoraj): izberi, katero leto se prikaže.',
},
'Graph: average per shot over time. Tap or drag on it to see each value.': {
'English': 'Graph: average per shot over time. Tap or drag on it to see each value.',
'Slovenian': 'Graf: povprečje na strel skozi čas. Tapni ali povleci po njem za posamezno vrednost.',
},
'By date / By score: sort the list by date or by best average per shot.': {
'English': 'By date / By score: sort the list by date or by best average per shot.',
'Slovenian': 'Po datumu / Po rezultatu: razvrsti seznam po datumu ali po najboljšem povprečju na strel.',
},
'Tap a session to see all its targets with the selected number of shots on one target.': {
'English': 'Tap a session to see all its targets with the selected number of shots on one target.',
'Slovenian': 'Tapni sejo za prikaz vseh njenih tarč z izbranim številom strelov na eni tarči.',
},
'Three dots on the right or long press: session details, single targets, rename and delete.': {
'English': 'Three dots on the right or long press: session details, single targets, rename and delete.',
'Slovenian': 'Tri pike na desni ali dolg pritisk: podrobnosti seje, posamezne tarče, preimenovanje in brisanje.',
},
'Year': {
'English': 'Year',
'Slovenian': 'Leto',
@@ -1268,10 +1309,6 @@ class AppTranslations {
'English': 'Flashlight',
'Slovenian': 'Svetilka',
},
'Settings icon: exposure, zoom and flashlight': {
'English': 'Settings icon: exposure, zoom and flashlight',
'Slovenian': 'Ikona nastavitev: osvetlitev, povečava in svetilka',
},
'Automatic (phone language)': {
'English': 'Automatic (phone language)',
'Slovenian': 'Samodejno (jezik telefona)',
+57
View File
@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
/// Help bottom sheet: one icon + sentence per control, close button at the end.
/// 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,
}) {
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')),
),
),
],
),
),
),
);
}