mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-03-24 00:33:14 -04:00
Begin UI for letting user set name and send texts
This commit is contained in:
@@ -15,8 +15,7 @@ class MeshUtilApplication : GeeksvilleApplication(null, "58e72ccc361883ea502510b
|
||||
|
||||
// We default to off in the manifest, FIXME turn on only if user approves
|
||||
// leave off when running in the debugger
|
||||
if (false && !Debug.isDebuggerConnected())
|
||||
if (!BuildConfig.DEBUG || !Debug.isDebuggerConnected())
|
||||
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,19 +4,35 @@ import androidx.annotation.DrawableRes
|
||||
import androidx.compose.Composable
|
||||
import androidx.compose.state
|
||||
import androidx.ui.animation.Crossfade
|
||||
import androidx.ui.core.Clip
|
||||
import androidx.ui.core.Modifier
|
||||
import androidx.ui.core.Text
|
||||
import androidx.ui.core.TextField
|
||||
import androidx.ui.foundation.VerticalScroller
|
||||
import androidx.ui.foundation.shape.corner.RoundedCornerShape
|
||||
import androidx.ui.graphics.Color
|
||||
import androidx.ui.input.ImeAction
|
||||
import androidx.ui.layout.*
|
||||
import androidx.ui.material.*
|
||||
import androidx.ui.material.surface.Surface
|
||||
import androidx.ui.text.TextStyle
|
||||
import androidx.ui.tooling.preview.Preview
|
||||
import androidx.ui.unit.dp
|
||||
import com.geeksville.android.Logging
|
||||
import com.geeksville.mesh.R
|
||||
|
||||
|
||||
object UILog : Logging
|
||||
|
||||
/// Given a human name, strip out the first letter of the first three words and return that as the initials for
|
||||
/// that user.
|
||||
fun getInitials(name: String): String {
|
||||
val words = name.split(Regex("\\s+")).filter { it.isNotEmpty() }.take(3).map { it.first() }
|
||||
.joinToString("")
|
||||
|
||||
return words
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun HomeContent() {
|
||||
Column {
|
||||
@@ -36,6 +52,51 @@ fun HomeContent() {
|
||||
Text("Text: ${it.text}")
|
||||
}
|
||||
|
||||
val message = state { "text message" }
|
||||
Surface(color = Color.Yellow) {
|
||||
Row {
|
||||
Clip(shape = RoundedCornerShape(15.dp)) {
|
||||
Padding(padding = 15.dp) {
|
||||
TextField(
|
||||
value = message.value,
|
||||
onValueChange = { message.value = it },
|
||||
textStyle = TextStyle(
|
||||
color = Color.DarkGray
|
||||
),
|
||||
imeAction = ImeAction.Send,
|
||||
onImeActionPerformed = {
|
||||
UILog.info("did IME action")
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val state = state { "fixme bob" }
|
||||
Surface(color = Color.LightGray) {
|
||||
Row {
|
||||
Clip(shape = RoundedCornerShape(15.dp)) {
|
||||
Padding(padding = 15.dp) {
|
||||
TextField(
|
||||
value = state.value,
|
||||
onValueChange = { state.value = it },
|
||||
textStyle = TextStyle(
|
||||
color = Color.DarkGray
|
||||
),
|
||||
imeAction = ImeAction.Done,
|
||||
onImeActionPerformed = {
|
||||
UILog.info("did IME action")
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Text(text = getInitials(state.value))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* FIXME - doens't work yet - probably because I'm not using release keys
|
||||
// If account is null, then show the signin button, otherwise
|
||||
val context = ambient(ContextAmbient)
|
||||
|
||||
Reference in New Issue
Block a user