Added navigation. Very nice!! ;D
This commit is contained in:
parent
f820265dba
commit
0c9b365f7f
103
lib/main.dart
103
lib/main.dart
@ -13,21 +13,98 @@ class MainApp extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Recurring Expense Tracker',
|
title: 'Recurring Expense Tracker',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.green),
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.green),
|
||||||
),
|
|
||||||
home: Scaffold(
|
|
||||||
body: ExpenseInputForm(),
|
|
||||||
//floatingActionButton: IconButton(onPressed: appState.newExpense(), icon: Icon(Icons.add)),
|
|
||||||
),
|
),
|
||||||
|
home: HomePage(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class HomePage extends StatefulWidget {
|
||||||
|
const HomePage({
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<HomePage> createState() => _HomePageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HomePageState extends State<HomePage> {
|
||||||
|
var pageSelected = 0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Widget page;
|
||||||
|
switch (pageSelected) {
|
||||||
|
case 0:
|
||||||
|
page = ExpenseInputForm();
|
||||||
|
case 1:
|
||||||
|
page = Placeholder();
|
||||||
|
case 2:
|
||||||
|
page = Placeholder();
|
||||||
|
case 3:
|
||||||
|
page = Placeholder();
|
||||||
|
case 4:
|
||||||
|
page = Placeholder();
|
||||||
|
default:
|
||||||
|
throw UnimplementedError('no widget for $pageSelected');
|
||||||
|
}
|
||||||
|
|
||||||
|
return LayoutBuilder(builder: (context, constraints) {
|
||||||
|
return Scaffold(
|
||||||
|
body: Row(
|
||||||
|
children: [
|
||||||
|
SafeArea(
|
||||||
|
child: NavigationRail(
|
||||||
|
extended: constraints.maxWidth >= 600,
|
||||||
|
destinations: [
|
||||||
|
NavigationRailDestination(
|
||||||
|
icon: Icon(Icons.payment),
|
||||||
|
label: Text('Expenses'),
|
||||||
|
),
|
||||||
|
NavigationRailDestination(
|
||||||
|
icon: Icon(Icons.account_balance),
|
||||||
|
label: Text('Income'),
|
||||||
|
),
|
||||||
|
NavigationRailDestination(
|
||||||
|
icon: Icon(Icons.attach_money),
|
||||||
|
label: Text('Liquid Assets'),
|
||||||
|
),
|
||||||
|
NavigationRailDestination(
|
||||||
|
icon: Icon(Icons.bar_chart),
|
||||||
|
label: Text('Projections'),
|
||||||
|
),
|
||||||
|
NavigationRailDestination(
|
||||||
|
icon: Icon(Icons.settings),
|
||||||
|
label: Text('Settings'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
selectedIndex: pageSelected,
|
||||||
|
onDestinationSelected: (value) {
|
||||||
|
setState(() {
|
||||||
|
pageSelected = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
color: Theme.of(context).colorScheme.primaryContainer,
|
||||||
|
child: page,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
//floatingActionButton: IconButton(onPressed: appState.newExpense(), icon: Icon(Icons.add)),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ExpenseInputForm extends StatefulWidget {
|
class ExpenseInputForm extends StatefulWidget {
|
||||||
const ExpenseInputForm({
|
const ExpenseInputForm({
|
||||||
super.key,
|
super.key,
|
||||||
@ -71,8 +148,8 @@ class _ExpenseInputFormState extends State<ExpenseInputForm> {
|
|||||||
height: inputHeight,
|
height: inputHeight,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||||
decoration: InputDecoration(
|
decoration:
|
||||||
labelText: "Cost", hintText: "Example: 10.00"),
|
InputDecoration(labelText: "Cost", hintText: "Example: 10.00"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
DropdownMenu(
|
DropdownMenu(
|
||||||
@ -88,9 +165,7 @@ class _ExpenseInputFormState extends State<ExpenseInputForm> {
|
|||||||
keyboardType: TextInputType.text,
|
keyboardType: TextInputType.text,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: "Description",
|
labelText: "Description",
|
||||||
hintText:
|
hintText: "Example: 1GB data with unlimited talk & text."),
|
||||||
"Example: 1GB data with unlimited talk & text."
|
|
||||||
),
|
|
||||||
)),
|
)),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user