Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4c71793
Added the ability to show images for each ingredient
smaliszewski15 Dec 1, 2022
0fcc03d
Added ability for users to upload their profile images on register an…
smaliszewski15 Dec 1, 2022
b0dc15b
Added password reset function on login
smaliszewski15 Dec 1, 2022
c40b85e
Started to create the Recipe Screen.
smaliszewski15 Dec 3, 2022
a97feac
Finish the bare UI for the Recipe feed page and respective pages.
smaliszewski15 Dec 3, 2022
fd89b1f
Some refactoring and some small bug fixes, mainly with the register p…
smaliszewski15 Dec 3, 2022
4795530
Moved API functions and classes to separate folder for ease of unders…
smaliszewski15 Dec 3, 2022
28d28b7
Temporary commit
smaliszewski15 Dec 4, 2022
d03d801
small change
smaliszewski15 Dec 4, 2022
28e1039
Fixed issue with recipes not displaying correctly on the individual r…
smaliszewski15 Dec 4, 2022
f5a6fe6
Added launcher icon
smaliszewski15 Dec 5, 2022
447307f
Merge branch 'main' into Recipe_UI_and_API_Connection
smaliszewski15 Dec 5, 2022
48b1031
Small changes to ingredient page
smaliszewski15 Dec 5, 2022
6f00ddd
Removed case for sending args to recipe screen
smaliszewski15 Dec 5, 2022
f4454c8
Added alert for when user attempts to make recipe without having the …
smaliszewski15 Dec 5, 2022
df8a406
Fixed recipe step-through
smaliszewski15 Dec 6, 2022
f5caebd
Fixed step-through for real this time
smaliszewski15 Dec 6, 2022
c623eb8
Bunch of fixes for API calls
smaliszewski15 Dec 7, 2022
f44fadc
Made more changes
smaliszewski15 Dec 7, 2022
f4720ed
Even more changes and fixes
smaliszewski15 Dec 7, 2022
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
Binary file modified android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 1 addition & 122 deletions ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,122 +1 @@
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@1x.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@1x.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@1x.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-App-83.5x83.5@2x.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Icon-App-1024x1024@1x.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
{"images":[{"size":"60x60","expected-size":"180","filename":"180.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"40x40","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"60x60","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"57x57","expected-size":"57","filename":"57.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"87","filename":"87.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"57x57","expected-size":"114","filename":"114.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"60","filename":"60.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"1024x1024","filename":"1024.png","expected-size":"1024","idiom":"ios-marketing","folder":"Assets.xcassets/AppIcon.appiconset/","scale":"1x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"72x72","expected-size":"72","filename":"72.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"76x76","expected-size":"152","filename":"152.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"50x50","expected-size":"100","filename":"100.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"76x76","expected-size":"76","filename":"76.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"50x50","expected-size":"50","filename":"50.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"72x72","expected-size":"144","filename":"144.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"40x40","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"83.5x83.5","expected-size":"167","filename":"167.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"20x20","expected-size":"20","filename":"20.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"idiom":"watch","filename":"172.png","folder":"Assets.xcassets/AppIcon.appiconset/","subtype":"38mm","scale":"2x","size":"86x86","expected-size":"172","role":"quickLook"},{"idiom":"watch","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","subtype":"38mm","scale":"2x","size":"40x40","expected-size":"80","role":"appLauncher"},{"idiom":"watch","filename":"88.png","folder":"Assets.xcassets/AppIcon.appiconset/","subtype":"40mm","scale":"2x","size":"44x44","expected-size":"88","role":"appLauncher"},{"idiom":"watch","filename":"102.png","folder":"Assets.xcassets/AppIcon.appiconset/","subtype":"41mm","scale":"2x","size":"45x45","expected-size":"102","role":"appLauncher"},{"idiom":"watch","filename":"92.png","folder":"Assets.xcassets/AppIcon.appiconset/","subtype":"41mm","scale":"2x","size":"46x46","expected-size":"92","role":"appLauncher"},{"idiom":"watch","filename":"100.png","folder":"Assets.xcassets/AppIcon.appiconset/","subtype":"44mm","scale":"2x","size":"50x50","expected-size":"100","role":"appLauncher"},{"idiom":"watch","filename":"196.png","folder":"Assets.xcassets/AppIcon.appiconset/","subtype":"42mm","scale":"2x","size":"98x98","expected-size":"196","role":"quickLook"},{"idiom":"watch","filename":"216.png","folder":"Assets.xcassets/AppIcon.appiconset/","subtype":"44mm","scale":"2x","size":"108x108","expected-size":"216","role":"quickLook"},{"idiom":"watch","filename":"48.png","folder":"Assets.xcassets/AppIcon.appiconset/","subtype":"38mm","scale":"2x","size":"24x24","expected-size":"48","role":"notificationCenter"},{"idiom":"watch","filename":"55.png","folder":"Assets.xcassets/AppIcon.appiconset/","subtype":"42mm","scale":"2x","size":"27.5x27.5","expected-size":"55","role":"notificationCenter"},{"idiom":"watch","filename":"66.png","folder":"Assets.xcassets/AppIcon.appiconset/","subtype":"45mm","scale":"2x","size":"33x33","expected-size":"66","role":"notificationCenter"},{"size":"29x29","expected-size":"87","filename":"87.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"watch","role":"companionSettings","scale":"3x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"watch","role":"companionSettings","scale":"2x"},{"size":"1024x1024","expected-size":"1024","filename":"1024.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"watch-marketing","scale":"1x"},{"size":"128x128","expected-size":"128","filename":"128.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"256x256","expected-size":"256","filename":"256.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"128x128","expected-size":"256","filename":"256.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"},{"size":"256x256","expected-size":"512","filename":"512.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"},{"size":"32x32","expected-size":"32","filename":"32.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"512x512","expected-size":"512","filename":"512.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"16x16","expected-size":"16","filename":"16.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"1x"},{"size":"16x16","expected-size":"32","filename":"32.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"},{"size":"32x32","expected-size":"64","filename":"64.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"},{"size":"512x512","expected-size":"1024","filename":"1024.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"mac","scale":"2x"}]}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
23 changes: 0 additions & 23 deletions ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 0 additions & 5 deletions ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md

