Skip to content

Commit

Permalink
Move scroll related function
Browse files Browse the repository at this point in the history
  • Loading branch information
jbartok committed Jul 12, 2024
1 parent a68a602 commit 7adb6e1
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package org.gradle.client.ui.composables

import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontFamily
import org.gradle.client.ui.connected.horizontalScrollContent

@Composable
fun FailureContent(exception: Exception) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.gradle.client.ui.composables

import androidx.compose.foundation.HorizontalScrollbar
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.rememberScrollbarAdapter
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp


@Composable
fun horizontalScrollContent(
content: @Composable ColumnScope.() -> Unit,
) {
Box(
modifier = Modifier.fillMaxSize()
) {
val stateHorizontal = rememberScrollState(0)

Box(
modifier = Modifier
.fillMaxSize()
.padding(bottom = 12.dp)
.horizontalScroll(stateHorizontal)
) {
Column {
content()
}
}

HorizontalScrollbar(
modifier = Modifier
.align(Alignment.BottomStart)
.fillMaxWidth(),
adapter = rememberScrollbarAdapter(stateHorizontal)
)
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package org.gradle.client.ui.connected

import androidx.compose.foundation.HorizontalScrollbar
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.rememberScrollbarAdapter
import androidx.compose.foundation.selection.selectable
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.PlayCircle
Expand All @@ -13,7 +9,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.arkivanov.decompose.extensions.compose.subscribeAsState
import org.gradle.client.ui.composables.FailureContent
import org.gradle.client.ui.composables.Loading
Expand Down Expand Up @@ -110,32 +105,3 @@ private fun ConnectedMainContent(component: ConnectedComponent, model: Connectio
)
}
}

@Composable
fun horizontalScrollContent(
content: @Composable ColumnScope.() -> Unit,
) {
Box(
modifier = Modifier.fillMaxSize()
) {
val stateHorizontal = rememberScrollState(0)

Box(
modifier = Modifier
.fillMaxSize()
.padding(bottom = 12.dp)
.horizontalScroll(stateHorizontal)
) {
Column {
content()
}
}

HorizontalScrollbar(
modifier = Modifier
.align(Alignment.BottomStart)
.fillMaxWidth(),
adapter = rememberScrollbarAdapter(stateHorizontal)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import org.gradle.client.ui.connected.horizontalScrollContent
import org.gradle.client.ui.composables.horizontalScrollContent
import org.gradle.tooling.model.build.BuildEnvironment

class GetBuildEnvironment : GetModelAction<BuildEnvironment> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import org.gradle.client.ui.connected.horizontalScrollContent
import org.gradle.client.ui.composables.horizontalScrollContent
import org.gradle.tooling.model.gradle.GradleBuild

class GetGradleBuild : GetModelAction<GradleBuild> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import org.gradle.client.ui.connected.horizontalScrollContent
import org.gradle.client.ui.composables.horizontalScrollContent
import org.gradle.tooling.model.GradleProject

class GetGradleProject : GetModelAction<GradleProject> {
Expand Down

0 comments on commit 7adb6e1

Please sign in to comment.