64 lines
2.1 KiB
Dart

// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:wyatt_ui_kit_example/home.dart';
import 'package:wyatt_ui_kit_example/theme/themes.dart';
void main(List<String> args) {
const forcePage = int.fromEnvironment('PAGE');
const forceTheme = int.fromEnvironment('THEME');
Themes.currentThemeIndex = forceTheme;
runApp(
const App(
defaultPage: forcePage,
defaultTheme: forceTheme,
),
);
}
class App extends StatelessWidget {
const App({required this.defaultPage, required this.defaultTheme, super.key});
final int defaultPage;
final int defaultTheme;
@override
Widget build(BuildContext context) => AdaptiveTheme(
initial: AdaptiveThemeMode.light,
light: Themes.lightFromTheme(defaultTheme),
dark: Themes.darkFromTheme(defaultTheme),
builder: (light, dark) => MaterialApp(
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
theme: light,
darkTheme: dark,
supportedLocales: const [
Locale('fr', ''),
],
title: title,
home: Home(
forceIndex: defaultPage,
),
),
);
}