Skip to content

Commit

Permalink
feat: adiciona navegação ao app.
Browse files Browse the repository at this point in the history
  • Loading branch information
larissaperinoto committed Jan 15, 2023
1 parent 2567f74 commit ee234f5
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 6 deletions.
84 changes: 78 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_application_4/repositories/dog_repository.dart';
import 'package:flutter_application_4/repositories/dog_repository_impl.dart';
import 'firebase_options.dart';
import 'package:provider/provider.dart';

FirebaseFirestore? db;

Expand All @@ -20,15 +21,19 @@ void main() async {
class MyApp extends StatelessWidget {
const MyApp({super.key});

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
return ChangeNotifierProvider(
create: (context) => MyAppState(),
child: MaterialApp(
title: 'Namer App',
theme: ThemeData(
useMaterial3: true,
colorScheme:
ColorScheme.fromSeed(seedColor: Color.fromARGB(255, 86, 7, 89)),
),
home: const MyHomePage(),
),
home: const MyHomePage(),
);
}
}
Expand All @@ -43,6 +48,65 @@ class MyHomePage extends StatefulWidget {
}

class _MyHomePageState extends State<MyHomePage> {
var selectedIndex = 0;

@override
Widget build(BuildContext context) {
Widget page;
switch (selectedIndex) {
case 0:
page = InitialPage();
break;
case 1:
page = FavoritesPage();
break;
default:
throw UnimplementedError('no widget for $selectedIndex');
}
return Scaffold(
body: Row(
children: [
SafeArea(
child: NavigationRail(
extended: false,
destinations: [
const NavigationRailDestination(
icon: const Icon(Icons.home),
label: Text('Home'),
),
const NavigationRailDestination(
icon: const Icon(Icons.favorite),
label: const Text('Favorites'),
),
],
selectedIndex: selectedIndex,
onDestinationSelected: (value) {
setState(() {
selectedIndex = value;
});
},
),
),
Expanded(
child: Container(
color: Theme.of(context).colorScheme.primaryContainer,
child: page,
),
),
],
),
);
}
}

class InitialPage extends StatefulWidget {
const InitialPage({super.key});

@override
State<InitialPage> createState() => _InitialPageState();
}

class _InitialPageState extends State<InitialPage> {
final DogRepository dogRepository = DogRepositoryImpl();

var currentDog =
Expand Down Expand Up @@ -117,3 +181,11 @@ class ImageCard extends StatelessWidget {
);
}
}

class FavoritesPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
throw UnimplementedError();
}
}
14 changes: 14 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
nested:
dependency: transitive
description:
name: nested
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
path:
dependency: transitive
description:
Expand All @@ -184,6 +191,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
provider:
dependency: "direct main"
description:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.5"
sky_engine:
dependency: transitive
description: flutter
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies:
firebase_core: ^2.4.1
cloud_firestore: ^4.3.1
dio: ^4.0.6
provider: ^6.0.5

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit ee234f5

Please sign in to comment.