ltx-flutter/ltx_flutter/lib/pages/tabs_page.dart

73 lines
2.1 KiB
Dart

import 'package:ltx_flutter/pages/account_page.dart';
import 'package:ltx_flutter/pages/categories_page.dart';
import 'package:ltx_flutter/pages/today_page.dart';
import 'package:flutter/material.dart';
import '../app_properties_bloc.dart';
class TabsPage extends StatefulWidget {
const TabsPage({Key? key}) : super(key: key);
@override
_TabsPageState createState() => _TabsPageState();
}
class _TabsPageState extends State<TabsPage> {
int _selectedIndex = 0;
static const _widgets = [TodayPage(), CategoriesPage(), AccountPage()];
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: StreamBuilder<Object>(
stream: appBloc.titleStream,
initialData: "Flutter",
builder: (context, snapshot) {
return Text(snapshot.data.toString());
}),
actions: [
Padding(
padding: const EdgeInsets.only(right: 28.0),
child: Row(
children: [
Text("Edit"),
StreamBuilder<Object>(
stream: appBloc.editable,
initialData: true,
builder: (context, snapshot) {
return Switch(
value: bool.parse(snapshot.data.toString()),
onChanged: (value) {
// print(value);
},
);
}),
],
),
)
],
),
body: _widgets.elementAt(_selectedIndex),
bottomNavigationBar: BottomNavigationBar(
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.today_outlined), label: "Today"),
BottomNavigationBarItem(
icon: Icon(Icons.category_outlined), label: "Categories"),
BottomNavigationBarItem(
icon: Icon(Icons.account_circle_outlined), label: "Account")
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
),
);
}
}