Skip to content

Commit 07d22f4

Browse files
committed
Add TitleText in SettingsScreen
1 parent d6db507 commit 07d22f4

File tree

5 files changed

+91
-22
lines changed

5 files changed

+91
-22
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.vladshurakov.jetnotesapp.feature_settings.presenter.components
2+
3+
import androidx.annotation.DrawableRes
4+
import androidx.annotation.StringRes
5+
import androidx.compose.foundation.layout.Arrangement
6+
import androidx.compose.foundation.layout.Row
7+
import androidx.compose.foundation.layout.padding
8+
import androidx.compose.foundation.layout.wrapContentHeight
9+
import androidx.compose.material3.Icon
10+
import androidx.compose.material3.Text
11+
import androidx.compose.runtime.Composable
12+
import androidx.compose.ui.Alignment
13+
import androidx.compose.ui.Modifier
14+
import androidx.compose.ui.res.painterResource
15+
import androidx.compose.ui.res.stringResource
16+
import androidx.compose.ui.unit.dp
17+
import com.vladshurakov.jetnotesapp.theme.MainTheme
18+
19+
@Composable
20+
fun TitleTextView(
21+
@StringRes name: Int,
22+
@DrawableRes icon: Int
23+
) {
24+
Row(
25+
verticalAlignment = Alignment.CenterVertically,
26+
horizontalArrangement = Arrangement.Start,
27+
modifier = Modifier.padding(start = 18.dp, top = 12.dp)
28+
) {
29+
Icon(
30+
painter = painterResource(id = icon),
31+
contentDescription = stringResource(id = name),
32+
tint = MainTheme.colors.invertColor
33+
)
34+
35+
Text(
36+
text = stringResource(id = name),
37+
style = MainTheme.typography.title,
38+
color = MainTheme.colors.primaryTextColor,
39+
modifier = Modifier
40+
.padding(start = 12.dp)
41+
.wrapContentHeight(align = Alignment.CenterVertically)
42+
)
43+
}
44+
}

app/src/main/java/com/vladshurakov/jetnotesapp/feature_settings/presenter/screen/SettingsScreen.kt

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import com.vladshurakov.jetnotesapp.feature_settings.presenter.components.Settin
4242
import com.vladshurakov.jetnotesapp.feature_settings.presenter.components.SettingsThemeDialog
4343
import com.vladshurakov.jetnotesapp.feature_settings.presenter.components.SettingsTopBar
4444
import com.vladshurakov.jetnotesapp.feature_settings.presenter.components.SettingsView
45+
import com.vladshurakov.jetnotesapp.feature_settings.presenter.components.TitleTextView
4546
import com.vladshurakov.jetnotesapp.feature_settings.presenter.viewmodel.SettingsEvent
4647
import com.vladshurakov.jetnotesapp.feature_settings.presenter.viewmodel.SettingsViewModel
4748
import com.vladshurakov.jetnotesapp.theme.MainTheme
@@ -163,13 +164,9 @@ fun SettingsScreen(
163164

164165
item {
165166

166-
Text(
167-
text = stringResource(R.string.appearance),
168-
style = MainTheme.typography.title,
169-
color = colors.primaryTextColor,
170-
modifier = Modifier
171-
.padding(start = 18.dp)
172-
.wrapContentHeight(align = Alignment.CenterVertically)
167+
TitleTextView(
168+
name = R.string.appearance,
169+
icon = R.drawable.ic_appearance
173170
)
174171

175172
SettingsView(
@@ -254,14 +251,10 @@ fun SettingsScreen(
254251
color = colors.secondaryTextColor,
255252
modifier = Modifier.padding(horizontal = 8.dp)
256253
)
257-
258-
Text(
259-
text = stringResource(id = R.string.export_import_data),
260-
style = MainTheme.typography.title,
261-
color = colors.primaryTextColor,
262-
modifier = Modifier
263-
.padding(start = 18.dp, top = 12.dp)
264-
.wrapContentHeight(align = Alignment.CenterVertically)
254+
255+
TitleTextView(
256+
name = R.string.export_import_data,
257+
icon = R.drawable.ic_zip
265258
)
266259

267260
TextButton(
@@ -310,13 +303,9 @@ fun SettingsScreen(
310303
modifier = Modifier.padding(horizontal = 8.dp)
311304
)
312305

313-
Text(
314-
text = stringResource(id = R.string.label_about),
315-
style = MainTheme.typography.title,
316-
color = colors.primaryTextColor,
317-
modifier = Modifier
318-
.padding(start = 18.dp, top = 12.dp)
319-
.wrapContentHeight(align = Alignment.CenterVertically)
306+
TitleTextView(
307+
name = R.string.label_about,
308+
icon = R.drawable.ic_about
320309
)
321310

322311
TextButton(
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:tint="#000000"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M11,7h2v2h-2zM11,11h2v6h-2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z" />
10+
</vector>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:tint="#000000"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M19,9l1.25,-2.75l2.75,-1.25l-2.75,-1.25l-1.25,-2.75l-1.25,2.75l-2.75,1.25l2.75,1.25z" />
10+
<path
11+
android:fillColor="@android:color/white"
12+
android:pathData="M19,15l-1.25,2.75l-2.75,1.25l2.75,1.25l1.25,2.75l1.25,-2.75l2.75,-1.25l-2.75,-1.25z" />
13+
<path
14+
android:fillColor="@android:color/white"
15+
android:pathData="M11.5,9.5L9,4L6.5,9.5L1,12l5.5,2.5L9,20l2.5,-5.5L17,12L11.5,9.5zM9.99,12.99L9,15.17l-0.99,-2.18L5.83,12l2.18,-0.99L9,8.83l0.99,2.18L12.17,12L9.99,12.99z" />
16+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:tint="#000000"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M20,6h-8l-2,-2H4C2.9,4 2.01,4.9 2.01,6L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8C22,6.9 21.1,6 20,6zM16,16h2v-2h-2v-2h2v-2h-2V8h4v10h-4V16zM16,16h-2v2H4V6h5.17l2,2H14v2h2v2h-2v2h2V16z" />
10+
</vector>

0 commit comments

Comments
 (0)