75 lines
2.6 KiB
Dart
75 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart'; // Import for SystemChrome
|
|
import 'package:intl/date_symbol_data_local.dart';
|
|
import 'screens/home_screen.dart';
|
|
import 'services/notification_service.dart';
|
|
import 'services/app_settings.dart';
|
|
import 'theme/app_theme.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await AppSettings.instance.load();
|
|
await initializeDateFormatting(); // Slovenian month/day names for every screen
|
|
try {
|
|
await NotificationService().initialize();
|
|
} catch (_) {}
|
|
// Refresh reminders in the background so they don't depend on opening the calendar
|
|
NotificationService().rescheduleFromCalendar();
|
|
|
|
// Lock orientation to portrait only
|
|
await SystemChrome.setPreferredOrientations([
|
|
DeviceOrientation.portraitUp,
|
|
DeviceOrientation.portraitDown,
|
|
]);
|
|
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
|
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Theme (Sistem / Svetla / Temna) and the hit colour change the whole app live
|
|
return ListenableBuilder(
|
|
listenable: AppSettings.instance,
|
|
builder: (context, _) {
|
|
final palette = AppSettings.instance.palette;
|
|
return MaterialApp(
|
|
title: 'SD Kovinar',
|
|
debugShowCheckedModeBanner: false,
|
|
theme: AppTheme.theme(palette),
|
|
builder: (context, child) {
|
|
final originalTextScaler = MediaQuery.of(context).textScaler;
|
|
final clampedScale = originalTextScaler.clamp(minScaleFactor: 0.8, maxScaleFactor: 1.2);
|
|
// Edge-to-edge (Android 15+) ignores the navigation bar color, so paint
|
|
// the system bar strip ourselves on every screen, matching our bars.
|
|
final systemBar = MediaQuery.viewPaddingOf(context).bottom;
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
value: AppTheme.overlay(palette),
|
|
child: MediaQuery(
|
|
data: MediaQuery.of(context).copyWith(textScaler: clampedScale),
|
|
child: Stack(
|
|
children: [
|
|
child!,
|
|
Positioned(
|
|
left: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
height: systemBar,
|
|
child: IgnorePointer(child: ColoredBox(color: palette.nav)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
home: const HomeScreen(),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|