manager-app/lib/Screens/Main/main_screen.dart
2023-12-05 14:38:47 +01:00

83 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:manager_app/Models/managerContext.dart';
import 'package:manager_app/Models/menu.dart';
import 'package:manager_app/Models/menuSection.dart';
import 'package:manager_app/Screens/Main/components/body.dart';
import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart';
import 'package:provider/provider.dart';
import 'package:responsive_framework/responsive_breakpoints.dart';
class MainScreen extends StatefulWidget {
MainScreen({Key? key}) : super(key: key);
@override
_MainScreenState createState() => _MainScreenState();
}
class _MainScreenState extends State<MainScreen> {
@override
Widget build(BuildContext context) {
final appContext = Provider.of<AppContext>(context);
ManagerAppContext managerAppContext = appContext.getContext();
print(managerAppContext.instanceId);
var isFortSt = managerAppContext.instanceId == "633ee379d9405f32f166f047";
if(!ResponsiveBreakpoints.of(context).equals(TABLET) || isFortSt) {
return Scaffold(
body: Body(showDevice: !isFortSt),
);
} else {
return Scaffold(
appBar: AppBar(title: Text("MyMuseum", style: new TextStyle(color: kPrimaryColor, fontSize: 30, fontWeight: FontWeight.w400, fontFamily: "Helvetica")), backgroundColor: kSecond.withOpacity(0.3), iconTheme: IconThemeData(color: kPrimaryColor)),
drawer: Drawer(
child: getMenu()
),
body: Body(showDevice: isFortSt),
);
}
}
getMenu() {
MenuSection devices = new MenuSection(name: "Appareils", type: "devices", order: 0);
MenuSection configurations = new MenuSection(name: "Visites", type: "configurations", order: 1);
MenuSection resources = new MenuSection(name: "Ressources", type: "resources", order: 2);
Menu menu = new Menu(title: "MyMuseum");
return ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: [
DrawerHeader(
decoration: BoxDecoration(
color: kPrimaryColor,
),
child: Text(menu.title),
),
ListTile(
title: Text(devices.name),
onTap: () {
// TODO Navigate to configurations screen (by route if possible)
},
),
ListTile(
title: Text(configurations.name),
onTap: () {
// TODO Navigate to configurations screen (by route if possible)
},
),
ListTile(
title: Text(resources.name),
onTap: () {
// TODO Navigate to resources screen (by route if possible)
},
),
],
);
}
}