|
|
|
@ -9,7 +9,6 @@ import androidx.compose.foundation.background
|
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
|
import androidx.compose.material3.DrawerState
|
|
|
|
|
import androidx.compose.material3.DrawerValue
|
|
|
|
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
|
|
import androidx.compose.material3.SheetValue
|
|
|
|
@ -26,6 +25,7 @@ import androidx.compose.runtime.rememberCoroutineScope
|
|
|
|
|
import androidx.compose.runtime.setValue
|
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.platform.LocalFocusManager
|
|
|
|
|
import androidx.hilt.navigation.compose.hiltViewModel
|
|
|
|
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
|
|
|
|
import androidx.navigation.NavHostController
|
|
|
|
@ -63,31 +63,17 @@ private val topLevelDestinations = listOf(
|
|
|
|
|
@Composable
|
|
|
|
|
fun MainScreen(
|
|
|
|
|
navController: NavHostController = rememberNavController(),
|
|
|
|
|
drawerState: DrawerState = rememberDrawerState(initialValue = DrawerValue.Closed),
|
|
|
|
|
startDestination: String = Routes.PUBLIC_BETS,
|
|
|
|
|
mainViewModel: MainViewModel = hiltViewModel(),
|
|
|
|
|
navigateToWelcomeScreen: () -> Unit
|
|
|
|
|
) {
|
|
|
|
|
val scope = rememberCoroutineScope()
|
|
|
|
|
|
|
|
|
|
val (loading, setLoading) = remember { mainViewModel.loading }
|
|
|
|
|
val currentUser by mainViewModel.currentUser.collectAsStateWithLifecycle()
|
|
|
|
|
val selectedBet by remember { mainViewModel.selectedBet }
|
|
|
|
|
val statusVisibility = remember { mutableStateOf(false) }
|
|
|
|
|
val sheetBackVisibility = remember { mutableStateOf(false) }
|
|
|
|
|
val setStatusVisibility = { it: Boolean ->
|
|
|
|
|
statusVisibility.value = it
|
|
|
|
|
if (it) sheetBackVisibility.value = true
|
|
|
|
|
}
|
|
|
|
|
val (participateSheetVisibility, setParticipateSheetVisibility) = remember { mutableStateOf(false) }
|
|
|
|
|
val focusManager = LocalFocusManager.current
|
|
|
|
|
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
|
|
|
|
|
|
|
|
|
val events = remember { mainViewModel.events }
|
|
|
|
|
val eventBottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
|
|
|
|
|
|
|
|
|
val betStatusDisplayer = remember {
|
|
|
|
|
BetStatusBottomSheetBetDisplayer(
|
|
|
|
|
openParticipateSheet = { setParticipateSheetVisibility(true) }
|
|
|
|
|
)
|
|
|
|
|
LaunchedEffect(key1 = drawerState.targetValue) {
|
|
|
|
|
focusManager.clearFocus()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val snackbarHostState = remember { SnackbarHostState() }
|
|
|
|
@ -111,6 +97,26 @@ fun MainScreen(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val (loading, setLoading) = remember { mainViewModel.loading }
|
|
|
|
|
val currentUser by mainViewModel.currentUser.collectAsStateWithLifecycle()
|
|
|
|
|
val selectedBet by remember { mainViewModel.selectedBet }
|
|
|
|
|
val statusVisibility = remember { mutableStateOf(false) }
|
|
|
|
|
val sheetBackVisibility = remember { mutableStateOf(false) }
|
|
|
|
|
val setStatusVisibility = { it: Boolean ->
|
|
|
|
|
statusVisibility.value = it
|
|
|
|
|
if (it) sheetBackVisibility.value = true
|
|
|
|
|
}
|
|
|
|
|
val (participateSheetVisibility, setParticipateSheetVisibility) = remember { mutableStateOf(false) }
|
|
|
|
|
|
|
|
|
|
val events = remember { mainViewModel.events }
|
|
|
|
|
val eventBottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
|
|
|
|
|
|
|
|
|
val betStatusDisplayer = remember {
|
|
|
|
|
BetStatusBottomSheetBetDisplayer(
|
|
|
|
|
openParticipateSheet = { setParticipateSheetVisibility(true) }
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val statusBottomSheetState = rememberModalBottomSheetState(
|
|
|
|
|
skipPartiallyExpanded = true,
|
|
|
|
|
confirmValueChange = {
|
|
|
|
|