mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-11-22 01:55:22 +01:00
All empty states now have the same style
This commit is contained in:
parent
1abced992b
commit
1cd5563b27
@ -7,18 +7,14 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.ui.theme.AppTheme
|
||||
|
||||
@ -28,23 +24,15 @@ fun EmptyStateComposable(
|
||||
modifier: Modifier = Modifier,
|
||||
) = EmptyStateComposable(
|
||||
modifier = spec.modifier(modifier),
|
||||
emojiModifier = spec.emojiModifier(),
|
||||
emojiText = spec.emojiText(),
|
||||
emojiTextStyle = spec.emojiTextStyle(),
|
||||
descriptionModifier = spec.descriptionModifier(),
|
||||
descriptionText = spec.descriptionText(),
|
||||
descriptionTextStyle = spec.descriptionTextStyle(),
|
||||
)
|
||||
|
||||
@Composable
|
||||
private fun EmptyStateComposable(
|
||||
modifier: Modifier,
|
||||
emojiModifier: Modifier,
|
||||
emojiText: String,
|
||||
emojiTextStyle: TextStyle,
|
||||
descriptionModifier: Modifier,
|
||||
descriptionText: String,
|
||||
descriptionTextStyle: TextStyle,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier,
|
||||
@ -52,15 +40,16 @@ private fun EmptyStateComposable(
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(
|
||||
modifier = emojiModifier,
|
||||
text = emojiText,
|
||||
style = emojiTextStyle,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
)
|
||||
|
||||
Text(
|
||||
modifier = descriptionModifier,
|
||||
modifier = Modifier
|
||||
.padding(top = 6.dp)
|
||||
.padding(horizontal = 16.dp),
|
||||
text = descriptionText,
|
||||
style = descriptionTextStyle,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -83,12 +72,8 @@ fun EmptyStateComposableNoCommentPreview() {
|
||||
|
||||
data class EmptyStateSpec(
|
||||
val modifier: (Modifier) -> Modifier,
|
||||
val emojiModifier: () -> Modifier,
|
||||
val emojiText: @Composable () -> String,
|
||||
val emojiTextStyle: @Composable () -> TextStyle,
|
||||
val descriptionText: @Composable () -> String,
|
||||
val descriptionModifier: () -> Modifier,
|
||||
val descriptionTextStyle: @Composable () -> TextStyle,
|
||||
) {
|
||||
companion object {
|
||||
|
||||
@ -99,34 +84,15 @@ data class EmptyStateSpec(
|
||||
.fillMaxWidth()
|
||||
.heightIn(min = 128.dp)
|
||||
},
|
||||
emojiModifier = { Modifier },
|
||||
emojiText = { "¯\\_(ツ)_/¯" },
|
||||
emojiTextStyle = { MaterialTheme.typography.titleLarge },
|
||||
descriptionModifier = {
|
||||
Modifier
|
||||
.padding(top = 6.dp)
|
||||
.padding(horizontal = 16.dp)
|
||||
},
|
||||
descriptionText = { stringResource(id = R.string.empty_list_subtitle) },
|
||||
descriptionTextStyle = { MaterialTheme.typography.bodyMedium }
|
||||
)
|
||||
|
||||
val NoComment =
|
||||
EmptyStateSpec(
|
||||
modifier = { it.padding(top = 85.dp) },
|
||||
emojiModifier = { Modifier.padding(bottom = 10.dp) },
|
||||
emojiText = { "(╯°-°)╯" },
|
||||
emojiTextStyle = {
|
||||
LocalTextStyle.current.merge(
|
||||
fontFamily = FontFamily.Monospace,
|
||||
fontSize = 35.sp,
|
||||
)
|
||||
},
|
||||
descriptionModifier = { Modifier },
|
||||
descriptionText = { stringResource(id = R.string.no_comments) },
|
||||
descriptionTextStyle = {
|
||||
LocalTextStyle.current.merge(fontSize = 24.sp)
|
||||
}
|
||||
)
|
||||
|
||||
val NoSearchResult =
|
||||
@ -145,10 +111,7 @@ data class EmptyStateSpec(
|
||||
NoComment.copy(
|
||||
modifier = { it.padding(top = 90.dp) },
|
||||
emojiText = { "(︶︹︺)" },
|
||||
emojiTextStyle = { LocalTextStyle.current.merge(fontSize = 45.sp) },
|
||||
descriptionModifier = { Modifier.padding(top = 20.dp) },
|
||||
descriptionText = { stringResource(id = R.string.content_not_supported) },
|
||||
descriptionTextStyle = { LocalTextStyle.current.merge(fontSize = 15.sp) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user