Skip to content

Commit a56738d

Browse files
authored
Merge pull request #89 from RajashekarRaju/shreyas/refactor-components
Design System Component Usage Test – Image, Card, Surface
2 parents ccccb94 + a802b7a commit a56738d

File tree

19 files changed

+393
-258
lines changed

19 files changed

+393
-258
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/developersbreach/composeactors/ui/components/NetworkImage.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.developersbreach.composeactors.ui.components
22

3-
import androidx.compose.foundation.Image
43
import androidx.compose.foundation.background
54
import androidx.compose.material.MaterialTheme
65
import androidx.compose.runtime.Composable
@@ -11,6 +10,7 @@ import androidx.compose.ui.layout.ContentScale
1110
import coil.compose.rememberImagePainter
1211
import com.developersbreach.composeactors.R
1312
import com.developersbreach.composeactors.ui.screens.actorDetails.ActorDetailsScreen
13+
import com.developersbreach.designsystem.components.CaImage
1414

1515
/**
1616
* Reusable composable used in all screens to load image.
@@ -29,7 +29,7 @@ fun LoadNetworkImage(
2929
shape: Shape,
3030
showAnimProgress: Boolean = true
3131
) {
32-
Image(
32+
CaImage(
3333
painter = rememberImagePainter(
3434
data = imageUrl,
3535
builder = {

app/src/main/java/com/developersbreach/composeactors/ui/screens/about/AboutScreen.kt

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package com.developersbreach.composeactors.ui.screens.about
22

3-
import androidx.compose.foundation.Image
43
import androidx.compose.foundation.layout.Column
54
import androidx.compose.foundation.layout.fillMaxSize
65
import androidx.compose.foundation.layout.fillMaxWidth
76
import androidx.compose.foundation.layout.padding
87
import androidx.compose.foundation.layout.wrapContentHeight
98
import androidx.compose.material.MaterialTheme
10-
import androidx.compose.material.Surface
119
import androidx.compose.material.Text
1210
import androidx.compose.runtime.Composable
1311
import androidx.compose.ui.Alignment
@@ -25,58 +23,61 @@ import androidx.compose.ui.unit.dp
2523
import androidx.compose.ui.unit.sp
2624
import com.developersbreach.composeactors.R
2725
import com.developersbreach.composeactors.ui.theme.ComposeActorsTheme
26+
import com.developersbreach.designsystem.components.CaImage
2827
import com.developersbreach.designsystem.components.CaScaffold
28+
import com.developersbreach.designsystem.components.CaSurface
2929

3030
@OptIn(ExperimentalTextApi::class)
3131
@Composable
3232
fun AboutScreen(
3333
navigateUp: () -> Unit
3434
) {
35-
Surface(
36-
color = MaterialTheme.colors.background,
37-
) {
38-
CaScaffold(
39-
modifier = Modifier,
40-
topBar = {
41-
AboutTopAppBar(navigateUp = navigateUp)
42-
},
43-
content = { paddingValues ->
44-
Column(
45-
horizontalAlignment = Alignment.CenterHorizontally,
46-
modifier = Modifier
47-
.fillMaxSize()
48-
.padding(paddingValues = paddingValues)
49-
) {
50-
Image(
51-
painter = painterResource(id = R.drawable.ic_tmdb_logo),
52-
contentDescription = stringResource(id = R.string.cd_tmdb_api_attribution_logo),
53-
modifier = Modifier
54-
.padding(80.dp)
55-
.fillMaxWidth()
56-
.wrapContentHeight()
57-
)
5835

59-
Text(
60-
text = stringResource(id = R.string.tmdb_api_attribution),
61-
modifier = Modifier.padding(horizontal = 40.dp),
62-
style = TextStyle(
63-
lineHeight = 24.sp,
64-
fontWeight = FontWeight.Normal,
65-
fontSize = 20.sp,
66-
textAlign = TextAlign.Center,
67-
brush = Brush.linearGradient(
68-
listOf(
69-
Color(0xFF90CEA1),
70-
Color(0xFF3CBEC9),
71-
Color(0xFF00B3E5)
36+
CaSurface(
37+
color = MaterialTheme.colors.background,
38+
content = {
39+
CaScaffold(
40+
modifier = Modifier,
41+
topBar = {
42+
AboutTopAppBar(navigateUp = navigateUp)
43+
},
44+
content = { paddingValues ->
45+
Column(
46+
horizontalAlignment = Alignment.CenterHorizontally,
47+
modifier = Modifier
48+
.fillMaxSize()
49+
.padding(paddingValues = paddingValues)
50+
) {
51+
CaImage(
52+
painter = painterResource(id = R.drawable.ic_tmdb_logo),
53+
contentDescription = stringResource(id = R.string.cd_tmdb_api_attribution_logo),
54+
modifier = Modifier
55+
.padding(80.dp)
56+
.fillMaxWidth()
57+
.wrapContentHeight()
58+
)
59+
Text(
60+
text = stringResource(id = R.string.tmdb_api_attribution),
61+
modifier = Modifier.padding(horizontal = 40.dp),
62+
style = TextStyle(
63+
lineHeight = 24.sp,
64+
fontWeight = FontWeight.Normal,
65+
fontSize = 20.sp,
66+
textAlign = TextAlign.Center,
67+
brush = Brush.linearGradient(
68+
listOf(
69+
Color(0xFF90CEA1),
70+
Color(0xFF3CBEC9),
71+
Color(0xFF00B3E5)
72+
)
73+
)
7274
)
7375
)
74-
)
75-
)
76-
}
77-
}
78-
)
79-
}
76+
}
77+
}
78+
)
79+
}
80+
)
8081
}
8182

8283
@Preview(showBackground = true)

app/src/main/java/com/developersbreach/composeactors/ui/screens/actorDetails/composables/ActorBiography.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.developersbreach.composeactors.ui.screens.actorDetails.composables
22

3-
import androidx.compose.foundation.Image
43
import androidx.compose.foundation.layout.Column
54
import androidx.compose.foundation.layout.Row
65
import androidx.compose.foundation.layout.Spacer
@@ -22,6 +21,7 @@ import androidx.compose.ui.unit.sp
2221
import com.developersbreach.composeactors.R
2322
import com.developersbreach.composeactors.ui.components.CategoryTitle
2423
import com.developersbreach.composeactors.ui.components.verticalGradientScrim
24+
import com.developersbreach.designsystem.components.CaImage
2525

2626
/**
2727
* @param biography shows paragraph with gradient background drawn from image.
@@ -47,14 +47,13 @@ internal fun ActorBiography(
4747
Row(
4848
verticalAlignment = Alignment.CenterVertically
4949
) {
50-
Image(
50+
CaImage(
5151
painter = painterResource(id = R.drawable.ic_biography),
5252
contentDescription = stringResource(id = R.string.cd_biography_icon),
5353
colorFilter = ColorFilter.tint(color = MaterialTheme.colors.onSurface),
5454
alpha = 0.5f,
5555
modifier = Modifier.size(36.dp),
5656
)
57-
5857
CategoryTitle(
5958
title = stringResource(R.string.cast_biography_title)
6059
)

app/src/main/java/com/developersbreach/composeactors/ui/screens/actorDetails/composables/ActorCastedMovies.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.developersbreach.composeactors.ui.screens.actorDetails.composables
22

3-
import androidx.compose.foundation.Image
43
import androidx.compose.foundation.clickable
54
import androidx.compose.foundation.layout.Arrangement
65
import androidx.compose.foundation.layout.PaddingValues
@@ -22,6 +21,7 @@ import com.developersbreach.composeactors.data.movie.model.Movie
2221
import com.developersbreach.composeactors.ui.components.CategoryTitle
2322
import com.developersbreach.composeactors.ui.components.LoadNetworkImage
2423
import com.developersbreach.composeactors.ui.screens.actorDetails.ActorDetailsData
24+
import com.developersbreach.designsystem.components.CaImage
2525
import kotlinx.coroutines.Job
2626

2727
/**
@@ -38,7 +38,7 @@ internal fun ActorCastedMovies(
3838
Row(
3939
verticalAlignment = Alignment.CenterVertically
4040
) {
41-
Image(
41+
CaImage(
4242
painter = painterResource(id = R.drawable.ic_movies_cast),
4343
contentDescription = stringResource(R.string.cd_cast_icon),
4444
colorFilter = ColorFilter.tint(color = MaterialTheme.colors.onSurface),
@@ -47,7 +47,6 @@ internal fun ActorCastedMovies(
4747
.padding(start = 12.dp)
4848
.size(36.dp)
4949
)
50-
5150
CategoryTitle(
5251
title = stringResource(R.string.cast_movie_title)
5352
)

app/src/main/java/com/developersbreach/composeactors/ui/screens/actorDetails/composables/ActorInfoHeader.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.developersbreach.composeactors.ui.screens.actorDetails.composables
22

3-
import androidx.compose.foundation.Image
43
import androidx.compose.foundation.layout.Arrangement
54
import androidx.compose.foundation.layout.Box
65
import androidx.compose.foundation.layout.Column
@@ -25,6 +24,7 @@ import com.developersbreach.composeactors.ui.theme.ComposeActorsTheme
2524
import com.developersbreach.composeactors.utils.calculateAge
2625
import com.developersbreach.composeactors.utils.getPlaceOfBirth
2726
import com.developersbreach.composeactors.utils.getPopularity
27+
import com.developersbreach.designsystem.components.CaImage
2828

2929
/**
3030
* Row with 3 elements which shows actor details just below actor image.
@@ -121,8 +121,8 @@ private fun CountryInfo(
121121
Box(
122122
modifier = Modifier.borderRevealAnimation()
123123
) {
124-
Image(
125-
painterResource(id = R.drawable.ic_globe),
124+
CaImage(
125+
painter = painterResource(id = R.drawable.ic_globe),
126126
contentDescription = stringResource(R.string.cd_place_of_birth_icon),
127127
colorFilter = ColorFilter.tint(color = MaterialTheme.colors.onSurface),
128128
modifier = Modifier

0 commit comments

Comments
 (0)