Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
AlertItem: save
Browse files Browse the repository at this point in the history
Signed-off-by: Aayush Gupta <[email protected]>
  • Loading branch information
theimpulson committed Aug 20, 2023
1 parent 13f389f commit 80cbeea
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions app/src/main/java/io/aayush/relabs/ui/components/AlertItem.kt
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
package io.aayush.relabs.ui.components

import android.text.format.DateUtils
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.SubcomposeAsyncImage
import coil.request.ImageRequest
import io.aayush.relabs.R
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale

@Composable
fun AlertItem(
Expand All @@ -36,12 +32,6 @@ fun AlertItem(
date: Int = 0,
onClicked: () -> Unit = {}
) {
var eventDate by remember { mutableStateOf("") }
LaunchedEffect(key1 = Unit) {
val sdf = SimpleDateFormat("dd/MM/yyyy", Locale.getDefault())
eventDate = sdf.format(Date(date.toLong()))
}

Row(
modifier = modifier,
verticalAlignment = Alignment.CenterVertically,
Expand All @@ -60,11 +50,20 @@ fun AlertItem(
.clip(CircleShape)
)
Spacer(modifier = Modifier.width(10.dp))
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start
Column(
verticalArrangement = Arrangement.Top,
horizontalAlignment = Alignment.Start
) {
Text(text = title, fontSize = 14.sp)
Text(
text = DateUtils.getRelativeTimeSpanString(
date.toLong() * 1000L,
Date().time,
DateUtils.MINUTE_IN_MILLIS
).toString(),
fontSize = 13.sp,
fontWeight = FontWeight.Light
)
}
}
}
Expand Down

0 comments on commit 80cbeea

Please sign in to comment.