// Helpful guides: // - https://flutter.dev/docs/cookbook/forms/validation import 'package:flutter/material.dart'; //import 'package:provider/provider.dart'; void main() { runApp(const MainApp()); } class MainApp extends StatelessWidget { const MainApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Recurring Expense Tracker', theme: ThemeData( useMaterial3: true, colorScheme: ColorScheme.fromSeed(seedColor: Colors.green), ), home: HomePage(), ); } } class HomePage extends StatefulWidget { const HomePage({ super.key, }); @override State createState() => _HomePageState(); } class _HomePageState extends State { 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 { const ExpenseInputForm({ super.key, }); @override State createState() => _ExpenseInputFormState(); } class _ExpenseInputFormState extends State { @override Widget build(BuildContext context) { const inputWidth = 400.0; const inputHeight = 50.0; const recurrenceValues = [ DropdownMenuEntry(value: Recurrence.daily, label: "Daily"), DropdownMenuEntry(value: Recurrence.weekly, label: "Weekly"), DropdownMenuEntry(value: Recurrence.biweekly, label: "Biweekly"), DropdownMenuEntry(value: Recurrence.montly, label: "Monthly"), DropdownMenuEntry(value: Recurrence.yearly, label: "Yearly"), ]; return Center( child: Column(mainAxisSize: MainAxisSize.min, spacing: 10, children: [ Text('Input an expense below!'), SizedBox( width: inputWidth, height: inputHeight, child: TextField( keyboardType: TextInputType.text, decoration: InputDecoration( labelText: "Name", hintText: "Example: Red Pocket Phone Bill", ), // https://docs.flutter.dev/cookbook/forms/retrieve-input //controller: nameFieldController, )), SizedBox( width: inputWidth, height: inputHeight, child: TextField( keyboardType: TextInputType.numberWithOptions(decimal: true), decoration: InputDecoration(labelText: "Cost", hintText: "Example: 10.00"), ), ), DropdownMenu( dropdownMenuEntries: recurrenceValues, width: inputWidth, label: Text("Recurrence"), hintText: "Example: Monthly", ), SizedBox( width: inputWidth, height: inputHeight, child: TextField( keyboardType: TextInputType.text, decoration: InputDecoration( labelText: "Description", hintText: "Example: 1GB data with unlimited talk & text."), )), ]), ); } } // https://www.tutorialspoint.com/dart_programming/dart_programming_enumeration.htm enum Recurrence { daily, weekly, biweekly, montly, yearly } class Expense { String name; double cost; Recurrence recurrence; String description; Expense(this.name, this.cost, this.recurrence, this.description); }