Skip to content

Commit 09366c0

Browse files
Merge pull request #2
Create UI draft
2 parents dd43efb + 60df0bc commit 09366c0

File tree

9 files changed

+652
-26
lines changed

9 files changed

+652
-26
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ dependencies {
4949
implementation(libs.androidx.ui.graphics)
5050
implementation(libs.androidx.ui.tooling.preview)
5151
implementation(libs.androidx.material3)
52+
implementation(libs.androidx.navigation.compose)
5253
testImplementation(libs.junit)
5354
androidTestImplementation(libs.androidx.junit)
5455
androidTestImplementation(libs.androidx.espresso.core)

app/src/main/java/org/vonderheidt/hips/MainActivity.kt

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,34 @@ package org.vonderheidt.hips
33
import android.os.Bundle
44
import androidx.activity.ComponentActivity
55
import androidx.activity.compose.setContent
6-
import androidx.activity.enableEdgeToEdge
76
import androidx.compose.foundation.layout.fillMaxSize
87
import androidx.compose.foundation.layout.padding
98
import androidx.compose.material3.Scaffold
10-
import androidx.compose.material3.Text
11-
import androidx.compose.runtime.Composable
129
import androidx.compose.ui.Modifier
13-
import androidx.compose.ui.tooling.preview.Preview
10+
import org.vonderheidt.hips.navigation.SetupNavGraph
1411
import org.vonderheidt.hips.ui.theme.HiPSTheme
1512

13+
/**
14+
* Class that defines the entry point into the app and calls the main screen.
15+
*/
1616
class MainActivity : ComponentActivity() {
17+
// Boilerplate code
1718
override fun onCreate(savedInstanceState: Bundle?) {
1819
super.onCreate(savedInstanceState)
19-
enableEdgeToEdge()
20+
21+
// Set MainScreen function as content of the main screen
2022
setContent {
23+
// Use HiPS theme for dark and light mode
2124
HiPSTheme {
25+
// Scaffold arranges top bar/bottom bar/floating action buttons/etc. on screen
26+
// innerPadding is necessary so that content and top bar/etc. don't overlap
2227
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
23-
Greeting(
24-
name = "Android",
25-
modifier = Modifier.padding(innerPadding)
26-
)
28+
val modifier: Modifier = Modifier.padding(innerPadding)
29+
30+
// Initialize navigation
31+
SetupNavGraph(modifier)
2732
}
2833
}
2934
}
3035
}
31-
}
32-
33-
@Composable
34-
fun Greeting(name: String, modifier: Modifier = Modifier) {
35-
Text(
36-
text = "Hello $name!",
37-
modifier = modifier
38-
)
39-
}
40-
41-
@Preview(showBackground = true)
42-
@Composable
43-
fun GreetingPreview() {
44-
HiPSTheme {
45-
Greeting("Android")
46-
}
4736
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.vonderheidt.hips.navigation
2+
3+
import androidx.compose.runtime.Composable
4+
import androidx.compose.ui.Modifier
5+
import androidx.navigation.NavHostController
6+
import androidx.navigation.compose.NavHost
7+
import androidx.navigation.compose.composable
8+
import androidx.navigation.compose.rememberNavController
9+
import org.vonderheidt.hips.ui.screens.HomeScreen
10+
import org.vonderheidt.hips.ui.screens.SettingsScreen
11+
12+
/**
13+
* Function that initializes the navigation.
14+
*/
15+
@Composable
16+
fun SetupNavGraph(modifier: Modifier) {
17+
val navController: NavHostController = rememberNavController()
18+
19+
NavHost(
20+
navController = navController,
21+
startDestination = Screen.Home.route
22+
) {
23+
composable(Screen.Home.route) { HomeScreen(navController, modifier) }
24+
composable(Screen.Settings.route) { SettingsScreen(navController, modifier) }
25+
}
26+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.vonderheidt.hips.navigation
2+
3+
/**
4+
* Class that defines routes to all screens.
5+
*/
6+
sealed class Screen(val route: String) {
7+
object Home: Screen("home")
8+
object Settings: Screen("settings")
9+
}

0 commit comments

Comments
 (0)