60 lines
1.8 KiB
Dart
60 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
import 'package:flutter_windowmanager_plus/flutter_windowmanager_plus.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'screens/splash_screen.dart';
|
|
import 'utils/app_lock_service.dart';
|
|
import 'utils/app_theme.dart';
|
|
import 'widgets/app_lock_overlay.dart';
|
|
|
|
// Global notifier for the primary theme color
|
|
final ValueNotifier<Color> themeNotifier =
|
|
ValueNotifier<Color>(const Color(0xFF3F51B5));
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await FlutterWindowManagerPlus.addFlags(FlutterWindowManagerPlus.FLAG_SECURE);
|
|
|
|
// Load saved theme color
|
|
final prefs = await SharedPreferences.getInstance();
|
|
final colorValue = prefs.getInt('primary_color_value');
|
|
if (colorValue != null) {
|
|
themeNotifier.value = Color(colorValue);
|
|
}
|
|
|
|
await AppLockService.instance.init();
|
|
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ValueListenableBuilder<Color>(
|
|
valueListenable: themeNotifier,
|
|
builder: (context, primaryColor, _) {
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
title: 'saba',
|
|
theme: AppTheme.neoDarkTheme(primaryColor),
|
|
builder: (context, child) => AppLockOverlay(
|
|
child: child ?? const SizedBox.shrink(),
|
|
),
|
|
localizationsDelegates: const [
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
],
|
|
supportedLocales: const [
|
|
Locale('fa', 'IR'),
|
|
],
|
|
locale: const Locale('fa', 'IR'),
|
|
home: const SplashScreen(),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|