2020-05-05 11:21:37 +00:00
|
|
|
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
2020-05-10 16:29:43 +00:00
|
|
|
import 'package:comunic/ui/routes/main_route/page_info.dart';
|
2019-11-01 13:55:28 +00:00
|
|
|
import 'package:comunic/ui/screens/notifications_screen.dart';
|
2020-05-06 16:54:32 +00:00
|
|
|
import 'package:comunic/ui/widgets/mobile_mode/mobile_appbar_widget.dart';
|
2019-04-22 17:16:26 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
/// Main route of the application
|
|
|
|
///
|
|
|
|
/// @author Pierre HUBERT
|
|
|
|
|
2020-05-05 11:21:37 +00:00
|
|
|
class SmartphoneMainRoute extends StatefulWidget implements MainRoute {
|
2020-05-09 12:07:14 +00:00
|
|
|
const SmartphoneMainRoute({Key key}) : super(key: key);
|
|
|
|
|
2019-04-23 09:08:38 +00:00
|
|
|
@override
|
2020-04-17 13:26:37 +00:00
|
|
|
State<StatefulWidget> createState() => _MainRouteState();
|
2019-04-23 09:08:38 +00:00
|
|
|
}
|
|
|
|
|
2020-04-15 16:06:20 +00:00
|
|
|
/// Private implementation of HomeController
|
2020-05-09 12:18:09 +00:00
|
|
|
class _MainRouteState extends MainController {
|
2020-05-10 16:29:43 +00:00
|
|
|
@override
|
|
|
|
PageInfo get defaultPage =>
|
|
|
|
PageInfo(type: PageType.NOTIFICATIONS_PAGE, child: NotificationsScreen());
|
2020-04-15 14:03:04 +00:00
|
|
|
|
2019-04-23 09:08:38 +00:00
|
|
|
/// Allows to go to previous tab
|
|
|
|
Future<bool> _willPop() async {
|
2020-05-10 16:29:43 +00:00
|
|
|
if (numberOfPages == 1) return true;
|
2019-04-23 09:08:38 +00:00
|
|
|
|
2020-04-16 11:26:04 +00:00
|
|
|
popPage();
|
2019-04-23 09:08:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-04-22 17:16:26 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2019-07-01 09:51:23 +00:00
|
|
|
return Container(
|
|
|
|
color: Colors.blueAccent,
|
|
|
|
child: SafeArea(
|
|
|
|
// Avoid OS areas
|
|
|
|
child: WillPopScope(
|
|
|
|
onWillPop: _willPop,
|
|
|
|
child: Scaffold(
|
2020-05-10 16:29:43 +00:00
|
|
|
appBar: currentPage.hideNavBar
|
2020-04-16 12:58:02 +00:00
|
|
|
? null
|
2020-05-10 16:29:43 +00:00
|
|
|
: ComunicMobileAppBar(currentPage: currentPage),
|
|
|
|
body: SafeArea(child: currentPage.child),
|
2019-07-01 09:51:23 +00:00
|
|
|
),
|
2019-04-23 09:08:38 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2019-04-22 17:16:26 +00:00
|
|
|
}
|
2019-04-23 09:08:38 +00:00
|
|
|
}
|