2021-04-07 14:35:18 +00:00
|
|
|
import 'package:comunic/models/conversation.dart';
|
2020-05-09 12:38:58 +00:00
|
|
|
import 'package:comunic/ui/dialogs/screen_dialog.dart';
|
2020-05-05 11:31:03 +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';
|
|
|
|
import 'package:comunic/ui/screens/newest_posts.dart';
|
2020-05-09 17:45:07 +00:00
|
|
|
import 'package:comunic/ui/widgets/tablet_mode/calls/calls_area.dart';
|
2020-05-09 05:07:14 +00:00
|
|
|
import 'package:comunic/ui/widgets/tablet_mode/conversations/conversations_area_widget.dart';
|
2020-05-05 16:18:09 +00:00
|
|
|
import 'package:comunic/ui/widgets/tablet_mode/current_user_panel.dart';
|
2020-05-08 14:06:10 +00:00
|
|
|
import 'package:comunic/ui/widgets/tablet_mode/global_search_field.dart';
|
2020-05-05 16:49:50 +00:00
|
|
|
import 'package:comunic/ui/widgets/tablet_mode/memberships_panel.dart';
|
2020-05-06 16:54:32 +00:00
|
|
|
import 'package:comunic/ui/widgets/tablet_mode/tablet_appbar_widget.dart';
|
2020-05-05 11:31:03 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
/// Main tablet route
|
|
|
|
///
|
|
|
|
/// @author Pierre Hubert
|
|
|
|
|
2020-05-11 11:24:01 +00:00
|
|
|
const _SideBarSize = 300.0;
|
|
|
|
|
2020-05-05 11:31:03 +00:00
|
|
|
class TabletRoute extends StatefulWidget implements MainRoute {
|
2020-05-09 12:07:14 +00:00
|
|
|
const TabletRoute({Key key}) : super(key: key);
|
|
|
|
|
2020-05-05 11:31:03 +00:00
|
|
|
@override
|
|
|
|
_TabletRouteState createState() => _TabletRouteState();
|
|
|
|
}
|
|
|
|
|
2020-05-09 12:18:09 +00:00
|
|
|
class _TabletRouteState extends MainController {
|
2020-05-09 06:17:52 +00:00
|
|
|
final _conversationsKey = GlobalKey<ConversationsAreaWidgetState>();
|
2020-05-09 17:45:07 +00:00
|
|
|
final _callsKey = GlobalKey<CallsAreaState>();
|
2020-05-09 06:17:52 +00:00
|
|
|
|
2020-05-10 16:29:43 +00:00
|
|
|
@override
|
|
|
|
PageInfo get defaultPage => PageInfo(child: NewestPostsScreen());
|
|
|
|
|
2020-05-05 11:31:03 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-05-11 16:32:58 +00:00
|
|
|
return WillPopScope(
|
|
|
|
onWillPop: willPop,
|
|
|
|
child: Scaffold(
|
|
|
|
appBar: _buildAppBar(),
|
|
|
|
body: _buildBody(),
|
|
|
|
),
|
2020-05-05 11:31:03 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-05-06 16:54:32 +00:00
|
|
|
Widget _buildAppBar() => ComunicTabletAppBarWidget();
|
2020-05-05 11:31:03 +00:00
|
|
|
|
2020-05-09 04:49:05 +00:00
|
|
|
Widget _buildBody() => Stack(
|
|
|
|
children: [
|
|
|
|
Row(children: <Widget>[_buildLeftPane(), _buildRightPane()]),
|
2020-05-09 06:17:52 +00:00
|
|
|
Positioned(
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
child: ConversationsAreaWidget(key: _conversationsKey),
|
2020-05-09 17:45:07 +00:00
|
|
|
),
|
|
|
|
CallsArea(key: _callsKey),
|
2020-05-09 04:49:05 +00:00
|
|
|
],
|
2020-05-05 11:31:03 +00:00
|
|
|
);
|
|
|
|
|
2020-05-05 16:18:09 +00:00
|
|
|
Widget _buildLeftPane() => Theme(
|
|
|
|
data: Theme.of(context).copyWith(
|
2021-02-07 16:09:08 +00:00
|
|
|
textTheme: TextTheme(bodyText2: TextStyle(color: Colors.white)),
|
2020-05-05 17:33:04 +00:00
|
|
|
iconTheme: IconThemeData(color: Colors.white),
|
|
|
|
),
|
2020-05-05 16:18:09 +00:00
|
|
|
child: Container(
|
2020-05-11 11:24:01 +00:00
|
|
|
width: _SideBarSize,
|
2020-05-05 16:18:09 +00:00
|
|
|
color: Color(0xFF222D32),
|
|
|
|
child: Column(
|
2020-05-05 16:49:50 +00:00
|
|
|
children: <Widget>[
|
|
|
|
CurrentUserPanel(),
|
2020-05-08 14:06:10 +00:00
|
|
|
Container(height: 10),
|
|
|
|
GlobalSearchField(),
|
|
|
|
Container(height: 10),
|
2020-05-11 11:50:13 +00:00
|
|
|
Expanded(child: MembershipsPanel(currentPage: currentPage))
|
2020-05-05 16:49:50 +00:00
|
|
|
],
|
2020-05-05 16:18:09 +00:00
|
|
|
),
|
|
|
|
),
|
2020-05-05 11:31:03 +00:00
|
|
|
);
|
|
|
|
|
2020-05-11 11:24:01 +00:00
|
|
|
Widget _buildRightPane() => Container(
|
2020-05-11 11:50:13 +00:00
|
|
|
key: currentPage.key,
|
|
|
|
width: MediaQuery.of(context).size.width - _SideBarSize,
|
|
|
|
child: currentPage.child,
|
|
|
|
);
|
2020-05-09 06:17:52 +00:00
|
|
|
|
|
|
|
@override
|
2020-05-10 16:29:43 +00:00
|
|
|
void pushPage(PageInfo page) {
|
|
|
|
if (page.canShowAsDialog == true)
|
|
|
|
showScreenDialog(context, page.child);
|
|
|
|
else
|
|
|
|
super.pushPage(page);
|
2020-05-09 06:17:52 +00:00
|
|
|
}
|
|
|
|
|
2021-04-07 14:35:18 +00:00
|
|
|
@override
|
|
|
|
void openConversation(Conversation conv, {fullScreen: false}) {
|
|
|
|
if (fullScreen)
|
|
|
|
super.openConversation(conv, fullScreen: fullScreen);
|
|
|
|
else
|
|
|
|
openConversationById(conv.id, fullScreen: false);
|
|
|
|
}
|
|
|
|
|
2020-05-09 06:17:52 +00:00
|
|
|
@override
|
2021-04-06 16:22:45 +00:00
|
|
|
void openConversationById(int convID, {fullScreen = false}) {
|
2020-05-10 16:29:43 +00:00
|
|
|
if (!fullScreen) {
|
|
|
|
popUntilMainRoute();
|
|
|
|
_conversationsKey.currentState.openConversations(convID);
|
|
|
|
} else
|
2021-04-06 16:22:45 +00:00
|
|
|
super.openConversationById(convID, fullScreen: fullScreen);
|
2020-05-09 06:17:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2020-05-09 17:45:07 +00:00
|
|
|
void startCall(int convID) => _callsKey.currentState.openCall(convID);
|
2020-05-05 11:31:03 +00:00
|
|
|
}
|