Implementation for loading DFU file.

This commit is contained in:
Sylwester Zieliński
2022-01-10 09:36:38 +01:00
parent c75f16657b
commit 0993799e42
29 changed files with 472 additions and 313 deletions

View File

@@ -4,8 +4,12 @@ import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
@@ -29,12 +33,11 @@ fun FeatureButton(
@StringRes name: Int,
onClick: () -> Unit
) {
ScreenSection {
ScreenSection(onClick = onClick) {
Column(
modifier = Modifier
.fillMaxWidth()
.height(150.dp)
.clickable { onClick() }
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {

View File

@@ -136,156 +136,161 @@ fun HomeView(callback: (NavDestination) -> Unit) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 16.dp)
.verticalScroll(rememberScrollState())
) {
Spacer(modifier = Modifier.height(16.dp))
Column(
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 16.dp)
) {
Spacer(modifier = Modifier.height(16.dp))
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_csc,
R.string.csc_module,
R.string.csc_module_full
) { callback(NavDestination.CSC) }
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_csc,
R.string.csc_module,
R.string.csc_module_full
) { callback(NavDestination.CSC) }
}
Spacer(modifier = Modifier.width(16.dp))
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_hrs, R.string.hrs_module,
R.string.hrs_module_full
) { callback(NavDestination.HRS) }
}
}
Spacer(modifier = Modifier.width(16.dp))
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_hrs, R.string.hrs_module,
R.string.hrs_module_full
) { callback(NavDestination.HRS) }
Spacer(modifier = Modifier.height(16.dp))
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_gls, R.string.gls_module,
R.string.gls_module_full
) { callback(NavDestination.GLS) }
}
Spacer(modifier = Modifier.width(16.dp))
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_hts, R.string.hts_module,
R.string.hts_module_full
) { callback(NavDestination.HTS) }
}
}
Spacer(modifier = Modifier.height(16.dp))
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_bps, R.string.bps_module,
R.string.bps_module_full
) { callback(NavDestination.BPS) }
}
Spacer(modifier = Modifier.width(16.dp))
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_rscs,
R.string.rscs_module,
R.string.rscs_module_full
) { callback(NavDestination.RSCS) }
}
}
Spacer(modifier = Modifier.height(16.dp))
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_prx, R.string.prx_module,
R.string.prx_module_full
) { callback(NavDestination.PRX) }
}
Spacer(modifier = Modifier.width(16.dp))
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_cgm, R.string.cgm_module,
R.string.cgm_module_full
) { callback(NavDestination.CGMS) }
}
}
Spacer(modifier = Modifier.height(16.dp))
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_uart, R.string.uart_module,
R.string.uart_module_full
) { callback(NavDestination.UART) }
}
}
Spacer(modifier = Modifier.height(16.dp))
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_dfu, R.string.dfu_module,
R.string.uart_module_full
) { callback(NavDestination.DFU) }
}
}
Spacer(modifier = Modifier.height(16.dp))
}
Spacer(modifier = Modifier.height(16.dp))
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_gls, R.string.gls_module,
R.string.gls_module_full
) { callback(NavDestination.GLS) }
}
Spacer(modifier = Modifier.width(16.dp))
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_hts, R.string.hts_module,
R.string.hts_module_full
) { callback(NavDestination.HTS) }
}
}
Spacer(modifier = Modifier.height(16.dp))
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_bps, R.string.bps_module,
R.string.bps_module_full
) { callback(NavDestination.BPS) }
}
Spacer(modifier = Modifier.width(16.dp))
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_rscs,
R.string.rscs_module,
R.string.rscs_module_full
) { callback(NavDestination.RSCS) }
}
}
Spacer(modifier = Modifier.height(16.dp))
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_prx, R.string.prx_module,
R.string.prx_module_full
) { callback(NavDestination.PRX) }
}
Spacer(modifier = Modifier.width(16.dp))
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_cgm, R.string.cgm_module,
R.string.cgm_module_full
) { callback(NavDestination.CGMS) }
}
}
Spacer(modifier = Modifier.height(16.dp))
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_uart, R.string.uart_module,
R.string.uart_module_full
) { callback(NavDestination.UART) }
}
}
Spacer(modifier = Modifier.height(16.dp))
Row(horizontalArrangement = Arrangement.SpaceEvenly) {
Box(
modifier = Modifier
.weight(1f)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
FeatureButton(
R.drawable.ic_dfu, R.string.dfu_module,
R.string.uart_module_full
) { callback(NavDestination.DFU) }
}
}
Spacer(modifier = Modifier.height(16.dp))
}
}
}