This file was deleted.

36 changes: 23 additions & 13 deletions lib/utils/APIutils.dart → lib/APIfunctions/APIutils.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
import 'dart:convert';
import 'dart:io';

import 'package:http/http.dart' as http;
import 'package:smart_chef/utils/authAPI.dart';
import 'package:smart_chef/APIfunctions/authAPI.dart';
import 'package:smart_chef/utils/ingredientData.dart';
import 'package:smart_chef/utils/recipeData.dart';
import 'package:smart_chef/utils/userData.dart';

const String API_PREFIX = "https://api-smart-chef.herokuapp.com/";
const String API_PREFIX = "api-smart-chef.herokuapp.com";
final baseHeader = {HttpHeaders.contentTypeHeader: 'application/json'};
final accessTokenHeader = {
HttpHeaders.contentTypeHeader: 'application/json',
HttpHeaders.authorizationHeader: user.accessToken
};

const int resultsPerPage = 30;
List<Instruction> instructionList = [];
List<IngredientData> ingredientsToAddToCart = [];
List<RecipeData> favorites = [];
int recipeId = 0;
UserData user = UserData.create();
final messageDelay = Future.delayed(Duration(seconds: 1));
final messageDelay = Future.delayed(const Duration(seconds: 1));
Map<String, List<IngredientData>> userInventory = {};

bool searchInventory(IngredientData ingred) {
for (var cat in userInventory.keys) {
for (var inv in userInventory[cat]!) {
if (ingred.ID == inv.ID) {
return true;
}
}
}
return false;
}

