SimpleCloudNotifier/flutter/lib/nav_layout.dart

118 lines
3.5 KiB
Dart
Raw Normal View History

2024-02-10 19:57:17 +01:00
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
2024-02-11 01:08:51 +01:00
import 'package:provider/provider.dart';
2024-02-10 19:57:17 +01:00
import 'bottom_fab/fab_bottom_app_bar.dart';
2024-02-11 01:08:51 +01:00
import 'pages/account/root.dart';
2024-02-10 19:57:17 +01:00
import 'pages/message_list/message_list.dart';
2024-02-11 01:08:51 +01:00
import 'state/app_theme.dart';
2024-02-10 19:57:17 +01:00
class SCNNavLayout extends StatefulWidget {
const SCNNavLayout({super.key});
@override
State<SCNNavLayout> createState() => _SCNNavLayoutState();
}
class _SCNNavLayoutState extends State<SCNNavLayout> {
int _selectedIndex = 0;
static const List<Widget> _subPages = <Widget>[
2024-02-11 01:08:51 +01:00
MessageListPage(title: 'Messages'),
MessageListPage(title: 'Page 2'),
AccountRootPage(),
MessageListPage(title: 'Page 4'),
2024-02-10 19:57:17 +01:00
];
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
void _onFABTapped(int index) {
setState(() {
//TODO
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: _buildAppBar(context),
2024-02-11 01:08:51 +01:00
body: _subPages.elementAt(_selectedIndex),
2024-02-10 19:57:17 +01:00
bottomNavigationBar: _buildNavBar(context),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: _buildFAB(context),
);
}
Widget _buildFAB(BuildContext context) {
return FloatingActionButton(
onPressed: () {},
tooltip: 'Increment',
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(17))),
elevation: 2.0,
child: const Icon(FontAwesomeIcons.solidPaperPlaneTop),
);
}
Widget _buildNavBar(BuildContext context) {
return FABBottomAppBar(
onTabSelected: _onItemTapped,
2024-02-11 01:08:51 +01:00
color: Theme.of(context).disabledColor,
selectedColor: Theme.of(context).primaryColorDark,
2024-02-10 19:57:17 +01:00
notchedShape: const AutomaticNotchedShape(
RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(15),
topRight: Radius.circular(15),
),
),
RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(17)),
),
),
items: [
FABBottomAppBarItem(iconData: FontAwesomeIcons.solidEnvelope, text: 'Messages'),
FABBottomAppBarItem(iconData: FontAwesomeIcons.solidSnake, text: 'Channels'),
FABBottomAppBarItem(iconData: FontAwesomeIcons.solidFileUser, text: 'Account'),
FABBottomAppBarItem(iconData: FontAwesomeIcons.solidGear, text: 'Settings'),
],
);
}
2024-02-11 01:08:51 +01:00
PreferredSizeWidget _buildAppBar(BuildContext context) {
2024-02-10 19:57:17 +01:00
return AppBar(
title: const Text('Simple Cloud Notifier 2.0'),
actions: <Widget>[
2024-02-11 01:08:51 +01:00
Consumer<AppTheme>(
builder: (context, appTheme, child) => IconButton(
icon: Icon(appTheme.darkMode ? FontAwesomeIcons.solidSun : FontAwesomeIcons.solidMoon),
tooltip: 'Debug',
onPressed: () {
appTheme.switchDarkMode();
},
),
),
2024-02-10 19:57:17 +01:00
IconButton(
icon: const Icon(FontAwesomeIcons.solidSpiderBlackWidow),
tooltip: 'Debug',
onPressed: () {},
),
IconButton(
icon: const Icon(FontAwesomeIcons.solidMagnifyingGlass),
tooltip: 'Search',
onPressed: () {},
),
IconButton(
icon: const Icon(FontAwesomeIcons.solidQrcode),
tooltip: 'Show Account QR Code',
onPressed: () {},
),
],
backgroundColor: Theme.of(context).secondaryHeaderColor,
);
}
}