diff --git a/TODO.md b/TODO.md index e7dab9ab0..1d9170756 100644 --- a/TODO.md +++ b/TODO.md @@ -1,9 +1,10 @@ # High priority MVP features required for first public alpha +* show real ID of me when I sent texts +* keep text entry box at bottom of screen * show user icons in chat -* show sent messages in chat -* make chat pretty and functional +* when I enter texts, send them to the device * let user set name and shortname * take video diff --git a/app/src/main/java/com/geeksville/mesh/ui/Messages.kt b/app/src/main/java/com/geeksville/mesh/ui/Messages.kt index 7063fdf55..a828785ab 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/Messages.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/Messages.kt @@ -7,11 +7,13 @@ import androidx.ui.core.Modifier import androidx.ui.core.Text import androidx.ui.core.TextField import androidx.ui.foundation.shape.corner.RoundedCornerShape +import androidx.ui.graphics.Color import androidx.ui.input.ImeAction import androidx.ui.layout.Column import androidx.ui.layout.LayoutPadding import androidx.ui.layout.LayoutSize import androidx.ui.layout.Row +import androidx.ui.material.Emphasis import androidx.ui.material.MaterialTheme import androidx.ui.material.ProvideEmphasis import androidx.ui.material.surface.Surface @@ -39,11 +41,23 @@ object MessagesState : Logging { // If the following (unused otherwise) line is commented out, the IDE preview window works. // if left in the preview always renders as empty. - val messages = mutableStateOf(MessagesState.testTexts) + val messages = mutableStateOf(MessagesState.testTexts, { a, b -> + a.size == b.size // If the # of messages changes, consider it important for rerender + }) + + fun addMessage(m: TextMessage) { + val l = messages.value.toMutableList() + l.add(m) + messages.value = l + } } private val dateFormat = SimpleDateFormat("h:mm a") +val TimestampEmphasis = object : Emphasis { + override fun emphasize(color: Color) = color.copy(alpha = 0.12f) +} + /** * A pretty version the text, with user icon to the left, name and time of arrival (copy slack look and feel) */ @@ -63,7 +77,7 @@ fun MessageCard(msg: TextMessage, modifier: Modifier = Modifier.None) { val user = node?.user val senderName = user?.longName ?: msg.from Text(text = senderName) - ProvideEmphasis(emphasis = MaterialTheme.emphasisLevels().disabled) { + ProvideEmphasis(emphasis = TimestampEmphasis) { Text( text = dateFormat.format(msg.date), modifier = LayoutPadding(left = 8.dp), @@ -115,6 +129,7 @@ fun MessagesContent() { imeAction = ImeAction.Send, onImeActionPerformed = { MessagesState.info("did IME action") + MessagesState.addMessage(TextMessage("fixme", message.value)) }, modifier = LayoutPadding(4.dp) )