This repository has been archived by the owner on Aug 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NewsScreen: Drop using figma for news items
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
- Loading branch information
1 parent
f7706d9
commit 0378b3c
Showing
12 changed files
with
137 additions
and
509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
app/src/main/java/io/aayush/relabs/ui/components/NewsItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package io.aayush.relabs.ui.components | ||
|
||
import android.os.Build | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.requiredHeight | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import coil.ImageLoader | ||
import coil.compose.SubcomposeAsyncImage | ||
import coil.decode.GifDecoder | ||
import coil.decode.ImageDecoderDecoder | ||
import coil.request.ImageRequest | ||
import io.aayush.relabs.R | ||
import io.aayush.relabs.ui.extensions.shimmer | ||
|
||
@Composable | ||
fun NewsItem( | ||
modifier: Modifier = Modifier, | ||
thumbnail: String = "", | ||
headline: String = "", | ||
description: String = "", | ||
author: String = "", | ||
date: String = "", | ||
onClicked: () -> Unit = {}, | ||
loading: Boolean = false, | ||
) { | ||
Column( | ||
modifier = modifier | ||
.clip(RoundedCornerShape(20.dp)) | ||
.background( | ||
color = if (isSystemInDarkTheme()) { | ||
MaterialTheme.colorScheme.onSecondary | ||
} else { | ||
MaterialTheme.colorScheme.secondary | ||
} | ||
) | ||
.padding(12.dp) | ||
.clickable { onClicked() }, | ||
verticalArrangement = Arrangement.spacedBy(10.dp, Alignment.CenterVertically), | ||
horizontalAlignment = Alignment.Start | ||
) { | ||
SubcomposeAsyncImage( | ||
model = ImageRequest.Builder(LocalContext.current) | ||
.data(thumbnail) | ||
.placeholder(R.drawable.ic_landscape) | ||
.crossfade(true) | ||
.build(), | ||
imageLoader = ImageLoader.Builder(LocalContext.current) | ||
.components { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { | ||
add(ImageDecoderDecoder.Factory()) | ||
} else { | ||
add(GifDecoder.Factory()) | ||
} | ||
}.build(), | ||
contentDescription = "", | ||
contentScale = ContentScale.Crop, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.requiredHeight(158.0.dp) | ||
.clip(RoundedCornerShape(20.dp)) | ||
.shimmer(loading) | ||
) | ||
Text( | ||
text = headline, | ||
fontSize = 22.sp, | ||
color = Color.White, | ||
fontWeight = FontWeight.Bold, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.shimmer(loading) | ||
) | ||
if (description.isNotBlank()) { | ||
Text( | ||
text = description, | ||
color = Color.White, | ||
fontSize = 15.sp, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.shimmer(loading) | ||
) | ||
} | ||
Column { | ||
Text( | ||
text = author, | ||
color = Color.White, | ||
fontSize = 13.sp, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.shimmer(loading) | ||
) | ||
Text( | ||
text = date, | ||
color = Color.White, | ||
fontSize = 12.sp, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.shimmer(loading) | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="960" | ||
android:viewportHeight="960"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M40,720L280,400L460,640L760,640L560,374L460,506L410,440L560,240L920,720L40,720ZM561,640L561,640L561,640L561,640L561,640ZM200,640L360,640L280,533L200,640ZM200,640L280,640L360,640L200,640Z"/> | ||
</vector> |
157 changes: 0 additions & 157 deletions
157
app/src/main/ui-package-resources/style-mappings/m3_design_kit.json
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.