pref: 状态屏优化
This commit is contained in:
parent
4fec7205da
commit
c68645b1e5
|
|
@ -26,6 +26,7 @@ import com.airbnb.lottie.compose.rememberLottieComposition
|
||||||
import com.huanchengfly.tieba.post.R
|
import com.huanchengfly.tieba.post.R
|
||||||
import com.huanchengfly.tieba.post.api.retrofit.exception.NoConnectivityException
|
import com.huanchengfly.tieba.post.api.retrofit.exception.NoConnectivityException
|
||||||
import com.huanchengfly.tieba.post.api.retrofit.exception.TiebaApiException
|
import com.huanchengfly.tieba.post.api.retrofit.exception.TiebaApiException
|
||||||
|
import com.huanchengfly.tieba.post.api.retrofit.exception.TiebaNotLoggedInException
|
||||||
import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorCode
|
import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorCode
|
||||||
import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorMessage
|
import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorMessage
|
||||||
import com.huanchengfly.tieba.post.arch.BaseComposeActivity.Companion.LocalWindowSizeClass
|
import com.huanchengfly.tieba.post.arch.BaseComposeActivity.Companion.LocalWindowSizeClass
|
||||||
|
|
@ -80,6 +81,7 @@ fun TipScreen(
|
||||||
enum class ErrorType {
|
enum class ErrorType {
|
||||||
NETWORK,
|
NETWORK,
|
||||||
SERVER,
|
SERVER,
|
||||||
|
NOT_LOGGED_IN,
|
||||||
UNKNOWN
|
UNKNOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,6 +116,7 @@ fun ErrorTipScreen(
|
||||||
val errorType = when (error) {
|
val errorType = when (error) {
|
||||||
is NoConnectivityException -> ErrorType.NETWORK
|
is NoConnectivityException -> ErrorType.NETWORK
|
||||||
is TiebaApiException -> ErrorType.SERVER
|
is TiebaApiException -> ErrorType.SERVER
|
||||||
|
is TiebaNotLoggedInException -> ErrorType.NOT_LOGGED_IN
|
||||||
else -> ErrorType.UNKNOWN
|
else -> ErrorType.UNKNOWN
|
||||||
}
|
}
|
||||||
val errorMessage = error.getErrorMessage()
|
val errorMessage = error.getErrorMessage()
|
||||||
|
|
@ -150,6 +153,10 @@ fun ErrorTipScreen(
|
||||||
ErrorType.UNKNOWN -> {
|
ErrorType.UNKNOWN -> {
|
||||||
Text(text = stringResource(id = R.string.title_unknown_error))
|
Text(text = stringResource(id = R.string.title_unknown_error))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorType.NOT_LOGGED_IN -> {
|
||||||
|
Text(text = stringResource(id = R.string.title_not_logged_in))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
|
|
@ -186,6 +193,16 @@ fun ErrorTipScreen(
|
||||||
.aspectRatio(2f)
|
.aspectRatio(2f)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorType.NOT_LOGGED_IN -> {
|
||||||
|
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.lottie_astronaut))
|
||||||
|
LottieAnimation(
|
||||||
|
composition = composition,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.aspectRatio(2f)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
message = {
|
message = {
|
||||||
|
|
@ -210,6 +227,10 @@ fun ErrorTipScreen(
|
||||||
ErrorType.UNKNOWN -> {
|
ErrorType.UNKNOWN -> {
|
||||||
Text(text = stringResource(id = R.string.message_unknown_error))
|
Text(text = stringResource(id = R.string.message_unknown_error))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorType.NOT_LOGGED_IN -> {
|
||||||
|
Text(text = stringResource(id = R.string.message_not_logged_in))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
appendMessage()
|
appendMessage()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ import com.airbnb.lottie.compose.LottieConstants
|
||||||
import com.airbnb.lottie.compose.rememberLottieComposition
|
import com.airbnb.lottie.compose.rememberLottieComposition
|
||||||
import com.huanchengfly.tieba.post.R
|
import com.huanchengfly.tieba.post.R
|
||||||
import com.huanchengfly.tieba.post.ui.common.theme.compose.ExtendedTheme
|
import com.huanchengfly.tieba.post.ui.common.theme.compose.ExtendedTheme
|
||||||
import com.huanchengfly.tieba.post.ui.widgets.compose.EmptyPlaceholder
|
import com.huanchengfly.tieba.post.ui.widgets.compose.Button
|
||||||
|
import com.huanchengfly.tieba.post.ui.widgets.compose.TipScreen
|
||||||
|
|
||||||
val DefaultLoadingScreen: @Composable StateScreenScope.() -> Unit = {
|
val DefaultLoadingScreen: @Composable StateScreenScope.() -> Unit = {
|
||||||
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.lottie_loading_paperplane))
|
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.lottie_loading_paperplane))
|
||||||
|
|
@ -34,7 +35,26 @@ val DefaultLoadingScreen: @Composable StateScreenScope.() -> Unit = {
|
||||||
}
|
}
|
||||||
|
|
||||||
val DefaultEmptyScreen: @Composable StateScreenScope.() -> Unit = {
|
val DefaultEmptyScreen: @Composable StateScreenScope.() -> Unit = {
|
||||||
EmptyPlaceholder()
|
TipScreen(
|
||||||
|
title = { Text(text = stringResource(id = R.string.title_empty)) },
|
||||||
|
image = {
|
||||||
|
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.lottie_empty_box))
|
||||||
|
LottieAnimation(
|
||||||
|
composition = composition,
|
||||||
|
iterations = LottieConstants.IterateForever,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.aspectRatio(2f)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
actions = {
|
||||||
|
if (canReload) {
|
||||||
|
Button(onClick = { reload() }) {
|
||||||
|
Text(text = stringResource(id = R.string.btn_refresh))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val DefaultErrorScreen: @Composable StateScreenScope.() -> Unit = {
|
val DefaultErrorScreen: @Composable StateScreenScope.() -> Unit = {
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -657,4 +657,6 @@
|
||||||
<string name="message_no_internet_connectivity">%s。请检查你的网络连接是否正常</string>
|
<string name="message_no_internet_connectivity">%s。请检查你的网络连接是否正常</string>
|
||||||
<string name="message_unknown_error">哦我的老伙计,我向你保证这真的是一个奇怪的错误……</string>
|
<string name="message_unknown_error">哦我的老伙计,我向你保证这真的是一个奇怪的错误……</string>
|
||||||
<string name="btn_reload">重新加载</string>
|
<string name="btn_reload">重新加载</string>
|
||||||
|
<string name="title_not_logged_in">你尚未登录</string>
|
||||||
|
<string name="message_not_logged_in">请登录后继续访问</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue