loc-chain-app/loc_chain_app/lib/widgets/navbar.dart

70 lines
1.9 KiB
Dart
Raw Normal View History

2021-04-10 15:26:20 +00:00
import 'package:flutter/material.dart';
import 'package:loc_chain_app/pages/home.dart';
import 'package:loc_chain_app/pages/keygen.dart';
2021-04-10 18:45:44 +00:00
import '../pages/bluetooth.dart';
import '../pages/settings.dart';
2021-04-10 15:26:20 +00:00
class NavBarWidget extends StatefulWidget {
NavBarWidget({Key key}) : super(key: key);
@override
_NavBarWidgetState createState() => _NavBarWidgetState();
}
class _NavBarWidgetState extends State<NavBarWidget> {
int _selectedIndex = 0;
StatefulWidget _selectedWidget;
static List<Widget> pages = <Widget>[
HomePage(
title: 'Home',
),
2021-04-10 18:45:44 +00:00
BluetoothPage(
title: 'Connect',
),
2021-04-10 15:26:20 +00:00
KeygenPage(
title: 'RSA Configuration',
),
2021-04-10 18:45:44 +00:00
SettingsPage(
title: 'Settings',
)
2021-04-10 15:26:20 +00:00
];
void _onItemTapped(int index) => setState(() {
_selectedIndex = index;
_selectedWidget = pages[_selectedIndex];
});
@override
Widget build(context) => Scaffold(
body: _selectedWidget,
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home_rounded),
label: 'Home',
backgroundColor: Colors.cyan,
),
2021-04-10 18:45:44 +00:00
BottomNavigationBarItem(
icon: Icon(Icons.bluetooth),
label: 'Connect',
backgroundColor: Colors.cyan,
),
2021-04-10 15:26:20 +00:00
BottomNavigationBarItem(
icon: Icon(Icons.lock_rounded),
label: 'RSA Configuration',
backgroundColor: Colors.cyan,
),
2021-04-10 18:45:44 +00:00
BottomNavigationBarItem(
icon: Icon(Icons.lock_rounded),
label: 'Settings',
backgroundColor: Colors.cyan,
),
2021-04-10 15:26:20 +00:00
],
currentIndex: _selectedIndex,
selectedItemColor: Colors.lightBlueAccent,
unselectedItemColor: Colors.lightBlue[200],
onTap: _onItemTapped,
),
);
}