mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Created custom appbar
This commit is contained in:
@ -3,6 +3,7 @@ import 'package:comunic/ui/screens/friends_list_screen.dart';
|
||||
import 'package:comunic/ui/screens/menus_screen.dart';
|
||||
import 'package:comunic/ui/screens/newest_posts.dart';
|
||||
import 'package:comunic/ui/tiles/custom_bottom_navigation_bar_item.dart';
|
||||
import 'package:comunic/ui/widgets/navbar_widget.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@ -16,14 +17,13 @@ class HomeRoute extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HomeRouteState extends State<HomeRoute> {
|
||||
int _currTab = 0;
|
||||
List<int> history = List();
|
||||
|
||||
BarCallbackActions _currTab = BarCallbackActions.OPEN_CONVERSATIONS;
|
||||
List<BarCallbackActions> history = List();
|
||||
|
||||
/// Change currently visible tab
|
||||
void _changeTab(int newTabNumber) {
|
||||
void _changeTab(BarCallbackActions newTab) {
|
||||
setState(() {
|
||||
_currTab = newTabNumber;
|
||||
_currTab = newTab;
|
||||
});
|
||||
}
|
||||
|
||||
@ -37,9 +37,9 @@ class _HomeRouteState extends State<HomeRoute> {
|
||||
}
|
||||
|
||||
/// Handles a new tab being tapped
|
||||
void _onTap(int number, BuildContext context) {
|
||||
if (_currTab != number) history.add(number);
|
||||
_changeTab(number);
|
||||
void _onTap(BarCallbackActions action) {
|
||||
if (_currTab != action) history.add(action);
|
||||
_changeTab(action);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -51,60 +51,37 @@ class _HomeRouteState extends State<HomeRoute> {
|
||||
/// Build the body of the application
|
||||
Widget _buildBody(BuildContext context) {
|
||||
switch (_currTab) {
|
||||
case 0:
|
||||
case BarCallbackActions.OPEN_CONVERSATIONS:
|
||||
return ConversationsListScreen();
|
||||
|
||||
case 1:
|
||||
case BarCallbackActions.OPEN_NEWEST_POSTS:
|
||||
return NewestPostsScreen();
|
||||
|
||||
case 2:
|
||||
case BarCallbackActions.OPEN_FRIENDS:
|
||||
return FriendsListScreen();
|
||||
|
||||
case 3:
|
||||
return MenuScreen();
|
||||
|
||||
default:
|
||||
throw "Invalid tab number : " + _currTab.toString();
|
||||
throw "Invalid tab : " + _currTab.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/// Build navigation bar items
|
||||
List<BottomNavigationBarItem> _buildNavigationBarItems() {
|
||||
return <BottomNavigationBarItem>[
|
||||
CustomNavigationBarItem(
|
||||
icon: Icon(Icons.chat),
|
||||
title: Text(tr("Conversations")),
|
||||
),
|
||||
CustomNavigationBarItem(
|
||||
icon: Icon(Icons.refresh),
|
||||
title: Text(tr("Newest")),
|
||||
),
|
||||
CustomNavigationBarItem(
|
||||
icon: Icon(Icons.group),
|
||||
title: Text(tr("Friends")),
|
||||
),
|
||||
CustomNavigationBarItem(
|
||||
icon: Icon(Icons.menu),
|
||||
title: Text(tr("Menu")),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: _willPop,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: _buildNavigationBarItems()[_currTab].title,
|
||||
),
|
||||
body: SafeArea(
|
||||
child: _buildBody(context),
|
||||
),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _currTab,
|
||||
items: _buildNavigationBarItems(),
|
||||
onTap: (i) => _onTap(i, context),
|
||||
return Container(
|
||||
color: Colors.blueAccent,
|
||||
child: SafeArea(
|
||||
// Avoid OS areas
|
||||
child: WillPopScope(
|
||||
onWillPop: _willPop,
|
||||
child: Scaffold(
|
||||
appBar: ComunicAppBar(
|
||||
onTap: _onTap,
|
||||
selectedAction: _currTab,
|
||||
),
|
||||
body: SafeArea(
|
||||
child: _buildBody(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user