mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-23 17:34:28 +01:00
Add fixes to UART screen
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTask"
|
||||
android:windowSoftInputMode="stateVisible|adjustResize"
|
||||
android:theme="@style/AppTheme.SplashScreen">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -7,6 +7,7 @@ import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@@ -103,7 +104,13 @@ fun LoggerIconAppBar(text: String, onClick: () -> Unit, onDisconnectClick: () ->
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
TextButton(onClick = { onDisconnectClick() }) {
|
||||
TextButton(
|
||||
onClick = { onDisconnectClick() },
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Color.Transparent,
|
||||
contentColor = MaterialTheme.colorScheme.onPrimary
|
||||
)
|
||||
) {
|
||||
Text(stringResource(id = R.string.disconnect))
|
||||
}
|
||||
IconButton(onClick = { onLoggerClick() }) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package no.nordicsemi.android.uart.view
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.filled.Edit
|
||||
@@ -37,8 +39,9 @@ internal fun MacroSection(viewState: UARTViewState, onEvent: (UARTViewEvent) ->
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(16.dp)
|
||||
) {
|
||||
ScreenSection {
|
||||
Column(
|
||||
|
||||
@@ -90,10 +90,16 @@ fun LazyListState.isScrolledToTheEnd() = layoutInfo.visibleItemsInfo.lastOrNull(
|
||||
|
||||
@Composable
|
||||
private fun MessageItemInput(record: UARTRecord) {
|
||||
Box(
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
contentAlignment = Alignment.CenterEnd
|
||||
horizontalAlignment = Alignment.End
|
||||
) {
|
||||
Text(
|
||||
text = record.timeToString(),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(topStart = 10.dp, topEnd = 10.dp, bottomStart = 10.dp))
|
||||
@@ -101,12 +107,6 @@ private fun MessageItemInput(record: UARTRecord) {
|
||||
.padding(8.dp),
|
||||
horizontalAlignment = Alignment.End
|
||||
) {
|
||||
Text(
|
||||
text = record.timeToString(),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.inverseOnSurface
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = record.text,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
@@ -118,22 +118,22 @@ private fun MessageItemInput(record: UARTRecord) {
|
||||
|
||||
@Composable
|
||||
private fun MessageItemOutput(record: UARTRecord) {
|
||||
Box(
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
contentAlignment = Alignment.CenterStart
|
||||
horizontalAlignment = Alignment.Start
|
||||
) {
|
||||
Text(
|
||||
text = record.timeToString(),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(topStart = 10.dp, topEnd = 10.dp, bottomEnd = 10.dp))
|
||||
.background(MaterialTheme.colorScheme.primary)
|
||||
.padding(8.dp)
|
||||
) {
|
||||
Text(
|
||||
text = record.timeToString(),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.inverseOnSurface,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = record.text,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
|
||||
@@ -5,7 +5,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import no.nordicsemi.android.material.you.ScreenSection
|
||||
import no.nordicsemi.android.material.you.Card
|
||||
import no.nordicsemi.android.uart.data.UARTData
|
||||
|
||||
@Composable
|
||||
@@ -20,8 +20,17 @@ internal fun UARTContentView(
|
||||
.fillMaxSize()
|
||||
) {
|
||||
|
||||
ScreenSection(modifier = Modifier.weight(1f)) {
|
||||
OutputSection(state.displayMessages, onEvent)
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 16.dp, top = 16.dp, end = 16.dp)
|
||||
) {
|
||||
OutputSection(state.displayMessages, onEvent)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
|
||||
Reference in New Issue
Block a user