Skip to content

Commit

Permalink
Merge pull request #2 from cepdnaclk/feature-bin-status
Browse files Browse the repository at this point in the history
Added routes.dart file to store routes of the app.
  • Loading branch information
chanukabdk authored Feb 25, 2025
2 parents ed39375 + 5e8ab9f commit 4860e11
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
29 changes: 10 additions & 19 deletions bin_owner_mobile_app/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:bin_owner_mobile_app/routes.dart';
import 'package:flutter/material.dart';

import './theme/theme.dart';
Expand All @@ -12,9 +13,11 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
title: 'GreenPulse',
theme: customTheme,
home: const MyHomePage(title: 'Flutter Demo Home Page'),
home: MyHomePage(title: "Home Page"),
initialRoute: AppRoutes.home,
routes: AppRoutes.routes,
);
}
}
Expand All @@ -28,14 +31,6 @@ class MyHomePage extends StatefulWidget {
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
setState(() {
_counter++;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -44,19 +39,15 @@ class _MyHomePageState extends State<MyHomePage> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('You have pushed the button this many times:'),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
ElevatedButton(
onPressed: () {
Navigator.pushNamed(context, AppRoutes.binLevel);
},
child: Text("Bin Status Page"),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
13 changes: 13 additions & 0 deletions bin_owner_mobile_app/lib/routes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:bin_owner_mobile_app/main.dart';
import 'package:flutter/material.dart';
import './screens/bin_level_screen.dart';

class AppRoutes {
static const String home = '/home';
static const String binLevel = '/bin-level-screen';

static Map<String, WidgetBuilder> routes = {
home: (context) => MyHomePage(title: 'Home Page'),
binLevel: (context) => BinLevelScreen(),
};
}
10 changes: 10 additions & 0 deletions bin_owner_mobile_app/lib/screens/bin_level_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:flutter/material.dart';

class BinLevelScreen extends StatelessWidget {
const BinLevelScreen({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(appBar: AppBar(title: Text('Bin Level Monitor')));
}
}

0 comments on commit 4860e11

Please sign in to comment.