Skip to content

Commit

Permalink
add screen
Browse files Browse the repository at this point in the history
  • Loading branch information
RocqJones committed Jul 9, 2024
1 parent 4dd5342 commit 41e3395
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/com/rocqjones/mesdk/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.rocqjones.me_design.screens.BottomSheetDialogScreen
import com.rocqjones.me_design.screens.EndlessScreen
import com.rocqjones.me_design.screens.GenHomeScreen
import com.rocqjones.me_design.screens.HomeScreen
import com.rocqjones.me_design.ui.theme.MeSDKTheme
import com.rocqjones.me_logic.models.Screen
Expand Down Expand Up @@ -57,6 +58,10 @@ fun MyAppMain() {
composable(Screen.BottomSheetDialogScreen.route) {
BottomSheetDialogScreen(navController)
}

composable(Screen.GenHomeScreen.route) {
GenHomeScreen()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.rocqjones.me_design.screens

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.rocqjones.me_design.ui.theme.MeSDKTheme
import com.rocqjones.me_logic.models.CardInfo
import com.rocqjones.me_logic.providers.SampleDataSource

@Composable
fun GenHomeScreen() {
Column(modifier = Modifier.padding(16.dp)) {
Text("Good Afternoon,", style = MaterialTheme.typography.titleSmall)
Text("Jones", style = MaterialTheme.typography.titleLarge)
Spacer(modifier = Modifier.height(16.dp))

// Use LazyRow for efficient scrolling if the number of buttons can grow
LazyRow(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(8.dp) // Use spacedBy for consistent spacing
) {
items(listOf("Home", "Emergency", "GariSearch", "PataPesa", "More")) { item ->
Button(onClick = {
// Handle navigation based on the item clicked
when (item) {
"Home" -> { /* navigate to home */ }
"Emergency" -> { /* navigate to emergency */ }
// ... and so on
}
}) {
Text(item)
}
}
}

Spacer(modifier = Modifier.height(16.dp))

val cardInfoList = getCardInfo()
// Use LazyColumn for efficient list rendering
LazyColumn(verticalArrangement = Arrangement.spacedBy(16.dp)) {
items(cardInfoList) { cardInfo ->
Card(
modifier = Modifier.fillMaxWidth().background(MaterialTheme.colorScheme.surface),
) {
Column(modifier = Modifier.padding(16.dp)) { // Add padding within the card
Text(cardInfo.title, style = MaterialTheme.typography.titleMedium)
Text(cardInfo.description, style = MaterialTheme.typography.bodyMedium)
}
}
}
}
}
}


// Dummy function to get card info (replace with actual data fetching)
fun getCardInfo(): List<CardInfo> {
return SampleDataSource.genList
}

@Preview(
showBackground = true,
widthDp = 300,
heightDp = 600
)
@Composable
fun GreetingPreview() {
MeSDKTheme {
GenHomeScreen()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ fun HomeScreen(navController: NavHostController) {
style = MaterialTheme.typography.bodyLarge
)
}

// Gen AI Home screen
Button(
modifier = Modifier.padding(padding).fillMaxWidth(),
shape = MaterialTheme.shapes.medium,
onClick = { navController.navigate(Screen.GenHomeScreen.route) }
) {
Text(
"Generated AI Screen",
style = MaterialTheme.typography.bodyLarge
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.rocqjones.me_logic.models

data class CardInfo(val title: String, val description: String)
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ sealed class Screen(val route: String) {
object HomeScreen : Screen("homeScreen")
object EndlessScreen : Screen("endlessScreen")
object BottomSheetDialogScreen : Screen("bottomSheetDialogScreen")
object GenHomeScreen : Screen("genHomeScreen")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.rocqjones.me_logic.providers

import com.rocqjones.me_logic.models.CardInfo

object SampleDataSource {
val genList = listOf(
CardInfo("Tools for Compose", "Android Studio brings a lot of new features specifically for Jetpack Compose. It embraces a code-first approach while improving the developer productivity without having to choose between using design interface or code editor."),
CardInfo("Iterative code development", "As a mobile developer, you're often developing your app's UI step by step rather than developing everything at once. Android Studio embraces this approach with Jetpack Compose by providing tools that don't require a full build to inspect, modify values, and verify the final result."),
CardInfo("Live Edit", "Live Edit is a feature that lets you update composables in emulators and physical devices in real time. This functionality minimizes context switches between writing and building your app, letting you focus on writing code longer without interruption."),
CardInfo("Make and review changes", "As you make supported changes in the editor, the virtual or physical test device updates automatically."),
CardInfo("Make and review changes", "As you make supported changes in the editor, the virtual or physical test device updates automatically."),
CardInfo("Make and review changes", "As you make supported changes in the editor, the virtual or physical test device updates automatically."),
CardInfo("Iterative code development", "As a mobile developer, you're often developing your app's UI step by step rather than developing everything at once. Android Studio embraces this approach with Jetpack Compose by providing tools that don't require a full build to inspect, modify values, and verify the final result."),
CardInfo("Tools for Compose", "Android Studio brings a lot of new features specifically for Jetpack Compose. It embraces a code-first approach while improving the developer productivity without having to choose between using design interface or code editor."),
)
}

0 comments on commit 41e3395

Please sign in to comment.