11package com.codandotv.streamplayerapp.feature_list_streams.list.presentation.widgets
22
3+ import androidx.annotation.StringRes
34import androidx.compose.foundation.background
45import androidx.compose.foundation.layout.Box
56import androidx.compose.foundation.layout.Column
@@ -42,15 +43,15 @@ import com.codandotv.streamplayerapp.feature_list_streams.list.domain.model.High
4243import com.codandotv.streamplayerapp.feature_list_streams.list.domain.model.IconAndTextInfo
4344
4445@Composable
45- fun HighlightBanner (data : HighlightBanner ? ) {
46+ fun HighlightBanner (modifier : Modifier = Modifier , data : HighlightBanner ? ) {
4647 data ? : return
4748
4849 Box (
49- modifier = Modifier
50+ modifier = modifier
5051 .fillMaxWidth()
5152 .height(500 .dp)
5253 ) {
53- ContentImage (data)
54+ ContentImage (imageUrl = data.imageUrl )
5455 BackgroundGradient ()
5556 Column (
5657 modifier = Modifier
@@ -59,28 +60,28 @@ fun HighlightBanner(data: HighlightBanner?) {
5960 horizontalAlignment = Alignment .CenterHorizontally
6061 ) {
6162 Spacer (modifier = Modifier .weight(1F ))
62- ContentType (data)
63- ContentName (data)
64- ContentRanking (data)
63+ ContentType (contentType = data.contentType )
64+ ContentName (name = data.name )
65+ ContentRanking (extraInfo = data.extraInfo, contentTypeAsPlural = data.contentTypeAsPlural )
6566 ActionButtons (Modifier .weight(0.3F ), data)
6667 }
6768 }
6869}
6970
7071@Composable
71- fun ContentImage (data : HighlightBanner ) {
72+ fun ContentImage (modifier : Modifier = Modifier , imageUrl : String ) {
7273 AsyncImage (
73- modifier = Modifier .fillMaxSize(),
74- model = data. imageUrl,
74+ modifier = modifier .fillMaxSize(),
75+ model = imageUrl,
7576 contentScale = ContentScale .Crop ,
7677 contentDescription = stringResource(id = R .string.highligh_banner_content)
7778 )
7879}
7980
8081@Composable
81- fun BackgroundGradient () {
82+ fun BackgroundGradient (modifier : Modifier = Modifier ) {
8283 Box (
83- modifier = Modifier
84+ modifier = modifier
8485 .fillMaxSize()
8586 .background(
8687 brush = Brush .verticalGradient(
@@ -94,11 +95,11 @@ fun BackgroundGradient() {
9495}
9596
9697@Composable
97- fun ContentName (data : HighlightBanner ) {
98+ fun ContentName (modifier : Modifier = Modifier , name : String ) {
9899 Text (
99- text = data. name,
100+ text = name,
100101 fontSize = 24 .sp,
101- modifier = Modifier
102+ modifier = modifier
102103 .padding(horizontal = 50 .dp)
103104 .padding(vertical = 4 .dp),
104105 textAlign = TextAlign .Center ,
@@ -107,18 +108,22 @@ fun ContentName(data: HighlightBanner) {
107108}
108109
109110@Composable
110- fun ContentRanking (data : HighlightBanner ) {
111- Row (verticalAlignment = Alignment .CenterVertically ) {
111+ fun ContentRanking (
112+ modifier : Modifier = Modifier ,
113+ extraInfo : IconAndTextInfo ,
114+ @StringRes contentTypeAsPlural : Int
115+ ) {
116+ Row (modifier = modifier, verticalAlignment = Alignment .CenterVertically ) {
112117 Icon (
113- painter = painterResource(id = data. extraInfo.icon),
118+ painter = painterResource(id = extraInfo.icon),
114119 contentDescription = stringResource(id = R .string.icon_highligh_banner_ranking),
115120 modifier = Modifier .size(24 .dp),
116121 tint = Color .Unspecified
117122 )
118123 Text (
119124 text = stringResource(
120- id = data. extraInfo.text,
121- stringResource(data. contentTypeAsPlural).lowercase()
125+ id = extraInfo.text,
126+ stringResource(contentTypeAsPlural).lowercase()
122127 ),
123128 Modifier .padding(start = 4 .dp),
124129 style = TextStyle (fontWeight = FontWeight .Bold ),
@@ -129,16 +134,16 @@ fun ContentRanking(data: HighlightBanner) {
129134}
130135
131136@Composable
132- fun ContentType (data : HighlightBanner ) {
133- Row (verticalAlignment = Alignment .CenterVertically ) {
137+ fun ContentType (modifier : Modifier = Modifier , @StringRes contentType : Int ) {
138+ Row (modifier = modifier, verticalAlignment = Alignment .CenterVertically ) {
134139 Icon (
135140 painter = painterResource(id = drawable.ic_netflix),
136141 contentDescription = stringResource(id = string.icon_netflix),
137142 modifier = Modifier .size(16 .dp),
138143 tint = Color .Unspecified
139144 )
140145 Text (
141- text = stringResource(data. contentType).uppercase(),
146+ text = stringResource(contentType).uppercase(),
142147 Modifier .padding(start = 4 .dp),
143148 fontSize = 12 .sp,
144149 color = MaterialTheme .colorScheme.onBackground,
@@ -217,47 +222,44 @@ fun InfoButton(
217222
218223@Composable
219224fun PlayButton (
225+ modifier : Modifier = Modifier ,
220226 onClick : () -> Unit
221227) {
222228 Button (
223229 onClick = { onClick.invoke() },
224230 colors = ButtonDefaults .buttonColors(containerColor = Color .White ),
225231 shape = RoundedCornerShape (4 .dp),
226232 contentPadding = PaddingValues (horizontal = 8 .dp),
227- modifier = Modifier
233+ modifier = modifier
228234 .padding(16 .dp)
229235 .defaultMinSize(
230236 minWidth = 28 .dp,
231237 minHeight = 28 .dp
232238 )
233239 ) {
234- Row (
235- verticalAlignment = Alignment .CenterVertically ,
240+ Icon (
241+ painter = painterResource(drawable.ic_play),
242+ contentDescription = stringResource(id = R .string.icon_play),
243+ tint = Color .Black ,
244+ modifier = Modifier .padding(vertical = 8 .dp)
245+ )
246+ Spacer (modifier = Modifier .width(4 .dp))
247+ Text (
248+ text = stringResource(id = R .string.highlight_banner_watch),
249+ color = Color .Black ,
250+ fontSize = 14 .sp,
236251 modifier = Modifier
237- .padding(vertical = 4 .dp)
238- .padding(end = 4 .dp)
239- ) {
240- Icon (
241- painter = painterResource(drawable.ic_play),
242- contentDescription = stringResource(id = R .string.icon_play),
243- tint = Color .Black ,
244- )
245- Spacer (modifier = Modifier .width(4 .dp))
246- Text (
247- text = stringResource(id = R .string.highlight_banner_watch),
248- color = Color .Black ,
249- fontSize = 14 .sp,
250- modifier = Modifier .padding(bottom = 2 .dp)
251- )
252- }
252+ .padding(bottom = 2 .dp)
253+ .padding(end = 8 .dp)
254+ )
253255 }
254256}
255257
256258@ThemePreviews
257259@Composable
258260fun HighlightBannerPreview () {
259261 HighlightBanner (
260- HighlightBanner (
262+ data = HighlightBanner (
261263 name = stringResource(id = string.app_name),
262264 imageUrl = String (),
263265 contentType = ContentType .getContentName(ContentType .SHOW ),
0 commit comments