Clean up layout; fix colors and auto-populate
This commit is contained in:
@@ -2,6 +2,7 @@ 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 'package:ltx_flutter/pages/today_views/infinity_view.dart';
|
||||
import '../app_properties_bloc.dart';
|
||||
|
||||
class TabsPage extends StatefulWidget {
|
||||
@@ -14,7 +15,7 @@ class TabsPage extends StatefulWidget {
|
||||
class _TabsPageState extends State<TabsPage> {
|
||||
int _selectedIndex = 0;
|
||||
|
||||
static const _widgets = [TodayPage(), CategoriesPage(), AccountPage()];
|
||||
static const _widgets = [TodayPage(), InfinityView(), CategoriesPage(), AccountPage()];
|
||||
|
||||
void _onItemTapped(int index) {
|
||||
setState(() {
|
||||
@@ -25,19 +26,22 @@ class _TabsPageState extends State<TabsPage> {
|
||||
@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());
|
||||
}),
|
||||
),
|
||||
// appBar: AppBar(
|
||||
// title: StreamBuilder<Object>(
|
||||
// stream: appBloc.titleStream,
|
||||
// initialData: "Flutter",
|
||||
// builder: (context, snapshot) {
|
||||
// return Text(snapshot.data.toString());
|
||||
// }),
|
||||
// ),
|
||||
body: _widgets.elementAt(_selectedIndex),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
type: BottomNavigationBarType.fixed,
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.today_outlined), label: "Today"),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.all_inclusive), label: "Grid"),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.category_outlined), label: "Categories"),
|
||||
BottomNavigationBarItem(
|
||||
|
||||
@@ -43,29 +43,7 @@ class NarrowView extends StatelessWidget {
|
||||
return DefaultTabController(
|
||||
length: 4,
|
||||
initialIndex: 0,
|
||||
child: Column(
|
||||
children: [
|
||||
TabBar(
|
||||
tabs: [
|
||||
Tab(icon: Icon(Icons.calendar_view_day)),
|
||||
Tab(icon: Icon(Icons.calendar_view_week)),
|
||||
Tab(icon: Icon(Icons.calendar_view_month)),
|
||||
Tab(icon: Icon(Icons.all_inclusive)),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: [
|
||||
DayView(),
|
||||
WeekView(),
|
||||
Icon(Icons.directions_car, size: 350),
|
||||
InfinityView(),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
child: DayView()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,6 +528,12 @@ class _HourFormFieldState extends State<HourFormField> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.category != null) {
|
||||
catNum = widget.category!.number.toString();
|
||||
fgColor = widget.category!.foregroundColor;
|
||||
catName = widget.category!.name;
|
||||
}
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
@@ -557,7 +563,14 @@ class _HourFormFieldState extends State<HourFormField> {
|
||||
"hourField-${widget.dayEntry.$id}-${widget.index.toString()}"),
|
||||
textInputAction: TextInputAction.next,
|
||||
onEditingComplete: () {
|
||||
String value = _controller.value.text;
|
||||
String value;
|
||||
String current = _controller.value.text;
|
||||
if(current == ""){
|
||||
value = getPreviousHourValue(widget);
|
||||
}
|
||||
else{
|
||||
value = current;
|
||||
}
|
||||
database.updateHours(widget.dayEntry, widget.index, value);
|
||||
setState(() {
|
||||
widget.category = categories.lookUp(num.parse(value));
|
||||
@@ -588,3 +601,10 @@ class _HourFormFieldState extends State<HourFormField> {
|
||||
);
|
||||
}
|
||||
}
|
||||
String getPreviousHourValue(widget) {
|
||||
int prevIndex = widget.index - 1;
|
||||
if(prevIndex < 0){ return "0";}
|
||||
else{
|
||||
return widget.dayEntry.data['hours'][prevIndex].toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user