Skip to content

Commit

Permalink
Merge pull request #78 from PDG-NUTRI/66-créer-la-page-add-meal
Browse files Browse the repository at this point in the history
66 créer la page add meal
  • Loading branch information
chloefont authored Aug 30, 2022
2 parents 910c5f4 + 18bb864 commit 6ae24b9
Show file tree
Hide file tree
Showing 15 changed files with 675 additions and 115 deletions.
Binary file added assets/images/placeholderfood.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 0 additions & 65 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
import 'package:cloud_firestore/cloud_firestore.dart';

import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:pdg_app/model/message.dart';
import 'package:pdg_app/widgets/forms/main_text_field.dart';
import 'package:pdg_app/router/router.gr.dart';
import 'package:pdg_app/theme.dart';
import 'firebase_options.dart';

import 'api/imessage.dart';
import 'api/firebase_message.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
IMessage msg = FirebaseMessage(FirebaseFirestore.instance);

final m1 = Message(uid: '', fromId: 'alice', toId: 'bob', content: "HELLOW");
msg.createMessage(m1);
log("test");
runApp(MyApp());
}

Expand All @@ -47,54 +33,3 @@ class MyApp extends StatelessWidget {
);
}
}

class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);

final String title;

@override
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
void _incrementCounter() {
setState(() {});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
MainTextField(
name: "Email",
icon: Icon(Icons.email_outlined),
keyboardType: TextInputType.emailAddress,
),
SizedBox(height: 10),
MainTextField(
name: "Password",
icon: Icon(Icons.password),
obscureText: true,
keyboardType: TextInputType.emailAddress,
),
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
16 changes: 15 additions & 1 deletion lib/router/router.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:auto_route/auto_route.dart';
import 'package:auto_route/empty_router_widgets.dart';
import 'package:pdg_app/screens/add_meal.dart';
import 'package:pdg_app/screens/chat.dart';
import 'package:pdg_app/screens/diary.dart';
import 'package:pdg_app/screens/login.dart';
Expand All @@ -24,8 +26,19 @@ import '../screens/home.dart';
path: 'chat',
),
AutoRoute(
page: DiaryScreen,
page: EmptyRouterPage,
name: "DiaryRouterPage",
path: 'diary',
children: [
AutoRoute(
path: '',
page: DiaryScreen,
),
AutoRoute(
path: 'add',
page: AddMealScreen,
),
],
),
AutoRoute(
page: ProfileScreen,
Expand All @@ -36,6 +49,7 @@ import '../screens/home.dart';
AutoRoute(
page: LoginScreen,
path: '/login',
initial: false,
),
AutoRoute(
page: RegisterScreen,
Expand Down
104 changes: 69 additions & 35 deletions lib/router/router.gr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,92 +11,109 @@
// ignore_for_file: type=lint

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:auto_route/auto_route.dart' as _i7;
import 'package:flutter/material.dart' as _i8;
import 'package:auto_route/auto_route.dart' as _i9;
import 'package:auto_route/empty_router_widgets.dart' as _i5;
import 'package:flutter/material.dart' as _i10;

import '../screens/add_meal.dart' as _i8;
import '../screens/chat.dart' as _i4;
import '../screens/diary.dart' as _i5;
import '../screens/diary.dart' as _i7;
import '../screens/home.dart' as _i1;
import '../screens/login.dart' as _i2;
import '../screens/profile.dart' as _i6;
import '../screens/register.dart' as _i3;

class AppRouter extends _i7.RootStackRouter {
AppRouter([_i8.GlobalKey<_i8.NavigatorState>? navigatorKey])
class AppRouter extends _i9.RootStackRouter {
AppRouter([_i10.GlobalKey<_i10.NavigatorState>? navigatorKey])
: super(navigatorKey);

@override
final Map<String, _i7.PageFactory> pagesMap = {
final Map<String, _i9.PageFactory> pagesMap = {
HomeScreenRoute.name: (routeData) {
return _i7.MaterialPageX<dynamic>(
return _i9.MaterialPageX<dynamic>(
routeData: routeData, child: const _i1.HomeScreen());
},
LoginScreenRoute.name: (routeData) {
return _i7.MaterialPageX<dynamic>(
return _i9.MaterialPageX<dynamic>(
routeData: routeData, child: const _i2.LoginScreen());
},
RegisterScreenRoute.name: (routeData) {
return _i7.MaterialPageX<dynamic>(
return _i9.MaterialPageX<dynamic>(
routeData: routeData, child: const _i3.RegisterScreen());
},
ChatScreenRoute.name: (routeData) {
return _i7.MaterialPageX<dynamic>(
return _i9.MaterialPageX<dynamic>(
routeData: routeData, child: const _i4.ChatScreen());
},
DiaryScreenRoute.name: (routeData) {
return _i7.MaterialPageX<dynamic>(
routeData: routeData, child: const _i5.DiaryScreen());
DiaryRouterPage.name: (routeData) {
return _i9.MaterialPageX<dynamic>(
routeData: routeData, child: const _i5.EmptyRouterPage());
},
ProfileScreenRoute.name: (routeData) {
return _i7.MaterialPageX<dynamic>(
return _i9.MaterialPageX<dynamic>(
routeData: routeData, child: const _i6.ProfileScreen());
},
DiaryScreenRoute.name: (routeData) {
return _i9.MaterialPageX<dynamic>(
routeData: routeData, child: const _i7.DiaryScreen());
},
AddMealScreenRoute.name: (routeData) {
return _i9.MaterialPageX<dynamic>(
routeData: routeData, child: const _i8.AddMealScreen());
}
};

@override
List<_i7.RouteConfig> get routes => [
_i7.RouteConfig('/#redirect',
List<_i9.RouteConfig> get routes => [
_i9.RouteConfig('/#redirect',
path: '/', redirectTo: '/home', fullMatch: true),
_i7.RouteConfig(HomeScreenRoute.name, path: '/home', children: [
_i7.RouteConfig('#redirect',
_i9.RouteConfig(HomeScreenRoute.name, path: '/home', children: [
_i9.RouteConfig('#redirect',
path: '',
parent: HomeScreenRoute.name,
redirectTo: 'diary',
fullMatch: true),
_i7.RouteConfig(ChatScreenRoute.name,
_i9.RouteConfig(ChatScreenRoute.name,
path: 'chat', parent: HomeScreenRoute.name),
_i7.RouteConfig(DiaryScreenRoute.name,
path: 'diary', parent: HomeScreenRoute.name),
_i7.RouteConfig(ProfileScreenRoute.name,
_i9.RouteConfig(DiaryRouterPage.name,
path: 'diary',
parent: HomeScreenRoute.name,
children: [
_i9.RouteConfig(DiaryScreenRoute.name,
path: '', parent: DiaryRouterPage.name),
_i9.RouteConfig(AddMealScreenRoute.name,
path: 'add', parent: DiaryRouterPage.name)
]),
_i9.RouteConfig(ProfileScreenRoute.name,
path: 'my', parent: HomeScreenRoute.name)
]),
_i7.RouteConfig(LoginScreenRoute.name, path: '/login'),
_i7.RouteConfig(RegisterScreenRoute.name, path: '/register'),
_i7.RouteConfig('*#redirect',
_i9.RouteConfig(LoginScreenRoute.name, path: '/login'),
_i9.RouteConfig(RegisterScreenRoute.name, path: '/register'),
_i9.RouteConfig('*#redirect',
path: '*', redirectTo: '/home/diary', fullMatch: true)
];
}

/// generated route for
/// [_i1.HomeScreen]
class HomeScreenRoute extends _i7.PageRouteInfo<void> {
const HomeScreenRoute({List<_i7.PageRouteInfo>? children})
class HomeScreenRoute extends _i9.PageRouteInfo<void> {
const HomeScreenRoute({List<_i9.PageRouteInfo>? children})
: super(HomeScreenRoute.name, path: '/home', initialChildren: children);

static const String name = 'HomeScreenRoute';
}

/// generated route for
/// [_i2.LoginScreen]
class LoginScreenRoute extends _i7.PageRouteInfo<void> {
class LoginScreenRoute extends _i9.PageRouteInfo<void> {
const LoginScreenRoute() : super(LoginScreenRoute.name, path: '/login');

static const String name = 'LoginScreenRoute';
}

/// generated route for
/// [_i3.RegisterScreen]
class RegisterScreenRoute extends _i7.PageRouteInfo<void> {
class RegisterScreenRoute extends _i9.PageRouteInfo<void> {
const RegisterScreenRoute()
: super(RegisterScreenRoute.name, path: '/register');

Expand All @@ -105,24 +122,41 @@ class RegisterScreenRoute extends _i7.PageRouteInfo<void> {

/// generated route for
/// [_i4.ChatScreen]
class ChatScreenRoute extends _i7.PageRouteInfo<void> {
class ChatScreenRoute extends _i9.PageRouteInfo<void> {
const ChatScreenRoute() : super(ChatScreenRoute.name, path: 'chat');

static const String name = 'ChatScreenRoute';
}

/// generated route for
/// [_i5.DiaryScreen]
class DiaryScreenRoute extends _i7.PageRouteInfo<void> {
const DiaryScreenRoute() : super(DiaryScreenRoute.name, path: 'diary');
/// [_i5.EmptyRouterPage]
class DiaryRouterPage extends _i9.PageRouteInfo<void> {
const DiaryRouterPage({List<_i9.PageRouteInfo>? children})
: super(DiaryRouterPage.name, path: 'diary', initialChildren: children);

static const String name = 'DiaryScreenRoute';
static const String name = 'DiaryRouterPage';
}

/// generated route for
/// [_i6.ProfileScreen]
class ProfileScreenRoute extends _i7.PageRouteInfo<void> {
class ProfileScreenRoute extends _i9.PageRouteInfo<void> {
const ProfileScreenRoute() : super(ProfileScreenRoute.name, path: 'my');

static const String name = 'ProfileScreenRoute';
}

/// generated route for
/// [_i7.DiaryScreen]
class DiaryScreenRoute extends _i9.PageRouteInfo<void> {
const DiaryScreenRoute() : super(DiaryScreenRoute.name, path: '');

static const String name = 'DiaryScreenRoute';
}

/// generated route for
/// [_i8.AddMealScreen]
class AddMealScreenRoute extends _i9.PageRouteInfo<void> {
const AddMealScreenRoute() : super(AddMealScreenRoute.name, path: 'add');

static const String name = 'AddMealScreenRoute';
}
Loading

0 comments on commit 6ae24b9

Please sign in to comment.