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. 17
      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 { dependencies {
// __LATEST_COMPOSE_RELEASE_VERSION__ // __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") classpath("com.android.tools.build:gradle:4.0.1")
// __KOTLIN_COMPOSE_VERSION__ // __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>> { ): MutableState<UiState<T>> {
val state: MutableState<UiState<T>> = remember { mutableStateOf(UiState.Loading) } val state: MutableState<UiState<T>> = remember { mutableStateOf(UiState.Loading) }
onCommit(*inputs) { DisposableEffect(*inputs) {
state.value = UiState.Loading state.value = UiState.Loading
repositoryCall { result -> repositoryCall { result ->
state.value = when (result) { state.value = when (result) {
@ -25,6 +25,7 @@ fun <T> uiStateFrom(
is Result.Error -> UiState.Error(result.exception) is Result.Error -> UiState.Error(result.exception)
} }
} }
onDispose { }
} }
return state return state

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

Loading…
Cancel
Save