Browse Source

Migrate to 0.3.0-build146 (issues example)

pull/328/head
Igor Demin 4 years ago
parent
commit
cda2c78aee
  1. 4
      examples/issues/build.gradle.kts
  2. 3
      examples/issues/common/src/jvmAndAndroidMain/kotlin/androidx/ui/examples/jetissues/data/Effects.kt
  3. 11
      examples/issues/common/src/jvmAndAndroidMain/kotlin/androidx/ui/examples/jetissues/view/JetIssuesView.kt

4
examples/issues/build.gradle.kts

@ -9,10 +9,10 @@ buildscript {
dependencies {
// __LATEST_COMPOSE_RELEASE_VERSION__
classpath("org.jetbrains.compose:compose-gradle-plugin:0.3.0-build135")
classpath("org.jetbrains.compose:compose-gradle-plugin:0.3.0-build146")
classpath("com.android.tools.build:gradle:4.0.1")
// __KOTLIN_COMPOSE_VERSION__
classpath(kotlin("gradle-plugin", version = "1.4.21"))
classpath(kotlin("gradle-plugin", version = "1.4.21-2"))
}
}

3
examples/issues/common/src/jvmAndAndroidMain/kotlin/androidx/ui/examples/jetissues/data/Effects.kt

@ -17,7 +17,7 @@ fun <T> uiStateFrom(
): MutableState<UiState<T>> {
val state: MutableState<UiState<T>> = remember { mutableStateOf(UiState.Loading) }
onCommit(*inputs) {
DisposableEffect(*inputs) {
state.value = UiState.Loading
repositoryCall { result ->
state.value = when (result) {
@ -25,6 +25,7 @@ fun <T> uiStateFrom(
is Result.Error -> UiState.Error(result.exception)
}
}
onDispose { }
}
return state

11
examples/issues/common/src/jvmAndAndroidMain/kotlin/androidx/ui/examples/jetissues/view/JetIssuesView.kt

@ -18,14 +18,12 @@ import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.luminance
import androidx.compose.ui.layout.WithConstraints
import androidx.compose.ui.selection.DisableSelection
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
@ -38,6 +36,7 @@ import androidx.ui.examples.jetissues.query.IssueQuery
import androidx.ui.examples.jetissues.query.IssuesQuery
import androidx.ui.examples.jetissues.query.type.OrderDirection
import androidx.ui.examples.jetissues.view.common.SelectionContainer
import kotlinx.coroutines.runBlocking
import org.ocpsoft.prettytime.PrettyTime
import java.lang.Integer.parseInt
import java.util.*
@ -59,7 +58,7 @@ fun JetIssuesView() {
@Composable
fun Main() {
val currentIssue: MutableState<IssuesQuery.Node?> = remember { mutableStateOf(null) }
WithConstraints {
BoxWithConstraints {
if (maxWidth.value > 1000) {
TwoColumnsLayout(currentIssue)
} else {
@ -203,14 +202,18 @@ fun OrderButton(order: MutableState<OrderDirection>, scroll: ScrollState) {
OrderDirection.DESC ->
Button(onClick = {
order.value = OrderDirection.ASC
runBlocking {
scroll.scrollTo(0F)
}
}) {
Text("ASC")
}
OrderDirection.ASC ->
Button(onClick = {
order.value = OrderDirection.DESC
runBlocking {
scroll.scrollTo(0F)
}
}) {
Text("DESC")
}
@ -228,8 +231,10 @@ fun FilterTabs(issuesState: MutableState<IssuesState>, scroll: ScrollState) {
selected = issuesState.value == it,
onClick = {
issuesState.value = it
runBlocking {
scroll.scrollTo(0F)
}
}
)
}
}

Loading…
Cancel
Save