From 20e870c277434150d932e56ea1f1633fd07d0956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sylwester=20Zieli=C5=84ski?= Date: Fri, 4 Feb 2022 09:46:40 +0100 Subject: [PATCH] Redesign home screen --- .../nrftoolbox/ExampleInstrumentedTest.kt | 22 --- .../android/nrftoolbox/FeatureButton.kt | 12 +- .../nordicsemi/android/nrftoolbox/HomeView.kt | 125 ++++++++---------- .../android/nrftoolbox/ExampleUnitTest.kt | 16 --- 4 files changed, 58 insertions(+), 117 deletions(-) delete mode 100644 app/src/androidTest/java/no/nordicsemi/android/nrftoolbox/ExampleInstrumentedTest.kt delete mode 100644 app/src/test/java/no/nordicsemi/android/nrftoolbox/ExampleUnitTest.kt diff --git a/app/src/androidTest/java/no/nordicsemi/android/nrftoolbox/ExampleInstrumentedTest.kt b/app/src/androidTest/java/no/nordicsemi/android/nrftoolbox/ExampleInstrumentedTest.kt deleted file mode 100644 index 8c2487ff..00000000 --- a/app/src/androidTest/java/no/nordicsemi/android/nrftoolbox/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -package no.nordicsemi.android.nrftoolbox - -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry -import org.junit.Assert.assertEquals -import org.junit.Test -import org.junit.runner.RunWith - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("no.nordicsemi.android.nrftoolbox", appContext.packageName) - } -} \ No newline at end of file diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/FeatureButton.kt b/app/src/main/java/no/nordicsemi/android/nrftoolbox/FeatureButton.kt index 28eadbae..2a4572d0 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/FeatureButton.kt +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/FeatureButton.kt @@ -29,10 +29,10 @@ fun FeatureButton( onClick: () -> Unit ) { ScreenSection(onClick = onClick) { - Column( + Row( modifier = Modifier.fillMaxWidth(), - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Center ) { Image( painter = painterResource(iconId), @@ -46,12 +46,12 @@ fun FeatureButton( .padding(16.dp) ) - Spacer(modifier = Modifier.height(8.dp)) + Spacer(modifier = Modifier.size(16.dp)) Text( text = stringResource(id = name), - style = MaterialTheme.typography.bodyMedium, - modifier = Modifier.fillMaxWidth().height(42.dp), + style = MaterialTheme.typography.titleMedium, + modifier = Modifier.fillMaxWidth(), textAlign = TextAlign.Center ) } diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/HomeView.kt b/app/src/main/java/no/nordicsemi/android/nrftoolbox/HomeView.kt index d2155e55..f765b13f 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/HomeView.kt +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/HomeView.kt @@ -3,8 +3,9 @@ package no.nordicsemi.android.nrftoolbox import androidx.compose.foundation.layout.* import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.stringResource @@ -31,62 +32,66 @@ fun HomeScreen() { ) { Spacer(modifier = Modifier.height(16.dp)) - DoubleSection( - leftView = { - FeatureButton(R.drawable.ic_csc, R.string.csc_module, R.string.csc_module_full) { - viewModel.openProfile(ProfileDestination.CSC) - } - }, - rightView = { - FeatureButton(R.drawable.ic_hrs, R.string.hrs_module, R.string.hrs_module_full) { - viewModel.openProfile(ProfileDestination.HRS) - } - } + Text( + text = "Bluetooth services", + style = MaterialTheme.typography.titleLarge, + modifier = Modifier.fillMaxWidth(), ) Spacer(modifier = Modifier.height(16.dp)) - DoubleSection( - leftView = { - FeatureButton(R.drawable.ic_gls, R.string.gls_module, R.string.gls_module_full) { - viewModel.openProfile(ProfileDestination.GLS) - } - }, - rightView = { - FeatureButton(R.drawable.ic_hts, R.string.hts_module, R.string.hts_module_full) { - viewModel.openProfile(ProfileDestination.HTS) - } - } - ) + FeatureButton(R.drawable.ic_csc, R.string.csc_module, R.string.csc_module_full) { + viewModel.openProfile(ProfileDestination.CSC) + } Spacer(modifier = Modifier.height(16.dp)) - DoubleSection( - leftView = { - FeatureButton(R.drawable.ic_bps, R.string.bps_module, R.string.bps_module_full) { - viewModel.openProfile(ProfileDestination.BPS) - } - }, - rightView = { - FeatureButton(R.drawable.ic_rscs, R.string.rscs_module, R.string.rscs_module_full) { - viewModel.openProfile(ProfileDestination.RSCS) - } - } - ) + FeatureButton(R.drawable.ic_hrs, R.string.hrs_module, R.string.hrs_module_full) { + viewModel.openProfile(ProfileDestination.HRS) + } Spacer(modifier = Modifier.height(16.dp)) - DoubleSection( - leftView = { - FeatureButton(R.drawable.ic_prx, R.string.prx_module, R.string.prx_module_full) { - viewModel.openProfile(ProfileDestination.PRX) - } - }, - rightView = { - FeatureButton(R.drawable.ic_cgm, R.string.cgm_module, R.string.cgm_module_full) { - viewModel.openProfile(ProfileDestination.CGMS) - } - } + FeatureButton(R.drawable.ic_gls, R.string.gls_module, R.string.gls_module_full) { + viewModel.openProfile(ProfileDestination.GLS) + } + + Spacer(modifier = Modifier.height(16.dp)) + + FeatureButton(R.drawable.ic_hts, R.string.hts_module, R.string.hts_module_full) { + viewModel.openProfile(ProfileDestination.HTS) + } + + Spacer(modifier = Modifier.height(16.dp)) + + FeatureButton(R.drawable.ic_bps, R.string.bps_module, R.string.bps_module_full) { + viewModel.openProfile(ProfileDestination.BPS) + } + + Spacer(modifier = Modifier.height(16.dp)) + + FeatureButton(R.drawable.ic_rscs, R.string.rscs_module, R.string.rscs_module_full) { + viewModel.openProfile(ProfileDestination.RSCS) + } + + Spacer(modifier = Modifier.height(16.dp)) + + FeatureButton(R.drawable.ic_prx, R.string.prx_module, R.string.prx_module_full) { + viewModel.openProfile(ProfileDestination.PRX) + } + + Spacer(modifier = Modifier.height(16.dp)) + + FeatureButton(R.drawable.ic_cgm, R.string.cgm_module, R.string.cgm_module_full) { + viewModel.openProfile(ProfileDestination.CGMS) + } + + Spacer(modifier = Modifier.height(16.dp)) + + Text( + text = "Utils services", + style = MaterialTheme.typography.titleLarge, + modifier = Modifier.fillMaxWidth(), ) Spacer(modifier = Modifier.height(16.dp)) @@ -107,29 +112,3 @@ fun HomeScreen() { } } } - -@Composable -private fun DoubleSection( - leftView: @Composable () -> Unit, - rightView: @Composable () -> Unit, -) { - Row(horizontalArrangement = Arrangement.SpaceEvenly) { - Box( - modifier = Modifier - .weight(1f) - .fillMaxSize(), - contentAlignment = Alignment.Center - ) { - leftView() - } - Spacer(modifier = Modifier.width(16.dp)) - Box( - modifier = Modifier - .weight(1f) - .fillMaxSize(), - contentAlignment = Alignment.Center - ) { - rightView() - } - } -} diff --git a/app/src/test/java/no/nordicsemi/android/nrftoolbox/ExampleUnitTest.kt b/app/src/test/java/no/nordicsemi/android/nrftoolbox/ExampleUnitTest.kt deleted file mode 100644 index f5fcf868..00000000 --- a/app/src/test/java/no/nordicsemi/android/nrftoolbox/ExampleUnitTest.kt +++ /dev/null @@ -1,16 +0,0 @@ -package no.nordicsemi.android.nrftoolbox - -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} \ No newline at end of file