Skip to content

Commit 0cff3a6

Browse files
committed
Improve AboutTab spacing
1 parent 4e55f1b commit 0cff3a6

2 files changed

Lines changed: 40 additions & 29 deletions

File tree

app/src/main/java/org/schabi/newpipe/ui/components/about/AboutTab.kt

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package org.schabi.newpipe.ui.components.about
22

33
import androidx.annotation.StringRes
4-
import androidx.compose.foundation.Image
54
import androidx.compose.foundation.layout.Arrangement
65
import androidx.compose.foundation.layout.Column
6+
import androidx.compose.foundation.layout.Spacer
77
import androidx.compose.foundation.layout.fillMaxWidth
8+
import androidx.compose.foundation.layout.height
89
import androidx.compose.foundation.layout.padding
910
import androidx.compose.foundation.layout.wrapContentSize
1011
import androidx.compose.foundation.layout.wrapContentWidth
@@ -15,12 +16,18 @@ import androidx.compose.material3.Text
1516
import androidx.compose.material3.TextButton
1617
import androidx.compose.runtime.Composable
1718
import androidx.compose.runtime.NonRestartableComposable
19+
import androidx.compose.runtime.remember
1820
import androidx.compose.ui.Alignment
1921
import androidx.compose.ui.Modifier
2022
import androidx.compose.ui.platform.LocalContext
21-
import androidx.compose.ui.res.painterResource
2223
import 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
2328
import androidx.compose.ui.unit.dp
29+
import androidx.core.content.ContextCompat.getDrawable
30+
import coil3.compose.AsyncImage
2431
import my.nanihadesuka.compose.ColumnScrollbar
2532
import org.schabi.newpipe.BuildConfig
2633
import 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
5969
fun 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
) {

app/src/main/res/drawable/icon.xml

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)