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