forked from Writand/writand
Merge branch 'frontend/navigation' into 'main'
feat: setup of navigation and main screens files See merge request EmmaVandewalle/writand!31
This commit is contained in:
commit
273c36d2f8
12 changed files with 233 additions and 15 deletions
|
@ -66,6 +66,8 @@ dependencies {
|
||||||
implementation "androidx.compose.material3:material3:1.2.1"
|
implementation "androidx.compose.material3:material3:1.2.1"
|
||||||
implementation 'androidx.test:core-ktx:1.6.1'
|
implementation 'androidx.test:core-ktx:1.6.1'
|
||||||
implementation 'com.google.ar:core:1.44.0'
|
implementation 'com.google.ar:core:1.44.0'
|
||||||
|
implementation 'androidx.navigation:navigation-runtime-ktx:2.7.7'
|
||||||
|
implementation 'androidx.navigation:navigation-compose:2.7.7'
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
|
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
|
||||||
|
|
|
@ -9,7 +9,9 @@ import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.navigation.compose.rememberNavController
|
||||||
|
import be.re.writand.navigation.WNavGraph
|
||||||
import be.re.writand.ui.theme.WritandTheme
|
import be.re.writand.ui.theme.WritandTheme
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
|
@ -22,22 +24,12 @@ class MainActivity : ComponentActivity() {
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
color = MaterialTheme.colorScheme.primary
|
color = MaterialTheme.colorScheme.primary
|
||||||
) {
|
) {
|
||||||
Greeting("Android")
|
WNavGraph(
|
||||||
|
navHostController = rememberNavController(),
|
||||||
|
modifier = Modifier.padding(5.dp)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun Greeting(name: String) {
|
|
||||||
Text(text = "Hello $name!")
|
|
||||||
}
|
|
||||||
|
|
||||||
@Preview(showBackground = true)
|
|
||||||
@Composable
|
|
||||||
fun DefaultPreview() {
|
|
||||||
WritandTheme {
|
|
||||||
Greeting("Android")
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package be.re.writand.navigation
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All the destinations of the different screens the navigator can go to.
|
||||||
|
* They are categorized, so it's easier to find/add destinations.
|
||||||
|
*/
|
||||||
|
object WAppDestinations {
|
||||||
|
// Start of application
|
||||||
|
const val SPLASH = "splash"
|
||||||
|
|
||||||
|
// Welcome screens for first time user
|
||||||
|
const val WELCOME_START = "welcome_start"
|
||||||
|
const val WELCOME_TOS = "welcome_tos"
|
||||||
|
const val WELCOME_SETTINGS = "welcome_settings"
|
||||||
|
|
||||||
|
// Project picker
|
||||||
|
const val PROJECT_PICKER = "project_picker"
|
||||||
|
|
||||||
|
// Editor view
|
||||||
|
const val MAIN_EDITOR = "main_editor"
|
||||||
|
}
|
68
app/src/main/java/be/re/writand/navigation/WNavGraph.kt
Normal file
68
app/src/main/java/be/re/writand/navigation/WNavGraph.kt
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
package be.re.writand.navigation
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.navigation.compose.NavHost
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import androidx.navigation.compose.composable
|
||||||
|
import be.re.writand.screens.editor.EditorScreen
|
||||||
|
import be.re.writand.screens.projectpicker.ProjectPickerScreen
|
||||||
|
import be.re.writand.screens.splash.SplashScreen
|
||||||
|
import be.re.writand.screens.welcome.WelcomeSettingsScreen
|
||||||
|
import be.re.writand.screens.welcome.WelcomeStartScreen
|
||||||
|
import be.re.writand.screens.welcome.WelcomeTOSScreen
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The navigation controller containing all the different screens a user can go to.
|
||||||
|
* @param[navHostController] the controller to go from one screen to another and back.
|
||||||
|
* @param[modifier] the general modifier that should be applied to all screens.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
fun WNavGraph(navHostController: NavHostController, modifier: Modifier) {
|
||||||
|
|
||||||
|
val onBackArrow: () -> Unit = { navHostController.navigateUp() }
|
||||||
|
|
||||||
|
NavHost(
|
||||||
|
navController = navHostController,
|
||||||
|
startDestination = WAppDestinations.SPLASH,
|
||||||
|
modifier = modifier
|
||||||
|
) {
|
||||||
|
|
||||||
|
|
||||||
|
// Start of application
|
||||||
|
|
||||||
|
composable(WAppDestinations.SPLASH) {
|
||||||
|
SplashScreen(navHostController = navHostController)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Welcome screens for first time user
|
||||||
|
|
||||||
|
composable(WAppDestinations.WELCOME_START) {
|
||||||
|
WelcomeStartScreen(navHostController = navHostController)
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(WAppDestinations.WELCOME_TOS) {
|
||||||
|
WelcomeTOSScreen(navHostController = navHostController)
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(WAppDestinations.WELCOME_SETTINGS) {
|
||||||
|
WelcomeSettingsScreen(navHostController = navHostController)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Project picker
|
||||||
|
|
||||||
|
composable(WAppDestinations.PROJECT_PICKER) {
|
||||||
|
ProjectPickerScreen(navHostController = navHostController)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Editor view
|
||||||
|
|
||||||
|
composable(WAppDestinations.MAIN_EDITOR) {
|
||||||
|
EditorScreen(navHostController = navHostController)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package be.re.writand.screens.editor
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun EditorScreen(
|
||||||
|
navHostController: NavHostController
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package be.re.writand.screens.projectpicker
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import be.re.writand.navigation.WAppDestinations
|
||||||
|
import be.re.writand.screens.components.WButton
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ProjectPickerScreen(
|
||||||
|
navHostController: NavHostController
|
||||||
|
) {
|
||||||
|
|
||||||
|
Box(modifier = Modifier.size(20.dp, 20.dp)) {
|
||||||
|
WButton(
|
||||||
|
text = "Create new",
|
||||||
|
onClick = { navHostController.navigate(WAppDestinations.MAIN_EDITOR) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package be.re.writand.screens.splash
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import be.re.writand.navigation.WAppDestinations
|
||||||
|
import be.re.writand.screens.components.WButton
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun SplashScreen(
|
||||||
|
navHostController: NavHostController
|
||||||
|
) {
|
||||||
|
|
||||||
|
Box(modifier = Modifier.size(20.dp, 20.dp)) {
|
||||||
|
WButton(
|
||||||
|
text = "Some fancy screen where you click...",
|
||||||
|
// TODO: find out which screen is next
|
||||||
|
onClick = { navHostController.navigate(WAppDestinations.WELCOME_START) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package be.re.writand.screens.splash
|
||||||
|
|
||||||
|
class SplashViewModel {
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package be.re.writand.screens.welcome
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import be.re.writand.navigation.WAppDestinations
|
||||||
|
import be.re.writand.screens.components.WButton
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun WelcomeSettingsScreen(
|
||||||
|
navHostController: NavHostController
|
||||||
|
) {
|
||||||
|
|
||||||
|
Box(modifier = Modifier.size(20.dp, 20.dp)) {
|
||||||
|
WButton(
|
||||||
|
text = "Finish",
|
||||||
|
onClick = { navHostController.navigate(WAppDestinations.PROJECT_PICKER) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package be.re.writand.screens.welcome
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import be.re.writand.navigation.WAppDestinations
|
||||||
|
import be.re.writand.screens.components.WButton
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun WelcomeStartScreen(
|
||||||
|
navHostController: NavHostController
|
||||||
|
) {
|
||||||
|
|
||||||
|
Box(modifier = Modifier.size(20.dp, 20.dp)) {
|
||||||
|
WButton(
|
||||||
|
text = "Next",
|
||||||
|
onClick = { navHostController.navigate(WAppDestinations.WELCOME_TOS) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package be.re.writand.screens.welcome
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import be.re.writand.navigation.WAppDestinations
|
||||||
|
import be.re.writand.screens.components.WButton
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun WelcomeTOSScreen(
|
||||||
|
navHostController: NavHostController
|
||||||
|
) {
|
||||||
|
|
||||||
|
Box(modifier = Modifier.size(20.dp, 20.dp)) {
|
||||||
|
WButton(
|
||||||
|
text = "Next",
|
||||||
|
onClick = { navHostController.navigate(WAppDestinations.WELCOME_SETTINGS) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue