-
Notifications
You must be signed in to change notification settings - Fork 0
Recipe home screen #2
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: master
Are you sure you want to change the base?
Changes from all commits
d9af122
0f6eadf
3d7ee01
430b2a0
82605c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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/ |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
||
|
|
@@ -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() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| fun Greeting(name: String, modifier: Modifier = Modifier) { | ||
| Text( | ||
| text = "Hello $name!", | ||
| modifier = modifier | ||
| ) | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| fun GreetingPreview() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not GreetingPreview but RecipeNavigationPreview() |
||
| RecipeTheme { | ||
| Greeting("Android") | ||
| ComposeNavigation() | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.example.recipe | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. S_1 -> RecipeHomeScreen |
||
| composable("S_2") { | ||
| RecipeDetails(navController) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check comment above |
||
| } | ||
| } | ||
| 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")} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| } | ||
| } | ||
|
|
||
| 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 | ||
| ) { | ||
|
|
||
| } |
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.
normally this called AppNameNavigation -> RecipeNavigation