adding i18n for dynamic page
This commit is contained in:
+25
-1
@@ -1,10 +1,14 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||
import 'package:sqlite3/sqlite3.dart';
|
||||
|
||||
import 'providers/locale_provider.dart';
|
||||
import 'l10n/app_localizations.dart';
|
||||
import 'Utils/dynamic_strings.dart';
|
||||
import 'screens/Attendance/attendance_service.dart';
|
||||
import 'screens/splash_screen/splash_screen.dart';
|
||||
|
||||
@@ -37,6 +41,14 @@ void main() async {
|
||||
// Background duty-tracking service (5-min GPS snapshots while punched in).
|
||||
AttendanceService.initService();
|
||||
|
||||
// Group-2 i18n bootstrap: locale pref + embedded dynamic tables + server
|
||||
// diff cache (all offline-first; reverts by removing provider wiring below).
|
||||
final localeProvider = LocaleProvider();
|
||||
final embedded = await DynamicStrings.loadEmbedded();
|
||||
localeProvider.seedTables(embedded);
|
||||
await localeProvider.loadServerCache();
|
||||
await localeProvider.init();
|
||||
|
||||
//Request notification permissions
|
||||
// await _requestNotificationPermissions();
|
||||
|
||||
@@ -49,7 +61,12 @@ void main() async {
|
||||
// initialDelay: const Duration(seconds: 5),
|
||||
// constraints: Constraints(networkType: NetworkType.connected),
|
||||
// );
|
||||
runApp(MyApp());
|
||||
runApp(
|
||||
ChangeNotifierProvider.value(
|
||||
value: localeProvider,
|
||||
child: const MyApp(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Future<void> _requestNotificationPermissions() async {
|
||||
@@ -217,10 +234,17 @@ final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
// }
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final locale = Provider.of<LocaleProvider>(context).locale;
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
// Group-2: ARB static words. Generated Hybrid screens additionally use
|
||||
// DynamicStrings.of(context).tr(key) for wireframe fields.
|
||||
locale: locale,
|
||||
supportedLocales: const [Locale('en'), Locale('hi')],
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
home: const SplashScreen(),
|
||||
routes: {},
|
||||
theme: ThemeData(
|
||||
|
||||
Reference in New Issue
Block a user