fluffychat/lib/components/default_bottom_navigation_bar.dart

56 lines
1.8 KiB
Dart
Raw Normal View History

2021-02-23 15:15:54 +01:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
class DefaultBottomNavigationBar extends StatelessWidget {
final int currentIndex;
const DefaultBottomNavigationBar({Key key, this.currentIndex = 1})
: super(key: key);
@override
Widget build(BuildContext context) {
return BottomNavigationBar(
onTap: (i) {
if (i == currentIndex) return;
switch (i) {
case 0:
AdaptivePageLayout.of(context)
.pushNamedAndRemoveUntilIsFirst('/contacts');
break;
case 1:
AdaptivePageLayout.of(context).pushNamedAndRemoveAllOthers('/');
break;
case 2:
AdaptivePageLayout.of(context)
.pushNamedAndRemoveUntilIsFirst('/discover');
break;
}
},
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
selectedItemColor: Theme.of(context).accentColor,
currentIndex: currentIndex,
type: BottomNavigationBarType.fixed,
2021-02-25 13:24:07 +01:00
showUnselectedLabels: true,
2021-02-23 15:15:54 +01:00
items: [
BottomNavigationBarItem(
icon: Icon(currentIndex == 0 ? Icons.people : Icons.people_outlined),
2021-02-27 11:13:39 +01:00
label: L10n.of(context).friends,
2021-02-23 15:15:54 +01:00
),
BottomNavigationBarItem(
icon: Icon(currentIndex == 1
? CupertinoIcons.chat_bubble_2_fill
: CupertinoIcons.chat_bubble_2),
label: L10n.of(context).messages,
),
BottomNavigationBarItem(
icon: Icon(currentIndex == 2
? CupertinoIcons.compass_fill
: CupertinoIcons.compass),
label: L10n.of(context).discover,
),
],
);
}
}