Skip to content

Commit 0536eb3

Browse files
committed
Adding Coil library to load remote images
1 parent 4475769 commit 0536eb3

File tree

7 files changed

+122
-66
lines changed

7 files changed

+122
-66
lines changed

buildSrc/src/main/java/Dependencies.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,11 @@ object Dependencies {
154154
Compose.composeMaterial3
155155
)
156156
}
157+
158+
object Coil: GroupLibs {
159+
const val coil = "io.coil-kt:coil-compose:${Versions.coilVersion}"
160+
161+
override val list: List<String>
162+
get() = listOf(Coil.coil)
163+
}
157164
}

buildSrc/src/main/java/Versions.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ object Versions {
2929
const val composeBomVersion = "2023.01.00"
3030
const val composeCompilerVersion = "1.4.2"
3131
const val composeMaterial3Version = "1.0.1"
32+
33+
const val coilVersion = "2.3.0"
3234
}

feature-list-streams/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ android {
2020

2121
Dependencies.UnitTest.list.forEach { testImplementation(it) }
2222
//Dependencies.AndroidTest.list.forEach { androidTestImplementation(it) }
23+
24+
Dependencies.Coil.list.forEach { implementation(it) }
2325
}
2426
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3-
3+
<uses-permission android:name="android.permission.INTERNET" />
44
</manifest>

feature-list-streams/src/main/java/com/codandotv/streamplayerapp/feature_list_streams/presentation/screens/ListStreamsScreen.kt

Lines changed: 61 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,89 @@
11
package com.codandotv.streamplayerapp.feature_list_streams.presentation.screens
22

3+
import androidx.compose.foundation.background
34
import androidx.compose.foundation.layout.Column
45
import androidx.compose.foundation.layout.Row
56
import androidx.compose.foundation.layout.Spacer
7+
import androidx.compose.foundation.layout.fillMaxSize
68
import androidx.compose.foundation.layout.fillMaxWidth
79
import androidx.compose.foundation.layout.height
10+
import androidx.compose.foundation.layout.padding
811
import androidx.compose.foundation.layout.size
912
import androidx.compose.foundation.lazy.LazyRow
1013
import androidx.compose.material3.Text
1114
import androidx.compose.runtime.Composable
1215
import androidx.compose.ui.Modifier
16+
import androidx.compose.ui.graphics.Color
1317
import androidx.compose.ui.tooling.preview.Preview
1418
import androidx.compose.ui.unit.dp
1519
import com.codandotv.streamplayerapp.feature_list_streams.presentation.widgets.StreamsCard
20+
import com.codandotv.streamplayerapp.feature_list_streams.presentation.widgets.StreamsCardContent
1621
import com.codandotv.streamplayerapp.feature_list_streams.presentation.widgets.StreamsCarousel
1722

