Skip to content

Commit

Permalink
Merge pull request #21 from Kaaveh/bugfix/baseviewmodel_instance
Browse files Browse the repository at this point in the history
[bugfix] handle instance of baseViewModel
  • Loading branch information
Kaaveh authored Jan 24, 2023
2 parents 2d10dc9 + 2aa77aa commit 673ab2a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/src/main/java/ir/kaaveh/composenews/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import androidx.compose.material.Scaffold
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.material.icons.filled.Home
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
import androidx.navigation.compose.currentBackStackEntryAsState
Expand All @@ -26,9 +30,6 @@ import ir.kaaveh.navigation.Destinations
@AndroidEntryPoint
class MainActivity : ComponentActivity() {

// TODO: handle viewModel more properly
private var baseViewModel: BaseViewModel = BaseViewModel()

private val items = listOf(
BottomNavItem(
name = "News",
Expand All @@ -47,6 +48,10 @@ class MainActivity : ComponentActivity() {
setContent {
ComposeNewsTheme {

// TODO: handle viewModel more properly
var baseViewModel: BaseViewModel by remember {
mutableStateOf(BaseViewModel())
}
val navController = rememberNavController()
val backStackEntry = navController.currentBackStackEntryAsState()
val currentScreenRoute = backStackEntry.value?.destination?.route
Expand Down

0 comments on commit 673ab2a

Please sign in to comment.