mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-19 15:34:26 +01:00
Migrate to material compose alpha10
This commit is contained in:
@@ -32,9 +32,6 @@ fun StringListDialog(config: StringListDialogConfig) {
|
|||||||
fun StringListView(config: StringListDialogConfig) {
|
fun StringListView(config: StringListDialogConfig) {
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier.height(300.dp),
|
modifier = Modifier.height(300.dp),
|
||||||
backgroundColor = MaterialTheme.colorScheme.surfaceVariant,
|
|
||||||
shape = RoundedCornerShape(10.dp),
|
|
||||||
elevation = 0.dp
|
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.padding(16.dp),
|
modifier = Modifier.padding(16.dp),
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package no.nordicsemi.android.uart.view
|
package no.nordicsemi.android.uart.view
|
||||||
|
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.GridCells
|
import androidx.compose.foundation.lazy.grid.GridCells
|
||||||
import androidx.compose.foundation.lazy.GridItemSpan
|
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||||
import androidx.compose.foundation.lazy.LazyVerticalGrid
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
@@ -38,7 +37,6 @@ import no.nordicsemi.android.utils.EMPTY
|
|||||||
|
|
||||||
private const val GRID_SIZE = 5
|
private const val GRID_SIZE = 5
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun UARTAddMacroDialog(macro: UARTMacro?, onEvent: (UARTViewEvent) -> Unit) {
|
internal fun UARTAddMacroDialog(macro: UARTMacro?, onEvent: (UARTViewEvent) -> Unit) {
|
||||||
val newLineChar = rememberSaveable { mutableStateOf(macro?.newLineChar ?: MacroEol.LF) }
|
val newLineChar = rememberSaveable { mutableStateOf(macro?.newLineChar ?: MacroEol.LF) }
|
||||||
@@ -62,7 +60,7 @@ internal fun UARTAddMacroDialog(macro: UARTMacro?, onEvent: (UARTViewEvent) -> U
|
|||||||
)
|
)
|
||||||
|
|
||||||
LazyVerticalGrid(
|
LazyVerticalGrid(
|
||||||
cells = GridCells.Fixed(GRID_SIZE),
|
columns = GridCells.Fixed(GRID_SIZE),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(horizontal = 16.dp)
|
.padding(horizontal = 16.dp)
|
||||||
.wrapContentHeight()
|
.wrapContentHeight()
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package no.nordicsemi.android.uart.view
|
package no.nordicsemi.android.uart.view
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.layout.RowScopeInstance.weight
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Add
|
import androidx.compose.material.icons.filled.Add
|
||||||
import androidx.compose.material.icons.filled.Delete
|
import androidx.compose.material.icons.filled.Delete
|
||||||
@@ -36,10 +35,12 @@ internal fun UARTContentView(
|
|||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
modifier = Modifier.padding(16.dp)
|
modifier = Modifier.padding(16.dp).fillMaxSize()
|
||||||
) {
|
) {
|
||||||
|
|
||||||
OutputSection(state.displayMessages, onEvent)
|
ScreenSection(modifier = Modifier.fillMaxSize()) {
|
||||||
|
OutputSection(state.displayMessages, onEvent)
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.size(16.dp))
|
Spacer(modifier = Modifier.size(16.dp))
|
||||||
|
|
||||||
@@ -207,40 +208,38 @@ private fun DeleteConfigurationDialog(onEvent: (UARTViewEvent) -> Unit, onDismis
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun OutputSection(records: List<UARTRecord>, onEvent: (UARTViewEvent) -> Unit) {
|
private fun OutputSection(records: List<UARTRecord>, onEvent: (UARTViewEvent) -> Unit) {
|
||||||
ScreenSection(modifier = Modifier.weight(1f)) {
|
Column(
|
||||||
Column(
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Row(
|
SectionTitle(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
resId = R.drawable.ic_output,
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
title = stringResource(R.string.uart_output),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
modifier = Modifier
|
||||||
) {
|
)
|
||||||
SectionTitle(
|
|
||||||
resId = R.drawable.ic_output,
|
IconButton(onClick = { onEvent(ClearOutputItems) }) {
|
||||||
title = stringResource(R.string.uart_output),
|
Icon(
|
||||||
modifier = Modifier
|
Icons.Default.Delete,
|
||||||
|
contentDescription = "Clear items.",
|
||||||
)
|
)
|
||||||
|
|
||||||
IconButton(onClick = { onEvent(ClearOutputItems) }) {
|
|
||||||
Icon(
|
|
||||||
Icons.Default.Delete,
|
|
||||||
contentDescription = "Clear items.",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.size(16.dp))
|
Spacer(modifier = Modifier.size(16.dp))
|
||||||
|
|
||||||
Column(modifier = Modifier.fillMaxWidth()) {
|
Column(modifier = Modifier.fillMaxWidth()) {
|
||||||
if (records.isEmpty()) {
|
if (records.isEmpty()) {
|
||||||
Text(text = stringResource(id = R.string.uart_output_placeholder))
|
Text(text = stringResource(id = R.string.uart_output_placeholder))
|
||||||
} else {
|
} else {
|
||||||
records.forEach {
|
records.forEach {
|
||||||
MessageItem(record = it)
|
MessageItem(record = it)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ dependencyResolutionManagement {
|
|||||||
library('nordic-theme', 'no.nordicsemi.android.common', 'theme').versionRef('commonlibraries')
|
library('nordic-theme', 'no.nordicsemi.android.common', 'theme').versionRef('commonlibraries')
|
||||||
|
|
||||||
library('localbroadcastmanager', 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0')
|
library('localbroadcastmanager', 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0')
|
||||||
library('material', 'com.google.android.material:material:1.6.0-alpha02')
|
library('material', 'com.google.android.material:material:1.6.0-rc01')
|
||||||
|
|
||||||
version('lifecycle', '2.4.1')
|
version('lifecycle', '2.4.1')
|
||||||
library('lifecycle-activity', 'androidx.lifecycle', 'lifecycle-runtime-ktx').versionRef('lifecycle')
|
library('lifecycle-activity', 'androidx.lifecycle', 'lifecycle-runtime-ktx').versionRef('lifecycle')
|
||||||
@@ -39,7 +39,7 @@ dependencyResolutionManagement {
|
|||||||
|
|
||||||
version('compose', '1.1.0')
|
version('compose', '1.1.0')
|
||||||
library('compose-ui', 'androidx.compose.ui', 'ui').versionRef('compose')
|
library('compose-ui', 'androidx.compose.ui', 'ui').versionRef('compose')
|
||||||
library('compose-material', 'androidx.compose.material3:material3:1.0.0-alpha05')
|
library('compose-material', 'androidx.compose.material3:material3:1.0.0-alpha10')
|
||||||
library('compose-tooling-preview', 'androidx.compose.ui', 'ui-tooling-preview').versionRef('compose')
|
library('compose-tooling-preview', 'androidx.compose.ui', 'ui-tooling-preview').versionRef('compose')
|
||||||
library('compose-navigation', 'androidx.navigation:navigation-compose:2.4.1')
|
library('compose-navigation', 'androidx.navigation:navigation-compose:2.4.1')
|
||||||
bundle('compose', ['compose-ui', 'compose-material', 'compose-tooling-preview', 'compose-navigation'])
|
bundle('compose', ['compose-ui', 'compose-material', 'compose-tooling-preview', 'compose-navigation'])
|
||||||
|
|||||||
Reference in New Issue
Block a user