google preperation 1
This commit is contained in:
+661
-1069
File diff suppressed because it is too large
Load Diff
+292
-217
@@ -4,27 +4,15 @@ import 'package:intl/intl.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../models/contact.dart';
|
||||
import '../services/app_settings.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../widgets/bar_tabs.dart';
|
||||
import '../services/google_calendar_service.dart';
|
||||
import '../services/notification_service.dart';
|
||||
import '../utils/translations.dart';
|
||||
import '../utils/target_colors.dart';
|
||||
|
||||
class Contact {
|
||||
final String firstName;
|
||||
final String lastName;
|
||||
final String phone;
|
||||
final String email;
|
||||
|
||||
Contact({
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.phone,
|
||||
required this.email,
|
||||
});
|
||||
|
||||
String get fullName => '$firstName $lastName';
|
||||
}
|
||||
|
||||
enum EventType {
|
||||
regular,
|
||||
competition,
|
||||
@@ -48,29 +36,13 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
bool _showContacts = false;
|
||||
late Color _backgroundColor;
|
||||
|
||||
final List<Contact> _contacts = [
|
||||
Contact(firstName: 'Domen', lastName: 'Pleterski', phone: '051227764', email: 'info@bl3k.com'),
|
||||
Contact(firstName: 'Ivan', lastName: 'Tandler', phone: '040471258', email: 'ivan.tandler@gmail.com'),
|
||||
Contact(firstName: 'Jože', lastName: 'Verhnjak', phone: '041443463', email: 'joze.verhnjak@gmail.com'),
|
||||
Contact(firstName: 'Branko', lastName: 'Pokeržnik', phone: '041291001', email: 'pokerznik.helena@gmail.com'),
|
||||
Contact(firstName: 'Franc', lastName: 'Žigart', phone: '041439597', email: 'franc.zigart@gmail.com'),
|
||||
Contact(firstName: 'Janez', lastName: 'Božič', phone: '041551704', email: 'janbozic@gmail.com'),
|
||||
Contact(firstName: 'Mitja', lastName: 'Čeh', phone: '070550383', email: 'mekabara@gmail.com'),
|
||||
Contact(firstName: 'Rado', lastName: 'Keter', phone: '041324529', email: 'rado.keter@gmail.com'),
|
||||
Contact(firstName: 'Karli', lastName: 'Proje', phone: '040424951', email: 'karl.project@gmail.com'),
|
||||
Contact(firstName: 'Jan', lastName: 'Pleterski', phone: '041842063', email: 'jan.pleterski1997@gmail.com'),
|
||||
Contact(firstName: 'Silvo', lastName: 'Poročnik', phone: '040860618', email: 'skobar.silvo@gmail.com'),
|
||||
Contact(firstName: 'Dušan', lastName: 'Onuk', phone: '070448303', email: 'dusan.onuk@gmail.com'),
|
||||
Contact(firstName: 'Matjaž', lastName: 'Pleterski', phone: '041603859', email: 'matjaz.pleterski@gmail.com'),
|
||||
Contact(firstName: 'Marko', lastName: 'Blimen', phone: '031610857', email: 'blimenmarko@gmail.com'),
|
||||
Contact(firstName: 'Doris', lastName: 'Fesel', phone: '070373987', email: 'doris.fesel@gmail.com'),
|
||||
];
|
||||
List<Contact> get _contacts => AppSettings.instance.clubContacts;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
initializeDateFormatting('sl_SI', null);
|
||||
_backgroundColor = TargetColors.getBackgroundColor('assets/target.png');
|
||||
_backgroundColor = AppSettings.instance.backgroundColor;
|
||||
_loadBulletColor();
|
||||
_loadLanguage();
|
||||
_loadSelectedTargetColor();
|
||||
@@ -81,13 +53,16 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
|
||||
Future<void> _loadLanguage() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
setState(() => _selectedLanguage = prefs.getString('language') ?? 'English');
|
||||
setState(
|
||||
() => _selectedLanguage = prefs.getString('language') ?? 'English');
|
||||
}
|
||||
|
||||
Future<void> _loadSelectedTargetColor() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final selectedTarget = prefs.getString('selectedTarget') ?? 'assets/target.png';
|
||||
setState(() => _backgroundColor = TargetColors.getBackgroundColor(selectedTarget));
|
||||
final selectedTarget =
|
||||
prefs.getString('selectedTarget') ?? 'assets/target.png';
|
||||
setState(() =>
|
||||
_backgroundColor = TargetColors.getBackgroundColor(selectedTarget));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -103,22 +78,38 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
|
||||
Color _getAccentColor() {
|
||||
switch (_bulletColor.toLowerCase()) {
|
||||
case 'blue': return Colors.blue;
|
||||
case 'green': return Colors.green;
|
||||
case 'yellow': return Colors.yellow;
|
||||
case 'purple': return Colors.purple;
|
||||
case 'cyan': return Colors.cyan;
|
||||
case 'teal': return Colors.teal;
|
||||
case 'indigo': return Colors.indigo;
|
||||
case 'pink': return Colors.pink;
|
||||
case 'lime': return Colors.lime;
|
||||
case 'mint': return Colors.greenAccent;
|
||||
case 'orange': return Colors.orange;
|
||||
case 'violet': return Colors.deepPurpleAccent;
|
||||
case 'amber': return Colors.amber;
|
||||
case 'brown': return Colors.brown;
|
||||
case 'grey': return Colors.grey;
|
||||
default: return Colors.blue;
|
||||
case 'blue':
|
||||
return Colors.blue;
|
||||
case 'green':
|
||||
return Colors.green;
|
||||
case 'yellow':
|
||||
return Colors.yellow;
|
||||
case 'purple':
|
||||
return Colors.purple;
|
||||
case 'cyan':
|
||||
return Colors.cyan;
|
||||
case 'teal':
|
||||
return Colors.teal;
|
||||
case 'indigo':
|
||||
return Colors.indigo;
|
||||
case 'pink':
|
||||
return Colors.pink;
|
||||
case 'lime':
|
||||
return Colors.lime;
|
||||
case 'mint':
|
||||
return Colors.greenAccent;
|
||||
case 'orange':
|
||||
return Colors.orange;
|
||||
case 'violet':
|
||||
return Colors.deepPurpleAccent;
|
||||
case 'amber':
|
||||
return Colors.amber;
|
||||
case 'brown':
|
||||
return Colors.brown;
|
||||
case 'grey':
|
||||
return Colors.grey;
|
||||
default:
|
||||
return Colors.blue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +121,9 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
EventType? _getEventType(CalendarEvent event) {
|
||||
if (event.summary == null) return null;
|
||||
final summary = event.summary!.toLowerCase();
|
||||
if (summary.contains('liga') || summary.contains('tekmovanje') || summary.contains('tekma')) {
|
||||
if (summary.contains('liga') ||
|
||||
summary.contains('tekmovanje') ||
|
||||
summary.contains('tekma')) {
|
||||
return EventType.competition;
|
||||
} else if (summary.contains('sestanek')) {
|
||||
return EventType.sestanek;
|
||||
@@ -159,7 +152,8 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
if (!_isValidEvent(event)) return false;
|
||||
if (_getEventType(event) == null) return false;
|
||||
if (event.startTime != null) {
|
||||
final eventDate = DateTime(event.startTime!.year, event.startTime!.month, event.startTime!.day);
|
||||
final eventDate = DateTime(event.startTime!.year,
|
||||
event.startTime!.month, event.startTime!.day);
|
||||
return eventDate.isAtSameMomentAs(today) || eventDate.isAfter(today);
|
||||
}
|
||||
return false;
|
||||
@@ -225,51 +219,62 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||
),
|
||||
builder: (context) {
|
||||
return RepaintBoundary(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: accentColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
contact.firstName[0].toUpperCase(),
|
||||
style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold),
|
||||
// SafeArea keeps the buttons above Android's gesture bar (edge-to-edge)
|
||||
return SafeArea(
|
||||
child: RepaintBoundary(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: accentColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
contact.firstName[0].toUpperCase(),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Text(
|
||||
_capitalize(contact.fullName),
|
||||
style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Text(
|
||||
_capitalize(contact.fullName),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildContactDetailRow(accentColor, Icons.phone, _t('Phone'), contact.phone, () {
|
||||
_copyToClipboard(contact.phone, 'Phone number');
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
const SizedBox(height: 12),
|
||||
_buildContactDetailRow(accentColor, Icons.email, _t('Email'), contact.email.toLowerCase(), () {
|
||||
_copyToClipboard(contact.email, 'Email address');
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
],
|
||||
_buildContactDetailRow(
|
||||
accentColor, Icons.phone, _t('Phone'), contact.phone, () {
|
||||
_copyToClipboard(contact.phone, 'Phone number');
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
const SizedBox(height: 12),
|
||||
_buildContactDetailRow(accentColor, Icons.email, _t('Email'),
|
||||
contact.email.toLowerCase(), () {
|
||||
_copyToClipboard(contact.email, 'Email address');
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -277,10 +282,12 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContactDetailRow(Color accentColor, IconData icon, String label, String value, VoidCallback onCopy) {
|
||||
Widget _buildContactDetailRow(Color accentColor, IconData icon, String label,
|
||||
String value, VoidCallback onCopy) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
||||
decoration: BoxDecoration(color: Colors.grey[850], borderRadius: BorderRadius.circular(10)),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[850], borderRadius: BorderRadius.circular(10)),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, color: accentColor, size: 20),
|
||||
@@ -289,13 +296,21 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(label, style: const TextStyle(color: Colors.grey, fontSize: 11)),
|
||||
Text(value, style: const TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w600), maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
Text(label,
|
||||
style: const TextStyle(color: Colors.grey, fontSize: 11)),
|
||||
Text(value,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(color: accentColor, borderRadius: BorderRadius.circular(8)),
|
||||
decoration: BoxDecoration(
|
||||
color: accentColor, borderRadius: BorderRadius.circular(8)),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
@@ -303,7 +318,8 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Icon(Icons.content_copy, color: Colors.white, size: 18),
|
||||
child:
|
||||
Icon(Icons.content_copy, color: Colors.white, size: 18),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -321,15 +337,18 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
itemBuilder: (context, index) {
|
||||
final contact = _contacts[index];
|
||||
return GestureDetector(
|
||||
onTap: () => _makePhoneCall(contact.phone),
|
||||
onLongPress: () => _showContactPopup(context, contact),
|
||||
// Card opens the info sheet (copy number/e-mail); the call strip on the right calls
|
||||
onTap: () => _showContactPopup(context, contact),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
color: Surfaces.current.card,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(color: Colors.grey.withValues(alpha: 0.3), blurRadius: 8, offset: const Offset(0, 2)),
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.15),
|
||||
blurRadius: 6,
|
||||
offset: const Offset(0, 2)),
|
||||
],
|
||||
),
|
||||
child: Stack(
|
||||
@@ -339,44 +358,62 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: accentColor.withValues(alpha: 0.6),
|
||||
borderRadius: const BorderRadius.only(topLeft: Radius.circular(12), topRight: Radius.circular(12)),
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(12),
|
||||
topRight: Radius.circular(12)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 4,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(2)),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(2)),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
_capitalize(contact.fullName),
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 14, vertical: 6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(children: [
|
||||
Icon(Icons.phone, size: 14, color: accentColor),
|
||||
const SizedBox(width: 6),
|
||||
Text(contact.phone, style: const TextStyle(fontSize: 12, color: Colors.black87, fontWeight: FontWeight.w500)),
|
||||
Text(contact.phone,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Surfaces.current.textPrimary,
|
||||
fontWeight: FontWeight.w500)),
|
||||
]),
|
||||
const SizedBox(height: 4),
|
||||
Row(children: [
|
||||
Icon(Icons.email, size: 14, color: accentColor),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Text(contact.email.toLowerCase(), style: const TextStyle(fontSize: 12, color: Colors.black87, fontWeight: FontWeight.w500), overflow: TextOverflow.ellipsis),
|
||||
child: Text(contact.email.toLowerCase(),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Surfaces.current.textPrimary,
|
||||
fontWeight: FontWeight.w500),
|
||||
overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
]),
|
||||
],
|
||||
@@ -385,19 +422,27 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
right: 0, top: 0, bottom: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
width: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: accentColor,
|
||||
borderRadius: const BorderRadius.only(topRight: Radius.circular(10), bottomRight: Radius.circular(10)),
|
||||
borderRadius: const BorderRadius.only(
|
||||
topRight: Radius.circular(10),
|
||||
bottomRight: Radius.circular(10)),
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () => _makePhoneCall(contact.phone),
|
||||
borderRadius: const BorderRadius.only(topRight: Radius.circular(10), bottomRight: Radius.circular(10)),
|
||||
child: const Center(child: Icon(Icons.call, color: Colors.white, size: 22)),
|
||||
borderRadius: const BorderRadius.only(
|
||||
topRight: Radius.circular(10),
|
||||
bottomRight: Radius.circular(10)),
|
||||
child: const Center(
|
||||
child: Icon(Icons.call,
|
||||
color: Colors.white, size: 22)),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -412,48 +457,64 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
|
||||
Color _eventColor(EventType type, Color accentColor) {
|
||||
switch (type) {
|
||||
case EventType.competition: return Colors.orange;
|
||||
case EventType.sestanek: return const Color(0xFFE53935);
|
||||
case EventType.regular: return accentColor;
|
||||
case EventType.competition:
|
||||
return Colors.orange;
|
||||
case EventType.sestanek:
|
||||
return const Color(0xFFE53935);
|
||||
case EventType.regular:
|
||||
return accentColor;
|
||||
}
|
||||
}
|
||||
|
||||
IconData _eventIcon(EventType type) {
|
||||
switch (type) {
|
||||
case EventType.competition: return Icons.emoji_events;
|
||||
case EventType.sestanek: return Icons.people;
|
||||
case EventType.regular: return Icons.calendar_today;
|
||||
case EventType.competition:
|
||||
return Icons.emoji_events;
|
||||
case EventType.sestanek:
|
||||
return Icons.people;
|
||||
case EventType.regular:
|
||||
return Icons.calendar_today;
|
||||
}
|
||||
}
|
||||
|
||||
String _eventBadgeLabel(EventType type) {
|
||||
switch (type) {
|
||||
case EventType.competition: return _t('COMPETITION');
|
||||
case EventType.sestanek: return _t('MEETING');
|
||||
case EventType.regular: return _t('DUTY');
|
||||
case EventType.competition:
|
||||
return _t('COMPETITION');
|
||||
case EventType.sestanek:
|
||||
return _t('MEETING');
|
||||
case EventType.regular:
|
||||
return _t('DUTY');
|
||||
}
|
||||
}
|
||||
|
||||
String _timeText(CalendarEvent event) {
|
||||
final startTime = event.startTime;
|
||||
if (event.isAllDay || startTime == null || event.endTime == null) return _t('All day');
|
||||
if (event.isAllDay || startTime == null || event.endTime == null)
|
||||
return _t('All day');
|
||||
return '${DateFormat('HH:mm').format(startTime.toLocal())} – ${DateFormat('HH:mm').format(event.endTime!.toLocal())}';
|
||||
}
|
||||
|
||||
Widget _buildEventCard(CalendarEvent event, Color accentColor, {bool highlight = false}) {
|
||||
// When [date] is given, the type stripe widens into a date block (upcoming list).
|
||||
Widget _buildEventCard(CalendarEvent event, Color accentColor,
|
||||
{bool highlight = false, DateTime? date, int daysFromToday = 0}) {
|
||||
final eventType = _getEventType(event);
|
||||
if (eventType == null) return const SizedBox();
|
||||
|
||||
final color = _eventColor(eventType, accentColor);
|
||||
final hasLocation = event.location != null && event.location!.isNotEmpty;
|
||||
|
||||
final surf = Surfaces.current;
|
||||
return RepaintBoundary(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
color: surf.card,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(color: Colors.black.withValues(alpha: 0.15), blurRadius: 6, offset: const Offset(0, 2)),
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.15),
|
||||
blurRadius: 6,
|
||||
offset: const Offset(0, 2)),
|
||||
],
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
@@ -461,23 +522,31 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// Type color stripe
|
||||
Container(width: 5, color: color),
|
||||
// Type color stripe, or date block for upcoming events
|
||||
date != null
|
||||
? _buildDateBlock(date, daysFromToday, color)
|
||||
: Container(width: 5, color: color),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.fromLTRB(12, highlight ? 12 : 10, 12, highlight ? 12 : 10),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
12, highlight ? 12 : 10, 12, highlight ? 12 : 10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
_buildTypeChip(_eventIcon(eventType), _eventBadgeLabel(eventType), color),
|
||||
_buildTypeChip(_eventIcon(eventType),
|
||||
_eventBadgeLabel(eventType), color),
|
||||
const Spacer(),
|
||||
Icon(Icons.access_time, size: 13, color: Colors.grey[700]),
|
||||
Icon(Icons.access_time,
|
||||
size: 13, color: surf.textSecondary),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
_timeText(event),
|
||||
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.grey[800]),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: surf.textSecondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -487,19 +556,21 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
style: TextStyle(
|
||||
fontSize: highlight ? 16 : 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.grey[900],
|
||||
color: surf.textPrimary,
|
||||
),
|
||||
),
|
||||
if (hasLocation) ...[
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.location_on, size: 13, color: Colors.grey[600]),
|
||||
Icon(Icons.location_on,
|
||||
size: 13, color: surf.textSecondary),
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Text(
|
||||
event.location!,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[700]),
|
||||
style: TextStyle(
|
||||
fontSize: 12, color: surf.textSecondary),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
@@ -530,13 +601,19 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
children: [
|
||||
Icon(icon, size: 11, color: color),
|
||||
const SizedBox(width: 4),
|
||||
Text(label, style: TextStyle(fontSize: 10, fontWeight: FontWeight.bold, color: color, letterSpacing: 0.6)),
|
||||
Text(label,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color,
|
||||
letterSpacing: 0.6)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionHeader(String label, Color dotColor, Color textColor, {String? trailing, Color? trailingColor}) {
|
||||
Widget _buildSectionHeader(String label, Color dotColor, Color textColor,
|
||||
{String? trailing, Color? trailingColor}) {
|
||||
return Row(
|
||||
children: [
|
||||
Container(
|
||||
@@ -545,7 +622,12 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
decoration: BoxDecoration(color: dotColor, shape: BoxShape.circle),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(label, style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold, color: textColor, letterSpacing: 1.4)),
|
||||
Text(label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: textColor,
|
||||
letterSpacing: 1.4)),
|
||||
if (trailing != null) ...[
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
@@ -560,32 +642,43 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDateColumn(DateTime date, int daysFromToday, Color accentColor, bool isLight) {
|
||||
Widget _buildDateBlock(DateTime date, int daysFromToday, Color color) {
|
||||
final locale = _selectedLanguage == 'Slovenian' ? 'sl_SI' : 'en_US';
|
||||
final relative = daysFromToday == 1
|
||||
? _t('Tomorrow')
|
||||
: _t('in {n} days').replaceAll('{n}', '$daysFromToday');
|
||||
|
||||
return SizedBox(
|
||||
width: 48,
|
||||
return Container(
|
||||
width: 56,
|
||||
color: color,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 2),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
DateFormat('EEE', locale).format(date).toUpperCase(),
|
||||
style: TextStyle(fontSize: 10, fontWeight: FontWeight.w700, color: isLight ? Colors.grey[700] : Colors.grey[400], letterSpacing: 0.8),
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white.withValues(alpha: 0.9),
|
||||
letterSpacing: 0.8),
|
||||
),
|
||||
Text(
|
||||
DateFormat('d').format(date),
|
||||
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: isLight ? Colors.black87 : Colors.white, height: 1.15),
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
height: 1.15),
|
||||
),
|
||||
Text(
|
||||
relative,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 9,
|
||||
fontWeight: daysFromToday == 1 ? FontWeight.bold : FontWeight.w500,
|
||||
color: daysFromToday == 1 ? accentColor : (isLight ? Colors.grey[600] : Colors.grey[500]),
|
||||
fontWeight:
|
||||
daysFromToday == 1 ? FontWeight.bold : FontWeight.w500,
|
||||
color: Colors.white.withValues(alpha: 0.9),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -606,17 +699,24 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
final textSecondary = isLight ? Colors.grey[700]! : Colors.grey[400]!;
|
||||
final textMuted = isLight ? Colors.grey[600]! : Colors.grey[500]!;
|
||||
|
||||
DateTime dayOf(CalendarEvent e) => DateTime(e.startTime!.year, e.startTime!.month, e.startTime!.day);
|
||||
DateTime dayOf(CalendarEvent e) =>
|
||||
DateTime(e.startTime!.year, e.startTime!.month, e.startTime!.day);
|
||||
|
||||
final todayEvents = _events.where((e) => e.startTime != null && dayOf(e).isAtSameMomentAs(today)).toList();
|
||||
final upcomingEvents = _events.where((e) => e.startTime != null && dayOf(e).isAfter(today)).toList();
|
||||
final todayEvents = _events
|
||||
.where((e) => e.startTime != null && dayOf(e).isAtSameMomentAs(today))
|
||||
.toList();
|
||||
final upcomingEvents = _events
|
||||
.where((e) => e.startTime != null && dayOf(e).isAfter(today))
|
||||
.toList();
|
||||
|
||||
// Build upcoming list grouped by month, date column shown once per day
|
||||
// Build upcoming list grouped by month, each card carries its own date block
|
||||
final upcomingWidgets = <Widget>[];
|
||||
DateTime? lastDay;
|
||||
for (final e in upcomingEvents) {
|
||||
final day = dayOf(e);
|
||||
final isNewMonth = lastDay == null || lastDay.month != day.month || lastDay.year != day.year;
|
||||
final isNewMonth = lastDay == null ||
|
||||
lastDay.month != day.month ||
|
||||
lastDay.year != day.year;
|
||||
final isNewDay = lastDay == null || !lastDay.isAtSameMomentAs(day);
|
||||
|
||||
if (isNewMonth) {
|
||||
@@ -624,23 +724,20 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
padding: EdgeInsets.fromLTRB(16, lastDay == null ? 4 : 18, 16, 8),
|
||||
child: Text(
|
||||
DateFormat('LLLL yyyy', locale).format(day).toUpperCase(),
|
||||
style: TextStyle(fontSize: 11, fontWeight: FontWeight.bold, color: textMuted, letterSpacing: 1.5),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: textMuted,
|
||||
letterSpacing: 1.5),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
upcomingWidgets.add(Padding(
|
||||
padding: EdgeInsets.fromLTRB(12, isNewDay && !isNewMonth ? 10 : 0, 16, 8),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
isNewDay
|
||||
? _buildDateColumn(day, day.difference(today).inDays, accentColor, isLight)
|
||||
: const SizedBox(width: 48),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: _buildEventCard(e, accentColor)),
|
||||
],
|
||||
),
|
||||
padding:
|
||||
EdgeInsets.fromLTRB(16, isNewDay && !isNewMonth ? 10 : 0, 16, 8),
|
||||
child: _buildEventCard(e, accentColor,
|
||||
date: day, daysFromToday: day.difference(today).inDays),
|
||||
));
|
||||
lastDay = day;
|
||||
}
|
||||
@@ -668,7 +765,8 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
if (todayEvents.isEmpty)
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 14),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 14, horizontal: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: textMuted.withValues(alpha: 0.12),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
@@ -677,15 +775,17 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
children: [
|
||||
Icon(Icons.event_busy, size: 18, color: textMuted),
|
||||
const SizedBox(width: 10),
|
||||
Text(_t('No events today'), style: TextStyle(fontSize: 13, color: textSecondary)),
|
||||
Text(_t('No events today'),
|
||||
style:
|
||||
TextStyle(fontSize: 13, color: textSecondary)),
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
...todayEvents.map((e) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: _buildEventCard(e, accentColor, highlight: true),
|
||||
)),
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: _buildEventCard(e, accentColor, highlight: true),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -693,7 +793,8 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
if (upcomingEvents.isNotEmpty) ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 24, 16, 10),
|
||||
child: _buildSectionHeader(_t('UPCOMING'), textMuted, textPrimary),
|
||||
child:
|
||||
_buildSectionHeader(_t('UPCOMING'), textMuted, textPrimary),
|
||||
),
|
||||
...upcomingWidgets,
|
||||
],
|
||||
@@ -705,9 +806,11 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
children: [
|
||||
Icon(Icons.event_available, size: 56, color: textMuted),
|
||||
const SizedBox(height: 12),
|
||||
Text(_t('No upcoming events'), style: TextStyle(fontSize: 15, color: textMuted)),
|
||||
Text(_t('No upcoming events'),
|
||||
style: TextStyle(fontSize: 15, color: textMuted)),
|
||||
const SizedBox(height: 6),
|
||||
Text(_t('Pull down to refresh'), style: TextStyle(fontSize: 13, color: textSecondary)),
|
||||
Text(_t('Pull down to refresh'),
|
||||
style: TextStyle(fontSize: 13, color: textSecondary)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -741,14 +844,19 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
const SizedBox(height: 24),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
child: Text(_errorMessage!, textAlign: TextAlign.center, style: const TextStyle(fontSize: 16, color: Colors.white70)),
|
||||
child: Text(_errorMessage!,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 16, color: Surfaces.current.textSecondary)),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton.icon(
|
||||
onPressed: _loadEvents,
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: Text(_t('Retry')),
|
||||
style: ElevatedButton.styleFrom(backgroundColor: accentColor, foregroundColor: Colors.white),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: accentColor,
|
||||
foregroundColor: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -760,19 +868,13 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
backgroundColor: _backgroundColor,
|
||||
body: Column(
|
||||
children: [
|
||||
// Tab bar
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[900],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildTab(_t('Calendar'), Icons.calendar_month, !_showContacts, () => setState(() => _showContacts = false)),
|
||||
const SizedBox(width: 6),
|
||||
_buildTab(_t('Contacts'), Icons.people, _showContacts, () => setState(() => _showContacts = true)),
|
||||
],
|
||||
),
|
||||
BarTabs(
|
||||
tabs: [
|
||||
BarTab(_t('Calendar'), Icons.calendar_month),
|
||||
BarTab(_t('Contacts'), Icons.people),
|
||||
],
|
||||
selected: _showContacts ? 1 : 0,
|
||||
onSelect: (i) => setState(() => _showContacts = i == 1),
|
||||
),
|
||||
// Body
|
||||
Expanded(
|
||||
@@ -784,31 +886,4 @@ class _CalendarScreenState extends State<CalendarScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTab(String label, IconData icon, bool active, VoidCallback onTap) {
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: active ? Colors.white : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, color: active ? Colors.black : Colors.grey[400], size: 18),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: active ? Colors.black : Colors.grey[400]),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+196
-266
@@ -7,6 +7,7 @@ import 'yolo_detector.dart';
|
||||
import 'preview_screen.dart';
|
||||
import '../utils/translations.dart';
|
||||
import '../utils/target_colors.dart';
|
||||
import '../widgets/camera_sheet.dart';
|
||||
|
||||
class CameraScreen extends StatefulWidget {
|
||||
const CameraScreen({super.key});
|
||||
@@ -26,9 +27,10 @@ class _CameraScreenState extends State<CameraScreen> {
|
||||
String _selectedLanguage = 'English';
|
||||
late Color _backgroundColor;
|
||||
|
||||
// Brightness and contrast controls
|
||||
double _brightness = 0.0; // -1.0 to 1.0
|
||||
double _contrast = 1.0; // 0.0 to 2.0
|
||||
// Real camera controls (they change the photo itself)
|
||||
double _exposure = 0, _minExposure = 0, _maxExposure = 0;
|
||||
double _zoom = 1, _minZoom = 1, _maxZoom = 1;
|
||||
bool _torch = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -40,24 +42,9 @@ class _CameraScreenState extends State<CameraScreen> {
|
||||
_loadBulletColor(); // 👈
|
||||
_loadLanguage();
|
||||
_loadSelectedTargetColor();
|
||||
_loadBrightnessContrast();
|
||||
YOLODetector.create().then((detector) => _yoloDetector = detector);
|
||||
}
|
||||
|
||||
Future<void> _loadBrightnessContrast() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
_brightness = prefs.getDouble('brightness') ?? 0.0;
|
||||
_contrast = prefs.getDouble('contrast') ?? 1.0;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _saveBrightnessContrast() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setDouble('brightness', _brightness);
|
||||
await prefs.setDouble('contrast', _contrast);
|
||||
}
|
||||
|
||||
String _t(String key) {
|
||||
return AppTranslations.translate(key, _selectedLanguage);
|
||||
}
|
||||
@@ -71,63 +58,63 @@ class _CameraScreenState extends State<CameraScreen> {
|
||||
|
||||
Future<void> _loadSelectedTargetColor() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final selectedTarget = prefs.getString('selectedTarget') ?? 'assets/target.png';
|
||||
final selectedTarget =
|
||||
prefs.getString('selectedTarget') ?? 'assets/target.png';
|
||||
setState(() {
|
||||
_backgroundColor = TargetColors.getBackgroundColor(selectedTarget);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _loadBulletColor() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final selected = prefs.getString('bulletColor') ?? 'Blue';
|
||||
setState(() {
|
||||
_bulletColor = _getColorFromName(selected);
|
||||
});
|
||||
}
|
||||
|
||||
Color _getColorFromName(String colorName) {
|
||||
switch (colorName.toLowerCase()) {
|
||||
case 'blue':
|
||||
return Colors.blue;
|
||||
case 'green':
|
||||
return Colors.green;
|
||||
case 'yellow':
|
||||
return Colors.yellow;
|
||||
case 'purple':
|
||||
return Colors.purple;
|
||||
case 'cyan':
|
||||
return Colors.cyan;
|
||||
case 'teal':
|
||||
return Colors.teal;
|
||||
case 'indigo':
|
||||
return Colors.indigo;
|
||||
case 'pink':
|
||||
return Colors.pink;
|
||||
case 'lime':
|
||||
return Colors.lime;
|
||||
case 'mint':
|
||||
return Colors.greenAccent;
|
||||
case 'orange':
|
||||
return Colors.orange;
|
||||
case 'violet':
|
||||
return Colors.deepPurpleAccent;
|
||||
case 'amber':
|
||||
return Colors.amber;
|
||||
case 'brown':
|
||||
return Colors.brown;
|
||||
case 'grey':
|
||||
return Colors.grey;
|
||||
default:
|
||||
return Colors.blue; // fallback
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final selected = prefs.getString('bulletColor') ?? 'Blue';
|
||||
setState(() {
|
||||
_bulletColor = _getColorFromName(selected);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Color _getColorFromName(String colorName) {
|
||||
switch (colorName.toLowerCase()) {
|
||||
case 'blue':
|
||||
return Colors.blue;
|
||||
case 'green':
|
||||
return Colors.green;
|
||||
case 'yellow':
|
||||
return Colors.yellow;
|
||||
case 'purple':
|
||||
return Colors.purple;
|
||||
case 'cyan':
|
||||
return Colors.cyan;
|
||||
case 'teal':
|
||||
return Colors.teal;
|
||||
case 'indigo':
|
||||
return Colors.indigo;
|
||||
case 'pink':
|
||||
return Colors.pink;
|
||||
case 'lime':
|
||||
return Colors.lime;
|
||||
case 'mint':
|
||||
return Colors.greenAccent;
|
||||
case 'orange':
|
||||
return Colors.orange;
|
||||
case 'violet':
|
||||
return Colors.deepPurpleAccent;
|
||||
case 'amber':
|
||||
return Colors.amber;
|
||||
case 'brown':
|
||||
return Colors.brown;
|
||||
case 'grey':
|
||||
return Colors.grey;
|
||||
default:
|
||||
return Colors.blue; // fallback
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadBulletCount() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
_numberOfBullets = prefs.getInt('bulletCount') ?? 5; // Load stored bullet count, default to 5
|
||||
_numberOfBullets = prefs.getInt('bulletCount') ??
|
||||
5; // Load stored bullet count, default to 5
|
||||
});
|
||||
}
|
||||
|
||||
@@ -146,7 +133,13 @@ Color _getColorFromName(String colorName) {
|
||||
enableAudio: false,
|
||||
);
|
||||
|
||||
_initializeControllerFuture = _controller!.initialize();
|
||||
_initializeControllerFuture = _controller!.initialize().then((_) async {
|
||||
// Ranges differ per phone; read them once the camera is ready
|
||||
_minExposure = await _controller!.getMinExposureOffset();
|
||||
_maxExposure = await _controller!.getMaxExposureOffset();
|
||||
_minZoom = await _controller!.getMinZoomLevel();
|
||||
_maxZoom = (await _controller!.getMaxZoomLevel()).clamp(_minZoom, 8.0);
|
||||
});
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
|
||||
@@ -193,7 +186,7 @@ Color _getColorFromName(String colorName) {
|
||||
builder: (context) => PreviewScreen(
|
||||
imagePath: croppedFile.path,
|
||||
detections: detections,
|
||||
bulletCount: _numberOfBullets, // Pass the bullet count
|
||||
bulletCount: _numberOfBullets, // Pass the bullet count
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -202,83 +195,40 @@ Color _getColorFromName(String colorName) {
|
||||
}
|
||||
}
|
||||
|
||||
// Method to show the dialog for selecting the number of bullets
|
||||
void _showBulletDialog() {
|
||||
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), // Increased padding for better spacing
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16.0),
|
||||
child: Text(
|
||||
_t('Select the number of bullets'),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
children: List.generate(5, (index) {
|
||||
final bulletNum = index + 1;
|
||||
final isSelected = _numberOfBullets == bulletNum;
|
||||
return ElevatedButton(
|
||||
onPressed: () {
|
||||
_selectBulletCount(bulletNum);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
isSelected ? _bulletColor : Colors.grey[800],
|
||||
foregroundColor: Colors.white,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'$bulletNum',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight:
|
||||
isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
],
|
||||
showCameraSheet(
|
||||
context,
|
||||
builder: (sheet) => StatefulBuilder(
|
||||
builder: (context, setSheetState) => Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CameraSheetHeader(
|
||||
title: _t('Select the number of bullets'), subtitle: '1 – 10'),
|
||||
SheetStepper(
|
||||
value: _numberOfBullets,
|
||||
min: 1,
|
||||
max: 10,
|
||||
accent: _bulletColor,
|
||||
onChanged: (n) {
|
||||
_selectBulletCount(n);
|
||||
setSheetState(() {});
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void _showHelpDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return Dialog(
|
||||
backgroundColor: Colors.grey[900],
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
@@ -287,16 +237,23 @@ Color _getColorFromName(String colorName) {
|
||||
children: [
|
||||
Text(
|
||||
_t('Help'),
|
||||
style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold),
|
||||
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')),
|
||||
_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)')),
|
||||
_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')),
|
||||
_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')),
|
||||
_buildHelpItem(Icons.crop_square,
|
||||
_t('Align target inside the square frame')),
|
||||
const SizedBox(height: 20),
|
||||
Center(
|
||||
child: ElevatedButton(
|
||||
@@ -332,116 +289,88 @@ Color _getColorFromName(String colorName) {
|
||||
);
|
||||
}
|
||||
|
||||
void _showBrightnessContrastDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setDialogState) {
|
||||
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,
|
||||
children: [
|
||||
Text(
|
||||
_t('Brightness & Contrast'),
|
||||
style: const TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
// Brightness slider
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${_t('Brightness')}: ${(_brightness * 100).toInt()}',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16),
|
||||
),
|
||||
Slider(
|
||||
value: _brightness,
|
||||
min: -1.0,
|
||||
max: 1.0,
|
||||
divisions: 40,
|
||||
activeColor: _bulletColor,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_brightness = value;
|
||||
});
|
||||
setDialogState(() {});
|
||||
_saveBrightnessContrast();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Contrast slider
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${_t('Contrast')}: ${(_contrast * 100).toInt()}%',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 16),
|
||||
),
|
||||
Slider(
|
||||
value: _contrast,
|
||||
min: 0.5,
|
||||
max: 2.0,
|
||||
divisions: 30,
|
||||
activeColor: _bulletColor,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_contrast = value;
|
||||
});
|
||||
setDialogState(() {});
|
||||
_saveBrightnessContrast();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_brightness = 0.0;
|
||||
_contrast = 1.0;
|
||||
});
|
||||
setDialogState(() {});
|
||||
_saveBrightnessContrast();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.grey[800],
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
child: Text(_t('Reset')),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: _bulletColor,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
child: Text(_t('Done')),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
void _showCameraControls() {
|
||||
showCameraSheet(
|
||||
context,
|
||||
builder: (sheet) => StatefulBuilder(
|
||||
builder: (context, setSheetState) {
|
||||
Future<void> apply(
|
||||
VoidCallback change, Future<void> Function() camera) async {
|
||||
setState(change);
|
||||
setSheetState(() {});
|
||||
try {
|
||||
await camera();
|
||||
} catch (_) {} // control not supported on this phone
|
||||
}
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CameraSheetHeader(
|
||||
title: _t('Image Settings'),
|
||||
trailing: TextButton.icon(
|
||||
style: TextButton.styleFrom(foregroundColor: Colors.white70),
|
||||
icon: const Icon(Icons.restart_alt_rounded, size: 18),
|
||||
label: Text(_t('Reset')),
|
||||
onPressed: () => apply(() {
|
||||
_exposure = 0;
|
||||
_zoom = _minZoom;
|
||||
}, () async {
|
||||
await _controller!.setExposureOffset(0);
|
||||
await _controller!.setZoomLevel(_minZoom);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
if (_maxExposure > _minExposure)
|
||||
SheetSlider(
|
||||
icon: Icons.exposure_rounded,
|
||||
label: _t('Exposure'),
|
||||
valueText:
|
||||
'${_exposure >= 0 ? '+' : ''}${_exposure.toStringAsFixed(1)}',
|
||||
value: _exposure,
|
||||
min: _minExposure,
|
||||
max: _maxExposure,
|
||||
accent: _bulletColor,
|
||||
onChanged: (v) => apply(() => _exposure = v,
|
||||
() => _controller!.setExposureOffset(v)),
|
||||
),
|
||||
if (_maxZoom > _minZoom)
|
||||
SheetSlider(
|
||||
icon: Icons.zoom_in_rounded,
|
||||
label: _t('Zoom'),
|
||||
valueText: '${_zoom.toStringAsFixed(1)}×',
|
||||
value: _zoom,
|
||||
min: _minZoom,
|
||||
max: _maxZoom,
|
||||
accent: _bulletColor,
|
||||
onChanged: (v) => apply(
|
||||
() => _zoom = v, () => _controller!.setZoomLevel(v)),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: SheetToggle(
|
||||
icon: _torch
|
||||
? Icons.flashlight_on_rounded
|
||||
: Icons.flashlight_off_rounded,
|
||||
label: _t('Flashlight'),
|
||||
active: _torch,
|
||||
accent: _bulletColor,
|
||||
onTap: () => apply(
|
||||
() => _torch = !_torch,
|
||||
() => _controller!
|
||||
.setFlashMode(_torch ? FlashMode.torch : FlashMode.off),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Update the bullet count and save it
|
||||
void _selectBulletCount(int number) {
|
||||
setState(() {
|
||||
_numberOfBullets = number; // Update the selected number
|
||||
@@ -519,8 +448,9 @@ Color _getColorFromName(String colorName) {
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.brightness_6, color: Colors.white, size: 24),
|
||||
onPressed: _showBrightnessContrastDialog,
|
||||
icon:
|
||||
const Icon(Icons.tune, color: Colors.white, size: 24),
|
||||
onPressed: _showCameraControls,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -540,35 +470,35 @@ Color _getColorFromName(String colorName) {
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
final screenSize = MediaQuery.of(context).size;
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
color: Colors.black, // covers any empty space
|
||||
child: FittedBox(
|
||||
fit: BoxFit.cover,
|
||||
child: SizedBox(
|
||||
width: _controller!.value.previewSize!.height,
|
||||
height: _controller!.value.previewSize!.width,
|
||||
child: CameraPreview(_controller!),
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
color: Colors.black, // covers any empty space
|
||||
child: FittedBox(
|
||||
fit: BoxFit.cover,
|
||||
child: SizedBox(
|
||||
width: _controller!.value.previewSize!.height,
|
||||
height: _controller!.value.previewSize!.width,
|
||||
child: CameraPreview(_controller!),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Container(
|
||||
width: screenSize.width * 0.9,
|
||||
height: screenSize.width * 0.9,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: _bulletColor.withValues(alpha: 0.9),
|
||||
width: 3,
|
||||
Center(
|
||||
child: Container(
|
||||
width: screenSize.width * 0.9,
|
||||
height: screenSize.width * 0.9,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: _bulletColor.withValues(alpha: 0.9),
|
||||
width: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/camera_setup.dart';
|
||||
import '../services/app_settings.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../widgets/section.dart';
|
||||
import '../widgets/text_prompt.dart';
|
||||
|
||||
/// Locations (strelišča), number of positions, and the camera IP of every
|
||||
/// position at every location.
|
||||
class CameraSettingsScreen extends StatelessWidget {
|
||||
const CameraSettingsScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListenableBuilder(
|
||||
listenable: AppSettings.instance,
|
||||
builder: (context, _) {
|
||||
final s = AppSettings.instance;
|
||||
final t = s.t;
|
||||
final setup = s.cameras;
|
||||
final surf = Surfaces.current;
|
||||
const firstPort = CameraSetup.firstPort;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: s.backgroundColor,
|
||||
appBar: AppBar(
|
||||
title: Text(t('Cameras'), style: const TextStyle(color: Colors.white)),
|
||||
backgroundColor: AppTheme.bar,
|
||||
iconTheme: const IconThemeData(color: Colors.white),
|
||||
scrolledUnderElevation: 0,
|
||||
),
|
||||
body: ListView(
|
||||
// Keep the last row clear of the system gesture bar (edge-to-edge)
|
||||
padding: EdgeInsets.fromLTRB(16, 4, 16, 24 + MediaQuery.paddingOf(context).bottom),
|
||||
children: [
|
||||
SectionHeader(t('Locations')),
|
||||
GroupCard(children: [
|
||||
for (final location in setup.locations)
|
||||
SettingsTile(
|
||||
leading: Icon(
|
||||
location == setup.clubLocation ? Icons.verified_rounded : Icons.place_rounded,
|
||||
color: location == setup.clubLocation ? Colors.green : s.bulletColor,
|
||||
),
|
||||
title: location,
|
||||
subtitle: location == setup.clubLocation ? t('Added with the club code') : null,
|
||||
value: t('{n} cameras').replaceAll('{n}', '${setup.camerasIn(location)}'),
|
||||
onTap: () => _editLocation(context, location),
|
||||
),
|
||||
SettingsTile(
|
||||
leading: Icon(Icons.add_rounded, color: surf.textSecondary),
|
||||
title: t('Add location'),
|
||||
onTap: () => _addLocation(context),
|
||||
),
|
||||
]),
|
||||
|
||||
SectionHeader(t('Positions')),
|
||||
GroupCard(children: [
|
||||
SettingsTile(
|
||||
title: t('Number of positions'),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.remove_rounded),
|
||||
color: surf.textPrimary,
|
||||
onPressed: setup.positions > 1 ? () => s.setPositionCount(setup.positions - 1) : null,
|
||||
),
|
||||
SizedBox(
|
||||
width: 28,
|
||||
child: Text(
|
||||
'${setup.positions}',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: surf.textPrimary),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add_rounded),
|
||||
color: surf.textPrimary,
|
||||
onPressed: setup.positions < CameraSetup.maxPositions
|
||||
? () => s.setPositionCount(setup.positions + 1)
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
]),
|
||||
|
||||
for (final location in setup.locations) ...[
|
||||
SectionHeader(location),
|
||||
GroupCard(children: [
|
||||
SettingsTile(
|
||||
leading: Icon(Icons.bolt_rounded, color: s.bulletColor),
|
||||
title: t('Set all cameras from one IP'),
|
||||
subtitle: t('Ports {from}–{to}')
|
||||
.replaceAll('{from}', '$firstPort')
|
||||
.replaceAll('{to}', '${firstPort + setup.positions - 1}'),
|
||||
onTap: () => _editHost(context, location),
|
||||
),
|
||||
for (int p = 1; p <= setup.positions; p++)
|
||||
SettingsTile(
|
||||
title: '${t('Camera')} $p',
|
||||
value: setup.ipFor(p, location).isEmpty ? '—' : setup.ipFor(p, location),
|
||||
onTap: () => _editCamera(context, p, location),
|
||||
),
|
||||
]),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _addLocation(BuildContext context) async {
|
||||
final s = AppSettings.instance;
|
||||
final name = await showTextPrompt(context, title: s.t('Add location'), hint: s.t('e.g. Home'));
|
||||
if (name == null || name.isEmpty) return;
|
||||
if (!await s.addLocation(name) && context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(s.t('This location already exists'))));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _editLocation(BuildContext context, String location) async {
|
||||
final s = AppSettings.instance;
|
||||
final name = await showTextPrompt(
|
||||
context,
|
||||
title: s.t('Location'),
|
||||
initial: location,
|
||||
resetLabel: s.t('Delete'),
|
||||
onReset: () => s.removeLocation(location),
|
||||
);
|
||||
if (name != null && name.isNotEmpty && name != location) await s.renameLocation(location, name);
|
||||
}
|
||||
|
||||
Future<void> _editHost(BuildContext context, String location) async {
|
||||
final s = AppSettings.instance;
|
||||
final first = s.cameras.ipFor(1, location);
|
||||
final host = await showTextPrompt(
|
||||
context,
|
||||
title: '${s.t('Set all cameras from one IP')} · $location',
|
||||
initial: first.split(':').first,
|
||||
hint: '192.168.0.10',
|
||||
keyboardType: TextInputType.url,
|
||||
);
|
||||
if (host != null && host.isNotEmpty) s.setLocationHost(location, host);
|
||||
}
|
||||
|
||||
Future<void> _editCamera(BuildContext context, int position, String location) async {
|
||||
final s = AppSettings.instance;
|
||||
final ip = await showTextPrompt(
|
||||
context,
|
||||
title: '${s.t('Camera')} $position · $location',
|
||||
initial: s.cameras.ipFor(position, location),
|
||||
hint: '192.168.0.10:${CameraSetup.firstPort + position - 1}',
|
||||
keyboardType: TextInputType.url,
|
||||
resetLabel: s.t('Remove'),
|
||||
onReset: () => s.setCameraIp(position, location, ''),
|
||||
);
|
||||
if (ip != null && ip.isNotEmpty) s.setCameraIp(position, location, ip);
|
||||
}
|
||||
}
|
||||
+89
-116
@@ -4,153 +4,126 @@ import 'calendar_screen.dart';
|
||||
import 'settings_screen.dart';
|
||||
import 'target_screen.dart';
|
||||
import '../widgets/bottom_nav.dart';
|
||||
//import 'login_screen.dart';
|
||||
import 'camera_screen.dart';
|
||||
import 'spectator_screen.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../utils/translations.dart';
|
||||
import '../utils/target_colors.dart';
|
||||
import '../services/app_settings.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
enum AppTab { book, shooting, camera, calendar, settings }
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
const HomeScreen({super.key});
|
||||
|
||||
@override
|
||||
_HomeScreenState createState() => _HomeScreenState();
|
||||
State<HomeScreen> createState() => _HomeScreenState();
|
||||
}
|
||||
|
||||
class _HomeScreenState extends State<HomeScreen> {
|
||||
int _selectedIndex = 1; // Default to Shooting Screen
|
||||
String _selectedLanguage = 'English';
|
||||
String _selectedTarget = 'assets/target.png';
|
||||
late Color _backgroundColor;
|
||||
AppTab _selected = AppTab.shooting;
|
||||
|
||||
static final List<Widget> _pages = <Widget>[
|
||||
BookScreen(),
|
||||
TargetScreen(),
|
||||
Placeholder(), // Placeholder for Scan - optional
|
||||
CalendarScreen(),
|
||||
SettingsScreen(),
|
||||
];
|
||||
static const Map<AppTab, String> _titles = {
|
||||
AppTab.book: 'Book',
|
||||
AppTab.shooting: 'Shooting',
|
||||
AppTab.camera: 'Camera',
|
||||
AppTab.calendar: 'Calendar',
|
||||
AppTab.settings: 'Settings',
|
||||
};
|
||||
|
||||
final List<String> _pageTitles = [
|
||||
'Book',
|
||||
'Shooting',
|
||||
'Scan',
|
||||
'Calendar',
|
||||
'Settings'
|
||||
];
|
||||
static const Map<AppTab, IconData> _icons = {
|
||||
AppTab.book: Icons.book,
|
||||
AppTab.shooting: Icons.my_location,
|
||||
AppTab.camera: Icons.camera_alt,
|
||||
AppTab.calendar: Icons.calendar_today,
|
||||
AppTab.settings: Icons.settings,
|
||||
};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Initialize with default target background color
|
||||
_backgroundColor = TargetColors.getBackgroundColor('assets/target.png');
|
||||
_loadLanguage();
|
||||
_loadSelectedTarget();
|
||||
// Calendar is only shown to club members (see Settings > Club code)
|
||||
List<AppTab> get _visibleTabs => [
|
||||
for (final tab in AppTab.values)
|
||||
if (tab != AppTab.calendar || AppSettings.instance.clubUnlocked) tab,
|
||||
];
|
||||
|
||||
Widget _page(AppTab tab) {
|
||||
switch (tab) {
|
||||
case AppTab.book:
|
||||
return const BookScreen();
|
||||
case AppTab.shooting:
|
||||
case AppTab.camera: // camera opens as its own route, never shown here
|
||||
return const TargetScreen();
|
||||
case AppTab.calendar:
|
||||
return const CalendarScreen();
|
||||
case AppTab.settings:
|
||||
return const SettingsScreen();
|
||||
}
|
||||
}
|
||||
|
||||
String _t(String key) {
|
||||
return AppTranslations.translate(key, _selectedLanguage);
|
||||
}
|
||||
|
||||
Future<void> _loadLanguage() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
_selectedLanguage = prefs.getString('language') ?? 'English';
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _loadSelectedTarget() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final selectedTarget =
|
||||
prefs.getString('selectedTarget') ?? 'assets/target.png';
|
||||
setState(() {
|
||||
_selectedTarget = selectedTarget;
|
||||
_backgroundColor = TargetColors.getBackgroundColor(selectedTarget);
|
||||
});
|
||||
}
|
||||
|
||||
void _onItemTapped(int index) {
|
||||
if (index == 2) {
|
||||
void _onTabTapped(AppTab tab) {
|
||||
if (tab == AppTab.camera) {
|
||||
_openCameraScan();
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
_selectedIndex = index;
|
||||
});
|
||||
// Reload language when switching screens to pick up any changes from Settings
|
||||
_loadLanguage();
|
||||
setState(() => _selected = tab);
|
||||
}
|
||||
|
||||
//void _logout() {
|
||||
// Navigator.of(context).pushAndRemoveUntil(
|
||||
// MaterialPageRoute(builder: (context) => const LoginScreen()),
|
||||
// (Route<dynamic> route) => false,
|
||||
// );
|
||||
//}
|
||||
|
||||
// When opening the camera screen, ensure the shooting screen is always selected after returning
|
||||
// When returning from the camera screen, always land on the Shooting tab
|
||||
void _openCameraScan() async {
|
||||
// Navigate to CameraScreen
|
||||
await Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (context) => const CameraScreen()),
|
||||
);
|
||||
|
||||
// After returning, ensure that Shooting screen (index 1) is selected
|
||||
setState(() {
|
||||
_selectedIndex = 1;
|
||||
});
|
||||
setState(() => _selected = AppTab.shooting);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
_t(_pageTitles[_selectedIndex]),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
backgroundColor: Colors.grey[900],
|
||||
iconTheme: const IconThemeData(color: Colors.white),
|
||||
automaticallyImplyLeading: false,
|
||||
scrolledUnderElevation: 0, // For Material 3 (Flutter 3.7+)
|
||||
actions: [
|
||||
if (_selectedIndex == 1)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.visibility_rounded, color: Colors.white),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SpectatorScreen(
|
||||
selectedLanguage: _selectedLanguage,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
return ListenableBuilder(
|
||||
listenable: AppSettings.instance,
|
||||
builder: (context, _) {
|
||||
final settings = AppSettings.instance;
|
||||
final tabs = _visibleTabs;
|
||||
if (!tabs.contains(_selected)) _selected = AppTab.settings; // calendar was just locked
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
settings.t(_titles[_selected]!),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 16.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'V1.2',
|
||||
style: TextStyle(
|
||||
color: Colors.grey[400],
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
backgroundColor: AppTheme.bar,
|
||||
iconTheme: const IconThemeData(color: Colors.white),
|
||||
automaticallyImplyLeading: false,
|
||||
scrolledUnderElevation: 0, // For Material 3 (Flutter 3.7+)
|
||||
actions: [
|
||||
if (_selected == AppTab.shooting)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.visibility_rounded, color: Colors.white),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SpectatorScreen(
|
||||
selectedLanguage: settings.language,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
backgroundColor: _backgroundColor,
|
||||
body: _pages[_selectedIndex],
|
||||
bottomNavigationBar: BottomNavBar(
|
||||
selectedIndex: _selectedIndex,
|
||||
onItemTapped: _onItemTapped,
|
||||
selectedLanguage: _selectedLanguage,
|
||||
),
|
||||
backgroundColor: settings.backgroundColor,
|
||||
body: _page(_selected),
|
||||
bottomNavigationBar: BottomNavBar(
|
||||
selectedIndex: tabs.indexOf(_selected),
|
||||
onItemTapped: (i) => _onTabTapped(tabs[i]),
|
||||
items: [
|
||||
for (final tab in tabs)
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(_icons[tab]),
|
||||
label: settings.t(_titles[tab]!),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,232 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_sign_in/google_sign_in.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../widgets/input_field.dart';
|
||||
import 'home_screen.dart';
|
||||
import 'register_screen.dart';
|
||||
|
||||
class LoginScreen extends StatefulWidget {
|
||||
const LoginScreen({super.key});
|
||||
|
||||
@override
|
||||
State<LoginScreen> createState() => _LoginScreenState();
|
||||
}
|
||||
|
||||
class _LoginScreenState extends State<LoginScreen> {
|
||||
final usernameController = TextEditingController();
|
||||
final passwordController = TextEditingController();
|
||||
bool rememberMe = false;
|
||||
|
||||
final GoogleSignIn _googleSignIn = GoogleSignIn(
|
||||
clientId: 'YOUR_WEB_CLIENT_ID_HERE',
|
||||
scopes: ['email'],
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_checkAutoLogin();
|
||||
}
|
||||
|
||||
Future<void> _checkAutoLogin() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final isRemembered = prefs.getBool('rememberMe') ?? false;
|
||||
final googleUser = prefs.getString('googleUser');
|
||||
|
||||
if (isRemembered) {
|
||||
final savedUsername = prefs.getString('loginUsername') ?? prefs.getString('username');
|
||||
final savedPassword = prefs.getString('password');
|
||||
if (savedUsername != null && savedPassword != null) {
|
||||
usernameController.text = savedUsername;
|
||||
passwordController.text = savedPassword;
|
||||
setState(() => rememberMe = true);
|
||||
}
|
||||
} else if (googleUser != null) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const HomeScreen()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _saveLoginDetails(String username, String password) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('loginUsername', username); // Ensures login uses latest username
|
||||
await prefs.setString('password', password);
|
||||
|
||||
if (rememberMe) {
|
||||
await prefs.setBool('rememberMe', true);
|
||||
} else {
|
||||
await prefs.remove('rememberMe');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void login() async {
|
||||
String username = usernameController.text.trim();
|
||||
String password = passwordController.text.trim();
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
String? savedUsername = prefs.getString('loginUsername') ?? prefs.getString('username'); // Get the latest username
|
||||
String? savedPassword = prefs.getString('password'); // Get the saved password
|
||||
|
||||
if (savedUsername == username && savedPassword == password) {
|
||||
await _saveLoginDetails(username, password);
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const HomeScreen()),
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Invalid username or password')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> googleLogin() async {
|
||||
try {
|
||||
final GoogleSignInAccount? googleUser = await _googleSignIn.signIn();
|
||||
if (googleUser != null) {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('googleUser', googleUser.displayName ?? 'Google User');
|
||||
await prefs.setString('googleEmail', googleUser.email);
|
||||
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const HomeScreen()),
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Google Sign-In Failed: $error')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/logo.png',
|
||||
width: 1000,
|
||||
height: 150,
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
InputField(
|
||||
hintText: 'Username',
|
||||
icon: Icons.person,
|
||||
controller: usernameController,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
InputField(
|
||||
hintText: 'Password',
|
||||
icon: Icons.lock,
|
||||
obscureText: true,
|
||||
controller: passwordController,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
/// Remember Me Checkbox - Centered
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Checkbox(
|
||||
value: rememberMe,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
rememberMe = value ?? false;
|
||||
});
|
||||
},
|
||||
activeColor: Colors.grey[800],
|
||||
),
|
||||
const Text(
|
||||
'Remember Me',
|
||||
style: TextStyle(
|
||||
color: Colors.black87,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
/// Login Button
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.grey[800],
|
||||
foregroundColor: Colors.white,
|
||||
minimumSize: const Size.fromHeight(50),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
onPressed: login,
|
||||
child: const Text('Login', style: TextStyle(fontSize: 18)),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
/// Horizontal Line with "or"
|
||||
Row(
|
||||
children: const [
|
||||
Expanded(
|
||||
child: Divider(color: Colors.grey, thickness: 1),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text("or", style: TextStyle(color: Colors.grey, fontSize: 16)),
|
||||
),
|
||||
Expanded(
|
||||
child: Divider(color: Colors.grey, thickness: 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
/// Google Sign-In Button (Styled same as Login)
|
||||
ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.grey[800], // Match Login Button
|
||||
foregroundColor: Colors.white,
|
||||
minimumSize: const Size.fromHeight(50),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
onPressed: googleLogin,
|
||||
icon: const Icon(Icons.g_mobiledata, size: 30), // Google Icon
|
||||
label: const Text('Sign in with Google', style: TextStyle(fontSize: 18)),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
/// Register Text (Styled in Blue)
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const RegisterScreen()),
|
||||
);
|
||||
},
|
||||
child: const Text(
|
||||
"Don't have an account? Register",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.grey, // Better visibility
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+96
-241
@@ -1,6 +1,8 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../utils/target_colors.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import 'package:flutter/services.dart' show rootBundle;
|
||||
import 'package:image/image.dart' as img;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
@@ -273,121 +275,9 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
"📏 Scale factors calculated: X=$_scaleFactorX, Y=$_scaleFactorY");
|
||||
}
|
||||
|
||||
Color _getBackgroundColorForTarget(String targetPath) {
|
||||
// Map each target to its background color (extracted from first pixel of each image)
|
||||
switch (targetPath) {
|
||||
case 'assets/target.png':
|
||||
return const Color(0xFFFFFFFF); // White
|
||||
|
||||
case 'assets/targets/Target1.jpg':
|
||||
return const Color(0xFFE8ECD5); // Light beige
|
||||
|
||||
case 'assets/targets/Target2.jpg':
|
||||
return const Color(0xFFC1DF87); // Light green
|
||||
|
||||
case 'assets/targets/Target3.jpg':
|
||||
return const Color(0xFFFEFEFE); // Off-white
|
||||
|
||||
case 'assets/targets/Target4.jpg':
|
||||
return const Color(0xFFD42931); // Red
|
||||
|
||||
case 'assets/targets/Target5.jpg':
|
||||
return const Color(0xFF02050A); // Very dark blue/black
|
||||
|
||||
case 'assets/targets/Target6.jpg':
|
||||
return const Color(0xFFF3E7D1); // Light beige
|
||||
|
||||
case 'assets/targets/Target7.jpg':
|
||||
return const Color(0xFFFFD454); // Bright yellow
|
||||
|
||||
case 'assets/targets/Target8.jpg':
|
||||
return const Color(0xFF1E5E81); // Dark teal blue
|
||||
|
||||
case 'assets/targets/Target9.jpg':
|
||||
return const Color(0xFFFEFEFC); // Off-white
|
||||
|
||||
case 'assets/targets/Target10.jpg':
|
||||
return const Color(0xFF98926E); // Olive green
|
||||
|
||||
case 'assets/targets/Target11.jpg':
|
||||
return const Color(0xFF13132B); // Dark blue
|
||||
|
||||
case 'assets/targets/Target12.jpg':
|
||||
return const Color(0xFFF5F4EF); // Off-white
|
||||
|
||||
case 'assets/targets/Target13.jpg':
|
||||
return const Color(0xFF174AA5); // Blue
|
||||
|
||||
case 'assets/targets/Target14.jpg':
|
||||
return const Color(0xFFFEE05E); // Light yellow
|
||||
|
||||
case 'assets/targets/Target15.jpg':
|
||||
return const Color(0xFFFFFFFF); // White
|
||||
|
||||
case 'assets/targets/Target16.jpg':
|
||||
return const Color(0xFF000000); // Black
|
||||
|
||||
case 'assets/targets/Target17.jpg':
|
||||
return const Color(0xFF21304D); // Dark blue
|
||||
|
||||
case 'assets/targets/Target18.jpg':
|
||||
return const Color(0xFF050608); // Very dark gray
|
||||
|
||||
case 'assets/targets/Target19.jpg':
|
||||
return const Color(0xFFF68527); // Warm orange
|
||||
|
||||
case 'assets/targets/Target20.jpg':
|
||||
return const Color(0xFFA9D9EF); // Light blue
|
||||
|
||||
case 'assets/targets/Target21.jpg':
|
||||
return const Color(0xFFDA6868); // Muted red
|
||||
|
||||
case 'assets/targets/Target22.jpg':
|
||||
return const Color(0xFFFBFAF6); // Off-white
|
||||
|
||||
case 'assets/targets/Target23.jpg':
|
||||
return const Color(0xFF000000); // Black
|
||||
|
||||
case 'assets/targets/Target24.jpg':
|
||||
return const Color(0xFFb7b7b7); // Gray
|
||||
|
||||
case 'assets/targets/Target25.jpg':
|
||||
return const Color(0xFF040308); // Very dark gray
|
||||
|
||||
case 'assets/targets/Target26.jpg':
|
||||
return const Color(0xFF161C2C); // Dark blue-gray
|
||||
|
||||
case 'assets/targets/Target27.jpg':
|
||||
return const Color(0xFF28A5DF); // Blue
|
||||
|
||||
case 'assets/targets/Target28.jpg':
|
||||
return const Color(0xFFFFFFFF); // White
|
||||
|
||||
case 'assets/targets/Target29.jpg':
|
||||
return const Color(0xFF180E27); // Dark purple
|
||||
|
||||
case 'assets/targets/Target30.jpg':
|
||||
return const Color(0xFFFDFDFB); // Off-white
|
||||
|
||||
case 'assets/targets/Target31.jpg':
|
||||
return const Color(0xFFC52736); // Red
|
||||
|
||||
case 'assets/targets/Target32.jpg':
|
||||
return const Color(0xFFFCF3EE); // Light cream
|
||||
|
||||
case 'assets/targets/Target33.jpg':
|
||||
return const Color(0xFFFCFCF3); // Very light off-white
|
||||
|
||||
case 'assets/targets/Target34.jpg':
|
||||
return const Color(0xFFFFFFFD); // Almost white
|
||||
|
||||
case 'assets/targets/Target35.jpg':
|
||||
return const Color(0xFFFFC5C4); // Light salmon
|
||||
|
||||
default:
|
||||
return Colors.grey[900]!; // Fallback to dark gray
|
||||
}
|
||||
}
|
||||
// One source of truth for target colors (utils/target_colors.dart)
|
||||
Color _getBackgroundColorForTarget(String targetPath) =>
|
||||
TargetColors.getBackgroundColor(targetPath);
|
||||
|
||||
Future<void> _loadBulletColor() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
@@ -940,6 +830,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
final targetData = {
|
||||
'date': dateString,
|
||||
'totalScore': _totalScore,
|
||||
'bulletCount': widget.bulletCount, // shots fired; missed ones are absent from 'bullets'
|
||||
'bullets': bulletsInDefaultCoordinates,
|
||||
};
|
||||
|
||||
@@ -1349,7 +1240,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
children: [
|
||||
// Training/Tournament Banner
|
||||
Container(
|
||||
color: Colors.grey[300],
|
||||
color: Surfaces.current.card,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16, vertical: 10),
|
||||
child: Row(
|
||||
@@ -1359,9 +1250,9 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
child: Text(
|
||||
_currentFolderName.isNotEmpty
|
||||
? _currentFolderName
|
||||
: 'No training selected',
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
: _t('No training selected'),
|
||||
style: TextStyle(
|
||||
color: Surfaces.current.textPrimary,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
@@ -1371,8 +1262,8 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
if (_currentDate.isNotEmpty)
|
||||
Text(
|
||||
_currentDate,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
style: TextStyle(
|
||||
color: Surfaces.current.textPrimary,
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
@@ -1636,7 +1527,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
Container(
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
color: Surfaces.current.card,
|
||||
borderRadius:
|
||||
const BorderRadius
|
||||
.only(
|
||||
@@ -1649,11 +1540,11 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'${index + 1}',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontWeight:
|
||||
FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: Colors.black87,
|
||||
color: Surfaces.current.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1728,7 +1619,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
Container(
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
color: Surfaces.current.card,
|
||||
borderRadius:
|
||||
const BorderRadius
|
||||
.only(
|
||||
@@ -1741,11 +1632,11 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'$bulletNum',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontWeight:
|
||||
FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: Colors.black87,
|
||||
color: Surfaces.current.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1791,129 +1682,93 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// Room for the save button, which sticks up out of the bottom bar
|
||||
const SizedBox(height: 40),
|
||||
],
|
||||
),
|
||||
_buildEditController(),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Top bar - Total Score
|
||||
Container(
|
||||
color: Colors.grey[300],
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.track_changes, size: 20, color: Colors.black),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
_t("Total score:"),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
// Same layout as the camera screen: number on the left, round white
|
||||
// main action docked in the notch, secondary icons on the right.
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
floatingActionButton: FloatingActionButton(
|
||||
backgroundColor: Colors.white,
|
||||
onPressed: _saveToLastFolder,
|
||||
tooltip: _t("Save"),
|
||||
child: const Icon(Icons.save, color: Colors.black),
|
||||
),
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
color: Colors.grey[900],
|
||||
shape: const CircularNotchedRectangle(),
|
||||
notchMargin: 8.0,
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
child: Row(
|
||||
children: [
|
||||
// Left - total score
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_t('Total').toUpperCase(),
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 1.2,
|
||||
color: Colors.white54,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'$_totalScore',
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
height: 1.1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
"$_totalScore",
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Bottom bar - Action Buttons
|
||||
BottomAppBar(
|
||||
color: Colors.grey[900],
|
||||
padding: EdgeInsets.zero,
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
child: Row(
|
||||
children: [
|
||||
// Plus button (left, no background)
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: IconButton(
|
||||
icon: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
const Icon(Icons.folder, color: Colors.white, size: 24),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: const Icon(Icons.add, color: Colors.grey, size: 10),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: _saveTargetDataWithDialog,
|
||||
),
|
||||
),
|
||||
),
|
||||
// Save button (center with white background)
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: SizedBox(
|
||||
width: 60,
|
||||
height: 40,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: _saveToLastFolder,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: const Icon(Icons.save,
|
||||
color: Colors.black, size: 20),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Edit button (right)
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: IconButton(
|
||||
icon: Icon(
|
||||
_isEditMode ? Icons.check : Icons.edit,
|
||||
color: _isEditMode ? Colors.red : Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isEditMode = !_isEditMode;
|
||||
_selectedBulletIndexInEdit = null;
|
||||
});
|
||||
},
|
||||
tooltip: _isEditMode ? _t("Done Editing") : _t("Edit Mode"),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Center space for FAB
|
||||
const SizedBox(width: 80),
|
||||
// Right - save to another folder, edit mode
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.create_new_folder_outlined, color: Colors.white, size: 24),
|
||||
onPressed: _saveTargetDataWithDialog,
|
||||
tooltip: _t("Save to folder"),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
_isEditMode ? Icons.check : Icons.edit,
|
||||
color: _isEditMode ? Colors.red : Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isEditMode = !_isEditMode;
|
||||
_selectedBulletIndexInEdit = null;
|
||||
});
|
||||
},
|
||||
tooltip: _isEditMode ? _t("Done Editing") : _t("Edit Mode"),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../widgets/input_field.dart';
|
||||
import 'login_screen.dart';
|
||||
|
||||
class RegisterScreen extends StatefulWidget {
|
||||
const RegisterScreen({super.key});
|
||||
|
||||
@override
|
||||
State<RegisterScreen> createState() => _RegisterScreenState();
|
||||
}
|
||||
|
||||
class _RegisterScreenState extends State<RegisterScreen> {
|
||||
final usernameController = TextEditingController();
|
||||
final emailController = TextEditingController();
|
||||
final passwordController = TextEditingController();
|
||||
final confirmPasswordController = TextEditingController();
|
||||
|
||||
Future<void> register() async {
|
||||
String username = usernameController.text.trim();
|
||||
String email = emailController.text.trim();
|
||||
String password = passwordController.text.trim();
|
||||
String confirmPassword = confirmPasswordController.text.trim();
|
||||
|
||||
if (username.isEmpty || email.isEmpty || password.isEmpty || confirmPassword.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('All fields are required')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(email)) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Invalid email format')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (password != confirmPassword) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Passwords do not match')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
// Check if the username or email is already taken
|
||||
String? existingUser = prefs.getString(username);
|
||||
String? existingEmail = prefs.getString(email);
|
||||
if (existingUser != null || existingEmail != null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Username or Email already exists. Choose another.')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Save user credentials in SharedPreferences
|
||||
await prefs.setString(username, password);
|
||||
await prefs.setString(email, username); // Store email linked to the username
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Registration Successful! Please Login')),
|
||||
);
|
||||
|
||||
// Redirect to Login Screen
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const LoginScreen()),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
/// Logo
|
||||
Image.asset(
|
||||
'assets/logo.png',
|
||||
width: 1000,
|
||||
height: 150,
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
|
||||
/// Username Field
|
||||
InputField(
|
||||
hintText: 'Username',
|
||||
icon: Icons.person,
|
||||
controller: usernameController,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
/// Email Field
|
||||
InputField(
|
||||
hintText: 'Email',
|
||||
icon: Icons.email,
|
||||
controller: emailController,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
/// Password Field
|
||||
InputField(
|
||||
hintText: 'Password',
|
||||
icon: Icons.lock,
|
||||
obscureText: true,
|
||||
controller: passwordController,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
/// Confirm Password Field
|
||||
InputField(
|
||||
hintText: 'Confirm Password',
|
||||
icon: Icons.lock,
|
||||
obscureText: true,
|
||||
controller: confirmPasswordController,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
/// Register Button
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.grey[800], // Match Login Button
|
||||
foregroundColor: Colors.white,
|
||||
minimumSize: const Size.fromHeight(50),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
onPressed: register,
|
||||
child: const Text('Register', style: TextStyle(fontSize: 18)),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
/// Horizontal Line with "or" (optional, in case Google Sign-Up is added)
|
||||
Row(
|
||||
children: const [
|
||||
Expanded(
|
||||
child: Divider(color: Colors.grey, thickness: 1),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text("or", style: TextStyle(color: Colors.grey, fontSize: 16)),
|
||||
),
|
||||
Expanded(
|
||||
child: Divider(color: Colors.grey, thickness: 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
/// Login Navigation (Styled in Blue)
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const LoginScreen()),
|
||||
);
|
||||
},
|
||||
child: const Text(
|
||||
"Already have an account? Login",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.grey, // Styled for better visibility
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../services/app_settings.dart';
|
||||
import '../services/target_repository.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../widgets/section.dart';
|
||||
import 'target_view.dart';
|
||||
|
||||
/// One training or tournament: its stats, its targets, and edit/delete actions.
|
||||
class SessionScreen extends StatefulWidget {
|
||||
final Session session;
|
||||
|
||||
const SessionScreen({super.key, required this.session});
|
||||
|
||||
@override
|
||||
State<SessionScreen> createState() => _SessionScreenState();
|
||||
}
|
||||
|
||||
class _SessionScreenState extends State<SessionScreen> {
|
||||
late Session _session = widget.session;
|
||||
|
||||
Future<void> _reload() async {
|
||||
final sessions = await TargetRepository.loadSessions();
|
||||
final updated = sessions.where((s) => s.name == _session.name);
|
||||
if (!mounted) return;
|
||||
if (updated.isEmpty) {
|
||||
Navigator.pop(context); // session no longer exists
|
||||
} else {
|
||||
setState(() => _session = updated.first);
|
||||
}
|
||||
}
|
||||
|
||||
void _openTargets(List<TargetRecord> targets) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => TargetViewScreen(
|
||||
jsonFiles: [for (final t in targets) t.file],
|
||||
refreshFolders: _reload,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _edit() async {
|
||||
final result = await showEditSessionDialog(context, _session);
|
||||
if (result == null) return;
|
||||
final ok = await TargetRepository.updateSession(_session, name: result.name, isTournament: result.isTournament);
|
||||
if (!mounted) return;
|
||||
if (!ok) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(AppSettings.instance.t('A folder with this name already exists'))),
|
||||
);
|
||||
return;
|
||||
}
|
||||
_session = Session(name: result.name, isTournament: result.isTournament, date: _session.date, targets: _session.targets);
|
||||
_reload();
|
||||
}
|
||||
|
||||
Future<void> _delete() async {
|
||||
final s = AppSettings.instance;
|
||||
final message = '${s.t('Are you sure you want to delete the folder')} "${_session.name}" ${s.t('and all of its contents?')}';
|
||||
if (await confirmDelete(context, message) != true) return;
|
||||
await TargetRepository.deleteSession(_session);
|
||||
if (mounted) Navigator.pop(context);
|
||||
}
|
||||
|
||||
Future<void> _deleteTarget(TargetRecord target) async {
|
||||
if (await confirmDelete(context, AppSettings.instance.t('Are you sure you want to delete this file?')) != true) return;
|
||||
await TargetRepository.deleteTarget(target);
|
||||
_reload();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListenableBuilder(
|
||||
listenable: AppSettings.instance,
|
||||
builder: (context, _) {
|
||||
final s = AppSettings.instance;
|
||||
final t = s.t;
|
||||
final surf = Surfaces.current;
|
||||
final session = _session;
|
||||
final stats = ShooterStats.of([session]);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: s.backgroundColor,
|
||||
appBar: AppBar(
|
||||
title: Text(session.name, style: const TextStyle(color: Colors.white)),
|
||||
backgroundColor: AppTheme.bar,
|
||||
iconTheme: const IconThemeData(color: Colors.white),
|
||||
scrolledUnderElevation: 0,
|
||||
actions: [
|
||||
IconButton(icon: const Icon(Icons.edit), tooltip: t('Edit'), onPressed: _edit),
|
||||
IconButton(icon: const Icon(Icons.delete, color: Colors.red), tooltip: t('Delete'), onPressed: _delete),
|
||||
],
|
||||
),
|
||||
body: ListView(
|
||||
// Keep the last row clear of the system gesture bar (edge-to-edge)
|
||||
padding: EdgeInsets.fromLTRB(16, 4, 16, 24 + MediaQuery.paddingOf(context).bottom),
|
||||
children: [
|
||||
SectionHeader(
|
||||
'${session.isTournament ? t('Tournament') : t('Training')} · ${DateFormat('d. M. yyyy').format(session.date)}',
|
||||
),
|
||||
StatGrid(tiles: [
|
||||
StatTile(label: t('Total'), value: '${session.totalScore}', caption: targetCount(session.targets.length)),
|
||||
StatTile(
|
||||
label: t('Average per shot'),
|
||||
value: stats.averagePerShot?.toStringAsFixed(2) ?? '–',
|
||||
caption: shotCount(stats.shots),
|
||||
),
|
||||
]),
|
||||
SectionHeader(t('Targets')),
|
||||
if (session.targets.isEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(t('No targets in this folder'), style: TextStyle(color: surf.textSecondary)),
|
||||
)
|
||||
else
|
||||
GroupCard(children: [
|
||||
for (int i = 0; i < session.targets.length; i++)
|
||||
SettingsTile(
|
||||
title: '${t('Target')} ${i + 1}',
|
||||
subtitle: '${DateFormat('HH:mm').format(session.targets[i].shotAt)} · ${shotCount(session.targets[i].shots)}',
|
||||
onTap: () => _openTargets([session.targets[i]]),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'${session.targets[i].score}',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: surf.textPrimary),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete, color: Colors.red, size: 20),
|
||||
onPressed: () => _deleteTarget(session.targets[i]),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
]),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// "1 target" / "5 targets", with Slovenian dual and plural forms.
|
||||
String targetCount(int n) {
|
||||
final s = AppSettings.instance;
|
||||
if (s.language != 'Slovenian') return n == 1 ? '1 target' : '$n targets';
|
||||
final mod = n % 100;
|
||||
final word = mod == 1 ? 'tarča' : mod == 2 ? 'tarči' : (mod == 3 || mod == 4) ? 'tarče' : 'tarč';
|
||||
return '$n $word';
|
||||
}
|
||||
|
||||
/// "1 shot" / "5 shots", with Slovenian dual and plural forms.
|
||||
String shotCount(int n) {
|
||||
final s = AppSettings.instance;
|
||||
if (s.language != 'Slovenian') return n == 1 ? '1 shot' : '$n shots';
|
||||
final mod = n % 100;
|
||||
final word = mod == 1 ? 'strel' : mod == 2 ? 'strela' : (mod == 3 || mod == 4) ? 'streli' : 'strelov';
|
||||
return '$n $word';
|
||||
}
|
||||
|
||||
Future<bool?> confirmDelete(BuildContext context, String message) {
|
||||
final s = AppSettings.instance;
|
||||
return showDialog<bool>(
|
||||
context: context,
|
||||
builder: (dialog) => AlertDialog(
|
||||
title: Text(s.t('Confirm Deletion')),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialog, false),
|
||||
child: Text(s.t('Cancel'), style: const TextStyle(color: Colors.white70)),
|
||||
),
|
||||
FilledButton(
|
||||
style: FilledButton.styleFrom(backgroundColor: Colors.red[700]),
|
||||
onPressed: () => Navigator.pop(dialog, true),
|
||||
child: Text(s.t('Yes, delete')),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class SessionEdit {
|
||||
final String name;
|
||||
final bool isTournament;
|
||||
|
||||
const SessionEdit(this.name, this.isTournament);
|
||||
}
|
||||
|
||||
/// Rename a session and choose training/tournament.
|
||||
Future<SessionEdit?> showEditSessionDialog(BuildContext context, Session session) {
|
||||
final s = AppSettings.instance;
|
||||
final controller = TextEditingController(text: session.name);
|
||||
var isTournament = session.isTournament;
|
||||
|
||||
return showDialog<SessionEdit>(
|
||||
context: context,
|
||||
builder: (dialog) => StatefulBuilder(
|
||||
builder: (context, setDialogState) => AlertDialog(
|
||||
title: Text(s.t('Folder Settings')),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
controller: controller,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
cursorColor: s.bulletColor,
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
fillColor: Colors.white10,
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide.none),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: s.bulletColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(s.t('Tournament'), style: const TextStyle(color: Colors.white)),
|
||||
secondary: Icon(Icons.emoji_events, color: isTournament ? s.bulletColor : Colors.white54),
|
||||
value: isTournament,
|
||||
activeTrackColor: s.bulletColor,
|
||||
onChanged: (v) => setDialogState(() => isTournament = v),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialog),
|
||||
child: Text(s.t('Cancel'), style: const TextStyle(color: Colors.white70)),
|
||||
),
|
||||
FilledButton(
|
||||
style: FilledButton.styleFrom(backgroundColor: s.bulletColor),
|
||||
onPressed: () {
|
||||
final name = controller.text.trim();
|
||||
if (name.isEmpty || name.contains('/')) return;
|
||||
Navigator.pop(dialog, SessionEdit(name, isTournament));
|
||||
},
|
||||
child: Text(s.t('Save')),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
+387
-1254
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mjpeg/flutter_mjpeg.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../utils/translations.dart';
|
||||
import '../services/wifi_binding.dart';
|
||||
|
||||
class SpectatorScreen extends StatefulWidget {
|
||||
final String selectedLanguage;
|
||||
@@ -20,18 +21,28 @@ class _SpectatorScreenState extends State<SpectatorScreen> {
|
||||
List<bool> _enabledCameras = List.generate(6, (_) => false); // Which cameras have IPs configured
|
||||
List<Map<String, dynamic>> _cameras = [];
|
||||
Color _bulletColor = Colors.blue; // default/fallback bullet color
|
||||
late final Future<void> _wifiReady;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_wifiReady = WifiBinding.acquire();
|
||||
_loadCameras();
|
||||
_loadBulletColor();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WifiBinding.release();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
String _t(String key) {
|
||||
return AppTranslations.translate(key, widget.selectedLanguage);
|
||||
}
|
||||
|
||||
Future<void> _loadCameras() async {
|
||||
await _wifiReady; // streams must start after traffic is pinned to Wi-Fi
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
List<Map<String, dynamic>> cameras = [];
|
||||
List<bool> enabledCameras = List.generate(6, (_) => false);
|
||||
|
||||
+240
-595
@@ -12,41 +12,34 @@ import 'yolo_detector.dart';
|
||||
import 'preview_screen.dart';
|
||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||
import '../utils/translations.dart';
|
||||
import '../widgets/camera_sheet.dart';
|
||||
import '../widgets/image_settings.dart';
|
||||
import '../services/wifi_binding.dart';
|
||||
|
||||
enum ImageFilterType { none, greyscale, invert }
|
||||
|
||||
// Top-level: runs in background isolate via compute()
|
||||
Uint8List _processStreamImage(List<dynamic> args) {
|
||||
final bytes = args[0] as Uint8List;
|
||||
final filter = args[1] as int; // ImageFilterType.index
|
||||
// Top-level: runs in background isolate via compute().
|
||||
// Crops the capture to a square; filters are already baked into the screenshot.
|
||||
Uint8List _processStreamImage(Uint8List bytes) {
|
||||
final decoded = img.decodeImage(bytes)!;
|
||||
final w = decoded.width, h = decoded.height;
|
||||
final size = w < h ? w : h;
|
||||
img.Image cropped = img.copyCrop(decoded,
|
||||
final cropped = img.copyCrop(decoded,
|
||||
x: (w - size) ~/ 2, y: (h - size) ~/ 2, width: size, height: size);
|
||||
img.Image processed;
|
||||
if (filter == ImageFilterType.greyscale.index) {
|
||||
processed = img.grayscale(cropped);
|
||||
} else if (filter == ImageFilterType.invert.index) {
|
||||
final result = img.Image.from(cropped);
|
||||
for (int y = 0; y < result.height; y++) {
|
||||
for (int x = 0; x < result.width; x++) {
|
||||
final p = result.getPixel(x, y);
|
||||
result.setPixelRgb(
|
||||
x, y, 255 - p.r.toInt(), 255 - p.g.toInt(), 255 - p.b.toInt());
|
||||
}
|
||||
}
|
||||
processed = result;
|
||||
} else {
|
||||
processed = cropped;
|
||||
}
|
||||
return Uint8List.fromList(img.encodeJpg(processed));
|
||||
return Uint8List.fromList(img.encodeJpg(cropped));
|
||||
}
|
||||
|
||||
class CameraStreamScreen extends StatefulWidget {
|
||||
final int cameraIndex;
|
||||
final int cameraIndex; // shooting position 1–6
|
||||
final String? ip; // chosen camera; falls back to the saved IP of the position
|
||||
final String? location; // strelišče the camera belongs to
|
||||
|
||||
const CameraStreamScreen({super.key, required this.cameraIndex});
|
||||
const CameraStreamScreen(
|
||||
{super.key, required this.cameraIndex, this.ip, this.location});
|
||||
|
||||
// Image settings are kept per camera, i.e. per position and location
|
||||
String get settingsId =>
|
||||
location == null ? '$cameraIndex' : '${cameraIndex}_$location';
|
||||
String get title =>
|
||||
location == null ? '$cameraIndex' : '$cameraIndex · $location';
|
||||
|
||||
@override
|
||||
State<CameraStreamScreen> createState() => _CameraStreamScreenState();
|
||||
@@ -60,15 +53,11 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
final ScreenshotController _screenshotController = ScreenshotController();
|
||||
final TransformationController _transformationController =
|
||||
TransformationController();
|
||||
ImageFilterType _selectedFilter = ImageFilterType.none;
|
||||
ImageAdjustments _image = const ImageAdjustments();
|
||||
|
||||
late YOLODetector _yoloDetector;
|
||||
int _numberOfBullets = 5;
|
||||
|
||||
// Brightness and contrast controls
|
||||
double _brightness = 0.0;
|
||||
double _contrast = 1.0;
|
||||
|
||||
late AnimationController _zoomAnimController;
|
||||
Animation<Matrix4>? _zoomAnimation;
|
||||
Matrix4? _originalMatrix;
|
||||
@@ -121,10 +110,13 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
bool _reloadEnabled = false;
|
||||
bool _waitEnabled = false;
|
||||
|
||||
late final Future<void> _wifiReady;
|
||||
|
||||
Future<void> _loadAllPrefs() async {
|
||||
await _wifiReady; // stream must start after traffic is pinned to Wi-Fi
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final filterIndex = prefs.getInt('selectedFilter');
|
||||
final url = prefs.getString('cameraIP_${widget.cameraIndex}');
|
||||
final image = await ImageAdjustments.load(widget.settingsId);
|
||||
final url = widget.ip ?? prefs.getString('cameraIP_${widget.cameraIndex}');
|
||||
final streamUrl = (url != null && url.trim().isNotEmpty)
|
||||
? (url.startsWith(RegExp(r"https?://")) ? url : "http://$url")
|
||||
: null;
|
||||
@@ -137,15 +129,9 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
setState(() {
|
||||
_selectedLanguage = prefs.getString('language') ?? 'English';
|
||||
_numberOfBullets = prefs.getInt('bulletCount') ?? 5;
|
||||
_selectedFilter = (filterIndex != null &&
|
||||
filterIndex >= 0 &&
|
||||
filterIndex < ImageFilterType.values.length)
|
||||
? ImageFilterType.values[filterIndex]
|
||||
: ImageFilterType.none;
|
||||
_image = image;
|
||||
_bulletColor =
|
||||
_getColorFromName(prefs.getString('bulletColor') ?? 'Blue');
|
||||
_brightness = prefs.getDouble('brightness') ?? 0.0;
|
||||
_contrast = prefs.getDouble('contrast') ?? 1.0;
|
||||
_streamUrl = streamUrl;
|
||||
_isError = streamUrl == null;
|
||||
if (savedShoot != null) _shootSeconds = savedShoot;
|
||||
@@ -184,6 +170,7 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_wifiReady = WifiBinding.acquire();
|
||||
_loadAllPrefs();
|
||||
|
||||
YOLODetector.create().then((detector) => _yoloDetector = detector);
|
||||
@@ -218,12 +205,6 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _saveBrightnessContrast() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setDouble('brightness', _brightness);
|
||||
await prefs.setDouble('contrast', _contrast);
|
||||
}
|
||||
|
||||
Color _getColorFromName(String colorName) {
|
||||
switch (colorName.toLowerCase()) {
|
||||
case 'blue':
|
||||
@@ -268,6 +249,8 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
statusBarIconBrightness: Brightness.light, // white icons
|
||||
systemNavigationBarColor: Colors.grey[900],
|
||||
systemNavigationBarIconBrightness: Brightness.light,
|
||||
// No grey scrim behind 3-button navigation; we paint the strip ourselves
|
||||
systemNavigationBarContrastEnforced: false,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -282,7 +265,8 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
|
||||
Future<void> _loadStreamUrl() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
String? url = prefs.getString('cameraIP_${widget.cameraIndex}');
|
||||
String? url =
|
||||
widget.ip ?? prefs.getString('cameraIP_${widget.cameraIndex}');
|
||||
|
||||
setState(() {
|
||||
_streamUrl = (url != null && url.trim().isNotEmpty)
|
||||
@@ -328,8 +312,7 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
final dir = await getApplicationDocumentsDirectory();
|
||||
final path = '${dir.path}/ip_capture_temp.jpg';
|
||||
|
||||
final processedBytes = await compute(
|
||||
_processStreamImage, [imageBytes, _selectedFilter.index]);
|
||||
final processedBytes = await compute(_processStreamImage, imageBytes);
|
||||
final file = File(path)..writeAsBytesSync(processedBytes);
|
||||
|
||||
// Detect objects in the image using YOLO
|
||||
@@ -396,232 +379,49 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
}
|
||||
|
||||
void _showImageSettingsDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setDialogState) {
|
||||
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: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
_t('Image Settings'),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, color: Colors.white),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'${_t('Brightness')}: ${(_brightness * 100).toInt()}',
|
||||
style:
|
||||
const TextStyle(color: Colors.white70, fontSize: 14),
|
||||
),
|
||||
Slider(
|
||||
value: _brightness,
|
||||
min: -1.0,
|
||||
max: 1.0,
|
||||
divisions: 40,
|
||||
activeColor: _bulletColor,
|
||||
onChanged: (value) {
|
||||
setState(() => _brightness = value);
|
||||
setDialogState(() {});
|
||||
_saveBrightnessContrast();
|
||||
},
|
||||
),
|
||||
Text(
|
||||
'${_t('Contrast')}: ${(_contrast * 100).toInt()}%',
|
||||
style:
|
||||
const TextStyle(color: Colors.white70, fontSize: 14),
|
||||
),
|
||||
Slider(
|
||||
value: _contrast,
|
||||
min: 0.5,
|
||||
max: 2.0,
|
||||
divisions: 30,
|
||||
activeColor: _bulletColor,
|
||||
onChanged: (value) {
|
||||
setState(() => _contrast = value);
|
||||
setDialogState(() {});
|
||||
_saveBrightnessContrast();
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
_t('Filter'),
|
||||
style:
|
||||
const TextStyle(color: Colors.white70, fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: ImageFilterType.values.map((f) {
|
||||
final isSelected = _selectedFilter == f;
|
||||
final label = f.toString().split('.').last;
|
||||
final translatedLabel =
|
||||
_t(label[0].toUpperCase() + label.substring(1));
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
setState(() => _selectedFilter = f);
|
||||
setDialogState(() {});
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt('selectedFilter', f.index);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 14, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
isSelected ? _bulletColor : Colors.grey[800],
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
translatedLabel,
|
||||
style: const TextStyle(
|
||||
color: Colors.white, fontSize: 13),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_brightness = 0.0;
|
||||
_contrast = 1.0;
|
||||
});
|
||||
setDialogState(() {});
|
||||
_saveBrightnessContrast();
|
||||
},
|
||||
child: Text(_t('Reset'),
|
||||
style: const TextStyle(color: Colors.white54)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
showImageSettingsSheet(
|
||||
context,
|
||||
initial: _image,
|
||||
settingsId: widget.settingsId,
|
||||
cameraLabel: "${_t('Camera')} ${widget.title}",
|
||||
accent: _bulletColor,
|
||||
t: _t,
|
||||
onChanged: (value) => setState(() => _image = value),
|
||||
);
|
||||
}
|
||||
|
||||
void _showBulletDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setDialogState) {
|
||||
Future<void> setCount(int count) async {
|
||||
final clamped = count.clamp(1, 10);
|
||||
setState(() => _numberOfBullets = clamped);
|
||||
setDialogState(() {});
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt('bulletCount', clamped);
|
||||
}
|
||||
showCameraSheet(
|
||||
context,
|
||||
builder: (sheet) => StatefulBuilder(
|
||||
builder: (context, setSheetState) {
|
||||
Future<void> setCount(int count) async {
|
||||
final clamped = count.clamp(1, 10);
|
||||
setState(() => _numberOfBullets = clamped);
|
||||
setSheetState(() {});
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt('bulletCount', clamped);
|
||||
}
|
||||
|
||||
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,
|
||||
children: [
|
||||
Text(
|
||||
_t('Select the number of bullets'),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: _numberOfBullets > 1
|
||||
? () => setCount(_numberOfBullets - 1)
|
||||
: null,
|
||||
icon: const Icon(Icons.remove,
|
||||
color: Colors.white, size: 28),
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: _numberOfBullets > 1
|
||||
? Colors.grey[700]
|
||||
: Colors.grey[850],
|
||||
shape: const CircleBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 24),
|
||||
Text(
|
||||
'$_numberOfBullets',
|
||||
style: TextStyle(
|
||||
fontSize: 48,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _bulletColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 24),
|
||||
IconButton(
|
||||
onPressed: _numberOfBullets < 10
|
||||
? () => setCount(_numberOfBullets + 1)
|
||||
: null,
|
||||
icon: const Icon(Icons.add,
|
||||
color: Colors.white, size: 28),
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: _numberOfBullets < 10
|
||||
? Colors.grey[700]
|
||||
: Colors.grey[850],
|
||||
shape: const CircleBorder(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'1 – 10',
|
||||
style:
|
||||
const TextStyle(color: Colors.white38, fontSize: 12),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: _bulletColor,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
child: Text(_t('Done')),
|
||||
),
|
||||
],
|
||||
),
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CameraSheetHeader(
|
||||
title: _t('Select the number of bullets'),
|
||||
subtitle: '1 – 10',
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
SheetStepper(
|
||||
value: _numberOfBullets,
|
||||
min: 1,
|
||||
max: 10,
|
||||
accent: _bulletColor,
|
||||
onChanged: setCount,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -706,6 +506,7 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
_flashController.dispose();
|
||||
_zoomAnimController.dispose();
|
||||
_yoloDetector.close();
|
||||
WifiBinding.release();
|
||||
_restoreScreenSettings();
|
||||
_setSystemBarStyle();
|
||||
super.dispose();
|
||||
@@ -1470,8 +1271,8 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
}
|
||||
|
||||
void _showTimerDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
showCameraSheet(
|
||||
context,
|
||||
builder: (ctx) => _TimerConfigDialog(
|
||||
shootSeconds: _shootSeconds,
|
||||
reloadSeconds: _reloadSecondsRaw,
|
||||
@@ -1510,142 +1311,11 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
);
|
||||
}
|
||||
|
||||
ColorFilter _buildColorFilter() {
|
||||
// Base filter matrix
|
||||
List<double> baseMatrix;
|
||||
|
||||
switch (_selectedFilter) {
|
||||
case ImageFilterType.greyscale:
|
||||
baseMatrix = [
|
||||
0.2126,
|
||||
0.7152,
|
||||
0.0722,
|
||||
0,
|
||||
0,
|
||||
0.2126,
|
||||
0.7152,
|
||||
0.0722,
|
||||
0,
|
||||
0,
|
||||
0.2126,
|
||||
0.7152,
|
||||
0.0722,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
];
|
||||
break;
|
||||
case ImageFilterType.invert:
|
||||
baseMatrix = [
|
||||
-1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
255.0,
|
||||
0.0,
|
||||
-1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
255.0,
|
||||
0.0,
|
||||
0.0,
|
||||
-1.0,
|
||||
0.0,
|
||||
255.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
];
|
||||
break;
|
||||
default:
|
||||
baseMatrix = [
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
];
|
||||
}
|
||||
|
||||
// Apply brightness and contrast adjustments
|
||||
final b = _brightness * 255.0; // Convert to 0-255 range
|
||||
final c = _contrast;
|
||||
|
||||
// Combine filter with brightness/contrast
|
||||
final adjustedMatrix = <double>[
|
||||
c,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
b,
|
||||
0.0,
|
||||
c,
|
||||
0.0,
|
||||
0.0,
|
||||
b,
|
||||
0.0,
|
||||
0.0,
|
||||
c,
|
||||
0.0,
|
||||
b,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
];
|
||||
|
||||
// Multiply base matrix with adjustment matrix
|
||||
return ColorFilter.matrix(_multiplyMatrices(baseMatrix, adjustedMatrix));
|
||||
}
|
||||
|
||||
List<double> _multiplyMatrices(List<double> a, List<double> b) {
|
||||
// For simplicity, just apply brightness/contrast on top of base filter
|
||||
final result = <double>[];
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
result.add(a[i]);
|
||||
}
|
||||
|
||||
// Apply contrast to RGB components
|
||||
result[0] = result[0] * b[0]; // R
|
||||
result[6] = result[6] * b[6]; // G
|
||||
result[12] = result[12] * b[12]; // B
|
||||
|
||||
// Apply brightness
|
||||
result[4] = result[4] + b[4]; // R offset
|
||||
result[9] = result[9] + b[9]; // G offset
|
||||
result[14] = result[14] + b[14]; // B offset
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("${_t('Camera')} ${widget.cameraIndex}"),
|
||||
title: Text("${_t('Camera')} ${widget.title}"),
|
||||
backgroundColor: Colors.grey[900],
|
||||
foregroundColor: Colors.white,
|
||||
leading: IconButton(
|
||||
@@ -1682,26 +1352,29 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
height: constraints.maxHeight,
|
||||
child: RepaintBoundary(
|
||||
child: ColorFiltered(
|
||||
colorFilter: _buildColorFilter(),
|
||||
child: Mjpeg(
|
||||
key: ValueKey(_streamUrl),
|
||||
stream: _streamUrl!,
|
||||
isLive: true,
|
||||
fit: BoxFit.contain,
|
||||
error: (context, error, stackTrace) {
|
||||
// Mark as error so we can display error placeholder outside filters
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isError = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
return SizedBox.expand(
|
||||
child: Container(color: Colors.black),
|
||||
);
|
||||
},
|
||||
colorFilter: _image.colorFilter,
|
||||
child: RotatedBox(
|
||||
quarterTurns: _image.quarterTurns,
|
||||
child: Mjpeg(
|
||||
key: ValueKey(_streamUrl),
|
||||
stream: _streamUrl!,
|
||||
isLive: true,
|
||||
fit: BoxFit.contain,
|
||||
error: (context, error, stackTrace) {
|
||||
// Mark as error so we can display error placeholder outside filters
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isError = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
return SizedBox.expand(
|
||||
child: Container(color: Colors.black),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1942,12 +1615,13 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.signal_cellular_off,
|
||||
// Mobile data can stay on: the app pins camera traffic to Wi-Fi
|
||||
const Icon(Icons.videocam_outlined,
|
||||
color: Colors.white, size: 18),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
_t("Mobile data is disabled"),
|
||||
_t("Cameras and PC are switched on"),
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 14,
|
||||
@@ -2230,187 +1904,158 @@ class _TimerConfigDialogState extends State<_TimerConfigDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = widget.bulletColor;
|
||||
return Dialog(
|
||||
backgroundColor: Colors.grey[900],
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CameraSheetHeader(
|
||||
title: _t('Shooting Timer'),
|
||||
icon: Icons.timer,
|
||||
iconColor: c,
|
||||
),
|
||||
|
||||
// Single / Full target
|
||||
Row(
|
||||
children: [
|
||||
// Header
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.timer, color: c, size: 22),
|
||||
const SizedBox(width: 8),
|
||||
Text(_t('Shooting Timer'),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
IconButton(
|
||||
icon:
|
||||
const Icon(Icons.close, color: Colors.white54, size: 20),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildTargetPill(false),
|
||||
const SizedBox(width: 8),
|
||||
_buildTargetPill(true),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const Divider(color: Colors.white12, height: 4),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Single / Full target
|
||||
// Shoot time — always on in full target, toggleable in single shot
|
||||
if (_targetSelected && _fullTarget)
|
||||
_buildAlwaysOnRow(
|
||||
_t('Shoot time'),
|
||||
Icons.play_circle_outline,
|
||||
Colors.blue,
|
||||
_shoot,
|
||||
() {
|
||||
setState(() {
|
||||
if (_shoot > _minSeconds) _shoot -= _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
() {
|
||||
setState(() {
|
||||
if (_shoot < _maxSeconds) _shoot += _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
)
|
||||
else
|
||||
_buildToggleRow(
|
||||
_t('Shoot time'),
|
||||
Icons.play_circle_outline,
|
||||
Colors.blue,
|
||||
_shootEnabled,
|
||||
(v) {
|
||||
setState(() => _shootEnabled = v);
|
||||
_notify();
|
||||
},
|
||||
_shoot,
|
||||
() {
|
||||
setState(() {
|
||||
if (_shoot > _minSeconds) _shoot -= _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
() {
|
||||
setState(() {
|
||||
if (_shoot < _maxSeconds) _shoot += _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
),
|
||||
const Divider(color: Colors.white12, height: 4),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Reload toggle + stepper
|
||||
_buildToggleRow(
|
||||
_t('Reload time'),
|
||||
Icons.refresh,
|
||||
Colors.orange,
|
||||
_reloadEnabled,
|
||||
(v) {
|
||||
setState(() => _reloadEnabled = v);
|
||||
_notify();
|
||||
},
|
||||
_reload,
|
||||
() {
|
||||
setState(() {
|
||||
if (_reload > _minSeconds) _reload -= _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
() {
|
||||
setState(() {
|
||||
if (_reload < _maxSeconds) _reload += _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
),
|
||||
const Divider(color: Colors.white12, height: 4),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Wait toggle + stepper
|
||||
_buildToggleRow(
|
||||
_t('Wait time'),
|
||||
Icons.hourglass_empty,
|
||||
Colors.red,
|
||||
_waitEnabled,
|
||||
(v) {
|
||||
setState(() => _waitEnabled = v);
|
||||
_notify();
|
||||
},
|
||||
_wait,
|
||||
() {
|
||||
setState(() {
|
||||
if (_wait > _minSeconds) _wait -= _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
() {
|
||||
setState(() {
|
||||
if (_wait < _maxSeconds) _wait += _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
),
|
||||
const Divider(color: Colors.white12, height: 12),
|
||||
const SizedBox(height: 4),
|
||||
|
||||
// Change target overlay toggle
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
_buildTargetPill(false),
|
||||
Icon(Icons.article_outlined,
|
||||
color: _changeTargetEnabled ? Colors.green : Colors.white38,
|
||||
size: 18),
|
||||
const SizedBox(width: 8),
|
||||
_buildTargetPill(true),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const Divider(color: Colors.white12, height: 4),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Shoot time — always on in full target, toggleable in single shot
|
||||
if (_targetSelected && _fullTarget)
|
||||
_buildAlwaysOnRow(
|
||||
_t('Shoot time'),
|
||||
Icons.play_circle_outline,
|
||||
Colors.blue,
|
||||
_shoot,
|
||||
() {
|
||||
setState(() {
|
||||
if (_shoot > _minSeconds) _shoot -= _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
() {
|
||||
setState(() {
|
||||
if (_shoot < _maxSeconds) _shoot += _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
)
|
||||
else
|
||||
_buildToggleRow(
|
||||
_t('Shoot time'),
|
||||
Icons.play_circle_outline,
|
||||
Colors.blue,
|
||||
_shootEnabled,
|
||||
(v) {
|
||||
setState(() => _shootEnabled = v);
|
||||
_notify();
|
||||
},
|
||||
_shoot,
|
||||
() {
|
||||
setState(() {
|
||||
if (_shoot > _minSeconds) _shoot -= _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
() {
|
||||
setState(() {
|
||||
if (_shoot < _maxSeconds) _shoot += _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
),
|
||||
const Divider(color: Colors.white12, height: 4),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Reload toggle + stepper
|
||||
_buildToggleRow(
|
||||
_t('Reload time'),
|
||||
Icons.refresh,
|
||||
Colors.orange,
|
||||
_reloadEnabled,
|
||||
(v) {
|
||||
setState(() => _reloadEnabled = v);
|
||||
_notify();
|
||||
},
|
||||
_reload,
|
||||
() {
|
||||
setState(() {
|
||||
if (_reload > _minSeconds) _reload -= _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
() {
|
||||
setState(() {
|
||||
if (_reload < _maxSeconds) _reload += _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
),
|
||||
const Divider(color: Colors.white12, height: 4),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Wait toggle + stepper
|
||||
_buildToggleRow(
|
||||
_t('Wait time'),
|
||||
Icons.hourglass_empty,
|
||||
Colors.red,
|
||||
_waitEnabled,
|
||||
(v) {
|
||||
setState(() => _waitEnabled = v);
|
||||
_notify();
|
||||
},
|
||||
_wait,
|
||||
() {
|
||||
setState(() {
|
||||
if (_wait > _minSeconds) _wait -= _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
() {
|
||||
setState(() {
|
||||
if (_wait < _maxSeconds) _wait += _step;
|
||||
});
|
||||
_notify();
|
||||
},
|
||||
),
|
||||
const Divider(color: Colors.white12, height: 12),
|
||||
const SizedBox(height: 4),
|
||||
|
||||
// Change target overlay toggle
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.article_outlined,
|
||||
Text(_t('Change target sign'),
|
||||
style: TextStyle(
|
||||
color: _changeTargetEnabled
|
||||
? Colors.green
|
||||
? Colors.white
|
||||
: Colors.white38,
|
||||
size: 18),
|
||||
const SizedBox(width: 8),
|
||||
Text(_t('Change target sign'),
|
||||
style: TextStyle(
|
||||
color: _changeTargetEnabled
|
||||
? Colors.white
|
||||
: Colors.white38,
|
||||
fontSize: 15)),
|
||||
],
|
||||
),
|
||||
Switch(
|
||||
value: _changeTargetEnabled,
|
||||
activeThumbColor: Colors.green,
|
||||
onChanged: (v) {
|
||||
setState(() => _changeTargetEnabled = v);
|
||||
widget.onChangeTargetToggle(v);
|
||||
},
|
||||
),
|
||||
fontSize: 15)),
|
||||
],
|
||||
),
|
||||
Switch(
|
||||
value: _changeTargetEnabled,
|
||||
activeThumbColor: Colors.green,
|
||||
onChanged: (v) {
|
||||
setState(() => _changeTargetEnabled = v);
|
||||
widget.onChangeTargetToggle(v);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+120
-140
@@ -1,153 +1,133 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'stream_screen.dart'; // Import the camera stream screen
|
||||
import '../utils/translations.dart';
|
||||
import '../utils/target_colors.dart';
|
||||
import '../services/app_settings.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import 'camera_settings_screen.dart';
|
||||
import 'stream_screen.dart';
|
||||
|
||||
class TargetScreen extends StatefulWidget {
|
||||
/// Shooting: one tile per position. A position with cameras at several
|
||||
/// locations asks where we are shooting before opening the stream.
|
||||
class TargetScreen extends StatelessWidget {
|
||||
const TargetScreen({super.key});
|
||||
|
||||
@override
|
||||
State<TargetScreen> createState() => _TargetScreenState();
|
||||
}
|
||||
|
||||
class _TargetScreenState extends State<TargetScreen> {
|
||||
List<bool> _cameraButtonsEnabled =
|
||||
List.generate(6, (_) => false); // Initially, all buttons are disabled
|
||||
String _selectedLanguage = 'English';
|
||||
late Color _backgroundColor;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Initialize with default target background color
|
||||
_backgroundColor = TargetColors.getBackgroundColor('assets/target.png');
|
||||
_loadLanguage();
|
||||
_loadSelectedTargetColor();
|
||||
_loadCameraData();
|
||||
}
|
||||
|
||||
String _t(String key) {
|
||||
return AppTranslations.translate(key, _selectedLanguage);
|
||||
}
|
||||
|
||||
Future<void> _loadLanguage() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
_selectedLanguage = prefs.getString('language') ?? 'English';
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _loadSelectedTargetColor() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final selectedTarget = prefs.getString('selectedTarget') ?? 'assets/target.png';
|
||||
setState(() {
|
||||
_backgroundColor = TargetColors.getBackgroundColor(selectedTarget);
|
||||
});
|
||||
}
|
||||
|
||||
/// Load the camera IPs from SharedPreferences and update button status
|
||||
Future<void> _loadCameraData() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final List<String> defaultIPs = [
|
||||
'192.168.0.134:9081',
|
||||
'192.168.0.134:9082',
|
||||
'192.168.0.134:9083',
|
||||
'192.168.0.134:9084',
|
||||
'192.168.0.134:9085',
|
||||
'192.168.0.134:9086',
|
||||
];
|
||||
|
||||
List<bool> cameraDataStatus = List.generate(6, (index) {
|
||||
String key = 'cameraIP_${index + 1}';
|
||||
|
||||
if (!prefs.containsKey(key)) {
|
||||
prefs.setString(key, defaultIPs[index]);
|
||||
return true; // Default set
|
||||
}
|
||||
|
||||
String? ip = prefs.getString(key);
|
||||
return ip != null && ip.isNotEmpty && ip != 'Not Set';
|
||||
});
|
||||
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_cameraButtonsEnabled = cameraDataStatus;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: _backgroundColor,
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
|
||||
void _openPosition(BuildContext context, int position) {
|
||||
final s = AppSettings.instance;
|
||||
final cameras = s.cameras.camerasAt(position);
|
||||
if (cameras.isEmpty) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (_) => const CameraSettingsScreen()));
|
||||
return;
|
||||
}
|
||||
if (cameras.length == 1) {
|
||||
_openStream(context, position, cameras.keys.first, cameras.values.first);
|
||||
return;
|
||||
}
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (sheet) => SafeArea(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
// Camera grid (6 cameras)
|
||||
Expanded(
|
||||
child: GridView.builder(
|
||||
itemCount: 6,
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 16,
|
||||
crossAxisSpacing: 16,
|
||||
childAspectRatio: 1,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final isEnabled = _cameraButtonsEnabled[index];
|
||||
return GestureDetector(
|
||||
onTap: isEnabled
|
||||
? () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
CameraStreamScreen(cameraIndex: index + 1),
|
||||
),
|
||||
);
|
||||
}
|
||||
: null,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: isEnabled ? Colors.grey[900] : Colors.grey[300],
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.videocam_rounded,
|
||||
color: isEnabled ? Colors.white : Colors.grey[500],
|
||||
size: 36,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
"${_t('Camera')} ${index + 1}",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: isEnabled ? Colors.white : Colors.grey[600],
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
s.t('Where are we shooting?'),
|
||||
style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
'${s.t('Camera')} $position',
|
||||
style: const TextStyle(color: Colors.white54, fontSize: 12),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
for (final entry in cameras.entries)
|
||||
ListTile(
|
||||
leading: Icon(Icons.place_rounded, color: s.bulletColor),
|
||||
title: Text(entry.key, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w600)),
|
||||
subtitle: Text(entry.value, style: const TextStyle(color: Colors.white54)),
|
||||
trailing: entry.key == s.cameras.activeLocation
|
||||
? Icon(Icons.check_rounded, color: s.bulletColor)
|
||||
: const Icon(Icons.chevron_right, color: Colors.white38),
|
||||
onTap: () {
|
||||
Navigator.pop(sheet);
|
||||
_openStream(context, position, entry.key, entry.value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _openStream(BuildContext context, int position, String location, String ip) {
|
||||
AppSettings.instance.setActiveLocation(location);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => CameraStreamScreen(cameraIndex: position, ip: ip, location: location),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListenableBuilder(
|
||||
listenable: AppSettings.instance,
|
||||
builder: (context, _) {
|
||||
final s = AppSettings.instance;
|
||||
final setup = s.cameras;
|
||||
|
||||
return GridView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(24, 32, 24, 32),
|
||||
itemCount: setup.positions,
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 16,
|
||||
crossAxisSpacing: 16,
|
||||
),
|
||||
itemBuilder: (context, i) {
|
||||
final position = i + 1;
|
||||
final locations = setup.camerasAt(position).keys.toList();
|
||||
final enabled = locations.isNotEmpty;
|
||||
final surf = Surfaces.current;
|
||||
|
||||
return Material(
|
||||
color: enabled ? Colors.grey[900] : surf.card,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: () => _openPosition(context, position),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
enabled ? Icons.videocam_rounded : Icons.videocam_off_rounded,
|
||||
color: enabled ? Colors.white : surf.textSecondary,
|
||||
size: 36,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'${s.t('Camera')} $position',
|
||||
style: TextStyle(
|
||||
color: enabled ? Colors.white : surf.textSecondary,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
enabled ? locations.join(' · ') : s.t('Not set up'),
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 12, color: enabled ? Colors.white60 : surf.textSecondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import 'package:flutter/services.dart' show rootBundle;
|
||||
import 'dart:convert';
|
||||
import 'package:image/image.dart' as img;
|
||||
@@ -85,9 +86,9 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
||||
_backgroundColor = _getBackgroundColorForTarget(selectedTarget);
|
||||
}
|
||||
|
||||
Color _getBackgroundColorForTarget(String targetPath) {
|
||||
return TargetColors.getBackgroundColor(targetPath);
|
||||
}
|
||||
// One source of truth for target colors (utils/target_colors.dart)
|
||||
Color _getBackgroundColorForTarget(String targetPath) =>
|
||||
TargetColors.getBackgroundColor(targetPath);
|
||||
|
||||
Future<void> _loadBulletColor() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
@@ -708,7 +709,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
||||
Container(
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
color: Surfaces.current.card,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(16),
|
||||
topRight: Radius.circular(16),
|
||||
@@ -719,10 +720,10 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(
|
||||
'${count}x',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: Colors.black87,
|
||||
color: Surfaces.current.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -801,7 +802,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
||||
Container(
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
color: Surfaces.current.card,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(16),
|
||||
topRight: Radius.circular(16),
|
||||
@@ -810,10 +811,10 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'${index + 1}',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: Colors.black87,
|
||||
color: Surfaces.current.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user