mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 00:21:19 +00:00
93 lines
2.5 KiB
Dart
93 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:managerapi/api.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:tablet_app/Components/MainView/main_view.dart';
|
|
import 'package:tablet_app/client.dart';
|
|
|
|
import 'Components/Previous/previous_view.dart';
|
|
import 'Models/tabletContext.dart';
|
|
import 'app_context.dart';
|
|
import 'constants.dart';
|
|
|
|
void main() {
|
|
String initialRoute;
|
|
|
|
initialRoute = '/main';
|
|
|
|
final MyApp myApp = MyApp(
|
|
initialRoute: initialRoute,
|
|
//context: localContext,
|
|
);
|
|
|
|
runApp(myApp);
|
|
}
|
|
|
|
class MyApp extends StatefulWidget {
|
|
final String initialRoute;
|
|
final TabletAppContext tabletAppContext;
|
|
final clientAPI = Client();
|
|
|
|
//final Context context;
|
|
MyApp({this.initialRoute, this.tabletAppContext});
|
|
|
|
// This widget is the root of your application.
|
|
@override
|
|
_MyAppState createState() => _MyAppState();
|
|
}
|
|
|
|
class _MyAppState extends State<MyApp> {
|
|
Client clientAPI = new Client();
|
|
|
|
TabletAppContext tabletAppContext;
|
|
|
|
@override
|
|
void initState() {
|
|
if (widget.tabletAppContext == null) {
|
|
tabletAppContext = new TabletAppContext();
|
|
// store user info locally
|
|
tabletAppContext.clientAPI = clientAPI;
|
|
tabletAppContext.language = "FR";
|
|
|
|
//appContext.setContext(tabletAppContext);
|
|
|
|
/*List<SectionDTO> sections = await clientAPI.sectionApi.sectionGetFromConfiguration("60b1257a2939c9163c3f0921");
|
|
print("number of sections " + sections.length.toString());
|
|
sections.forEach((element) {
|
|
print(element);
|
|
});*/
|
|
|
|
} else {
|
|
tabletAppContext = widget.tabletAppContext;
|
|
}
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ChangeNotifierProvider<AppContext>(
|
|
create: (_) => AppContext(tabletAppContext),
|
|
child: MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
title: 'Tablet App Demo',
|
|
initialRoute: widget.initialRoute,
|
|
/*supportedLocales: [
|
|
const Locale('en', 'US'),
|
|
const Locale('fr', 'FR'),
|
|
],*/
|
|
theme: ThemeData(
|
|
primarySwatch: Colors.grey,
|
|
scaffoldBackgroundColor: kBackgroundGrey,
|
|
//fontFamily: "Vollkorn",
|
|
textTheme: TextTheme(bodyText1: TextStyle(color: kMainRed)),
|
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
),
|
|
routes: {
|
|
'/previous': (context) => PreviousViewWidget(title: 'Tablet App Demo Home Page'),
|
|
'/main': (context) => MainViewWidget()
|
|
}
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|