23+
val streamsCategoryX = listOf(
24+
StreamsCardContent(
25+
contentDescription = "test",
26+
url = "https://image.tmdb.org/t/p/w300/gU84Leiw6dYyxcx3S7kfneLnVJH.jpg"
27+
),
28+
StreamsCardContent(
29+
contentDescription = "test",
30+
url = "https://image.tmdb.org/t/p/w300/evgwd37VHBJhXvSr88Mrx5riFil.jpg"
31+
),
32+
StreamsCardContent(
33+
contentDescription = "test",
34+
url = "https://image.tmdb.org/t/p/w300/wAKExQIBBiApsucimUIv6aiJsWF.jpg"
35+
),
36+
StreamsCardContent(
37+
contentDescription = "test",
38+
url = "https://image.tmdb.org/t/p/w300/mKEDE9r2ggqtGv5krCFLuELh7ED.jpg"
39+
),
40+
StreamsCardContent(
41+
contentDescription = "test",
42+
url = "https://image.tmdb.org/t/p/w300/ojCfQ8syImYWJ38sta46BOz00PC.jpg"
43+
)
44+
)
45+
46+
val streamsCategoryY = listOf(
47+
StreamsCardContent(
48+
contentDescription = "test",
49+
url = "https://image.tmdb.org/t/p/w300/lOrPcXLAfdtWFSeMPdMiBLwlvtv.jpg"
50+
),
51+
StreamsCardContent(
52+
contentDescription = "test",
53+
url = "https://image.tmdb.org/t/p/w300/yjs9NikrKZUmIX3ou3J9QiUcQUP.jpg"
54+
), StreamsCardContent(
55+
contentDescription = "test",
56+
url = "https://image.tmdb.org/t/p/w300/vfdO4lUxZaUrRhI60Gvf5WEqdhY.jpg"
57+
),
58+
StreamsCardContent(
59+
contentDescription = "test",
60+
url = "https://image.tmdb.org/t/p/w300/qdzIpsDH1D0uiFTvFQL9WW4MEZ4.jpg"
61+
),
62+
StreamsCardContent(
63+
contentDescription = "test",
64+
url = "https://image.tmdb.org/t/p/w300/i17CbxJ8GrGvPneiknjGyJrbqvp.jpg"
65+
)
66+
)
67+
1868
@Composable
1969
fun ListStreamsScreen() {
20-
Column {
70+
Column(
71+
modifier = Modifier
72+
.background(Color.Black)
73+
.fillMaxSize()
74+
) {
2175
StreamsCarousel(
22-
title = "Comédia", streams = listOf(
23-
"Chuck Norris",
24-
"Super Mario",
25-
"Mortal Combat",
26-
"Chuck Norris",
27-
"Super Mario",
28-
"Mortal Combat",
29-
"Chuck Norris",
30-
"Super Mario",
31-
"Mortal Combat",
32-
"Chuck Norris",
33-
"Super Mario",
34-
"Mortal Combat"
35-
)
76+
title = "Category X",
77+
contentList = streamsCategoryX,
78+
modifier = Modifier.padding(vertical = 8.dp)
3679
)
3780

3881
Spacer(modifier = Modifier.height(12.dp))
3982

4083
StreamsCarousel(
41-
title = "Ação", streams = listOf(
42-
"Chuck Norris",
43-
"Super Mario",
44-
"Mortal Combat",
45-
"Chuck Norris",
46-
"Super Mario",
47-
"Mortal Combat",
48-
"Chuck Norris",
49-
"Super Mario",
50-
"Mortal Combat",
51-
"Chuck Norris",
52-
"Super Mario",
53-
"Mortal Combat"
54-
)
84+
title = "Category Y",
85+
contentList = streamsCategoryY,
86+
modifier = Modifier.padding(vertical = 8.dp)
5587
)
5688
}
5789
}
Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,47 @@
11
package com.codandotv.streamplayerapp.feature_list_streams.presentation.widgets
22

3-
import androidx.compose.foundation.background
4-
import androidx.compose.foundation.layout.Box
5-
import androidx.compose.foundation.layout.Column
3+
import androidx.compose.foundation.layout.padding
64
import androidx.compose.foundation.layout.size
7-
import androidx.compose.material3.Text
5+
import androidx.compose.foundation.shape.RoundedCornerShape
6+
import androidx.compose.material3.Card
87
import androidx.compose.runtime.Composable
98
import androidx.compose.ui.Modifier
10-
import androidx.compose.ui.graphics.Color
9+
import androidx.compose.ui.layout.ContentScale
1110
import androidx.compose.ui.tooling.preview.Preview
1211
import androidx.compose.ui.unit.dp
12+
import coil.compose.AsyncImage
13+
14+
data class StreamsCardContent(
15+
val url: String,
16+
val contentDescription: String,
17+
)
1318

1419
@Composable
15-
fun StreamsCard(streamTitle: String) {
16-
Column {
17-
// Coil - Carregar Imagem do movie
18-
Box(
19-
modifier = Modifier
20-
.background(Color.Blue)
21-
.size(height = 120.dp, width = 80.dp)
20+
fun StreamsCard(content: StreamsCardContent) {
21+
Card(
22+
shape = RoundedCornerShape(6.dp),
23+
modifier = Modifier.size(
24+
width = 100.dp,
25+
height = 140.dp
26+
).padding(
27+
horizontal = 4.dp
28+
)
29+
) {
30+
AsyncImage(
31+
model = content.url,
32+
contentScale = ContentScale.FillBounds,
33+
contentDescription = content.contentDescription
2234
)
23-
24-
Text(streamTitle)
2535
}
2636
}
2737

28-
@Preview(device = "id:Nexus 6")
38+
@Preview
2939
@Composable
3040
fun StreamsCardPreview() {
31-
StreamsCard("Filme1")
41+
StreamsCard(
42+
StreamsCardContent(
43+
url = "https://image.tmdb.org/t/p/w300/evgwd37VHBJhXvSr88Mrx5riFil.jpg",
44+
contentDescription = "Test 1"
45+
)
46+
)
3247
}

feature-list-streams/src/main/java/com/codandotv/streamplayerapp/feature_list_streams/presentation/widgets/StreamsCarousel.kt

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,33 @@ import androidx.compose.foundation.layout.Spacer
55
import androidx.compose.foundation.layout.fillMaxWidth
66
import androidx.compose.foundation.layout.size
77
import androidx.compose.foundation.lazy.LazyRow
8+
import androidx.compose.material3.MaterialTheme
89
import androidx.compose.material3.Text
910
import androidx.compose.runtime.Composable
1011
import androidx.compose.ui.Modifier
12+
import androidx.compose.ui.graphics.Color
13+
import androidx.compose.ui.text.font.FontWeight
1114
import androidx.compose.ui.tooling.preview.Preview
1215
import androidx.compose.ui.unit.dp
16+
import androidx.compose.ui.unit.sp
1317

1418
@Composable
15-
fun StreamsCarousel(title: String, streams: List<String>, modifier: Modifier = Modifier) {
19+
fun StreamsCarousel(title: String, contentList: List<StreamsCardContent>, modifier: Modifier = Modifier) {
1620
Column(modifier = modifier) {
17-
Text(title)
21+
Text(
22+
title,
23+
style = MaterialTheme.typography.headlineMedium.copy(
24+
color = Color.White,
25+
fontWeight = FontWeight.Bold,
26+
fontSize = 20.sp
27+
)
28+
)
1829

19-
LazyRow(modifier = Modifier.fillMaxWidth()) {
20-
items(streams.size) {
21-
StreamsCard(streams[it])
30+
Spacer(modifier = Modifier.size(8.dp))
2231

23-
Spacer(modifier = Modifier.size(12.dp))
32+
LazyRow(modifier = Modifier.fillMaxWidth()) {
33+
items(contentList.size) {
34+
StreamsCard(contentList[it])
2435
}
2536
}
2637
}
@@ -31,19 +42,6 @@ fun StreamsCarousel(title: String, streams: List<String>, modifier: Modifier = M
3142
fun StreamsCarouselPreview() {
3243
StreamsCarousel(
3344
title = "Ação",
34-
streams = listOf(
35-
"Chuck Norris",
36-
"Super Mario",
37-
"Mortal Combat",
38-
"Chuck Norris",
39-
"Super Mario",
40-
"Mortal Combat",
41-
"Chuck Norris",
42-
"Super Mario",
43-
"Mortal Combat",
44-
"Chuck Norris",
45-
"Super Mario",
46-
"Mortal Combat"
47-
)
45+
contentList = emptyList()
4846
)
4947
}

0 commit comments

Comments
 (0)