Started replacement of the old tabs system with the new one

This commit is contained in:
Abdelilah El Aissaoui 2022-04-08 20:21:56 +02:00
parent fac5cbf16a
commit 4f84c38fb4
4 changed files with 17 additions and 24 deletions

View File

@ -15,6 +15,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@ -28,6 +29,7 @@ import app.di.DaggerAppComponent
import app.theme.AppTheme import app.theme.AppTheme
import app.theme.primaryTextColor import app.theme.primaryTextColor
import app.theme.secondaryTextColor import app.theme.secondaryTextColor
import app.ui.AppTab
import app.ui.components.RepositoriesTabPanel import app.ui.components.RepositoriesTabPanel
import app.ui.components.TabInformation import app.ui.components.TabInformation
import app.ui.dialogs.SettingsDialog import app.ui.dialogs.SettingsDialog
@ -232,28 +234,13 @@ class App {
@Composable @Composable
private fun TabsContent(tabs: List<TabInformation>, selectedTabKey: Int) { private fun TabsContent(tabs: List<TabInformation>, selectedTabKey: Int) {
LazyColumn( val selectedTab = tabs.firstOrNull { it.key == selectedTabKey } ?: return
Box(
modifier = Modifier modifier = Modifier
.fillMaxSize(), .fillMaxSize(),
) { ) {
items(items = tabs, key = { it.key }) { AppTab(selectedTab.tabViewModel)
val isItemSelected = it.key == selectedTabKey
var tabMod: Modifier = if (!isItemSelected)
Modifier.size(0.dp)
else
Modifier
.fillParentMaxSize()
tabMod = tabMod.background(MaterialTheme.colors.primary)
.alpha(if (isItemSelected) 1f else -1f)
.zIndex(if (isItemSelected) 1f else -1f)
Box(
modifier = tabMod,
) {
it.content(it)
}
}
} }
} }

View File

@ -28,9 +28,9 @@ fun RepositoryOpenPage(tabViewModel: TabViewModel) {
val selectedItem by tabViewModel.selectedItem.collectAsState() val selectedItem by tabViewModel.selectedItem.collectAsState()
var showNewBranchDialog by remember { mutableStateOf(false) } var showNewBranchDialog by remember { mutableStateOf(false) }
LaunchedEffect(selectedItem) { // LaunchedEffect(selectedItem) {
tabViewModel.newDiffSelected = null // tabViewModel.newDiffSelected = null
} // }
if (showNewBranchDialog) { if (showNewBranchDialog) {
NewBranchDialog( NewBranchDialog(

View File

@ -101,7 +101,7 @@ fun Log(
if (logStatus is LogStatus.Loaded) { if (logStatus is LogStatus.Loaded) {
val hasUncommitedChanges = logStatus.hasUncommitedChanges val hasUncommitedChanges = logStatus.hasUncommitedChanges
val commitList = logStatus.plotCommitList val commitList = logStatus.plotCommitList
val verticalScrollState = rememberLazyListState() val verticalScrollState by logViewModel.lazyListState.collectAsState()
val searchFilter = logViewModel.logSearchFilterResults.collectAsState() val searchFilter = logViewModel.logSearchFilterResults.collectAsState()
val searchFilterValue = searchFilter.value val searchFilterValue = searchFilter.value
// With this method, whenever the scroll changes, the log is recomposed and the graph list is updated with // With this method, whenever the scroll changes, the log is recomposed and the graph list is updated with

View File

@ -1,5 +1,6 @@
package app.viewmodels package app.viewmodels
import androidx.compose.foundation.lazy.LazyListState
import app.git.* import app.git.*
import app.git.graph.GraphCommitList import app.git.graph.GraphCommitList
import app.git.graph.GraphNode import app.git.graph.GraphNode
@ -31,7 +32,6 @@ class LogViewModel @Inject constructor(
private val rebaseManager: RebaseManager, private val rebaseManager: RebaseManager,
private val tagsManager: TagsManager, private val tagsManager: TagsManager,
private val mergeManager: MergeManager, private val mergeManager: MergeManager,
private val repositoryManager: RepositoryManager,
private val remoteOperationsManager: RemoteOperationsManager, private val remoteOperationsManager: RemoteOperationsManager,
private val tabState: TabState, private val tabState: TabState,
) { ) {
@ -45,6 +45,12 @@ class LogViewModel @Inject constructor(
private val _focusCommit = MutableSharedFlow<GraphNode>() private val _focusCommit = MutableSharedFlow<GraphNode>()
val focusCommit: SharedFlow<GraphNode> = _focusCommit val focusCommit: SharedFlow<GraphNode> = _focusCommit
val lazyListState = MutableStateFlow(
LazyListState(
0,
0
)
)
private val _logSearchFilterResults = MutableStateFlow<LogSearch>(LogSearch.NotSearching) private val _logSearchFilterResults = MutableStateFlow<LogSearch>(LogSearch.NotSearching)
val logSearchFilterResults: StateFlow<LogSearch> = _logSearchFilterResults val logSearchFilterResults: StateFlow<LogSearch> = _logSearchFilterResults