11package org.schabi.newpipe.ui.components.about
22
33import androidx.annotation.StringRes
4- import androidx.compose.foundation.Image
54import androidx.compose.foundation.layout.Arrangement
65import androidx.compose.foundation.layout.Column
6+ import androidx.compose.foundation.layout.Spacer
77import androidx.compose.foundation.layout.fillMaxWidth
8+ import androidx.compose.foundation.layout.height
89import androidx.compose.foundation.layout.padding
910import androidx.compose.foundation.layout.wrapContentSize
1011import androidx.compose.foundation.layout.wrapContentWidth
@@ -15,12 +16,18 @@ import androidx.compose.material3.Text
1516import androidx.compose.material3.TextButton
1617import androidx.compose.runtime.Composable
1718import androidx.compose.runtime.NonRestartableComposable
19+ import androidx.compose.runtime.remember
1820import androidx.compose.ui.Alignment
1921import androidx.compose.ui.Modifier
2022import androidx.compose.ui.platform.LocalContext
21- import androidx.compose.ui.res.painterResource
2223import androidx.compose.ui.res.stringResource
24+ import androidx.compose.ui.text.style.TextAlign
25+ import androidx.compose.ui.tooling.preview.Preview
26+ import androidx.compose.ui.tooling.preview.PreviewParameter
27+ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
2328import androidx.compose.ui.unit.dp
29+ import androidx.core.content.ContextCompat.getDrawable
30+ import coil3.compose.AsyncImage
2431import my.nanihadesuka.compose.ColumnScrollbar
2532import org.schabi.newpipe.BuildConfig
2633import org.schabi.newpipe.R
@@ -54,6 +61,9 @@ private class AboutData(
5461 @StringRes val url : Int
5562)
5663
64+ private class AboutDataProvider : CollectionPreviewParameterProvider <AboutData >(ABOUT_ITEMS )
65+
66+ @Preview(backgroundColor = 0xFFFFFFFF , showBackground = true )
5767@Composable
5868@NonRestartableComposable
5969fun AboutTab () {
@@ -73,18 +83,32 @@ fun AboutTab() {
7383 .wrapContentSize(Alignment .Center ),
7484 horizontalAlignment = Alignment .CenterHorizontally
7585 ) {
76- Image (
77- painter = painterResource(R .drawable.icon),
78- contentDescription = stringResource(R .string.app_name)
86+ // note: the preview
87+ val context = LocalContext .current
88+ val launcherDrawable = remember { getDrawable(context, R .mipmap.ic_launcher) }
89+ AsyncImage (
90+ model = launcherDrawable,
91+ contentDescription = stringResource(R .string.app_name),
7992 )
93+ Spacer (Modifier .height(4 .dp))
8094 Text (
95+ text = stringResource(R .string.app_name),
8196 style = MaterialTheme .typography.titleLarge,
82- text = stringResource(R .string.app_name)
97+ textAlign = TextAlign .Center ,
98+ )
99+ Text (
100+ text = BuildConfig .VERSION_NAME ,
101+ style = MaterialTheme .typography.titleMedium,
102+ textAlign = TextAlign .Center ,
103+ )
104+ Text (
105+ modifier = Modifier .fillMaxWidth(),
106+ text = stringResource(R .string.app_description),
107+ textAlign = TextAlign .Center ,
83108 )
84- Text (text = BuildConfig .VERSION_NAME )
85109 }
86110
87- Text (text = stringResource( R .string.app_description ))
111+ Spacer (modifier = Modifier .height( 4 .dp ))
88112
89113 for (item in ABOUT_ITEMS ) {
90114 AboutItem (item)
@@ -93,19 +117,24 @@ fun AboutTab() {
93117 }
94118}
95119
120+ @Preview(backgroundColor = 0xFFFFFFFF , showBackground = true )
96121@Composable
97122@NonRestartableComposable
98- private fun AboutItem (aboutData : AboutData ) {
123+ private fun AboutItem (@PreviewParameter( AboutDataProvider :: class ) aboutData : AboutData ) {
99124 Column {
100125 Text (
101126 text = stringResource(aboutData.title),
102127 style = MaterialTheme .typography.titleMedium
103128 )
104- Text (text = stringResource(aboutData.description))
129+ Text (
130+ text = stringResource(aboutData.description),
131+ style = MaterialTheme .typography.bodyMedium
132+ )
105133
106134 val context = LocalContext .current
107135 TextButton (
108- modifier = Modifier .fillMaxWidth()
136+ modifier = Modifier
137+ .fillMaxWidth()
109138 .wrapContentWidth(Alignment .End ),
110139 onClick = { ShareUtils .openUrlInApp(context, context.getString(aboutData.url)) }
111140 ) {
0 commit comments