From ee234f536d1e60466f8fd5b7f0f01d4092e6b63e Mon Sep 17 00:00:00 2001 From: Larissa Perinoto Date: Sun, 15 Jan 2023 18:26:02 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20adiciona=20navega=C3=A7=C3=A3o=20ao=20a?= =?UTF-8?q?pp.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 84 +++++++++++++++++++++++++++++++++++++++++++++++---- pubspec.lock | 14 +++++++++ pubspec.yaml | 1 + 3 files changed, 93 insertions(+), 6 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index d299e5d..f2f9253 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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; @@ -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(), ); } } @@ -43,6 +48,65 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { + 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 createState() => _InitialPageState(); +} + +class _InitialPageState extends State { final DogRepository dogRepository = DogRepositoryImpl(); var currentDog = @@ -117,3 +181,11 @@ class ImageCard extends StatelessWidget { ); } } + +class FavoritesPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + // TODO: implement build + throw UnimplementedError(); + } +} diff --git a/pubspec.lock b/pubspec.lock index b1b3620..c84e586 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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: @@ -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 diff --git a/pubspec.yaml b/pubspec.yaml index 8e967f1..08d2de4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: