diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..144ac7a --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/java/net/buzzert/kordophonedroid/ui/conversationlist/ConversationListScreen.kt b/app/src/main/java/net/buzzert/kordophonedroid/ui/conversationlist/ConversationListScreen.kt index 98fdbac..0608e64 100644 --- a/app/src/main/java/net/buzzert/kordophonedroid/ui/conversationlist/ConversationListScreen.kt +++ b/app/src/main/java/net/buzzert/kordophonedroid/ui/conversationlist/ConversationListScreen.kt @@ -1,18 +1,21 @@ package net.buzzert.kordophonedroid.ui.conversationlist -import android.widget.Space +import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.runtime.Composable import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.* +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.rounded.Info +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -29,7 +32,11 @@ fun ConversationListScreen( Scaffold( topBar = { - TopAppBar(title = { Text("Conversations") }) + TopAppBar(title = { Text("Conversations") }, actions = { + Button(onClick = { /*TODO*/ }) { + Icon(Icons.Rounded.Info, contentDescription = "Info") + } + }) } ) { LazyColumn(state = listState) { @@ -37,6 +44,7 @@ fun ConversationListScreen( ConversationListItem( name = "James Magahern", id = "asdf", + isUnread = false, onClick = { onMessageSelected("asdf") } ) } @@ -45,21 +53,70 @@ fun ConversationListScreen( } @Composable -fun ConversationListItem(name: String, id: String, onClick: () -> Unit) { +fun ConversationListItem( + name: String, + id: String, + isUnread: Boolean, + onClick: () -> Unit +) { + val unreadSize = 12.dp + val horizontalPadding = 8.dp + Row( Modifier - .padding(horizontal = 8.dp) .clickable(onClick = onClick) ) { - Column { - Spacer(Modifier.height(8.dp)) - Text( - name, - style = TextStyle(fontSize = 18.sp, fontWeight = FontWeight.Bold) + Spacer(Modifier.width(horizontalPadding)) + + // Unread icon + if (isUnread) { + UnreadIndicator( + size = unreadSize, + modifier = Modifier.align(Alignment.CenterVertically) ) + } else { + Spacer(modifier = Modifier.size(unreadSize)) + } + + Spacer(Modifier.width(horizontalPadding)) + + Column { + Spacer(Modifier.height(horizontalPadding)) + Row( + horizontalArrangement = Arrangement.SpaceBetween, + modifier = Modifier.fillMaxWidth() + ) { + Text( + name, + style = TextStyle(fontSize = 18.sp, fontWeight = FontWeight.Bold) + ) + + Spacer(Modifier.weight(1f)) + + Text("13:37", + modifier = Modifier.align(Alignment.CenterVertically), + color = MaterialTheme.colors.onBackground.copy(alpha = 0.4f) + ) + + Spacer(Modifier.width(horizontalPadding)) + } + Text("This is a test.") + Spacer(Modifier.height(8.dp)) Divider() } } +} + +@Composable +fun UnreadIndicator(size: Dp, modifier: Modifier = Modifier) { + Box( + modifier = modifier + .size(size) + .background( + color = MaterialTheme.colors.primary, + shape = CircleShape + ) + ) } \ No newline at end of file