Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Models: Add code generation #47

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ Mobile application for Yakosa Project, using Flutter Framework (DART).
* common/ : Contains every UI components used in more than one screen or component
* utils/ : Every files needed for computing/processing

## Generate the GraphQL types

Modify the `codegen.yml` to point to your graphql schema and run:
```
$ yarn install
$ yarn generate
```


## Launch the app !

From the root of the project :
Expand All @@ -28,4 +37,4 @@ When Flutter is running :

To launch flutter with the local backend (127.0.0.1:3000) use:

$ flutter run -t lib/main_debug.dart
$ flutter run -t lib/main_debug.dart
4 changes: 4 additions & 0 deletions codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
schema: http://localhost:3000/graphql
generates:
lib/models/graphql.dart:
- dart
4 changes: 2 additions & 2 deletions lib/components/shopping_list/bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/widgets.dart';
import 'package:graphql/client.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:yakosa/components/shopping_list/quantity_picker.dart';
import 'package:yakosa/models/product.dart';
import 'package:yakosa/models/graphql.dart';

class ShoppingListBottomSheet extends StatelessWidget {
final ListProduct _product;
Expand Down Expand Up @@ -40,4 +40,4 @@ class ShoppingListBottomSheet extends StatelessWidget {
)
);
}
}
}
4 changes: 2 additions & 2 deletions lib/components/shopping_list/product_tile.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:yakosa/models/product.dart';
import 'package:yakosa/models/graphql.dart';

class ProductTile extends StatelessWidget {
final ListProduct product;
Expand Down Expand Up @@ -30,4 +30,4 @@ class ProductTile extends StatelessWidget {
)
);
}
}
}
4 changes: 2 additions & 2 deletions lib/components/shopping_list/quantity_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:yakosa/models/product.dart';
import 'package:yakosa/models/graphql.dart';

class QuantityPicker extends StatefulWidget {
final ListProduct product;
Expand Down Expand Up @@ -89,4 +89,4 @@ class _QuantityPickerState extends State<QuantityPicker> {
_currentQuantity += 1;
});
}
}
}
20 changes: 0 additions & 20 deletions lib/models/user.dart

This file was deleted.

4 changes: 2 additions & 2 deletions lib/screens/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:yakosa/models/user.dart';
import 'package:yakosa/models/graphql.dart';

import 'package:yakosa/components/settings_page/setting_button.dart';

Expand Down Expand Up @@ -79,4 +79,4 @@ class SettingsPageState extends State<SettingsPage> {
await googleSignIn.signOut();
Navigator.pushReplacementNamed(context, '/login');
}
}
}
2 changes: 1 addition & 1 deletion lib/screens/shopping_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/widgets.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:yakosa/components/shopping_list/bottom_sheet.dart';
import 'package:yakosa/components/shopping_list/product_tile.dart';
import 'package:yakosa/models/product.dart';
import 'package:yakosa/models/graphql.dart';


class ShoppingListPage extends StatelessWidget {
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/shopping_lists.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:yakosa/models/shopping_list.dart';
import 'package:yakosa/models/graphql.dart';
import 'package:yakosa/screens/shopping_list.dart';

class ShoppingListsPage extends StatelessWidget {
Expand Down Expand Up @@ -48,4 +48,4 @@ class ShoppingListsPage extends StatelessWidget {
}
));
}
}
}
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "yakosa-flutter",
"version": "1.0.0",
"repository": "git@github.com:hugodelahousse/Yakosa-Flutter",
"author": "Hugo Delahousse <hugo.delahousse@epita.fr>",
"license": "MIT",
"scripts": {
"generate": "graphql-codegen"
},
"dependencies": {
"@graphql-codegen/cli": "^1.2.1",
"@graphql-codegen/dart": "https://github.com/hugodelahousse/graphql-codegen-dart",
"graphql": "^14.3.1"
}
}
Loading