-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
107 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
app/src/main/java/com/github/jvsena42/floresta/presentation/MainActivity.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/github/jvsena42/floresta/presentation/ui/screens/main/Destinations.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.github.jvsena42.floresta.presentation.ui.screens.main | ||
|
||
import androidx.annotation.DrawableRes | ||
import com.github.jvsena42.floresta.R | ||
|
||
|
||
|
||
enum class Destinations( | ||
val route: String, | ||
val label: String, | ||
@DrawableRes val icon: Int | ||
) { | ||
HOME(route = "Home", label = "Home", R.drawable.ic_add) | ||
} |
90 changes: 90 additions & 0 deletions
90
app/src/main/java/com/github/jvsena42/floresta/presentation/ui/screens/main/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.github.jvsena42.floresta.presentation.ui.screens.main | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.activity.enableEdgeToEdge | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.foundation.shape.CornerSize | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.NavigationBar | ||
import androidx.compose.material3.NavigationBarDefaults | ||
import androidx.compose.material3.NavigationBarItem | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.unit.dp | ||
import androidx.navigation.NavGraph.Companion.findStartDestination | ||
import androidx.navigation.compose.NavHost | ||
import androidx.navigation.compose.composable | ||
import androidx.navigation.compose.rememberNavController | ||
import com.github.jvsena42.floresta.presentation.ui.screens.home.ScreenHome | ||
import com.github.jvsena42.floresta.presentation.ui.theme.FlorestaTheme | ||
import com.github.jvsena42.floresta.presentation.ui.theme.Primary | ||
import org.koin.androidx.compose.KoinAndroidContext | ||
|
||
class MainActivity : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
enableEdgeToEdge() | ||
setContent { | ||
var navigationSelectedItem by remember { mutableStateOf(Destinations.HOME) } | ||
val navController = rememberNavController() | ||
|
||
FlorestaTheme { | ||
KoinAndroidContext { | ||
Scaffold(modifier = Modifier.fillMaxSize(), | ||
bottomBar = { | ||
NavigationBar( | ||
containerColor = Primary | ||
) { | ||
Destinations.entries.forEach { destination -> | ||
NavigationBarItem( | ||
selected = destination == navigationSelectedItem, | ||
onClick = { | ||
navigationSelectedItem = destination | ||
navController.navigate(destination.route) { | ||
popUpTo(navController.graph.findStartDestination().id) { | ||
saveState = true | ||
} | ||
launchSingleTop = true | ||
restoreState = true | ||
} | ||
}, | ||
label = { | ||
destination.label | ||
}, | ||
icon = { | ||
Icon( | ||
painter = painterResource(destination.icon), | ||
contentDescription = destination.label | ||
) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
) { innerPadding -> | ||
NavHost( | ||
navController = navController, | ||
startDestination = Destinations.HOME.route, | ||
modifier = Modifier.padding(paddingValues = innerPadding) | ||
) { | ||
composable(Destinations.HOME.route) { | ||
ScreenHome() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...42/floresta/presentation/MainViewmodel.kt → ...entation/ui/screens/main/MainViewmodel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters