84 lines
2.9 KiB
Dart
84 lines
2.9 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:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
import 'package:wyatt_ui_components/wyatt_ui_components.dart';
|
|
import 'package:wyatt_ui_kit/wyatt_ui_kit.dart';
|
|
import 'package:wyatt_ui_kit_example/cubit/app_mode_cubit.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) {
|
|
final brightness =
|
|
WidgetsBinding.instance.platformDispatcher.platformBrightness;
|
|
return BlocProvider(
|
|
create: (context) => AppModeCubit(
|
|
theme: defaultTheme,
|
|
brightness: brightness,
|
|
),
|
|
child: Builder(
|
|
builder: (context) => BlocBuilder<AppModeCubit, AppModeState>(
|
|
builder: (context, state) {
|
|
final light = Themes.lightFromTheme(state.theme);
|
|
final dark = Themes.darkFromTheme(state.theme);
|
|
final theme = state.brightness == Brightness.light ? light : dark;
|
|
return ComponentTheme(
|
|
data: WyattComponentThemeData.wyattComponentThemeData,
|
|
child: MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
localizationsDelegates: const [
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
],
|
|
theme: theme,
|
|
supportedLocales: const [
|
|
Locale('fr', ''),
|
|
],
|
|
title: title,
|
|
home: Home(
|
|
forceIndex: defaultPage,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|