From d27161eb9861b907b8322ea4dee3de669caf732b Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Thu, 21 Oct 2021 01:37:15 +0200 Subject: [PATCH] Added non-functional settings button --- src/main/kotlin/app/App.kt | 54 +++++++++++++------ .../app/ui/components/RepositoriesTabPanel.kt | 36 ++++++++----- src/main/resources/settings.svg | 1 + 3 files changed, 61 insertions(+), 30 deletions(-) create mode 100644 src/main/resources/settings.svg diff --git a/src/main/kotlin/app/App.kt b/src/main/kotlin/app/App.kt index 349a59b..03ceb89 100644 --- a/src/main/kotlin/app/App.kt +++ b/src/main/kotlin/app/App.kt @@ -5,12 +5,13 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.material.LinearProgressIndicator -import androidx.compose.material.MaterialTheme +import androidx.compose.material.* import androidx.compose.runtime.* +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.graphics.DefaultAlpha +import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import androidx.compose.ui.window.* import androidx.compose.ui.zIndex @@ -76,25 +77,44 @@ class Main { modifier = Modifier.background(MaterialTheme.colors.surface) ) { - RepositoriesTabPanel( + Row( modifier = Modifier .padding(top = 4.dp, bottom = 2.dp, start = 4.dp, end = 4.dp) .fillMaxWidth(), - tabs = tabs.value, - selectedTabKey = selectedTabKey, - onTabSelected = { newSelectedTabKey -> - selectedTabKey = newSelectedTabKey - }, - newTabContent = { key -> - newAppTab(key) - }, - onTabsUpdated = { tabInformationList -> - tabs.value = tabInformationList - }, - onTabClosed = { key -> - appStateManager.repositoryTabRemoved(key) + verticalAlignment = Alignment.CenterVertically, + ) { + RepositoriesTabPanel( + modifier = Modifier + .weight(1f), + tabs = tabs.value, + selectedTabKey = selectedTabKey, + onTabSelected = { newSelectedTabKey -> + selectedTabKey = newSelectedTabKey + }, + newTabContent = { key -> + newAppTab(key) + }, + onTabsUpdated = { tabInformationList -> + tabs.value = tabInformationList + }, + onTabClosed = { key -> + appStateManager.repositoryTabRemoved(key) + } + ) + IconButton( + modifier = Modifier + .padding(horizontal = 8.dp) + .size(24.dp), + onClick = {} + ) { + Icon( + painter = painterResource("settings.svg"), + contentDescription = null, + modifier = Modifier.fillMaxSize(), + tint = MaterialTheme.colors.primary, + ) } - ) + } LazyColumn( modifier = Modifier diff --git a/src/main/kotlin/app/ui/components/RepositoriesTabPanel.kt b/src/main/kotlin/app/ui/components/RepositoriesTabPanel.kt index 04a7515..2611082 100644 --- a/src/main/kotlin/app/ui/components/RepositoriesTabPanel.kt +++ b/src/main/kotlin/app/ui/components/RepositoriesTabPanel.kt @@ -1,8 +1,14 @@ package app.ui.components +import androidx.compose.foundation.HorizontalScrollbar import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* +import androidx.compose.foundation.lazy.LazyListScope +import androidx.compose.foundation.lazy.LazyRow +import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.lazy.rememberLazyListState +import androidx.compose.foundation.rememberScrollbarAdapter import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.* import androidx.compose.material.icons.Icons @@ -45,7 +51,7 @@ fun RepositoriesTabPanel( onTabsUpdated(tabsCopy) } ) { - tabs.forEach { tab -> + items(items = tabs) { tab -> Tab( title = tab.title, selected = tab.key == selectedTabKey, @@ -97,21 +103,25 @@ fun RepositoriesTabPanel( fun TabPanel( modifier: Modifier = Modifier, onNewTabClicked: () -> Unit, - tabs: @Composable RowScope.() -> Unit + tabs: LazyListScope.() -> Unit ) { - Row(modifier = modifier) { + LazyRow( + modifier = modifier, + ) { this.tabs() - IconButton( - onClick = onNewTabClicked, - modifier = Modifier - .size(36.dp), - ) { - Icon( - imageVector = Icons.Default.Add, - contentDescription = null, - tint = MaterialTheme.colors.primary - ) + item { + IconButton( + onClick = onNewTabClicked, + modifier = Modifier + .size(36.dp), + ) { + Icon( + imageVector = Icons.Default.Add, + contentDescription = null, + tint = MaterialTheme.colors.primary + ) + } } } } diff --git a/src/main/resources/settings.svg b/src/main/resources/settings.svg new file mode 100644 index 0000000..f53024e --- /dev/null +++ b/src/main/resources/settings.svg @@ -0,0 +1 @@ + \ No newline at end of file