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.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
@ -28,6 +29,7 @@ import app.di.DaggerAppComponent
import app.theme.AppTheme
import app.theme.primaryTextColor
import app.theme.secondaryTextColor
import app.ui.AppTab
import app.ui.components.RepositoriesTabPanel
import app.ui.components.TabInformation
import app.ui.dialogs.SettingsDialog
@ -232,28 +234,13 @@ class App {
@Composable
private fun TabsContent(tabs: List<TabInformation>, selectedTabKey: Int) {
LazyColumn(
val selectedTab = tabs.firstOrNull { it.key == selectedTabKey } ?: return
Box(
modifier = Modifier
.fillMaxSize(),
) {
items(items = tabs, key = { it.key }) {
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)
}
}
AppTab(selectedTab.tabViewModel)
}
}

View File

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

View File

@ -101,7 +101,7 @@ fun Log(
if (logStatus is LogStatus.Loaded) {
val hasUncommitedChanges = logStatus.hasUncommitedChanges
val commitList = logStatus.plotCommitList
val verticalScrollState = rememberLazyListState()
val verticalScrollState by logViewModel.lazyListState.collectAsState()
val searchFilter = logViewModel.logSearchFilterResults.collectAsState()
val searchFilterValue = searchFilter.value
// 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
import androidx.compose.foundation.lazy.LazyListState
import app.git.*
import app.git.graph.GraphCommitList
import app.git.graph.GraphNode
@ -31,7 +32,6 @@ class LogViewModel @Inject constructor(
private val rebaseManager: RebaseManager,
private val tagsManager: TagsManager,
private val mergeManager: MergeManager,
private val repositoryManager: RepositoryManager,
private val remoteOperationsManager: RemoteOperationsManager,
private val tabState: TabState,
) {
@ -45,6 +45,12 @@ class LogViewModel @Inject constructor(
private val _focusCommit = MutableSharedFlow<GraphNode>()
val focusCommit: SharedFlow<GraphNode> = _focusCommit
val lazyListState = MutableStateFlow(
LazyListState(
0,
0
)
)
private val _logSearchFilterResults = MutableStateFlow<LogSearch>(LogSearch.NotSearching)
val logSearchFilterResults: StateFlow<LogSearch> = _logSearchFilterResults