diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index c3fadf5..5d70e81 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -6,6 +6,8 @@
+
+
with WidgetsBindingObserver {
Map> _groupedFiles = {}; // Files grouped by folder
Map _folderCreationDates = {}; // Folder creation dates
Map _folderScores = {}; // Folder scores (sum of scores of all target files inside)
+ Map _fileScores = {}; // Per-file score cache to avoid sync reads in build
Color _bulletColor = Colors.blue; // default fallback
Map _folderTypes = {}; // true = tournament, false = training
String _folderFilter = 'all';
@@ -136,6 +137,7 @@ Color _getColorFromName(String colorName) {
Map folderDates = {};
Map folderScores = {};
Map folderTypes = {};
+ Map fileScores = {};
for (var folder in folders) {
String folderName = folder.path.split('/').last;
@@ -177,7 +179,9 @@ Color _getColorFromName(String colorName) {
for (var file in targetFiles) {
final jsonString = await file.readAsString();
final data = jsonDecode(jsonString);
- totalScore += _getScoreFromJson(data);
+ final score = _getScoreFromJson(data);
+ fileScores[file.path] = score;
+ totalScore += score;
}
groupedFiles[folderName] = targetFiles;
@@ -201,6 +205,7 @@ Color _getColorFromName(String colorName) {
_folderTypes = {
for (var name in sortedFolderNames) name: folderTypes[name]!
};
+ _fileScores = fileScores;
});
} catch (e) {
debugPrint("Error loading target data files: $e");
@@ -782,7 +787,7 @@ Widget _buildTargetsList(String folderName) {
children: targetFiles.asMap().entries.map((entry) {
final index = entry.key;
final file = entry.value;
- final score = _getScoreFromJson(jsonDecode(file.readAsStringSync()));
+ final score = _fileScores[file.path] ?? 0;
final fileName = "${_t('Target')} ${index + 1}";
return Container(
diff --git a/lib/screens/calendar_screen.dart b/lib/screens/calendar_screen.dart
index e25db66..a24688d 100644
--- a/lib/screens/calendar_screen.dart
+++ b/lib/screens/calendar_screen.dart
@@ -26,9 +26,9 @@ class Contact {
}
enum EventType {
- regular, // Dežurstvo and other regular events
- competition, // Liga and Tekmovanje (League and Competition events)
- sestanek, // Meetings
+ regular,
+ competition,
+ sestanek,
}
class CalendarScreen extends StatefulWidget {
@@ -46,10 +46,8 @@ class _CalendarScreenState extends State {
String _bulletColor = 'Blue';
String _selectedLanguage = 'English';
bool _showContacts = false;
- bool _showDebugPreview = false;
late Color _backgroundColor;
- // Members contact list
final List _contacts = [
Contact(firstName: 'Domen', lastName: 'Pleterski', phone: '051227764', email: 'info@bl3k.com'),
Contact(firstName: 'Ivan', lastName: 'Tandler', phone: '040471258', email: 'ivan.tandler@gmail.com'),
@@ -71,8 +69,7 @@ class _CalendarScreenState extends State {
@override
void initState() {
super.initState();
- initializeDateFormatting('sl_SI', null); // Initialize Slovenian locale
- // Initialize with default target background color
+ initializeDateFormatting('sl_SI', null);
_backgroundColor = TargetColors.getBackgroundColor('assets/target.png');
_loadBulletColor();
_loadLanguage();
@@ -80,29 +77,17 @@ class _CalendarScreenState extends State {
_loadEvents();
}
- String _t(String key) {
- return AppTranslations.translate(key, _selectedLanguage);
- }
+ String _t(String key) => AppTranslations.translate(key, _selectedLanguage);
Future _loadLanguage() async {
final prefs = await SharedPreferences.getInstance();
- setState(() {
- _selectedLanguage = prefs.getString('language') ?? 'English';
- });
+ setState(() => _selectedLanguage = prefs.getString('language') ?? 'English');
}
Future _loadSelectedTargetColor() async {
final prefs = await SharedPreferences.getInstance();
final selectedTarget = prefs.getString('selectedTarget') ?? 'assets/target.png';
- setState(() {
- _backgroundColor = TargetColors.getBackgroundColor(selectedTarget);
- });
- }
-
- void _toggleDebugPreview() {
- setState(() {
- _showDebugPreview = !_showDebugPreview;
- });
+ setState(() => _backgroundColor = TargetColors.getBackgroundColor(selectedTarget));
}
@override
@@ -113,70 +98,38 @@ class _CalendarScreenState extends State {
Future _loadBulletColor() async {
final prefs = await SharedPreferences.getInstance();
- setState(() {
- _bulletColor = prefs.getString('bulletColor') ?? 'Blue';
- });
+ setState(() => _bulletColor = prefs.getString('bulletColor') ?? 'Blue');
}
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;
}
}
bool _isValidEvent(CalendarEvent event) {
- // Filter out events with empty summaries
- if (event.summary == null || event.summary!.trim().isEmpty) {
- return false;
- }
-
- final summary = event.summary!.trim();
-
- // Only exclude very short single-character entries
- // This allows short event names like "Meeting", "Training", etc.
- if (summary.length < 2) {
- return false;
- }
-
- return true;
+ if (event.summary == null || event.summary!.trim().isEmpty) return false;
+ return event.summary!.trim().length >= 2;
}
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')) {
return EventType.competition;
} else if (summary.contains('sestanek')) {
@@ -184,8 +137,6 @@ class _CalendarScreenState extends State {
} else if (summary.contains('dežurstvo')) {
return EventType.regular;
}
-
- // No matching keywords - skip this event
return null;
}
@@ -201,24 +152,14 @@ class _CalendarScreenState extends State {
endDate: DateTime.now().add(const Duration(days: 365)),
);
- // Get today's date at midnight for comparison
final now = DateTime.now();
final today = DateTime(now.year, now.month, now.day);
- // Filter: valid events AND matching keywords AND events from today onwards
final filteredEvents = events.where((event) {
if (!_isValidEvent(event)) return false;
-
- // Check if event has a matching keyword type
if (_getEventType(event) == null) return false;
-
- // Only include events that are today or in the future
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;
@@ -231,16 +172,12 @@ class _CalendarScreenState extends State {
});
if (mounted) {
- setState(() {
- _events = filteredEvents;
- });
+ setState(() => _events = filteredEvents);
}
NotificationService().scheduleEventNotifications(filteredEvents);
} catch (e) {
if (mounted) {
- setState(() {
- _errorMessage = 'Error loading events: $e';
- });
+ setState(() => _errorMessage = 'Error loading events: $e');
}
} finally {
if (mounted) {
@@ -250,10 +187,7 @@ class _CalendarScreenState extends State {
}
Future _makePhoneCall(String phoneNumber) async {
- final Uri launchUri = Uri(
- scheme: 'tel',
- path: phoneNumber,
- );
+ final Uri launchUri = Uri(scheme: 'tel', path: phoneNumber);
try {
await launchUrl(launchUri);
} catch (e) {
@@ -284,7 +218,6 @@ class _CalendarScreenState extends State {
void _showContactPopup(BuildContext context, Contact contact) {
final accentColor = _getAccentColor();
-
showModalBottomSheet(
context: context,
backgroundColor: Colors.grey[900],
@@ -299,7 +232,6 @@ class _CalendarScreenState extends State {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- // Header with contact name
Padding(
padding: const EdgeInsets.only(bottom: 20),
child: Row(
@@ -314,159 +246,29 @@ class _CalendarScreenState extends State {
child: Center(
child: Text(
contact.firstName[0].toUpperCase(),
- style: const TextStyle(
- color: Colors.white,
- fontSize: 24,
- fontWeight: FontWeight.bold,
- ),
+ style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold),
),
),
),
const SizedBox(width: 16),
Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- _capitalize(contact.fullName),
- style: const TextStyle(
- color: Colors.white,
- fontSize: 18,
- fontWeight: FontWeight.bold,
- ),
- ),
- ],
+ child: Text(
+ _capitalize(contact.fullName),
+ style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold),
),
),
],
),
),
-
- // Phone number row
- Container(
- padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
- decoration: BoxDecoration(
- color: Colors.grey[850],
- borderRadius: BorderRadius.circular(10),
- ),
- child: Row(
- children: [
- Icon(Icons.phone, color: accentColor, size: 20),
- const SizedBox(width: 12),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- _t('Phone'),
- style: const TextStyle(
- color: Colors.grey,
- fontSize: 11,
- ),
- ),
- Text(
- contact.phone,
- style: const TextStyle(
- color: Colors.white,
- fontSize: 14,
- fontWeight: FontWeight.w600,
- ),
- ),
- ],
- ),
- ),
- Container(
- decoration: BoxDecoration(
- color: accentColor,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Material(
- color: Colors.transparent,
- child: InkWell(
- onTap: () {
- _copyToClipboard(contact.phone, 'Phone number');
- Navigator.pop(context);
- },
- borderRadius: BorderRadius.circular(8),
- child: const Padding(
- padding: EdgeInsets.all(8),
- child: Icon(
- Icons.content_copy,
- color: Colors.white,
- size: 18,
- ),
- ),
- ),
- ),
- ),
- ],
- ),
- ),
-
+ _buildContactDetailRow(accentColor, Icons.phone, _t('Phone'), contact.phone, () {
+ _copyToClipboard(contact.phone, 'Phone number');
+ Navigator.pop(context);
+ }),
const SizedBox(height: 12),
-
- // Email row
- Container(
- padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
- decoration: BoxDecoration(
- color: Colors.grey[850],
- borderRadius: BorderRadius.circular(10),
- ),
- child: Row(
- children: [
- Icon(Icons.email, color: accentColor, size: 20),
- const SizedBox(width: 12),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- _t('Email'),
- style: const TextStyle(
- color: Colors.grey,
- fontSize: 11,
- ),
- ),
- Text(
- contact.email.toLowerCase(),
- 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),
- ),
- child: Material(
- color: Colors.transparent,
- child: InkWell(
- onTap: () {
- _copyToClipboard(contact.email, 'Email address');
- Navigator.pop(context);
- },
- borderRadius: BorderRadius.circular(8),
- child: const Padding(
- padding: EdgeInsets.all(8),
- child: Icon(
- Icons.content_copy,
- color: Colors.white,
- size: 18,
- ),
- ),
- ),
- ),
- ),
- ],
- ),
- ),
+ _buildContactDetailRow(accentColor, Icons.email, _t('Email'), contact.email.toLowerCase(), () {
+ _copyToClipboard(contact.email, 'Email address');
+ Navigator.pop(context);
+ }),
],
),
),
@@ -475,15 +277,49 @@ class _CalendarScreenState extends State {
);
}
+ 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)),
+ child: Row(
+ children: [
+ Icon(icon, color: accentColor, size: 20),
+ const SizedBox(width: 12),
+ Expanded(
+ 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),
+ ],
+ ),
+ ),
+ Container(
+ decoration: BoxDecoration(color: accentColor, borderRadius: BorderRadius.circular(8)),
+ child: Material(
+ color: Colors.transparent,
+ child: InkWell(
+ onTap: onCopy,
+ borderRadius: BorderRadius.circular(8),
+ child: const Padding(
+ padding: EdgeInsets.all(8),
+ child: Icon(Icons.content_copy, color: Colors.white, size: 18),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
Widget _buildContactsList() {
final accentColor = _getAccentColor();
-
return ListView.builder(
itemCount: _contacts.length,
padding: const EdgeInsets.all(8),
itemBuilder: (context, index) {
final contact = _contacts[index];
-
return GestureDetector(
onTap: () => _makePhoneCall(contact.phone),
onLongPress: () => _showContactPopup(context, contact),
@@ -493,11 +329,7 @@ class _CalendarScreenState extends State {
color: Colors.grey[300],
borderRadius: BorderRadius.circular(12),
boxShadow: [
- BoxShadow(
- color: Colors.grey.withValues(alpha: 0.3),
- blurRadius: 8,
- offset: const Offset(0, 2),
- ),
+ BoxShadow(color: Colors.grey.withValues(alpha: 0.3), blurRadius: 8, offset: const Offset(0, 2)),
],
),
child: Stack(
@@ -505,115 +337,67 @@ class _CalendarScreenState extends State {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- // Header bar with bullet color and transparency
Container(
width: double.infinity,
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: [
- // White indicator line
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),
- // Contact name in white
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),
),
),
],
),
),
- // Main content with phone and email info
Padding(
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,
- ),
- ),
- ],
- ),
+ 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)),
+ ]),
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,
- ),
- ),
- ],
- ),
+ 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),
+ ),
+ ]),
],
),
),
],
),
- // Phone button on the right (wider now)
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: 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)),
),
),
),
@@ -626,97 +410,329 @@ class _CalendarScreenState extends State {
);
}
+ 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;
+ }
+ }
+
+ 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;
+ }
+ }
+
+ String _eventBadgeLabel(EventType type) {
+ switch (type) {
+ 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');
+ return '${DateFormat('HH:mm').format(startTime.toLocal())} – ${DateFormat('HH:mm').format(event.endTime!.toLocal())}';
+ }
+
+ Widget _buildEventCard(CalendarEvent event, Color accentColor, {bool highlight = false}) {
+ final eventType = _getEventType(event);
+ if (eventType == null) return const SizedBox();
+
+ final color = _eventColor(eventType, accentColor);
+ final hasLocation = event.location != null && event.location!.isNotEmpty;
+
+ return RepaintBoundary(
+ child: Container(
+ decoration: BoxDecoration(
+ color: Colors.grey[300],
+ borderRadius: BorderRadius.circular(12),
+ boxShadow: [
+ BoxShadow(color: Colors.black.withValues(alpha: 0.15), blurRadius: 6, offset: const Offset(0, 2)),
+ ],
+ ),
+ clipBehavior: Clip.antiAlias,
+ child: IntrinsicHeight(
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ // Type color stripe
+ Container(width: 5, color: color),
+ Expanded(
+ child: Padding(
+ 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),
+ const Spacer(),
+ Icon(Icons.access_time, size: 13, color: Colors.grey[700]),
+ const SizedBox(width: 4),
+ Text(
+ _timeText(event),
+ style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.grey[800]),
+ ),
+ ],
+ ),
+ const SizedBox(height: 8),
+ Text(
+ event.summary ?? _t('Untitled Event'),
+ style: TextStyle(
+ fontSize: highlight ? 16 : 14,
+ fontWeight: FontWeight.w700,
+ color: Colors.grey[900],
+ ),
+ ),
+ if (hasLocation) ...[
+ const SizedBox(height: 4),
+ Row(
+ children: [
+ Icon(Icons.location_on, size: 13, color: Colors.grey[600]),
+ const SizedBox(width: 4),
+ Expanded(
+ child: Text(
+ event.location!,
+ style: TextStyle(fontSize: 12, color: Colors.grey[700]),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ ],
+ ),
+ ],
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildTypeChip(IconData icon, String label, Color color) {
+ return Container(
+ padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
+ decoration: BoxDecoration(
+ color: color.withValues(alpha: 0.15),
+ borderRadius: BorderRadius.circular(20),
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ 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)),
+ ],
+ ),
+ );
+ }
+
+ Widget _buildSectionHeader(String label, Color dotColor, Color textColor, {String? trailing, Color? trailingColor}) {
+ return Row(
+ children: [
+ Container(
+ width: 8,
+ height: 8,
+ 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)),
+ if (trailing != null) ...[
+ const SizedBox(width: 8),
+ Expanded(
+ child: Text(
+ '· $trailing',
+ style: TextStyle(fontSize: 12, color: trailingColor ?? textColor),
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ ],
+ ],
+ );
+ }
+
+ Widget _buildDateColumn(DateTime date, int daysFromToday, Color accentColor, bool isLight) {
+ 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,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.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),
+ ),
+ Text(
+ DateFormat('d').format(date),
+ style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: isLight ? Colors.black87 : 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]),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ bool _isLightBackground() {
+ return _backgroundColor.computeLuminance() > 0.4;
+ }
+
+ Widget _buildCalendarView(Color accentColor) {
+ final now = DateTime.now();
+ final today = DateTime(now.year, now.month, now.day);
+ final locale = _selectedLanguage == 'Slovenian' ? 'sl_SI' : 'en_US';
+ final isLight = _isLightBackground();
+ final textPrimary = isLight ? Colors.black87 : Colors.white;
+ 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);
+
+ 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
+ final upcomingWidgets = [];
+ DateTime? lastDay;
+ for (final e in upcomingEvents) {
+ final day = dayOf(e);
+ final isNewMonth = lastDay == null || lastDay.month != day.month || lastDay.year != day.year;
+ final isNewDay = lastDay == null || !lastDay.isAtSameMomentAs(day);
+
+ if (isNewMonth) {
+ upcomingWidgets.add(Padding(
+ 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),
+ ),
+ ));
+ }
+
+ 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)),
+ ],
+ ),
+ ));
+ lastDay = day;
+ }
+
+ return RefreshIndicator(
+ onRefresh: _loadEvents,
+ color: accentColor,
+ child: ListView(
+ physics: const AlwaysScrollableScrollPhysics(),
+ children: [
+ // TODAY section
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 16, 16, 0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ _buildSectionHeader(
+ _t('TODAY'),
+ accentColor,
+ textPrimary,
+ trailing: DateFormat('EEEE, d. MMMM', locale).format(now),
+ trailingColor: textSecondary,
+ ),
+ const SizedBox(height: 10),
+ if (todayEvents.isEmpty)
+ Container(
+ width: double.infinity,
+ padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 14),
+ decoration: BoxDecoration(
+ color: textMuted.withValues(alpha: 0.12),
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Row(
+ children: [
+ Icon(Icons.event_busy, size: 18, color: textMuted),
+ const SizedBox(width: 10),
+ 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),
+ )),
+ ],
+ ),
+ ),
+
+ if (upcomingEvents.isNotEmpty) ...[
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 24, 16, 10),
+ child: _buildSectionHeader(_t('UPCOMING'), textMuted, textPrimary),
+ ),
+ ...upcomingWidgets,
+ ],
+
+ if (_events.isEmpty) ...[
+ const SizedBox(height: 32),
+ Center(
+ child: Column(
+ children: [
+ Icon(Icons.event_available, size: 56, color: textMuted),
+ const SizedBox(height: 12),
+ 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)),
+ ],
+ ),
+ ),
+ ],
+
+ const SizedBox(height: 24),
+ ],
+ ),
+ );
+ }
+
@override
Widget build(BuildContext context) {
final accentColor = _getAccentColor();
- // Debug preview - disabled by default, set _showDebugPreview = true to enable
- if (_showDebugPreview) {
- return Scaffold(
- backgroundColor: Colors.white,
- appBar: AppBar(
- backgroundColor: Colors.grey[900],
- centerTitle: true,
- title: const Text(
- 'Debug Preview',
- style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
- ),
- leading: IconButton(
- icon: const Icon(Icons.close, color: Colors.white),
- onPressed: _toggleDebugPreview,
- ),
- ),
- body: ListView(
- padding: const EdgeInsets.all(16),
- children: [
- const SizedBox(height: 8),
- // Regular event
- Text(
- 'Regular Event (Dežurstvo)',
- style: TextStyle(
- fontSize: 14,
- fontWeight: FontWeight.bold,
- color: Colors.grey[600],
- ),
- ),
- const SizedBox(height: 8),
- _buildSampleEventCard(accentColor, EventType.regular),
- const SizedBox(height: 24),
- // Competition event
- Text(
- 'Competition Event (Tekmovanje)',
- style: TextStyle(
- fontSize: 14,
- fontWeight: FontWeight.bold,
- color: Colors.grey[600],
- ),
- ),
- const SizedBox(height: 8),
- _buildSampleEventCard(accentColor, EventType.competition),
- const SizedBox(height: 24),
- // Meeting event
- Text(
- 'Meeting Event (Sestanek)',
- style: TextStyle(
- fontSize: 14,
- fontWeight: FontWeight.bold,
- color: Colors.grey[600],
- ),
- ),
- const SizedBox(height: 8),
- _buildSampleEventCard(accentColor, EventType.sestanek),
- const SizedBox(height: 32),
- // Other dates section
- Text(
- 'Other Dates (without emphasis)',
- style: TextStyle(
- fontSize: 14,
- fontWeight: FontWeight.bold,
- color: Colors.grey[600],
- ),
- ),
- const SizedBox(height: 8),
- _buildOtherDateEventCard(accentColor, EventType.regular, 'Tomorrow'),
- const SizedBox(height: 12),
- _buildOtherDateEventCard(accentColor, EventType.competition, 'Next Week'),
- const SizedBox(height: 12),
- _buildOtherDateEventCard(accentColor, EventType.sestanek, 'In 5 days'),
- const SizedBox(height: 24),
- ],
- ),
- );
- }
-
if (_isLoading && _events.isEmpty) {
return Scaffold(
- body: Center(
- child: CircularProgressIndicator(color: accentColor),
- ),
+ backgroundColor: _backgroundColor,
+ body: Center(child: CircularProgressIndicator(color: accentColor)),
);
}
if (_errorMessage != null && _events.isEmpty) {
return Scaffold(
+ backgroundColor: _backgroundColor,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@@ -725,21 +741,14 @@ class _CalendarScreenState extends State {
const SizedBox(height: 24),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
- child: Text(
- _errorMessage!,
- textAlign: TextAlign.center,
- style: const TextStyle(fontSize: 16),
- ),
+ child: Text(_errorMessage!, textAlign: TextAlign.center, style: const TextStyle(fontSize: 16, color: Colors.white70)),
),
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),
),
],
),
@@ -751,712 +760,55 @@ class _CalendarScreenState extends State {
backgroundColor: _backgroundColor,
body: Column(
children: [
- // Tab buttons
+ // Tab bar
Container(
- padding: const EdgeInsets.all(6),
+ padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
decoration: BoxDecoration(
color: Colors.grey[900],
- border: Border(
- bottom: BorderSide(color: Colors.grey[800]!, width: 1),
- ),
),
child: Row(
children: [
- Expanded(
- child: GestureDetector(
- onTap: () {
- setState(() {
- _showContacts = false;
- });
- },
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
- decoration: BoxDecoration(
- color: !_showContacts ? Colors.white : Colors.transparent,
- borderRadius: BorderRadius.circular(10),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(
- Icons.calendar_month,
- color: !_showContacts ? Colors.black : Colors.grey[400],
- size: 18,
- ),
- const SizedBox(width: 6),
- Text(
- _t('Calendar'),
- style: TextStyle(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: !_showContacts ? Colors.black : Colors.grey[400],
- ),
- ),
- ],
- ),
- ),
- ),
- ),
+ _buildTab(_t('Calendar'), Icons.calendar_month, !_showContacts, () => setState(() => _showContacts = false)),
const SizedBox(width: 6),
- Expanded(
- child: GestureDetector(
- onTap: () {
- setState(() {
- _showContacts = true;
- });
- },
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
- decoration: BoxDecoration(
- color: _showContacts ? Colors.white : Colors.transparent,
- borderRadius: BorderRadius.circular(10),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(
- Icons.people,
- color: _showContacts ? Colors.black : Colors.grey[400],
- size: 18,
- ),
- const SizedBox(width: 6),
- Text(
- _t('Contacts'),
- style: TextStyle(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: _showContacts ? Colors.black : Colors.grey[400],
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- if (_showDebugPreview) ...[
- const SizedBox(width: 6),
- GestureDetector(
- onTap: _toggleDebugPreview,
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
- decoration: BoxDecoration(
- color: Colors.grey[800],
- borderRadius: BorderRadius.circular(10),
- border: Border.all(color: Colors.amber, width: 1),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(
- Icons.bug_report,
- color: Colors.amber,
- size: 16,
- ),
- const SizedBox(width: 4),
- const Text(
- 'Debug',
- style: TextStyle(
- fontSize: 11,
- fontWeight: FontWeight.w600,
- color: Colors.amber,
- ),
- ),
- ],
- ),
- ),
- ),
- ],
+ _buildTab(_t('Contacts'), Icons.people, _showContacts, () => setState(() => _showContacts = true)),
],
),
),
- // Body content
+ // Body
Expanded(
child: _showContacts
? _buildContactsList()
- : RefreshIndicator(
- onRefresh: _loadEvents,
- color: accentColor,
- child: _events.isEmpty
- ? ListView(
- children: [
- const SizedBox(height: 24),
- Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Icon(Icons.event_available, size: 64, color: Colors.grey[400]),
- const SizedBox(height: 16),
- Text(
- _t('No upcoming events'),
- style: const TextStyle(fontSize: 16, color: Colors.grey),
- ),
- const SizedBox(height: 8),
- Text(
- _t('Pull down to refresh'),
- style: TextStyle(fontSize: 14, color: Colors.grey[400]),
- ),
- ],
- ),
- ),
- const SizedBox(height: 32),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Text(
- _t('Example Event Preview'),
- style: TextStyle(
- fontSize: 18,
- fontWeight: FontWeight.bold,
- color: Colors.grey[700],
- ),
- textAlign: TextAlign.center,
- ),
- ),
- const SizedBox(height: 16),
- _buildSampleEventCard(accentColor, EventType.regular),
- const SizedBox(height: 8),
- _buildSampleEventCard(accentColor, EventType.competition),
- const SizedBox(height: 8),
- _buildSampleEventCard(accentColor, EventType.sestanek),
- ],
- )
- : ListView.builder(
- itemCount: _events.length,
- padding: const EdgeInsets.all(8),
- itemBuilder: (context, index) {
- final event = _events[index];
- return _buildEventCard(event, accentColor);
- },
- ),
- ),
+ : _buildCalendarView(accentColor),
),
],
),
);
}
- Widget _buildSampleEventCard(Color accentColor, EventType eventType) {
- // Color coding for each event type
- Color cardAccentColor;
- Color backgroundColor = Colors.grey[300]!;
- IconData eventIcon;
- String title;
- String time;
-
- switch (eventType) {
- case EventType.competition:
- cardAccentColor = Colors.orange;
- eventIcon = Icons.emoji_events;
- title = _t('League / Competition');
- time = '09:00 - 18:00';
- break;
- case EventType.sestanek:
- cardAccentColor = Colors.red;
- eventIcon = Icons.groups;
- title = _t('Team Meeting');
- time = '18:00 - 19:00';
- break;
- case EventType.regular:
- cardAccentColor = accentColor;
- eventIcon = Icons.event;
- title = _t('Duty Shift');
- time = '14:00 - 16:00';
- break;
- }
-
- return RepaintBoundary(
- child: Container(
- margin: const EdgeInsets.symmetric(vertical: 6, horizontal: 16),
- decoration: BoxDecoration(
- color: backgroundColor,
- borderRadius: BorderRadius.circular(12),
- boxShadow: [
- // Strong glow effect for today's events (sample is always today)
- BoxShadow(
- color: cardAccentColor.withValues(alpha: 0.4),
- blurRadius: 20,
- offset: const Offset(0, 6),
- ),
- // Subtle inner shadow
- BoxShadow(
- color: Colors.grey.withValues(alpha: 0.1),
- blurRadius: 4,
- offset: const Offset(0, 2),
- ),
- ],
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- // Date header
- Container(
- width: double.infinity,
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
- decoration: BoxDecoration(
- color: cardAccentColor,
- borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(12),
- topRight: Radius.circular(12),
- ),
- ),
- child: Row(
- children: [
- // Small white indicator line
- Container(
- width: 4,
- height: 16,
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(2),
- ),
- ),
- const SizedBox(width: 8),
- Text(
- _t('Today'),
- style: const TextStyle(
- fontSize: 14,
- fontWeight: FontWeight.bold,
- color: Colors.white,
- ),
- ),
- const Spacer(),
- // Event type badge - filled badges for all types
- Container(
- padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
- decoration: BoxDecoration(
- color: cardAccentColor,
- borderRadius: BorderRadius.circular(12),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(eventIcon, size: 12, color: Colors.white),
- const SizedBox(width: 4),
- Text(
- eventType == EventType.competition
- ? _t('TEKMOWANIE')
- : eventType == EventType.sestanek
- ? _t('SESTANEK')
- : _t('DEŽURSTVO'),
- style: const TextStyle(
- fontSize: 10,
- fontWeight: FontWeight.bold,
- color: Colors.white,
- letterSpacing: 0.8,
- ),
- ),
- ],
- ),
- ),
- ],
- ),
+ 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),
),
- // Main content
- Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- // Title with icon
- Row(
- children: [
- Icon(eventIcon, size: 20, color: cardAccentColor),
- const SizedBox(width: 8),
- Expanded(
- child: Text(
- title,
- style: const TextStyle(
- fontSize: 15,
- fontWeight: FontWeight.w600,
- color: Colors.black87,
- ),
- ),
- ),
- ],
- ),
- const SizedBox(height: 8),
- // Time range
- _buildDetailRowInline(
- icon: Icons.access_time,
- value: time,
- accentColor: cardAccentColor,
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- );
- }
-
- Widget _buildOtherDateEventCard(Color accentColor, EventType eventType, String dateLabel) {
- // Color coding for each event type
- Color cardAccentColor;
- Color backgroundColor = Colors.grey[300]!;
- IconData eventIcon;
- String title;
- String time;
-
- switch (eventType) {
- case EventType.competition:
- cardAccentColor = Colors.orange;
- eventIcon = Icons.emoji_events;
- title = _t('League / Competition');
- time = '09:00 - 18:00';
- break;
- case EventType.sestanek:
- cardAccentColor = Colors.red;
- eventIcon = Icons.groups;
- title = _t('Team Meeting');
- time = '18:00 - 19:00';
- break;
- case EventType.regular:
- cardAccentColor = accentColor;
- eventIcon = Icons.event;
- title = _t('Duty Shift');
- time = '14:00 - 16:00';
- break;
- }
-
- return RepaintBoundary(
- child: Container(
- margin: const EdgeInsets.symmetric(vertical: 6, horizontal: 16),
- decoration: BoxDecoration(
- color: backgroundColor,
- borderRadius: BorderRadius.circular(12),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- // Date header
- Container(
- width: double.infinity,
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
- decoration: BoxDecoration(
- color: cardAccentColor.withValues(alpha: 0.7),
- borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(12),
- topRight: Radius.circular(12),
- ),
- ),
- child: Row(
- children: [
- // Small white indicator line
- Container(
- width: 4,
- height: 16,
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(2),
- ),
- ),
- const SizedBox(width: 8),
- Text(
- dateLabel,
- style: const TextStyle(
- fontSize: 14,
- fontWeight: FontWeight.bold,
- color: Colors.white,
- ),
- ),
- const Spacer(),
- // Event type badge
- Container(
- padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
- decoration: BoxDecoration(
- color: cardAccentColor,
- borderRadius: BorderRadius.circular(12),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(eventIcon, size: 12, color: Colors.white),
- const SizedBox(width: 4),
- Text(
- eventType == EventType.competition
- ? _t('TEKMOVANJE')
- : eventType == EventType.sestanek
- ? _t('SESTANEK')
- : _t('DEŽURSTVO'),
- style: const TextStyle(
- fontSize: 10,
- fontWeight: FontWeight.bold,
- color: Colors.white,
- letterSpacing: 0.8,
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- // Main content
- Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- // Title with icon
- Row(
- children: [
- Icon(eventIcon, size: 20, color: cardAccentColor),
- const SizedBox(width: 8),
- Expanded(
- child: Text(
- title,
- style: const TextStyle(
- fontSize: 15,
- fontWeight: FontWeight.w600,
- color: Colors.black87,
- ),
- ),
- ),
- ],
- ),
- const SizedBox(height: 8),
- // Time range
- _buildDetailRowInline(
- icon: Icons.access_time,
- value: time,
- accentColor: cardAccentColor,
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- );
- }
-
- Widget _buildEventCard(CalendarEvent event, Color accentColor) {
- final startTime = event.startTime;
- final isAllDay = event.isAllDay;
- final eventType = _getEventType(event);
-
- // Color coding for each event type
- Color cardAccentColor;
- Color backgroundColor;
- IconData eventIcon;
-
- switch (eventType) {
- case EventType.competition:
- cardAccentColor = Colors.orange;
- backgroundColor = Colors.grey[300]!;
- eventIcon = Icons.emoji_events; // Trophy icon for competitions
- break;
- case EventType.sestanek:
- cardAccentColor = Colors.red;
- backgroundColor = Colors.grey[300]!;
- eventIcon = Icons.groups; // People icon for meetings
- break;
- case EventType.regular:
- cardAccentColor = accentColor;
- backgroundColor = Colors.grey[300]!;
- eventIcon = Icons.event;
- break;
- case null:
- // This case should never happen due to filtering, but required by compiler
- return const SizedBox();
- }
-
- // Format the date for display
- String dateText = '';
- bool isToday = false;
- if (startTime != null) {
- final now = DateTime.now();
- final today = DateTime(now.year, now.month, now.day);
- final eventDay = DateTime(startTime.year, startTime.month, startTime.day);
- final difference = eventDay.difference(today).inDays;
-
- if (difference == 0) {
- dateText = _t('Today');
- isToday = true;
- } else if (difference == 1) {
- dateText = _t('Tomorrow');
- } else {
- // Use locale based on selected language
- final locale = _selectedLanguage == 'Slovenian' ? 'sl_SI' : 'en_US';
- dateText = DateFormat('EEEE, MMMM d', locale).format(startTime);
- // Capitalize first letter of day and month
- if (dateText.isNotEmpty) {
- dateText = dateText[0].toUpperCase() + dateText.substring(1);
- }
- }
- }
-
- return RepaintBoundary(
- child: Container(
- margin: const EdgeInsets.symmetric(vertical: 6, horizontal: 16),
- decoration: BoxDecoration(
- color: backgroundColor,
- borderRadius: BorderRadius.circular(12),
- boxShadow: [
- // Strong glow effect only for today's events
- if (isToday) ...[
- BoxShadow(
- color: cardAccentColor.withValues(alpha: 0.4),
- blurRadius: 20,
- offset: const Offset(0, 6),
- ),
- BoxShadow(
- color: Colors.grey.withValues(alpha: 0.1),
- blurRadius: 4,
- offset: const Offset(0, 2),
+ 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]),
),
],
- ],
+ ),
),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- // Date header
- Container(
- width: double.infinity,
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
- decoration: BoxDecoration(
- color: isToday ? cardAccentColor : cardAccentColor.withValues(alpha: 0.7),
- borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(12),
- topRight: Radius.circular(12),
- ),
- ),
- child: Row(
- children: [
- // Small white indicator line
- Container(
- width: 4,
- height: 16,
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(2),
- ),
- ),
- const SizedBox(width: 8),
- Text(
- dateText,
- style: const TextStyle(
- fontSize: 14,
- fontWeight: FontWeight.bold,
- color: Colors.white,
- ),
- ),
- const Spacer(),
- // Event type badge - filled badges for all types
- Container(
- padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
- decoration: BoxDecoration(
- color: cardAccentColor,
- borderRadius: BorderRadius.circular(12),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(eventIcon, size: 12, color: Colors.white),
- const SizedBox(width: 4),
- Text(
- eventType == EventType.competition
- ? _t('TEKMOVANJE')
- : eventType == EventType.sestanek
- ? _t('SESTANEK')
- : _t('DEŽURSTVO'),
- style: const TextStyle(
- fontSize: 10,
- fontWeight: FontWeight.bold,
- color: Colors.white,
- letterSpacing: 0.8,
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- // Main content
- Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- // Title with icon
- Row(
- children: [
- Icon(eventIcon, size: 20, color: cardAccentColor),
- const SizedBox(width: 8),
- Expanded(
- child: Text(
- event.summary ?? _t('Untitled Event'),
- style: TextStyle(
- fontSize: 15,
- fontWeight: FontWeight.w600,
- color: Colors.black87,
- ),
- ),
- ),
- ],
- ),
- const SizedBox(height: 8),
- // Time range (if not all day)
- if (!isAllDay && startTime != null && event.endTime != null) ...[
- _buildDetailRowInline(
- icon: Icons.access_time,
- value: '${DateFormat('HH:mm').format(startTime.toLocal())} - ${DateFormat('HH:mm').format(event.endTime!.toLocal())}',
- accentColor: cardAccentColor,
- ),
- const SizedBox(height: 6),
- ],
- if (isAllDay) ...[
- _buildDetailRowInline(
- icon: Icons.access_time,
- value: _t('All day'),
- accentColor: cardAccentColor,
- ),
- const SizedBox(height: 6),
- ],
- // Location
- if (event.location != null && event.location!.isNotEmpty) ...[
- _buildDetailRowInline(
- icon: Icons.location_on,
- value: event.location!,
- accentColor: cardAccentColor,
- ),
- ],
- ],
- ),
- ),
- ],
- ),
),
);
}
-
- Widget _buildDetailRowInline({
- required IconData icon,
- required String value,
- required Color accentColor,
- }) {
- return Row(
- children: [
- Icon(icon, size: 16, color: accentColor),
- const SizedBox(width: 6),
- Expanded(
- child: Text(
- value,
- style: const TextStyle(
- fontSize: 13,
- color: Colors.black87,
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- ),
- ),
- ],
- );
- }
-
}
diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart
index c6ba113..988225c 100644
--- a/lib/screens/home_screen.dart
+++ b/lib/screens/home_screen.dart
@@ -133,7 +133,7 @@ class _HomeScreenState extends State {
padding: const EdgeInsets.only(right: 16.0),
child: Center(
child: Text(
- 'V1.1',
+ 'V1.2',
style: TextStyle(
color: Colors.grey[400],
fontSize: 12,
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index e9995ff..ddbe238 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -50,7 +50,6 @@ class _SettingsScreenState extends State {
bool _notifyDezuranje = true;
bool _notifySestanek = true;
bool _notifyTekma = true;
-
String _selectedLanguage = 'English';
final List