Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_sandbox/routes/index.dart';
import 'package:flutter_sandbox/widgets/components/drawer.dart';
import 'package:flutter_sandbox/widgets/screens/messages.dart';
import 'package:flutter_sandbox/widgets/screens/profile.dart';

void main() => runApp(MyApp());

Expand All @@ -12,6 +15,11 @@ class MyApp extends StatelessWidget {
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Home Page'),
routes: <String, WidgetBuilder> {
Routes.home: (BuildContext context) => MyHomePage(title: 'Home Page'),
Routes.messages: (BuildContext context) => MessagesScreen(),
Routes.profile: (BuildContext context) => ProfileScreen(),
},
);
}
}
Expand Down
8 changes: 8 additions & 0 deletions lib/routes/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:flutter_sandbox/widgets/screens/messages.dart';
import 'package:flutter_sandbox/widgets/screens/profile.dart';

class Routes {
static const String home = '/home';
static const String messages = MessagesScreen.routeName;
static const String profile = ProfileScreen.routeName;
}
25 changes: 16 additions & 9 deletions lib/widgets/components/drawer.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_sandbox/routes/index.dart';

class AppDrawer extends StatelessWidget {
@override
Expand All @@ -20,17 +21,23 @@ class AppDrawer extends StatelessWidget {
),
),
ListTile(
leading: Icon(Icons.message),
title: Text('Home'),
),
leading: Icon(Icons.home),
title: Text('Home'),
onTap: () {
Navigator.of(context).pushReplacementNamed(Routes.home);
}),
ListTile(
leading: Icon(Icons.message),
title: Text('Messages'),
),
leading: Icon(Icons.message),
title: Text('Messages'),
onTap: () {
Navigator.of(context).pushReplacementNamed(Routes.messages);
}),
ListTile(
leading: Icon(Icons.account_circle),
title: Text('Profile'),
),
leading: Icon(Icons.account_circle),
title: Text('Profile'),
onTap: () {
Navigator.of(context).pushReplacementNamed(Routes.profile);
}),
ListTile(
leading: Icon(Icons.close),
title: Text('Colse Drawer'),
Expand Down
16 changes: 16 additions & 0 deletions lib/widgets/screens/messages.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter_sandbox/widgets/components/drawer.dart';

class MessagesScreen extends StatelessWidget {
static const String routeName = '/messages';

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
title: Text("Messages"),
),
drawer: AppDrawer(),
body: Center(child: Text("Messages")));
}
}
16 changes: 16 additions & 0 deletions lib/widgets/screens/profile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter_sandbox/widgets/components/drawer.dart';

class ProfileScreen extends StatelessWidget {
static const String routeName = '/profile';

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
title: Text("Profile"),
),
drawer: AppDrawer(),
body: Center(child: Text("Profile")));
}
}