-
Notifications
You must be signed in to change notification settings - Fork 28
Initial Commit #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Initial Commit #36
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- PR title is not correct
- PR Description is not updated
- Commit Message is not correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do add screenshots and working video as well
setContent { | ||
JayRecipesXTheme { | ||
val viewModel = RecipeViewModel() | ||
val state = viewModel.recipes.collectAsState() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason why collecting the data even before the screen initialize?
data class RecipeModel( | ||
val id: Int, | ||
val name: String, | ||
val ingredients: List<String>, | ||
val instructions: String, | ||
val cookingTime: Int, | ||
val servings: Int, | ||
val isVegetarian: Boolean, | ||
val imageUrl: String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if any of them null or empty or not come from API?
Will it crash?
import kotlin.random.Random | ||
|
||
class RecipeRepoImpl : IRecipeRepo { | ||
val recipes = mutableListOf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why public?
|
||
override fun getRandomRecipe(): RecipeModel { | ||
val randomIndex = Random.nextInt(recipes.size) | ||
return recipes[randomIndex]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indexOutOfBound?
import com.example.jay_recipesx.features.RecipeHome.Domain.Repositories.IRecipeRepo | ||
|
||
class GetRandomRecipe(private val iRecipeRepo: IRecipeRepo) { | ||
fun call(): RecipeModel = iRecipeRepo.getRandomRecipe() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call()
means?
Column { | ||
|
||
|
||
AsyncImage( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why empty lines?
|
||
|
||
AsyncImage( | ||
model = (state.value as RecipeHomeSuccessState).recipes.imageUrl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will there be a chance of crash as RecipeHomeSuccessState
?
sealed class RecipeHomeEvent { | ||
|
||
class GetRandomRecipeEvent() : RecipeHomeEvent() | ||
class GetSimilarRecipeEvent(id: String) : RecipeHomeEvent() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why sealed class, why not interface?
any rational?
class RecipeViewModel : ViewModel() { | ||
|
||
// State Flow | ||
private val iRecipeRepo = RecipeRepoImpl() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why inside viewmodel?
is RecipeHomeEvent.GetSimilarRecipeEvent -> { | ||
} | ||
else -> { | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why empty?
class AppFunctions { | ||
companion object { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Class provide reusable functions to all over the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why can't we just use function, and use it directly?
fun provideRecipeApi(): RecipeApi { | ||
return Retrofit.Builder() | ||
.baseUrl("https://api.spoonacular.com") | ||
.addConverterFactory(GsonConverterFactory.create()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use Kotlin serialization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not aware of this will check this.
interface RecipeApi { | ||
@Headers( | ||
"Content-Type: application/json", | ||
"x-api-key: 6b129304251e43469b1faa962b367fed" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it good idea to pass api key publically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it's not good idea to pass the API will update this
Fixed Bugs, Added DI and Retrofit
Description
Please include a summary of the changes you have made. Highlight the key aspects of your project.
Checklist
README.md
file with a brief overview of the project, how to set it up, and any relevant information.Screenshots
Screen Recording
RMX1851.2024-10-08.20-12-48.mp4
Project README
Please ensure that your project's
README.md
is detailed and includes:The Recipe App 🍽️ is a user-friendly application designed to fetch and display one random recipe at a time. It provides users with a summary of the recipe's instructions and steps, making it easy to explore new culinary delights 🌟. The app aims to inspire home cooks 👩🍳👨🍳 by offering a diverse selection of recipes and encourages experimentation in the kitchen 🥘.
Random Recipe Fetching: The app fetches one random recipe from a predefined API or database each time it is launched or when the user presses a button.
Recipe Summary: Each recipe displays a concise summary, including key ingredients and steps for easy understanding.
User-Friendly Interface: Designed with simplicity in mind, allowing users to navigate easily and enjoy their cooking experience.
Interactive Button: A dedicated button to fetch a new random recipe, encouraging users to discover more cooking ideas.
Additional Notes
Is there anything else the maintainers should know about your contribution?
Thank you for your contribution!