google preperation 1
This commit is contained in:
+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]),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user