diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/main/home/HomePage.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/main/home/HomePage.kt index 16f0767f..176ad62a 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/main/home/HomePage.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/main/home/HomePage.kt @@ -82,6 +82,7 @@ import com.huanchengfly.tieba.post.ui.widgets.compose.Avatar import com.huanchengfly.tieba.post.ui.widgets.compose.Button import com.huanchengfly.tieba.post.ui.widgets.compose.ConfirmDialog import com.huanchengfly.tieba.post.ui.widgets.compose.LongClickMenu +import com.huanchengfly.tieba.post.ui.widgets.compose.TextButton import com.huanchengfly.tieba.post.ui.widgets.compose.Toolbar import com.huanchengfly.tieba.post.ui.widgets.compose.accountNavIconIfCompact import com.huanchengfly.tieba.post.ui.widgets.compose.rememberDialogState @@ -380,7 +381,7 @@ fun HomePage( val context = LocalContext.current val isLoading by viewModel.uiState.collectPartialAsState( prop1 = HomeUiState::isLoading, - initial = false + initial = true ) val forums by viewModel.uiState.collectPartialAsState( prop1 = HomeUiState::forums, @@ -577,15 +578,15 @@ fun EmptyScreen( .fillMaxWidth() .aspectRatio(2f) ) - Text( - text = stringResource(id = R.string.title_empty), - style = MaterialTheme.typography.h6, - color = ExtendedTheme.colors.text, - textAlign = TextAlign.Center, - ) if (!loggedIn) { Text( text = stringResource(id = R.string.title_empty_login), + style = MaterialTheme.typography.h6, + color = ExtendedTheme.colors.text, + textAlign = TextAlign.Center, + ) + Text( + text = stringResource(id = R.string.home_empty_login), style = MaterialTheme.typography.body1, color = ExtendedTheme.colors.textSecondary, textAlign = TextAlign.Center @@ -599,9 +600,16 @@ fun EmptyScreen( ) { Text(text = stringResource(id = R.string.button_login)) } + } else { + Text( + text = stringResource(id = R.string.title_empty), + style = MaterialTheme.typography.h6, + color = ExtendedTheme.colors.text, + textAlign = TextAlign.Center, + ) } if (canOpenExplore) { - Button( + TextButton( onClick = onOpenExplore, modifier = Modifier .fillMaxWidth() diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/widgets/compose/Buttons.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/widgets/compose/Buttons.kt index 133f5f1a..7a0d01a5 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/widgets/compose/Buttons.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/widgets/compose/Buttons.kt @@ -11,6 +11,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.ButtonColors import androidx.compose.material.ButtonDefaults import androidx.compose.material.ButtonElevation +import androidx.compose.material.ContentAlpha import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.LocalContentAlpha import androidx.compose.material.MaterialTheme @@ -22,6 +23,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Shape import androidx.compose.ui.unit.dp import com.huanchengfly.tieba.post.ui.common.theme.compose.ExtendedTheme @@ -69,4 +71,34 @@ fun Button( } } } +} + +@Composable +fun TextButton( + onClick: () -> Unit, + modifier: Modifier = Modifier, + enabled: Boolean = true, + interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, + shape: Shape = RoundedCornerShape(100), + border: BorderStroke? = null, + color: Color = ExtendedTheme.colors.text, + contentPadding: PaddingValues = ButtonDefaults.ContentPadding, + content: @Composable RowScope.() -> Unit +) { + Button( + onClick = onClick, + modifier = modifier, + enabled = enabled, + interactionSource = interactionSource, + shape = shape, + border = border, + colors = ButtonDefaults.buttonColors( + backgroundColor = color.copy(alpha = 0.1f), + contentColor = color, + disabledBackgroundColor = color.copy(alpha = ContentAlpha.disabled * 0.1f), + disabledContentColor = color.copy(alpha = ContentAlpha.disabled) + ), + contentPadding = contentPadding, + content = content + ) } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ee56f885..aa4c02d0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -645,7 +645,8 @@ 链接 用户 这里什么都没有 - 请登录之后查看你的关注。\n或者你也可以先去逛逛发现? + 请登录之后查看你的关注。\n或者你也可以先去逛逛发现? 去登录 随便看看 + 你还未登录