mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-24 01:44:23 +01:00
Redesign manager approach
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package no.nordicsemi.android.theme.view
|
||||
package no.nordicsemi.android.theme.view.scanner
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -19,6 +19,7 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import no.nordicsemi.android.theme.R
|
||||
import no.nordicsemi.android.theme.view.ScreenSection
|
||||
|
||||
@Composable
|
||||
fun DeviceConnectingView() {
|
||||
@@ -0,0 +1,72 @@
|
||||
package no.nordicsemi.android.theme.view.scanner
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.HighlightOff
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import no.nordicsemi.android.theme.R
|
||||
import no.nordicsemi.android.theme.view.ScreenSection
|
||||
|
||||
enum class Reason {
|
||||
USER, LINK_LOSS, MISSING_SERVICE
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun DeviceDisconnectedView(reason: Reason) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(16.dp)
|
||||
) {
|
||||
ScreenSection {
|
||||
Icon(
|
||||
imageVector = Icons.Default.HighlightOff,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onSecondary,
|
||||
modifier = Modifier
|
||||
.background(
|
||||
color = MaterialTheme.colorScheme.secondary,
|
||||
shape = CircleShape
|
||||
)
|
||||
.padding(8.dp)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
|
||||
Text(
|
||||
text = stringResource(id = R.string.device_disconnected),
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
|
||||
val text = when (reason) {
|
||||
Reason.USER -> stringResource(id = R.string.device_reason_user)
|
||||
Reason.LINK_LOSS -> stringResource(id = R.string.device_reason_link_loss)
|
||||
Reason.MISSING_SERVICE -> stringResource(id = R.string.device_reason_missing_service)
|
||||
}
|
||||
|
||||
Text(
|
||||
text = text,
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun DeviceDisconnectedView_Preview() {
|
||||
DeviceConnectingView()
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package no.nordicsemi.android.theme.view.scanner
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.HourglassTop
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import no.nordicsemi.android.theme.R
|
||||
import no.nordicsemi.android.theme.view.ScreenSection
|
||||
|
||||
@Composable
|
||||
fun NoDeviceView() {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(16.dp)
|
||||
) {
|
||||
ScreenSection {
|
||||
Icon(
|
||||
imageVector = Icons.Default.HourglassTop,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onSecondary,
|
||||
modifier = Modifier
|
||||
.background(
|
||||
color = MaterialTheme.colorScheme.secondary,
|
||||
shape = CircleShape
|
||||
)
|
||||
.padding(8.dp)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
|
||||
Text(
|
||||
text = stringResource(id = R.string.device_connecting),
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
|
||||
Text(
|
||||
text = stringResource(id = R.string.device_explanation),
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
|
||||
Text(
|
||||
text = stringResource(id = R.string.device_please_wait),
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.titleLarge
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun NoDeviceView_Preview() {
|
||||
DeviceConnectingView()
|
||||
}
|
||||
@@ -11,6 +11,11 @@
|
||||
<string name="disconnect">DISCONNECT</string>
|
||||
<string name="field_battery">Battery</string>
|
||||
|
||||
<string name="device_disconnected">Disconnected</string>
|
||||
<string name="device_reason_user">Device disconnected successfully.</string>
|
||||
<string name="device_reason_link_loss">Device signal has been lost.</string>
|
||||
<string name="device_reason_missing_service">Device was disconnected, because required services are missing.</string>
|
||||
|
||||
<string name="device_connecting">Connecting</string>
|
||||
<string name="device_explanation">The mobile is trying to connect to peripheral device.</string>
|
||||
<string name="device_please_wait">Please wait...</string>
|
||||
|
||||
Reference in New Issue
Block a user