Skip to content
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
2 changes: 2 additions & 0 deletions recipe_app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
Expand Down
30 changes: 15 additions & 15 deletions recipe_app/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: "80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819"
revision: "dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668"
channel: "stable"

project_type: app
Expand All @@ -13,26 +13,26 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: android
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: ios
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: linux
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: macos
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: web
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: windows
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668

# User provided section

Expand Down
2 changes: 1 addition & 1 deletion recipe_app/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# recipe_app
# geeks_for_geeks

A new Flutter project.

Expand Down
1 change: 0 additions & 1 deletion recipe_app/Recipe_Finder_App_Flutter
Submodule Recipe_Finder_App_Flutter deleted from 435fbe
4 changes: 2 additions & 2 deletions recipe_app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

android {
namespace = "com.example.recipe_app"
namespace = "com.example.geeks_for_geeks"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion

Expand All @@ -21,7 +21,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.recipe_app"
applicationId = "com.example.geeks_for_geeks"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
Expand Down
4 changes: 3 additions & 1 deletion recipe_app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:label="recipe_app"
android:label="geeks_for_geeks"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.recipe_app
package com.example.geeks_for_geeks

import io.flutter.embedding.android.FlutterActivity

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
4 changes: 2 additions & 2 deletions recipe_app/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

include ":app"
12 changes: 6 additions & 6 deletions recipe_app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.recipeApp;
PRODUCT_BUNDLE_IDENTIFIER = com.example.geeksForGeeks;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand All @@ -384,7 +384,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.recipeApp.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.example.geeksForGeeks.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -401,7 +401,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.recipeApp.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.example.geeksForGeeks.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
Expand All @@ -416,7 +416,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.recipeApp.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.example.geeksForGeeks.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
Expand Down Expand Up @@ -547,7 +547,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.recipeApp;
PRODUCT_BUNDLE_IDENTIFIER = com.example.geeksForGeeks;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -569,7 +569,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.recipeApp;
PRODUCT_BUNDLE_IDENTIFIER = com.example.geeksForGeeks;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
4 changes: 2 additions & 2 deletions recipe_app/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Recipe App</string>
<string>Geeks For Geeks</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>recipe_app</string>
<string>geeks_for_geeks</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
Expand Down
109 changes: 109 additions & 0 deletions recipe_app/lib/HomePage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Importing the dart:convert library for JSON encoding and decoding.
import 'dart:convert';
// Importing Flutter's material design package.
import 'package:flutter/material.dart';
// Importing the RecipeDetailPage for navigation.
import 'package:geeks_for_geeks/RecipeDetailPage.dart';
// Importing the HTTP package for making API requests.
import 'package:http/http.dart' as http;

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

@override
State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
// API key for accessing the Spoonacular API.
final String apiKey = "API_KEY";
// List to store the fetched recipes.
List recipes = [];

@override
void initState() {
super.initState();
// Fetching recipe IDs when the widget is initialized.
fetchRecipeIDs();
}

// Function to fetch random recipe IDs from the Spoonacular API.
Future<void> fetchRecipeIDs() async {
// API endpoint for fetching random recipes.
final url = Uri.parse(
"https://api.spoonacular.com/recipes/random?number=50&apiKey=$apiKey");
// Making a GET request to the API.
final response = await http.get(url);
if (response.statusCode == 200) {
// If the response is successful, decode the JSON response.
List<dynamic> randomRecipes = json.decode(response.body)['recipes'];
// Extracting recipe IDs from the response.
List<String> recipeIds =
randomRecipes.map((recipe) => recipe['id'].toString()).toList();
fetchRecipes(recipeIds); // Fetching detailed recipes using the IDs.
} else {
// Logging an error message if the request fails.
print("Failed to fetch recipe IDs");
}
}

// Function to fetch detailed recipe information using recipe IDs.
Future<void> fetchRecipes(List<String> ids) async {
// API endpoint for fetching detailed recipe information.
final url = Uri.parse(
"https://api.spoonacular.com/recipes/informationBulk?ids=${ids.join(',')}&apiKey=$apiKey");
// Making a GET request to the API.
final response = await http.get(url);

if (response.statusCode == 200) {
setState(() {
// Updating the state with the fetched recipes.
recipes = json.decode(response.body);
});
} else {
// Logging an error message if the request fails.
print("Failed to load recipes");
}
}

@override
Widget build(BuildContext context) {
// Building the UI for the HomePage widget.
return Scaffold(
appBar: AppBar(
title: const Text("Recipes"),
backgroundColor: Colors.green,
centerTitle: true,
foregroundColor: Colors.white,
),
body: recipes.isEmpty
? const Center(
child:
CircularProgressIndicator()) // Showing a loading indicator if recipes are not yet loaded.
: ListView.builder(
// Building a list view to display the recipes.
itemCount: recipes.length, // Number of items in the list.
itemBuilder: (context, index) {
final recipe = recipes[
index]; // Accessing the recipe at the current index.
return ListTile(
leading:
Image.network(recipe['image'], width: 50, height: 50),
title: Text(recipe['title']),
onTap: () {
// Navigating to the RecipeDetailPage when a recipe is tapped.
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => RecipeDetailPage(
recipe:
recipe), // Passing the recipe to the detail page.
),
);
},
);
},
),
);
}
}
53 changes: 53 additions & 0 deletions recipe_app/lib/RecipeDetailPage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';

// A stateless widget to display recipe details
class RecipeDetailPage extends StatelessWidget {
// A map to hold the recipe details
final Map recipe;

// Constructor to initialize the recipe map
const RecipeDetailPage({super.key, required this.recipe});

@override
Widget build(BuildContext context) {
return Scaffold(
// AppBar with title, background color, and styling
appBar: AppBar(
title: Text(recipe['title']),
backgroundColor: Colors.green,
centerTitle: true,
foregroundColor: Colors.white,
),
body: Padding(
// Padding around the body content
padding: const EdgeInsets.all(16.0),
child: SingleChildScrollView(
// Scrollable content for the recipe details
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Display the recipe image
Image.network(recipe['image']),
const SizedBox(height: 10), // Spacing between elements
// Display the recipe title with styling
Text(recipe['title'],
style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold)),
const SizedBox(height: 10), // Spacing between elements
// Display the number of servings
Text("Servings: ${recipe['servings']}"),
const SizedBox(height: 10), // Spacing between elements
// Display the preparation time
Text("Ready in ${recipe['readyInMinutes']} minutes"),
// Display the source name of the recipe
Text("sourceName:${recipe['sourceName']}"),
// Display whether the recipe is dairy-free
Text("dairyFree:${recipe['dairyFree']}"),
// Display whether the recipe is cheap
Text("cheap:${recipe['cheap']}"),
],
),
),
),
);
}
}
21 changes: 11 additions & 10 deletions recipe_app/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import 'package:flutter/material.dart';
import 'package:recipe_app/presentation/recipe_page.dart';

import 'package:geeks_for_geeks/HomePage.dart';

void main() {
runApp(const HomePage());
runApp(const MyApp());
}

class HomePage extends StatelessWidget {
const HomePage({super.key});
class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text("GFG Recipe App"),
),
body: const RecipePage(),
debugShowCheckedModeBanner: false,
title: 'Recipe App',
theme: ThemeData(
primarySwatch: Colors.orange,
),
home: const HomePage(),
);
}
}

Loading