Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 72 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,74 @@
# Built application files
*.apk
*.aar
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.idea/
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/gradle.xml
# .idea/assetWizardSettings.xml
# .idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
*.jks
*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx
local.properties
.cxx/
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
# MacOS
.DS_Store
# App Specific cases
app/release/output.json
.idea/codeStyles/
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

18 changes: 0 additions & 18 deletions .idea/gradle.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/migrations.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/misc.xml

This file was deleted.

2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ dependencies {
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")
implementation("androidx.navigation:navigation-compose:2.7.7")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
Expand Down
17 changes: 2 additions & 15 deletions app/src/main/java/com/example/recipe/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ package com.example.recipe
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.recipe.ui.theme.RecipeTheme

Expand All @@ -17,30 +14,20 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
RecipeTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Greeting("Android")
ComposeNavigation()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normally this called AppNameNavigation -> RecipeNavigation

}
}
}
}
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(
text = "Hello $name!",
modifier = modifier
)
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not GreetingPreview but RecipeNavigationPreview()

RecipeTheme {
Greeting("Android")
ComposeNavigation()
}
}
24 changes: 24 additions & 0 deletions app/src/main/java/com/example/recipe/Navication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.recipe
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file name should be equal to the method inside it -> RecipeNavigation.kt


import android.annotation.SuppressLint
import androidx.compose.runtime.Composable
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.example.recipe.screens.RecipeDetails
import com.example.recipe.screens.RecipeHomeScreen

@SuppressLint("ComposableDestinationInComposeScope")
@Composable
fun ComposeNavigation() {

val navController = rememberNavController()
NavHost(navController = navController, startDestination = "S_1") {
composable("S_1") {
RecipeHomeScreen()
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S_1 -> RecipeHomeScreen

composable("S_2") {
RecipeDetails(navController)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. RecipeDetails -> RecipeDetailsScreen
  2. do not send navController: encaspsulate all nav logic inside navigation file -> ComposableFunction(){paramsIfAny-> navController.navigate(....)}

}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check comment above

}
}
96 changes: 96 additions & 0 deletions app/src/main/java/com/example/recipe/RecipeCard.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.example.recipe

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.example.recipe.ui.theme.RecipeTheme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun RecipeCard(navHostController: NavHostController) {
Spacer(modifier = Modifier.padding(24.dp))

Card(
modifier = Modifier
.height(112.dp)
.padding(start = 16.dp),
colors = CardDefaults.cardColors(containerColor = Color.Transparent),
shape = RoundedCornerShape(0),
onClick = {navHostController.navigate("S_2")}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code is not formatted, never push code that is not formatted please

) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
) {
Column(modifier = Modifier.weight(1f)) {
Text(
text = "Meat Loaf",
maxLines = 2,
overflow = TextOverflow.Clip,
fontSize = 20.sp,
fontWeight = FontWeight.Bold,
)

Text(
text = "Yummy home made meat loaf, great for left lovers.",
maxLines = 2,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.padding(bottom = 4.dp),
fontSize = 13.sp,
lineHeight = 18.sp,
color = Color.Gray,
)

Spacer(Modifier.weight(1f))

Text(text = "01.05.2018")
}

Spacer(Modifier.width(16.dp))

Image(
painter = painterResource(id = R.drawable.meat_loaf_web),
contentDescription = null,
modifier = Modifier
.fillMaxHeight()
.clip(RoundedCornerShape(bottomStart = 10.dp, topStart = 10.dp)),
contentScale = ContentScale.Crop,
)
}
}
}

@Preview(showBackground = true)
@Composable
fun RecipeCardPreview() {
val navController = rememberNavController()
RecipeTheme {
RecipeCard(navController)
}
}

11 changes: 11 additions & 0 deletions app/src/main/java/com/example/recipe/screens/RecipeDetails.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.recipe.screens

import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController

@Composable
fun RecipeDetails(
navHostController: NavHostController
) {

}
Loading