RegExp emailValidation = RegExp(
r'^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$');
Expand Down Expand Up @@ -49,8 +61,7 @@ Future<bool> refreshTokenStatus() async {
switch (changeToken.statusCode) {
case 200:
var tokens = json.decode(changeToken.body);
user.accessToken = tokens['accessToken']['token'];
user.refreshToken = tokens['refreshToken']['token'];
user.defineTokens(tokens);
return true;
case 400:
return false;
Expand All @@ -73,8 +84,7 @@ Future<bool> reauthenticateUser() async {
switch (response.statusCode) {
case 200:
var data = json.decode(response.body);
user.accessToken = data['accessToken'];
user.refreshToken = data['refreshToken'];
user.defineTokens(data);
print('Successful relog');
return true;
case 400:
Expand Down
46 changes: 38 additions & 8 deletions lib/utils/authAPI.dart → lib/APIfunctions/authAPI.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:io';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:smart_chef/utils/APIutils.dart';
import 'package:smart_chef/APIfunctions/APIutils.dart';

class Authentication {
static const String apiRoute = 'auth';
Expand All @@ -10,7 +10,7 @@ class Authentication {
http.Response response;

try {
response = await http.post(Uri.parse('$API_PREFIX$apiRoute/login'),
response = await http.post(Uri.https(API_PREFIX, '${apiRoute}/login'),
body: json.encode(payload),
headers: baseHeader);
} catch (e) {
Expand All @@ -26,7 +26,7 @@ class Authentication {

try {
Map<String, dynamic> tokenBody = {'refreshToken': user.refreshToken};
response = await http.post(Uri.parse('$API_PREFIX$apiRoute/refreshJWT'),
response = await http.post(Uri.https(API_PREFIX, '${apiRoute}/refreshJWT'),
body: json.encode(tokenBody),
headers: baseHeader);
} catch (e) {
Expand All @@ -41,7 +41,7 @@ class Authentication {
http.Response response;

try {
response = await http.post(Uri.parse('$API_PREFIX$apiRoute/register'),
response = await http.post(Uri.https(API_PREFIX, '${apiRoute}/register'),
body: json.encode(payload),
headers: baseHeader);
} catch (e) {
Expand All @@ -55,13 +55,13 @@ class Authentication {
static Future<http.Response> logout() async {
http.Response response;

final headers = {
final header = {
HttpHeaders.contentTypeHeader: 'application/json',
HttpHeaders.authorizationHeader: user.accessToken
};

try {
response = await http.get(Uri.parse('$API_PREFIX$apiRoute/logout'), headers: headers);
response = await http.get(Uri.https(API_PREFIX, '${apiRoute}/logout'), headers: header);
} catch (e) {
print(e.toString());
throw Exception('Could not connect to server');
Expand All @@ -74,7 +74,7 @@ class Authentication {
http.Response response;

try {
response = await http.post(Uri.parse('$API_PREFIX$apiRoute/send-verification-code'),
response = await http.post(Uri.https(API_PREFIX, '${apiRoute}/send-verification-code'),
body: json.encode(payload),
headers: baseHeader);
} catch (e) {
Expand All @@ -89,7 +89,37 @@ class Authentication {
http.Response response;

try {
response = await http.post(Uri.parse('$API_PREFIX$apiRoute/confirm-verification-code'),
response = await http.post(Uri.https(API_PREFIX, '${apiRoute}/confirm-verification-code'),
body: json.encode(payload),
headers: baseHeader);
} catch (e) {
print(e.toString());
throw Exception('Could not connect to server');
}

return response;
}

static Future<http.Response> requestResetCode(Map<String, dynamic> payload) async {
http.Response response;

try {
response = await http.post(Uri.https(API_PREFIX, '${apiRoute}/request-password-reset'),
body: json.encode(payload),
headers: baseHeader);
} catch (e) {
print(e.toString());
throw Exception('Could not connect to server');
}

return response;
}

static Future<http.Response> resetPassword(Map<String, dynamic> payload) async {
http.Response response;

try {
response = await http.post(Uri.https(API_PREFIX, '${apiRoute}/perform-password-reset'),
body: json.encode(payload),
headers: baseHeader);
} catch (e) {
Expand Down
Loading