├── .gitignore ├── .idea ├── .gitignore ├── compiler.xml ├── deploymentTargetDropDown.xml ├── gradle.xml ├── misc.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── breakfastapi │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── breakfastapi │ │ │ ├── BaseApplication.kt │ │ │ ├── MainActivity.kt │ │ │ ├── database │ │ │ ├── FavouriteRecipeDao.kt │ │ │ └── RecipeDatabase.kt │ │ │ ├── di │ │ │ └── AppModule.kt │ │ │ ├── model │ │ │ └── Recipe.kt │ │ │ ├── network │ │ │ ├── ApiService.kt │ │ │ └── RecipeDto.kt │ │ │ ├── repository │ │ │ ├── Repository.kt │ │ │ └── Repository_Impl.kt │ │ │ ├── ui │ │ │ ├── presentation │ │ │ │ ├── ListItem.kt │ │ │ │ ├── Navigation.kt │ │ │ │ ├── favourites │ │ │ │ │ ├── FavouriteRecipeContent.kt │ │ │ │ │ ├── FavouriteRecipeListAppBar.kt │ │ │ │ │ ├── FavouriteRecipeListViewModel.kt │ │ │ │ │ └── FavouritesRecipeList.kt │ │ │ │ ├── recipedetail │ │ │ │ │ ├── CustomSnackbar.kt │ │ │ │ │ ├── RecipeDetail.kt │ │ │ │ │ ├── RecipeDetailAppBar.kt │ │ │ │ │ └── RecipeDetailContent.kt │ │ │ │ └── recipelist │ │ │ │ │ ├── RecipeList.kt │ │ │ │ │ ├── RecipeListAppBar.kt │ │ │ │ │ ├── RecipeListContent.kt │ │ │ │ │ └── RecipeListViewModel.kt │ │ │ └── theme │ │ │ │ ├── Color.kt │ │ │ │ ├── Shape.kt │ │ │ │ ├── Theme.kt │ │ │ │ └── Type.kt │ │ │ └── util │ │ │ ├── AssetParamType.kt │ │ │ ├── Constants.kt │ │ │ ├── Food.kt │ │ │ ├── Helper.kt │ │ │ ├── NetworkStatus.kt │ │ │ ├── Resource.kt │ │ │ └── Routes.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── beef.jpg │ │ ├── bread.jpg │ │ ├── brisket.jpg │ │ ├── burger.jpg │ │ ├── cake.jpg │ │ ├── casserole.jpg │ │ ├── cheese.jpg │ │ ├── chicken.jpg │ │ ├── chili.jpg │ │ ├── chop.jpg │ │ ├── cookie.jpg │ │ ├── fish.jpg │ │ ├── food.jpg │ │ ├── ham.jpg │ │ ├── ic_baseline_access_time_24.xml │ │ ├── meat.jpg │ │ ├── meatball.jpg │ │ ├── meatloaf.jpg │ │ ├── pasta.jpg │ │ ├── pie.jpg │ │ ├── pizza.jpg │ │ ├── pork.jpg │ │ ├── potato.jpg │ │ ├── ribs.jpg │ │ ├── rice.jpg │ │ ├── salad.jpg │ │ ├── sandwich.jpg │ │ ├── sausage.jpg │ │ ├── shrimp.jpg │ │ ├── slowcook.jpg │ │ ├── soup.jpg │ │ ├── steak.jpg │ │ ├── stew.jpg │ │ └── turkey.jpg │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.webp │ │ └── values │ │ ├── colors.xml │ │ ├── ic_launcher_background.xml │ │ ├── strings.xml │ │ └── themes.xml │ └── test │ └── java │ └── com │ └── breakfastapi │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/deploymentTargetDropDown.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The BreakfastAPI Android App 2 | 3 | ## Concepts 4 | 5 | * Kotlin 6 | * Jetpack compose 7 | * Coroutines 8 | * MVVM 9 | * Lifecycle scopes 10 | * Retrofit 11 | * okHttp 12 | * Hilt (Dagger) 13 | * Coil 14 | * Compose Navigation 15 | * Room persistence library 16 | * Scaffold 17 | * Snackbar/SnackbarHost 18 | 19 | ## Special thank you to 20 | 21 | * MariiaSizova 22 | * Pixabay for the free images 23 | 24 | ## 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'org.jetbrains.kotlin.android' 4 | id 'kotlin-kapt' 5 | id 'dagger.hilt.android.plugin' 6 | id 'kotlin-parcelize' 7 | } 8 | 9 | android { 10 | compileSdk 31 11 | 12 | defaultConfig { 13 | applicationId "com.breakfastapi" 14 | minSdk 21 15 | targetSdk 31 16 | versionCode 1 17 | versionName "1.0" 18 | 19 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 20 | vectorDrawables { 21 | useSupportLibrary true 22 | } 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled false 28 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_8 33 | targetCompatibility JavaVersion.VERSION_1_8 34 | } 35 | kotlinOptions { 36 | jvmTarget = '1.8' 37 | } 38 | buildFeatures { 39 | compose true 40 | } 41 | composeOptions { 42 | kotlinCompilerExtensionVersion compose_version 43 | } 44 | packagingOptions { 45 | resources { 46 | excludes += '/META-INF/{AL2.0,LGPL2.1}' 47 | } 48 | } 49 | } 50 | 51 | dependencies { 52 | 53 | implementation 'androidx.core:core-ktx:1.7.0' 54 | implementation "androidx.compose.ui:ui:$compose_version" 55 | implementation "androidx.compose.material:material:$compose_version" 56 | implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" 57 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' 58 | implementation 'androidx.activity:activity-compose:1.3.1' 59 | testImplementation 'junit:junit:4.13.2' 60 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 61 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 62 | androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" 63 | debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" 64 | 65 | // Dagger Hilt 66 | def daggerhilt = "2.40.5" 67 | implementation "com.google.dagger:hilt-android:$daggerhilt" 68 | kapt "com.google.dagger:hilt-compiler:$daggerhilt" 69 | kaptAndroidTest "com.google.dagger:hilt-android-compiler:2$daggerhilt" 70 | implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03" 71 | implementation "androidx.hilt:hilt-navigation-compose:1.0.0" 72 | 73 | // Coroutines 74 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0' 75 | 76 | // Retrofit + GSON 77 | def retrofit = "2.9.0" 78 | implementation "com.squareup.retrofit2:retrofit:$retrofit" 79 | implementation "com.squareup.retrofit2:converter-gson:$retrofit" 80 | 81 | //Lifecycle 82 | implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0" 83 | 84 | //Coil 85 | def coil = "1.4.0" 86 | implementation("io.coil-kt:coil-compose:$coil") 87 | implementation("io.coil-kt:coil:$coil") 88 | 89 | //Room 90 | def roomVersion = "2.4.1" 91 | implementation "androidx.room:room-ktx:$roomVersion" 92 | kapt "androidx.room:room-compiler:$roomVersion" 93 | 94 | 95 | 96 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/breakfastapi/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.breakfastapi", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 14 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/BaseApplication.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi 2 | 3 | import android.app.Application 4 | import dagger.hilt.android.HiltAndroidApp 5 | 6 | @HiltAndroidApp 7 | class BaseApplication : Application() { 8 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi 2 | 3 | import android.os.Bundle 4 | import androidx.activity.ComponentActivity 5 | import androidx.activity.compose.setContent 6 | import androidx.compose.foundation.layout.fillMaxSize 7 | import androidx.compose.material.MaterialTheme 8 | import androidx.compose.material.Surface 9 | import androidx.compose.ui.Modifier 10 | import com.breakfastapi.ui.presentation.Navigation 11 | import com.breakfastapi.ui.theme.BreakfastAPITheme 12 | import dagger.hilt.android.AndroidEntryPoint 13 | 14 | @AndroidEntryPoint 15 | class MainActivity : ComponentActivity() { 16 | override fun onCreate(savedInstanceState: Bundle?) { 17 | super.onCreate(savedInstanceState) 18 | setContent { 19 | BreakfastAPITheme { 20 | Surface( 21 | modifier = Modifier.fillMaxSize(), 22 | color = MaterialTheme.colors.background 23 | ) { 24 | Navigation() 25 | } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/database/FavouriteRecipeDao.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.database 2 | 3 | import androidx.room.* 4 | import androidx.room.OnConflictStrategy.REPLACE 5 | import com.breakfastapi.model.Recipe 6 | import kotlinx.coroutines.flow.Flow 7 | 8 | @Dao 9 | interface FavouriteRecipeDao { 10 | 11 | @Query("SELECT * FROM recipe") 12 | fun getFavouriteRecipes() : Flow> 13 | 14 | @Insert(onConflict = REPLACE) 15 | suspend fun insertFavouriteRecipe(recipe: Recipe) 16 | 17 | @Delete 18 | suspend fun deleteFavouriteRecipe(recipe: Recipe) 19 | 20 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/database/RecipeDatabase.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.database 2 | 3 | import androidx.room.Database 4 | import androidx.room.RoomDatabase 5 | import com.breakfastapi.model.Recipe 6 | 7 | @Database(entities = [Recipe::class], version = 1) 8 | abstract class RecipeDatabase : RoomDatabase() { 9 | 10 | abstract fun favouriteRecipeDao(): FavouriteRecipeDao 11 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/di/AppModule.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.di 2 | 3 | import android.app.Application 4 | import androidx.room.Room 5 | import com.breakfastapi.database.RecipeDatabase 6 | import com.breakfastapi.network.ApiService 7 | import com.breakfastapi.repository.Repository 8 | import com.breakfastapi.repository.Repository_Impl 9 | import com.breakfastapi.util.Constants 10 | import dagger.Module 11 | import dagger.Provides 12 | import dagger.hilt.InstallIn 13 | import dagger.hilt.components.SingletonComponent 14 | import retrofit2.Retrofit 15 | import retrofit2.converter.gson.GsonConverterFactory 16 | import javax.inject.Singleton 17 | 18 | @Module 19 | @InstallIn(SingletonComponent::class) 20 | object AppModule { 21 | 22 | @Singleton 23 | @Provides 24 | fun provideApiService(): ApiService { 25 | return Retrofit.Builder() 26 | .baseUrl(Constants.BASE_URL) 27 | .addConverterFactory(GsonConverterFactory.create()) 28 | .build() 29 | .create(ApiService::class.java) 30 | } 31 | 32 | @Singleton 33 | @Provides 34 | fun provideRepository(apiService: ApiService, recipeDatabase: RecipeDatabase): Repository { 35 | return Repository_Impl(apiService, recipeDatabase) 36 | } 37 | 38 | @Singleton 39 | @Provides 40 | fun ProvideReceipeDatabase(application: Application): RecipeDatabase { 41 | return Room.databaseBuilder(application, RecipeDatabase::class.java, "recipe_db") 42 | .fallbackToDestructiveMigration().build() 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/model/Recipe.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.model 2 | 3 | import android.os.Parcelable 4 | import androidx.room.Entity 5 | import androidx.room.PrimaryKey 6 | import kotlinx.parcelize.Parcelize 7 | 8 | @Parcelize 9 | @Entity (tableName = "recipe") 10 | data class Recipe( 11 | @PrimaryKey(autoGenerate = false) 12 | val id: Long, 13 | val recipeName: String, 14 | val totalDuration: Long, 15 | val ingredientsString: String, 16 | val directionsString: String 17 | ) : Parcelable -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/network/ApiService.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.network 2 | 3 | import retrofit2.http.GET 4 | 5 | interface ApiService { 6 | 7 | @GET(".") 8 | suspend fun getRecipe() : ResponseDto 9 | 10 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/network/RecipeDto.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.network 2 | 3 | import com.breakfastapi.model.Recipe 4 | import com.breakfastapi.util.Helper 5 | import com.google.gson.annotations.SerializedName 6 | 7 | data class RecipeDto( 8 | @SerializedName("id") 9 | val id: Long, 10 | 11 | @SerializedName("name") 12 | val recipeName: String, 13 | 14 | @SerializedName("total_duration") 15 | val totalDuration: Long, 16 | 17 | @SerializedName("ingredients") 18 | val ingredients: List, 19 | 20 | @SerializedName("directions") 21 | val directions: String 22 | ) 23 | 24 | fun RecipeDto.toRecipe(): Recipe { 25 | return Recipe( 26 | id, 27 | recipeName, 28 | totalDuration, 29 | Helper.getStringFromList(ingredients), 30 | Helper.removeBrackets(directions) 31 | ) 32 | } 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/repository/Repository.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.repository 2 | 3 | import com.breakfastapi.model.Recipe 4 | import com.breakfastapi.util.Resource 5 | import kotlinx.coroutines.flow.Flow 6 | 7 | interface Repository { 8 | 9 | suspend fun getRecipe() : Resource 10 | 11 | fun getFavouriteRecipes() : Flow> 12 | suspend fun insertFavouriteRecipe(recipe: Recipe) 13 | suspend fun deleteFavouriteRecipe(recipe: Recipe) 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/repository/Repository_Impl.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.repository 2 | 3 | import com.breakfastapi.database.RecipeDatabase 4 | import com.breakfastapi.model.Recipe 5 | import com.breakfastapi.network.ApiService 6 | import com.breakfastapi.network.toRecipe 7 | import com.breakfastapi.util.Resource 8 | import kotlinx.coroutines.flow.Flow 9 | 10 | class Repository_Impl( 11 | private val apiService: ApiService, 12 | private val favouriteRecipeDatabase: RecipeDatabase 13 | ) : Repository { 14 | 15 | private val favouriteRecipeDao = favouriteRecipeDatabase.favouriteRecipeDao() 16 | 17 | override suspend fun getRecipe(): Resource { 18 | val response = try { 19 | apiService.getRecipe() 20 | } catch (ex: Exception) { 21 | return Resource.Error(ex) 22 | } 23 | return Resource.Success(response.recipe!!.toRecipe()) 24 | } 25 | 26 | override fun getFavouriteRecipes(): Flow> { 27 | return favouriteRecipeDao.getFavouriteRecipes() 28 | } 29 | 30 | override suspend fun insertFavouriteRecipe(recipe: Recipe) { 31 | favouriteRecipeDao.insertFavouriteRecipe(recipe) 32 | } 33 | 34 | override suspend fun deleteFavouriteRecipe(recipe: Recipe) { 35 | return favouriteRecipeDao.deleteFavouriteRecipe(recipe) 36 | } 37 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/ListItem.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation 2 | 3 | import androidx.compose.foundation.BorderStroke 4 | import androidx.compose.foundation.Image 5 | import androidx.compose.foundation.background 6 | import androidx.compose.foundation.clickable 7 | import androidx.compose.foundation.layout.* 8 | import androidx.compose.foundation.shape.AbsoluteCutCornerShape 9 | import androidx.compose.material.Card 10 | import androidx.compose.material.MaterialTheme 11 | import androidx.compose.material.Text 12 | import androidx.compose.runtime.Composable 13 | import androidx.compose.ui.Alignment 14 | import androidx.compose.ui.Modifier 15 | import androidx.compose.ui.graphics.Color 16 | import androidx.compose.ui.text.style.TextAlign 17 | import androidx.compose.ui.unit.dp 18 | import coil.compose.rememberImagePainter 19 | import com.breakfastapi.model.Recipe 20 | import com.breakfastapi.util.getFood 21 | 22 | @Composable 23 | fun ListItem(recipe: Recipe, onClick: () -> Unit) { 24 | Card( 25 | modifier = Modifier 26 | .fillMaxWidth() 27 | .clickable { onClick() }, 28 | shape = AbsoluteCutCornerShape(0.dp), 29 | border = BorderStroke(0.3.dp, color = Color.LightGray) 30 | ) { 31 | Row( 32 | modifier = Modifier 33 | .fillMaxWidth() 34 | .padding(top = 3.dp, bottom = 3.dp), 35 | verticalAlignment = Alignment.CenterVertically, 36 | ) 37 | { 38 | Column( 39 | horizontalAlignment = Alignment.Start, modifier = Modifier 40 | .fillMaxSize(.80f) 41 | ) { 42 | Row(verticalAlignment = Alignment.CenterVertically) 43 | { 44 | var food = getFood(recipe.recipeName.lowercase()) 45 | Image( 46 | painter = rememberImagePainter(food.imageInt), 47 | contentDescription = food.imageName, 48 | modifier = Modifier 49 | .size(75.dp) 50 | .padding(5.dp) 51 | ) 52 | Column() { 53 | Text(recipe.recipeName, style = MaterialTheme.typography.h1) 54 | Text(recipe.ingredientsString, style = MaterialTheme.typography.body1) 55 | } 56 | } 57 | } 58 | Column( 59 | modifier = Modifier 60 | .fillMaxWidth() 61 | .padding(start = 10.dp, end = 10.dp), 62 | horizontalAlignment = Alignment.End 63 | ) { 64 | 65 | Column( 66 | horizontalAlignment = Alignment.CenterHorizontally 67 | ) { 68 | 69 | 70 | Text( 71 | "${recipe.totalDuration}", 72 | style = MaterialTheme.typography.h2, 73 | textAlign = TextAlign.Center 74 | ) 75 | Text( 76 | "minutes", 77 | style = MaterialTheme.typography.h4, 78 | textAlign = TextAlign.Center 79 | ) 80 | } 81 | } 82 | } 83 | } 84 | } 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/Navigation.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation 2 | 3 | import androidx.compose.runtime.Composable 4 | import androidx.hilt.navigation.compose.hiltViewModel 5 | import androidx.navigation.compose.NavHost 6 | import androidx.navigation.compose.composable 7 | import androidx.navigation.compose.rememberNavController 8 | import androidx.navigation.navArgument 9 | import com.breakfastapi.model.Recipe 10 | import com.breakfastapi.ui.presentation.favourites.FavouriteRecipeListViewModel 11 | import com.breakfastapi.ui.presentation.recipelist.RecipeListViewModel 12 | import com.breakfastapi.util.AssetParamType 13 | import com.breakfastapi.util.Routes 14 | 15 | @Composable 16 | fun Navigation() { 17 | var vmRecipeList: RecipeListViewModel = hiltViewModel() 18 | var vmFavouriteList: FavouriteRecipeListViewModel = hiltViewModel() 19 | 20 | var nav = rememberNavController() 21 | NavHost(navController = nav, startDestination = Routes.HOME.route) 22 | { 23 | composable(Routes.HOME.route) 24 | { 25 | RecipeList(nav, vmRecipeList) 26 | } 27 | composable( 28 | "${Routes.RECIPE.route}/{recipe}", 29 | arguments = listOf( 30 | navArgument("recipe") { 31 | type = AssetParamType() 32 | })) 33 | { 34 | val recipe = it.arguments?.getParcelable("recipe") 35 | if (recipe != null) { 36 | RecipeDetail(recipe, nav, vmFavouriteList) 37 | } 38 | } 39 | 40 | composable(Routes.FAVOURITES.route) 41 | { 42 | FavouriteRecipeList(nav, vmFavouriteList) 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/favourites/FavouriteRecipeContent.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation.favourites 2 | 3 | import android.net.Uri 4 | import androidx.compose.foundation.layout.Box 5 | import androidx.compose.foundation.layout.fillMaxSize 6 | import androidx.compose.foundation.layout.padding 7 | import androidx.compose.foundation.lazy.LazyColumn 8 | import androidx.compose.foundation.lazy.itemsIndexed 9 | import androidx.compose.material.Text 10 | import androidx.compose.runtime.Composable 11 | import androidx.compose.ui.Alignment 12 | import androidx.compose.ui.Modifier 13 | import androidx.compose.ui.unit.dp 14 | import androidx.navigation.NavController 15 | import com.breakfastapi.ui.presentation.ListItem 16 | import com.breakfastapi.util.Constants 17 | import com.breakfastapi.util.Routes 18 | import com.google.gson.Gson 19 | 20 | @Composable 21 | fun FavouriteRecipeContent(nav: NavController, vmFavouriteList: FavouriteRecipeListViewModel) { 22 | 23 | Box(modifier = Modifier.fillMaxSize()) 24 | { 25 | 26 | LazyColumn() { 27 | itemsIndexed(vmFavouriteList.favouriteRecipes.value) 28 | { index, recipe -> 29 | ListItem(recipe, { 30 | val jsonRecipe = Uri.encode(Gson().toJson(recipe)) 31 | nav.navigate("${Routes.RECIPE.route}/${jsonRecipe}") 32 | }) 33 | } 34 | } 35 | 36 | if(vmFavouriteList.favouriteRecipes.value.size == 0) 37 | { 38 | Text( 39 | Constants.FAVOURITES_EMPTY_MSG, modifier = Modifier 40 | .align(Alignment.Center) 41 | .padding(start = 10.dp, end = 10.dp)) 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/favourites/FavouriteRecipeListAppBar.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation.favourites 2 | 3 | import androidx.compose.foundation.clickable 4 | import androidx.compose.foundation.layout.* 5 | import androidx.compose.material.Icon 6 | import androidx.compose.material.MaterialTheme 7 | import androidx.compose.material.Text 8 | import androidx.compose.material.TopAppBar 9 | import androidx.compose.material.icons.Icons 10 | import androidx.compose.material.icons.filled.ArrowBack 11 | import androidx.compose.material.icons.filled.Favorite 12 | import androidx.compose.runtime.Composable 13 | import androidx.compose.ui.Alignment 14 | import androidx.compose.ui.Modifier 15 | import androidx.compose.ui.text.style.TextAlign 16 | import androidx.compose.ui.unit.dp 17 | 18 | @Composable 19 | fun FavouriteRecipeListAppBar(onClickNavigate: () -> Unit) { 20 | TopAppBar( 21 | backgroundColor = MaterialTheme.colors.primary, 22 | contentColor = MaterialTheme.colors.onPrimary 23 | ) { 24 | Box( 25 | modifier = Modifier 26 | .fillMaxWidth() 27 | ) 28 | { 29 | 30 | Icon( 31 | imageVector = Icons.Filled.ArrowBack, 32 | contentDescription = "Back", 33 | modifier = Modifier 34 | .padding(start = 10.dp) 35 | .align(Alignment.CenterStart) 36 | .clickable { 37 | onClickNavigate() 38 | } 39 | ) 40 | 41 | Text( 42 | "Favourites", 43 | style = MaterialTheme.typography.h1, 44 | modifier = Modifier 45 | .fillMaxWidth() 46 | .align(Alignment.Center), 47 | textAlign = TextAlign.Center 48 | ) 49 | } 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/favourites/FavouriteRecipeListViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation.favourites 2 | 3 | import androidx.compose.material.* 4 | import androidx.compose.runtime.MutableState 5 | import androidx.compose.runtime.mutableStateOf 6 | import androidx.lifecycle.ViewModel 7 | import androidx.lifecycle.viewModelScope 8 | import com.breakfastapi.model.Recipe 9 | import com.breakfastapi.repository.Repository 10 | import dagger.hilt.android.lifecycle.HiltViewModel 11 | import kotlinx.coroutines.launch 12 | import javax.inject.Inject 13 | 14 | @HiltViewModel 15 | class FavouriteRecipeListViewModel @Inject constructor( 16 | private val repository: Repository 17 | ) : ViewModel() { 18 | 19 | var favouriteRecipes: MutableState> = mutableStateOf(listOf()) 20 | 21 | init { 22 | loadFavouriteRecipes() 23 | } 24 | 25 | fun loadFavouriteRecipes(): Unit { 26 | viewModelScope.launch { 27 | repository.getFavouriteRecipes().collect { 28 | favouriteRecipes.value = it 29 | } 30 | } 31 | } 32 | 33 | fun updateFavouriteRecipe(recipe: Recipe, isFavourite: Boolean, scaffoldState: ScaffoldState) { 34 | 35 | if (isFavourite) 36 | viewModelScope.launch { 37 | repository.insertFavouriteRecipe(recipe) 38 | scaffoldState.snackbarHostState.showSnackbar( 39 | "Recipe added to favourites", 40 | "Hide", 41 | SnackbarDuration.Short 42 | ) 43 | } 44 | else 45 | viewModelScope.launch { 46 | repository.deleteFavouriteRecipe(recipe) 47 | scaffoldState.snackbarHostState.showSnackbar( 48 | "Recipe removed from favourites", 49 | "Hide", 50 | SnackbarDuration.Short 51 | ) 52 | } 53 | } 54 | 55 | //I check against the list rather than querying the db 56 | fun ifFavouriteRecipeExists(recipe: Recipe): Boolean { 57 | if (favouriteRecipes.value.size != 0) { 58 | if (favouriteRecipes.value.contains(recipe)) 59 | //if( favouriteRecipes.value.any{ r -> r.id == recipe.id }) { 60 | return true 61 | } 62 | return false 63 | } 64 | 65 | 66 | //Used for internal testing 67 | private fun addFakeFavouriteRecipes() { 68 | for (i in 1..2000) { 69 | viewModelScope.launch { 70 | repository.insertFavouriteRecipe( 71 | Recipe( 72 | i.toLong(), 73 | i.toString(), 74 | i.toLong(), 75 | "bling, blah, blah, blah", 76 | "Cook the food. Then eat the food." 77 | ) 78 | ) 79 | } 80 | } 81 | } 82 | 83 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/favourites/FavouritesRecipeList.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation 2 | 3 | import androidx.compose.material.Scaffold 4 | import androidx.compose.material.rememberScaffoldState 5 | import androidx.compose.runtime.Composable 6 | import androidx.navigation.NavController 7 | import com.breakfastapi.ui.presentation.favourites.FavouriteRecipeContent 8 | import com.breakfastapi.ui.presentation.favourites.FavouriteRecipeListAppBar 9 | import com.breakfastapi.ui.presentation.favourites.FavouriteRecipeListViewModel 10 | 11 | @Composable 12 | fun FavouriteRecipeList(nav: NavController, vmFavouriteList: FavouriteRecipeListViewModel) { 13 | 14 | val scaffoldState = rememberScaffoldState() 15 | 16 | Scaffold( 17 | topBar = { FavouriteRecipeListAppBar({ nav.navigateUp() }) }, 18 | content = { FavouriteRecipeContent(nav, vmFavouriteList) }, 19 | scaffoldState = scaffoldState, 20 | snackbarHost = { 21 | scaffoldState.snackbarHostState 22 | } 23 | ) 24 | } 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/recipedetail/CustomSnackbar.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation.recipedetail 2 | 3 | import androidx.compose.material.* 4 | import androidx.compose.runtime.Composable 5 | import androidx.compose.ui.Modifier 6 | 7 | @Composable 8 | fun CustomSnackbar( 9 | snackbarHostState: SnackbarHostState, 10 | modifier: Modifier 11 | ) { 12 | SnackbarHost( 13 | hostState = snackbarHostState, 14 | modifier = modifier, 15 | snackbar = { 16 | Snackbar( 17 | action = { snackbarHostState.currentSnackbarData?.dismiss() }, 18 | content = { Text(it.message) }) 19 | }) 20 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/recipedetail/RecipeDetail.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation 2 | 3 | import android.content.ActivityNotFoundException 4 | import android.content.Intent 5 | import androidx.compose.material.Scaffold 6 | import androidx.compose.material.icons.Icons 7 | import androidx.compose.material.icons.filled.Favorite 8 | import androidx.compose.material.icons.filled.FavoriteBorder 9 | import androidx.compose.material.rememberScaffoldState 10 | import androidx.compose.runtime.Composable 11 | import androidx.compose.runtime.mutableStateOf 12 | import androidx.compose.runtime.remember 13 | import androidx.compose.ui.platform.LocalContext 14 | import androidx.navigation.NavController 15 | import com.breakfastapi.model.Recipe 16 | import com.breakfastapi.ui.presentation.favourites.FavouriteRecipeListViewModel 17 | 18 | @Composable 19 | fun RecipeDetail( 20 | recipe: Recipe, 21 | nav: NavController, 22 | vmFavouriteList: FavouriteRecipeListViewModel 23 | ) { 24 | val ctx = LocalContext.current 25 | var isFavourite = remember { mutableStateOf(vmFavouriteList.ifFavouriteRecipeExists(recipe))} 26 | val scaffoldState = rememberScaffoldState() 27 | 28 | Scaffold( 29 | topBar = { 30 | RecipeDetailAppBar( 31 | onClickNavigate = { nav.navigateUp() }, 32 | onClickEmail = { 33 | val intent = Intent(Intent.ACTION_SEND) 34 | intent.type = "message/rfc822" 35 | intent.putExtra(Intent.EXTRA_SUBJECT, recipe.recipeName) 36 | intent.putExtra( 37 | Intent.EXTRA_TEXT, 38 | "Ingredients: ${recipe.ingredientsString}\n\nDirections: ${recipe.directionsString}" 39 | ) 40 | try { 41 | ctx.startActivity(Intent.createChooser(intent, "Email client")) 42 | } catch (ex: ActivityNotFoundException) { 43 | //todo later - handle some errors yo! 44 | } 45 | }, 46 | onClickFavourite = { 47 | isFavourite.value = !isFavourite.value 48 | vmFavouriteList.updateFavouriteRecipe( 49 | recipe, 50 | isFavourite.value, 51 | scaffoldState 52 | ) 53 | }, 54 | imageVector = if (isFavourite.value) Icons.Default.Favorite else Icons.Filled.FavoriteBorder 55 | ) 56 | }, 57 | content = { 58 | RecipeDetailContent(recipe) 59 | }, 60 | scaffoldState = scaffoldState 61 | ) 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/recipedetail/RecipeDetailAppBar.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation 2 | 3 | import androidx.compose.foundation.clickable 4 | import androidx.compose.foundation.layout.Arrangement 5 | import androidx.compose.foundation.layout.Row 6 | import androidx.compose.foundation.layout.fillMaxWidth 7 | import androidx.compose.foundation.layout.padding 8 | import androidx.compose.material.* 9 | import androidx.compose.material.icons.Icons 10 | import androidx.compose.material.icons.filled.ArrowBack 11 | import androidx.compose.material.icons.filled.Share 12 | import androidx.compose.runtime.Composable 13 | import androidx.compose.ui.Modifier 14 | import androidx.compose.ui.graphics.vector.ImageVector 15 | import androidx.compose.ui.unit.dp 16 | 17 | @Composable 18 | fun RecipeDetailAppBar( 19 | onClickNavigate: () -> Unit, 20 | onClickEmail: () -> Unit, 21 | onClickFavourite: () -> Unit, 22 | imageVector: ImageVector 23 | ) { 24 | TopAppBar( 25 | backgroundColor = MaterialTheme.colors.primary, 26 | contentColor = MaterialTheme.colors.onPrimary 27 | ) { 28 | Row( 29 | modifier = Modifier 30 | .fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween 31 | ) 32 | { 33 | Icon( 34 | imageVector = Icons.Filled.ArrowBack, 35 | contentDescription = "Back", 36 | modifier = Modifier 37 | .padding(start = 10.dp) 38 | .clickable { 39 | onClickNavigate() 40 | } 41 | ) 42 | Row() 43 | { 44 | 45 | Icon( 46 | imageVector = imageVector, 47 | contentDescription = "Favourite", 48 | modifier = Modifier 49 | .padding(end = 20.dp) 50 | .clickable { 51 | onClickFavourite() 52 | } 53 | ) 54 | Icon( 55 | imageVector = Icons.Filled.Share, 56 | contentDescription = "Share", 57 | modifier = Modifier 58 | .padding(end = 10.dp) 59 | .clickable { 60 | onClickEmail() 61 | } 62 | ) 63 | } 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/recipedetail/RecipeDetailContent.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation 2 | 3 | import androidx.compose.foundation.Image 4 | import androidx.compose.foundation.layout.* 5 | import androidx.compose.foundation.lazy.LazyColumn 6 | import androidx.compose.material.* 7 | import androidx.compose.runtime.Composable 8 | import androidx.compose.ui.Alignment 9 | import androidx.compose.ui.Modifier 10 | import androidx.compose.ui.res.painterResource 11 | import androidx.compose.ui.unit.dp 12 | import coil.compose.rememberImagePainter 13 | import coil.size.OriginalSize 14 | import com.breakfastapi.R 15 | import com.breakfastapi.model.Recipe 16 | import com.breakfastapi.ui.presentation.recipedetail.CustomSnackbar 17 | import com.breakfastapi.util.Constants 18 | import com.breakfastapi.util.Helper.getListFromString 19 | import com.breakfastapi.util.Helper.getTimeFormatted 20 | import com.breakfastapi.util.getFood 21 | 22 | @Composable 23 | fun RecipeDetailContent(recipe: Recipe) { 24 | 25 | val scaffoldState = rememberScaffoldState() 26 | 27 | Box(modifier = Modifier.fillMaxSize()) 28 | { 29 | LazyColumn(modifier = Modifier.padding(start = 10.dp, end = 10.dp)) 30 | { 31 | item() 32 | { 33 | Column() 34 | { 35 | Row( 36 | modifier = Modifier 37 | .fillMaxWidth() 38 | .padding(top = 10.dp) 39 | ) 40 | { 41 | Column(modifier = Modifier.fillMaxWidth(.7f)) { 42 | Text(recipe.recipeName, style = MaterialTheme.typography.h6) 43 | } 44 | Column(modifier = Modifier.fillMaxWidth()) { 45 | Text( 46 | "id: ${recipe.id}", 47 | style = MaterialTheme.typography.h1, 48 | modifier = Modifier 49 | .align(Alignment.End) 50 | ) 51 | } 52 | } 53 | 54 | var food = getFood(recipe.recipeName.lowercase()) 55 | Image( 56 | painter = rememberImagePainter( 57 | data = food.imageInt, 58 | builder = { size(OriginalSize) }, 59 | ), 60 | contentDescription = food.imageName, 61 | modifier = Modifier 62 | .fillMaxSize() 63 | .padding(5.dp) 64 | ) 65 | Row(verticalAlignment = Alignment.CenterVertically) 66 | { 67 | Image( 68 | painter = painterResource(R.drawable.ic_baseline_access_time_24), 69 | contentDescription = "time", modifier = Modifier.padding(end = 3.dp) 70 | ) 71 | Text( 72 | "${getTimeFormatted(recipe.totalDuration)}", 73 | style = MaterialTheme.typography.h2 74 | ) 75 | } 76 | Spacer(modifier = Modifier.padding(5.dp)) 77 | Text("Ingredients: ", style = MaterialTheme.typography.h3) 78 | Text(recipe.ingredientsString, style = MaterialTheme.typography.subtitle2) 79 | Spacer(modifier = Modifier.padding(5.dp)) 80 | Text("Directions: ", style = MaterialTheme.typography.h3) 81 | var dirList = getListFromString(recipe.directionsString, Constants.PERIOD) 82 | dirList.forEachIndexed { index, direction -> 83 | Row(modifier = Modifier.padding(bottom = 5.dp)) 84 | { 85 | Text("${index + 1} ", style = MaterialTheme.typography.h3) 86 | Text("$direction", style = MaterialTheme.typography.body2) 87 | } 88 | } 89 | } 90 | } 91 | } 92 | CustomSnackbar( 93 | snackbarHostState = scaffoldState.snackbarHostState, 94 | modifier = Modifier.align(Alignment.BottomCenter)) 95 | } 96 | } 97 | 98 | 99 | -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/recipelist/RecipeList.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation 2 | 3 | import androidx.compose.material.* 4 | import androidx.compose.runtime.Composable 5 | import androidx.navigation.NavController 6 | import com.breakfastapi.ui.presentation.recipelist.RecipeListAppBar 7 | import com.breakfastapi.ui.presentation.recipelist.RecipeListContent 8 | import com.breakfastapi.ui.presentation.recipelist.RecipeListViewModel 9 | import com.breakfastapi.util.Routes 10 | 11 | @Composable 12 | fun RecipeList(nav: NavController, vmRecipeList: RecipeListViewModel) { 13 | 14 | val scaffoldState = rememberScaffoldState() 15 | 16 | Scaffold ( 17 | topBar = { RecipeListAppBar({ nav.navigate(Routes.FAVOURITES.route) })}, 18 | content = { RecipeListContent(nav,vmRecipeList)}, 19 | scaffoldState = scaffoldState, 20 | snackbarHost = {scaffoldState.snackbarHostState} 21 | ) 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/recipelist/RecipeListAppBar.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation.recipelist 2 | 3 | import androidx.compose.foundation.clickable 4 | import androidx.compose.foundation.layout.* 5 | import androidx.compose.material.Icon 6 | import androidx.compose.material.MaterialTheme 7 | import androidx.compose.material.Text 8 | import androidx.compose.material.TopAppBar 9 | import androidx.compose.material.icons.Icons 10 | import androidx.compose.material.icons.filled.Favorite 11 | import androidx.compose.runtime.Composable 12 | import androidx.compose.ui.Alignment 13 | import androidx.compose.ui.Modifier 14 | import androidx.compose.ui.text.style.TextAlign 15 | import androidx.compose.ui.unit.dp 16 | 17 | @Composable 18 | fun RecipeListAppBar(onClickFavourite: () -> Unit) { 19 | TopAppBar( 20 | backgroundColor = MaterialTheme.colors.primary, 21 | contentColor = MaterialTheme.colors.onPrimary 22 | ) { 23 | Box( 24 | modifier = Modifier 25 | .fillMaxWidth() 26 | ) 27 | { 28 | 29 | Text( 30 | "Recipes", 31 | style = MaterialTheme.typography.h1, 32 | textAlign = TextAlign.Center, 33 | modifier = Modifier.align(Alignment.Center) 34 | ) 35 | 36 | Icon( 37 | imageVector = Icons.Filled.Favorite, 38 | contentDescription = "Favourites", 39 | modifier = Modifier 40 | .padding(end = 10.dp) 41 | .align(Alignment.CenterEnd) 42 | .clickable { 43 | onClickFavourite() 44 | } 45 | ) 46 | } 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/recipelist/RecipeListContent.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation.recipelist 2 | 3 | import android.net.Uri 4 | import androidx.compose.foundation.layout.Box 5 | import androidx.compose.foundation.layout.fillMaxSize 6 | import androidx.compose.foundation.layout.padding 7 | import androidx.compose.foundation.lazy.LazyColumn 8 | import androidx.compose.foundation.lazy.itemsIndexed 9 | import androidx.compose.material.CircularProgressIndicator 10 | import androidx.compose.material.Text 11 | import androidx.compose.runtime.Composable 12 | import androidx.compose.ui.Alignment 13 | import androidx.compose.ui.Modifier 14 | import androidx.compose.ui.unit.dp 15 | import androidx.navigation.NavController 16 | import com.breakfastapi.ui.presentation.ListItem 17 | import com.breakfastapi.util.NetworkStatus 18 | import com.breakfastapi.util.Routes 19 | import com.google.gson.Gson 20 | 21 | @Composable 22 | fun RecipeListContent(nav: NavController, vmRecipeList: RecipeListViewModel) 23 | { 24 | Box(modifier = Modifier.fillMaxSize()) 25 | { 26 | LazyColumn() { 27 | 28 | itemsIndexed(vmRecipeList.recipes.value) 29 | { index, recipe -> 30 | ListItem(recipe, { 31 | 32 | val jsonRecipe = Uri.encode(Gson().toJson(recipe)) 33 | nav.navigate("${Routes.RECIPE.route}/${jsonRecipe}") 34 | }) 35 | 36 | if (((index + 1) >= vmRecipeList.recipes.value.size) && vmRecipeList.networkStatus.value == NetworkStatus.READY) { 37 | vmRecipeList.loadRecipe() 38 | } 39 | } 40 | } 41 | if (vmRecipeList.networkStatus.value == NetworkStatus.LOADING) 42 | CircularProgressIndicator(modifier = Modifier.align(Alignment.Center)) 43 | 44 | //also don't show if the network went down after a non-zero number of sucessful calls 45 | if (vmRecipeList.networkStatus.value == NetworkStatus.ERROR && vmRecipeList.recipes.value.size == 0) 46 | Text( 47 | vmRecipeList.networkStatus.value.msg, 48 | modifier = Modifier 49 | .align(Alignment.Center) 50 | .padding(start = 10.dp, end = 10.dp) 51 | ) 52 | } 53 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/presentation/recipelist/RecipeListViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.presentation.recipelist 2 | 3 | import androidx.compose.runtime.MutableState 4 | import androidx.compose.runtime.mutableStateOf 5 | import androidx.lifecycle.ViewModel 6 | import androidx.lifecycle.viewModelScope 7 | import com.breakfastapi.model.Recipe 8 | import com.breakfastapi.repository.Repository 9 | import com.breakfastapi.util.Constants 10 | import com.breakfastapi.util.NetworkStatus 11 | import com.breakfastapi.util.Resource 12 | import dagger.hilt.android.lifecycle.HiltViewModel 13 | import kotlinx.coroutines.async 14 | import kotlinx.coroutines.launch 15 | import javax.inject.Inject 16 | 17 | @HiltViewModel 18 | class RecipeListViewModel @Inject constructor( 19 | private val repository: Repository 20 | ) : ViewModel() { 21 | 22 | var recipes: MutableState> = mutableStateOf(listOf()) 23 | var networkStatus = mutableStateOf(NetworkStatus.READY) 24 | 25 | init { 26 | loadRecipe() 27 | } 28 | 29 | fun loadRecipe() { 30 | viewModelScope.launch { 31 | networkStatus.value = NetworkStatus.LOADING 32 | for (apiCall in 1..Constants.PAGESIZE) { 33 | async { 34 | var result = repository.getRecipe() 35 | when (result) { 36 | is Resource.Success -> { 37 | recipes.value += result.data 38 | if (apiCall == Constants.PAGESIZE) 39 | networkStatus.value = NetworkStatus.READY 40 | } 41 | is Resource.Error -> { 42 | networkStatus.value = NetworkStatus.ERROR 43 | networkStatus.value.msg = result.exception.localizedMessage 44 | } 45 | is Resource.Loading -> { 46 | } 47 | } 48 | } 49 | } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/theme/Color.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.theme 2 | 3 | import androidx.compose.ui.graphics.Color 4 | 5 | val Purple200 = Color(0xFFBB86FC) 6 | val Purple500 = Color(0xFF6200EE) 7 | val Purple700 = Color(0xFF3700B3) 8 | val Teal200 = Color(0xFF03DAC5) 9 | val Red400 = Color(0xFFcc0000) 10 | val Black = Color(0xFF000000) 11 | val Teal900 = Color(0xFF05978C) -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/theme/Shape.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.theme 2 | 3 | import androidx.compose.foundation.shape.RoundedCornerShape 4 | import androidx.compose.material.Shapes 5 | import androidx.compose.ui.unit.dp 6 | 7 | val Shapes = Shapes( 8 | small = RoundedCornerShape(4.dp), 9 | medium = RoundedCornerShape(4.dp), 10 | large = RoundedCornerShape(0.dp) 11 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/theme/Theme.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.theme 2 | 3 | import androidx.compose.foundation.isSystemInDarkTheme 4 | import androidx.compose.material.MaterialTheme 5 | import androidx.compose.material.darkColors 6 | import androidx.compose.material.lightColors 7 | import androidx.compose.runtime.Composable 8 | 9 | private val DarkColorPalette = darkColors( 10 | primary = Red400, 11 | primaryVariant = Purple700, 12 | secondary = Teal200 13 | ) 14 | 15 | private val LightColorPalette = lightColors( 16 | primary = Teal900, 17 | primaryVariant = Purple700, 18 | secondary = Teal200 19 | ) 20 | 21 | @Composable 22 | fun BreakfastAPITheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { 23 | val colors = if (darkTheme) { 24 | DarkColorPalette 25 | } else { 26 | LightColorPalette 27 | } 28 | 29 | MaterialTheme( 30 | colors = colors, 31 | typography = Typography, 32 | shapes = Shapes, 33 | content = content 34 | ) 35 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/ui/theme/Type.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.ui.theme 2 | 3 | import androidx.compose.material.Typography 4 | import androidx.compose.ui.graphics.Color 5 | import androidx.compose.ui.text.TextStyle 6 | import androidx.compose.ui.text.font.FontFamily 7 | import androidx.compose.ui.text.font.FontStyle 8 | import androidx.compose.ui.text.font.FontWeight 9 | import androidx.compose.ui.unit.sp 10 | 11 | val Typography = Typography( 12 | body1 = TextStyle( 13 | fontFamily = FontFamily.Default, 14 | fontWeight = FontWeight.Light, 15 | fontSize = 11.sp, 16 | color = Color.Gray 17 | ), 18 | body2 = TextStyle( 19 | fontFamily = FontFamily.SansSerif, 20 | fontWeight = FontWeight.Normal, 21 | fontSize = 14.sp, 22 | ), 23 | h1 = TextStyle( 24 | fontFamily = FontFamily.Default, 25 | fontWeight = FontWeight.Normal, 26 | fontSize = 15.sp 27 | ), 28 | h2 = TextStyle( 29 | fontFamily = FontFamily.Default, 30 | fontWeight = FontWeight.Thin, 31 | fontSize = 16.sp 32 | ), 33 | h3 = TextStyle( 34 | fontFamily = FontFamily.SansSerif, 35 | fontWeight = FontWeight.Bold, 36 | fontSize = 14.sp, 37 | ), 38 | h4 = TextStyle( 39 | fontFamily = FontFamily.Default, 40 | fontWeight = FontWeight.Thin, 41 | fontSize = 12.sp 42 | ), 43 | h6 = TextStyle( 44 | fontFamily = FontFamily.Default, 45 | fontWeight = FontWeight.Bold, 46 | fontSize = 16.sp 47 | ), 48 | 49 | subtitle2 = TextStyle( 50 | fontFamily = FontFamily.Default, 51 | fontWeight = FontWeight.Normal, 52 | fontStyle = FontStyle.Italic, 53 | fontSize = 12.sp, 54 | ), 55 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/util/AssetParamType.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.util 2 | 3 | import android.os.Bundle 4 | import androidx.navigation.NavType 5 | import com.breakfastapi.model.Recipe 6 | import com.google.gson.Gson 7 | 8 | class AssetParamType : NavType(isNullableAllowed = false) { 9 | override fun get(bundle: Bundle, key: String): Recipe? { 10 | return bundle.getParcelable(key) 11 | } 12 | 13 | override fun parseValue(value: String): Recipe { 14 | return Gson().fromJson(value, Recipe::class.java) 15 | } 16 | 17 | override fun put(bundle: Bundle, key: String, value: Recipe) { 18 | bundle.putParcelable(key, value) 19 | } 20 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/util/Constants.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.util 2 | 3 | object Constants { 4 | val BASE_URL = "https://breakfastapi.fun/" 5 | val COMMA = "," 6 | val PERIOD = "." 7 | val PAGESIZE = 10 // # of recipes to load at one time 8 | 9 | val FAVOURITES_EMPTY_MSG = "No recipes saved to favourites" 10 | } 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/util/Food.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.util 2 | 3 | import com.breakfastapi.R 4 | 5 | data class Food(val imageName: String, val imageInt: Int) 6 | 7 | val foodList = listOf( 8 | Food("beef", R.drawable.beef), 9 | Food("bread", R.drawable.bread), 10 | Food("brisket", R.drawable.brisket), 11 | Food("burger", R.drawable.burger), 12 | Food("cake", R.drawable.cake), 13 | Food("casserole", R.drawable.casserole), 14 | Food("cheese", R.drawable.cheese), 15 | Food("chicken", R.drawable.chicken), 16 | Food("chili", R.drawable.chili), 17 | Food("chop", R.drawable.chop), 18 | Food("cookie", R.drawable.cookie), 19 | Food("fish", R.drawable.fish), 20 | Food("ham", R.drawable.ham), 21 | Food("meatball", R.drawable.meatball), //meatball should be before meat 22 | Food("meatloaf", R.drawable.meatloaf), //ditto 23 | Food("meat", R.drawable.meat), 24 | Food("pasta", R.drawable.pasta), 25 | Food("pizza", R.drawable.pizza), 26 | Food("pie", R.drawable.pie), 27 | Food("pork", R.drawable.pork), 28 | Food("potato", R.drawable.potato), 29 | Food("rib", R.drawable.ribs), 30 | Food("rice", R.drawable.rice), 31 | Food("salad", R.drawable.salad), 32 | Food("sandwich", R.drawable.sandwich), 33 | Food("sausage", R.drawable.sausage), 34 | Food("shrimp", R.drawable.shrimp), 35 | Food("soup", R.drawable.soup), 36 | Food("steak", R.drawable.steak), 37 | Food("stew", R.drawable.stew), 38 | Food("turkey", R.drawable.turkey), 39 | Food("slow", R.drawable.slowcook) //somewhat generic so I put last 40 | ) 41 | private val genericFood = Food("food", R.drawable.food) 42 | 43 | fun getFood(input: String): Food { 44 | foodList.forEach { 45 | if (input.contains(it.imageName)) 46 | return it 47 | } 48 | return genericFood 49 | } 50 | 51 | 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/util/Helper.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.util 2 | 3 | import java.lang.StringBuilder 4 | 5 | object Helper { 6 | fun getListFromString(input: String, delimiter: String): List { 7 | var newInput = removeBrackets(input) 8 | var output = mutableListOf() 9 | val list: List = newInput.split(delimiter).map { it -> it.trim() } 10 | list.forEach { it -> 11 | if (it.isNotEmpty()) 12 | output.add("$it") 13 | } 14 | return output 15 | } 16 | 17 | fun getTimeFormatted(mins: Long) : String 18 | { 19 | val hours: Int = mins.toInt() / 60 20 | val minutes: Int = mins.toInt() % 60 21 | var time : StringBuilder = StringBuilder("") 22 | if(hours!=0) 23 | time.append("${hours}h ") 24 | if(minutes !=0) 25 | time.append("${minutes}m") 26 | if(time.isNotEmpty()) 27 | return time.toString() 28 | else 29 | return "?" 30 | } 31 | 32 | fun getStringFromList(list: List) : String 33 | { return list.joinToString(", ") 34 | } 35 | 36 | fun removeBrackets(input: String): String { 37 | return input.replace("'", "") 38 | } 39 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/util/NetworkStatus.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.util 2 | 3 | enum class NetworkStatus(var msg: String) { 4 | 5 | READY("Ready"), 6 | LOADING("Loading"), 7 | ERROR("Error"), 8 | } -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/util/Resource.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.util 2 | 3 | sealed class Resource { 4 | data class Success(val data: T): Resource() 5 | data class Error(val exception: Throwable): Resource() 6 | object Loading: Resource() 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/breakfastapi/util/Routes.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi.util 2 | 3 | enum class Routes(val route: String) 4 | { 5 | HOME("home"), 6 | RECIPE("recipe"), 7 | FAVOURITES("favourites") 8 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/beef.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/beef.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/bread.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/bread.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/brisket.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/brisket.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/burger.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/burger.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/cake.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/cake.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/casserole.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/casserole.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/cheese.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/cheese.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/chicken.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/chicken.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/chili.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/chili.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/chop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/chop.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/cookie.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/cookie.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/fish.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/fish.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/food.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/food.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/ham.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/ham.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_access_time_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/meat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/meat.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/meatball.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/meatball.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/meatloaf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/meatloaf.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/pasta.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/pasta.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/pie.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/pie.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/pizza.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/pizza.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/pork.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/pork.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/potato.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/potato.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/ribs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/ribs.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/rice.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/rice.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/salad.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/salad.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/sandwich.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/sandwich.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/sausage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/sausage.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/shrimp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/shrimp.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/slowcook.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/slowcook.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/soup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/soup.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/steak.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/steak.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/stew.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/stew.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/turkey.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/drawable/turkey.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_back.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_fore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_fore.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_back.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_fore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_fore.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_back.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_fore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_fore.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_back.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_fore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_fore.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_back.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_fore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_fore.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | #FFcc0000 11 | #FF05978C 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FCFCFC 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BreakfastAPI 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/breakfastapi/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.breakfastapi 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | compose_version = '1.0.1' 4 | } 5 | dependencies { 6 | classpath "com.google.dagger:hilt-android-gradle-plugin:2.39.1" 7 | } 8 | }// Top-level build file where you can add configuration options common to all sub-projects/modules. 9 | plugins { 10 | id 'com.android.application' version '7.1.1' apply false 11 | id 'com.android.library' version '7.1.1' apply false 12 | id 'org.jetbrains.kotlin.android' version '1.5.21' apply false 13 | } 14 | 15 | task clean(type: Delete) { 16 | delete rootProject.buildDir 17 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official 20 | # Enables namespacing of each library's R class so that its R class includes only the 21 | # resources declared in the library itself and none from the library's dependencies, 22 | # thereby reducing the size of the R class for that library 23 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcLab1/BreakfastAPI/38cddbb2d2fcb60b8fecfbdb92c4431693bd194d/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Feb 11 20:07:32 EST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | rootProject.name = "BreakfastAPI" 16 | include ':app' 17 | --------------------------------------------------------------------------------