From 82446f2af099f3b04cb95923b79b28cf1b5c3f27 Mon Sep 17 00:00:00 2001 From: "brian.orwe" Date: Mon, 30 Oct 2023 00:00:11 +0300 Subject: [PATCH 1/3] Make the press reaction more visible --- .../com/droidconke/chai/colors/ChaiColors.kt | 4 +-- .../models/SessionsInformationDomainModel.kt | 17 ++++++++++- .../common/bottomnav/BottomNavigationBar.kt | 28 ++++++++++++------- .../presentation/feed/view/FeedComponent.kt | 2 +- .../components/HomeHeaderSectionComponent.kt | 17 ++++++++++- .../components/HomeSectionHeaderComponent.kt | 21 ++++++++++++-- .../home/components/HomeSessionSection.kt | 1 - .../home/components/HomeSpeakerComponent.kt | 3 +- .../home/components/HomeToolbarComponent.kt | 16 ++++++++++- .../presentation/home/screen/HomeScreen.kt | 2 +- .../sessions/components/CustomSwitch.kt | 17 +++++++++-- .../components/SessionStateComponent.kt | 8 +++--- .../speakers/view/SpeakersScreen.kt | 3 +- .../utils/ChaiLightAndDarkComposePreview.kt | 17 ++++++++++- .../sessions/view/SessionScreenTest.kt | 2 -- 15 files changed, 126 insertions(+), 32 deletions(-) diff --git a/chai/src/main/java/com/droidconke/chai/colors/ChaiColors.kt b/chai/src/main/java/com/droidconke/chai/colors/ChaiColors.kt index fdf4720c..a39aac0f 100644 --- a/chai/src/main/java/com/droidconke/chai/colors/ChaiColors.kt +++ b/chai/src/main/java/com/droidconke/chai/colors/ChaiColors.kt @@ -36,7 +36,7 @@ data class ChaiColors( val activeBottomNavIconColor: Color = Color.Unspecified, val inactiveBottomNavIconColor: Color = Color.Unspecified, val titleTextColorPrimary: Color = Color.Unspecified, - val linkTextColorPrimary: Color = Color.Unspecified, + val linkTextColorPrimary: Color = Color.Unspecified ) val LocalChaiColorsPalette = staticCompositionLocalOf { ChaiColors() } @@ -61,4 +61,4 @@ val ChaiDarkColorPalette = ChaiColors( inactiveBottomNavIconColor = ChaiWhite, titleTextColorPrimary = ChaiWhite, linkTextColorPrimary = ChaiLightGrey -) +) \ No newline at end of file diff --git a/domain/src/main/java/com/android254/domain/models/SessionsInformationDomainModel.kt b/domain/src/main/java/com/android254/domain/models/SessionsInformationDomainModel.kt index e261472e..3e3134d3 100644 --- a/domain/src/main/java/com/android254/domain/models/SessionsInformationDomainModel.kt +++ b/domain/src/main/java/com/android254/domain/models/SessionsInformationDomainModel.kt @@ -1,6 +1,21 @@ +/* + * Copyright 2023 DroidconKE + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android254.domain.models data class SessionsInformationDomainModel( val sessions: List, val eventDays: List -) +) \ No newline at end of file diff --git a/presentation/src/main/java/com/android254/presentation/common/bottomnav/BottomNavigationBar.kt b/presentation/src/main/java/com/android254/presentation/common/bottomnav/BottomNavigationBar.kt index 68287203..121d820a 100644 --- a/presentation/src/main/java/com/android254/presentation/common/bottomnav/BottomNavigationBar.kt +++ b/presentation/src/main/java/com/android254/presentation/common/bottomnav/BottomNavigationBar.kt @@ -15,9 +15,12 @@ */ package com.android254.presentation.common.bottomnav +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import androidx.navigation.NavDestination.Companion.hierarchy @@ -30,23 +33,28 @@ import com.android254.presentation.common.theme.DroidconKE2023Theme @Composable fun BottomNavigationBar(navController: NavHostController) { - BottomAppBar(containerColor = MaterialTheme.colorScheme.background) { + BottomAppBar( + containerColor = MaterialTheme.colorScheme.background + ) { val navBackStackEntry by navController.currentBackStackEntryAsState() val currentDestination = navBackStackEntry?.destination bottomNavigationDestinations.forEach { destination -> - val selected = - currentDestination?.hierarchy?.any { it.route == destination.route } == true NavigationBarItem( - selected = selected, + selected = currentDestination?.hierarchy?.any { it.route == destination.route } == true, icon = { - Icon( - painter = painterResource(id = destination.icon), - contentDescription = destination.title - ) + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center + ) { + Icon( + painter = painterResource(id = destination.icon), + contentDescription = destination.title + ) + Text(text = destination.title) + } }, - label = { Text(text = destination.title) }, - alwaysShowLabel = true, + alwaysShowLabel = false, onClick = { navController.navigate(destination.route) { launchSingleTop = true diff --git a/presentation/src/main/java/com/android254/presentation/feed/view/FeedComponent.kt b/presentation/src/main/java/com/android254/presentation/feed/view/FeedComponent.kt index 30d423c5..aa45e692 100644 --- a/presentation/src/main/java/com/android254/presentation/feed/view/FeedComponent.kt +++ b/presentation/src/main/java/com/android254/presentation/feed/view/FeedComponent.kt @@ -63,7 +63,7 @@ fun FeedComponent( .wrapContentHeight(), shape = RoundedCornerShape(5), elevation = CardDefaults.cardElevation(defaultElevation = 2.dp), - colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.onPrimary), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.onPrimary) ) { Column( modifier = Modifier.padding(vertical = 8.dp, horizontal = 16.dp), diff --git a/presentation/src/main/java/com/android254/presentation/home/components/HomeHeaderSectionComponent.kt b/presentation/src/main/java/com/android254/presentation/home/components/HomeHeaderSectionComponent.kt index 06b3d24d..18385864 100644 --- a/presentation/src/main/java/com/android254/presentation/home/components/HomeHeaderSectionComponent.kt +++ b/presentation/src/main/java/com/android254/presentation/home/components/HomeHeaderSectionComponent.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2023 DroidconKE + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android254.presentation.home.components import androidx.compose.material3.Text @@ -23,7 +38,7 @@ fun HomeHeaderSectionComponent() { @ChaiLightAndDarkComposePreview @Composable -private fun HomeHeaderSectionComponentPreview(){ +private fun HomeHeaderSectionComponentPreview() { ChaiDCKE22Theme { HomeHeaderSectionComponent() } diff --git a/presentation/src/main/java/com/android254/presentation/home/components/HomeSectionHeaderComponent.kt b/presentation/src/main/java/com/android254/presentation/home/components/HomeSectionHeaderComponent.kt index d6960e4a..1b7a7a46 100644 --- a/presentation/src/main/java/com/android254/presentation/home/components/HomeSectionHeaderComponent.kt +++ b/presentation/src/main/java/com/android254/presentation/home/components/HomeSectionHeaderComponent.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2023 DroidconKE + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android254.presentation.home.components import android.content.res.Configuration @@ -83,7 +98,7 @@ fun HomeSectionHeaderComponent( .width(34.dp) .background( color = MaterialTheme.chaiColorsPalette.linkTextColorPrimary.copy(alpha = 0.11f), - shape = RoundedCornerShape(14.dp), + shape = RoundedCornerShape(14.dp) ) ) { Text( @@ -102,11 +117,11 @@ fun HomeSectionHeaderComponent( @Preview( name = "Light", - uiMode = Configuration.UI_MODE_NIGHT_NO, + uiMode = Configuration.UI_MODE_NIGHT_NO ) @Preview( name = "Dark", - uiMode = Configuration.UI_MODE_NIGHT_YES, + uiMode = Configuration.UI_MODE_NIGHT_YES ) @Composable private fun HomeSectionHeaderComponentPreview() { diff --git a/presentation/src/main/java/com/android254/presentation/home/components/HomeSessionSection.kt b/presentation/src/main/java/com/android254/presentation/home/components/HomeSessionSection.kt index 2a226720..273f4c68 100644 --- a/presentation/src/main/java/com/android254/presentation/home/components/HomeSessionSection.kt +++ b/presentation/src/main/java/com/android254/presentation/home/components/HomeSessionSection.kt @@ -80,7 +80,6 @@ fun HomeSessionSection( } } - @Composable fun HomeSessionContent( session: SessionPresentationModel, diff --git a/presentation/src/main/java/com/android254/presentation/home/components/HomeSpeakerComponent.kt b/presentation/src/main/java/com/android254/presentation/home/components/HomeSpeakerComponent.kt index 74083b26..f7e05d64 100644 --- a/presentation/src/main/java/com/android254/presentation/home/components/HomeSpeakerComponent.kt +++ b/presentation/src/main/java/com/android254/presentation/home/components/HomeSpeakerComponent.kt @@ -71,7 +71,8 @@ fun HomeSpeakerComponent(speaker: SpeakerUI, onClick: () -> Unit = {}) { ) .border( border = BorderStroke( - 2.dp, color = colorResource(id = R.color.cyan) + 2.dp, + color = colorResource(id = R.color.cyan) ), shape = RoundedCornerShape(12.dp) ) diff --git a/presentation/src/main/java/com/android254/presentation/home/components/HomeToolbarComponent.kt b/presentation/src/main/java/com/android254/presentation/home/components/HomeToolbarComponent.kt index 916943de..76fca9a5 100644 --- a/presentation/src/main/java/com/android254/presentation/home/components/HomeToolbarComponent.kt +++ b/presentation/src/main/java/com/android254/presentation/home/components/HomeToolbarComponent.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2023 DroidconKE + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android254.presentation.home.components import androidx.compose.runtime.Composable @@ -26,7 +41,6 @@ fun HomeToolbarComponent( } } - @ChaiLightAndDarkComposePreview @Composable private fun HomeToolbarComponentPreview() { diff --git a/presentation/src/main/java/com/android254/presentation/home/screen/HomeScreen.kt b/presentation/src/main/java/com/android254/presentation/home/screen/HomeScreen.kt index be5b3b21..a408efdb 100644 --- a/presentation/src/main/java/com/android254/presentation/home/screen/HomeScreen.kt +++ b/presentation/src/main/java/com/android254/presentation/home/screen/HomeScreen.kt @@ -52,7 +52,7 @@ fun HomeRoute( navigateToFeedbackScreen: () -> Unit = {}, navigateToSessionScreen: () -> Unit = {}, onActionClicked: () -> Unit = {}, - onSessionClicked: (sessionId: String) -> Unit = {}, + onSessionClicked: (sessionId: String) -> Unit = {} ) { val homeViewState by homeViewModel.viewState.collectAsStateWithLifecycle() val isSyncing by homeViewModel.isSyncing.collectAsStateWithLifecycle() diff --git a/presentation/src/main/java/com/android254/presentation/sessions/components/CustomSwitch.kt b/presentation/src/main/java/com/android254/presentation/sessions/components/CustomSwitch.kt index e2fe7b97..94ecbd86 100644 --- a/presentation/src/main/java/com/android254/presentation/sessions/components/CustomSwitch.kt +++ b/presentation/src/main/java/com/android254/presentation/sessions/components/CustomSwitch.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2023 DroidconKE + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android254.presentation.sessions.components import androidx.compose.animation.core.animateFloatAsState @@ -29,7 +44,6 @@ import androidx.compose.ui.unit.dp import com.android254.presentation.utils.ChaiLightAndDarkComposePreview import com.droidconke.chai.ChaiDCKE22Theme - @Composable fun CustomSwitch( width: Dp = 72.dp, @@ -107,7 +121,6 @@ private fun animateAlignmentAsState( } } - @ChaiLightAndDarkComposePreview @Composable private fun CustomSwitchPreview() { diff --git a/presentation/src/main/java/com/android254/presentation/sessions/components/SessionStateComponent.kt b/presentation/src/main/java/com/android254/presentation/sessions/components/SessionStateComponent.kt index b1e17b0e..316a5fce 100644 --- a/presentation/src/main/java/com/android254/presentation/sessions/components/SessionStateComponent.kt +++ b/presentation/src/main/java/com/android254/presentation/sessions/components/SessionStateComponent.kt @@ -59,11 +59,11 @@ fun SessionsStateComponent( ) { val swipeRefreshState = rememberSwipeRefreshState(isRefreshing = isRefreshing) - if (sessionsUiState.isLoading){ + if (sessionsUiState.isLoading) { SessionLoadingComponent() } - if (sessionsUiState.isEmpty){ + if (sessionsUiState.isEmpty) { Column( modifier = Modifier .fillMaxSize(), @@ -89,11 +89,11 @@ fun SessionsStateComponent( } } - if (sessionsUiState.isError){ + if (sessionsUiState.isError) { SessionsErrorComponent(errorMessage = sessionsUiState.errorMessage, retry = retry) } - if (!sessionsUiState.isEmpty){ + if (!sessionsUiState.isEmpty) { SessionListComponent( swipeRefreshState = swipeRefreshState, sessions = sessionsUiState.sessions, diff --git a/presentation/src/main/java/com/android254/presentation/speakers/view/SpeakersScreen.kt b/presentation/src/main/java/com/android254/presentation/speakers/view/SpeakersScreen.kt index 2ddb69a3..f72ce7e9 100644 --- a/presentation/src/main/java/com/android254/presentation/speakers/view/SpeakersScreen.kt +++ b/presentation/src/main/java/com/android254/presentation/speakers/view/SpeakersScreen.kt @@ -68,6 +68,7 @@ fun SpeakersRoute( navigateToSpeaker = navigateToSpeaker ) } + @Composable private fun SpeakersScreen( uiState: SpeakersScreenUiState, @@ -82,7 +83,7 @@ private fun SpeakersScreen( text = stringResource(id = R.string.speakers_label), fontSize = 24.sp, fontFamily = FontFamily(Font(R.font.montserrat_regular)), - color = MaterialTheme.chaiColorsPalette.textColorPrimary, + color = MaterialTheme.chaiColorsPalette.textColorPrimary ) }, navigationIcon = { diff --git a/presentation/src/main/java/com/android254/presentation/utils/ChaiLightAndDarkComposePreview.kt b/presentation/src/main/java/com/android254/presentation/utils/ChaiLightAndDarkComposePreview.kt index f50b6b72..9d5a22be 100644 --- a/presentation/src/main/java/com/android254/presentation/utils/ChaiLightAndDarkComposePreview.kt +++ b/presentation/src/main/java/com/android254/presentation/utils/ChaiLightAndDarkComposePreview.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2023 DroidconKE + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.android254.presentation.utils import android.content.res.Configuration @@ -11,4 +26,4 @@ import androidx.compose.ui.tooling.preview.Preview name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES ) -annotation class ChaiLightAndDarkComposePreview +annotation class ChaiLightAndDarkComposePreview \ No newline at end of file diff --git a/presentation/src/test/java/com/android254/presentation/sessions/view/SessionScreenTest.kt b/presentation/src/test/java/com/android254/presentation/sessions/view/SessionScreenTest.kt index 4a4dc689..a9ace868 100644 --- a/presentation/src/test/java/com/android254/presentation/sessions/view/SessionScreenTest.kt +++ b/presentation/src/test/java/com/android254/presentation/sessions/view/SessionScreenTest.kt @@ -50,7 +50,6 @@ class SessionScreenTest { @Test fun hasExpectedButtons() = runTest { - composeTestRule.setContent { DroidconKE2023Theme { SessionsScreen( @@ -78,7 +77,6 @@ class SessionScreenTest { @Test fun `should show topBar`() = runTest { - composeTestRule.setContent { DroidconKE2023Theme() { SessionsScreen( From e9d40a8dd310e64addabc03123ffce70f493b544 Mon Sep 17 00:00:00 2001 From: "brian.orwe" Date: Mon, 30 Oct 2023 00:22:00 +0300 Subject: [PATCH 2/3] Fix bottom bar text, highlight when selected --- .../common/bottomnav/BottomNavigationBar.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/presentation/src/main/java/com/android254/presentation/common/bottomnav/BottomNavigationBar.kt b/presentation/src/main/java/com/android254/presentation/common/bottomnav/BottomNavigationBar.kt index 121d820a..1a77726e 100644 --- a/presentation/src/main/java/com/android254/presentation/common/bottomnav/BottomNavigationBar.kt +++ b/presentation/src/main/java/com/android254/presentation/common/bottomnav/BottomNavigationBar.kt @@ -40,8 +40,9 @@ fun BottomNavigationBar(navController: NavHostController) { val currentDestination = navBackStackEntry?.destination bottomNavigationDestinations.forEach { destination -> + val selected = currentDestination?.hierarchy?.any { it.route == destination.route } == true NavigationBarItem( - selected = currentDestination?.hierarchy?.any { it.route == destination.route } == true, + selected = selected, icon = { Column( horizontalAlignment = Alignment.CenterHorizontally, @@ -51,7 +52,10 @@ fun BottomNavigationBar(navController: NavHostController) { painter = painterResource(id = destination.icon), contentDescription = destination.title ) - Text(text = destination.title) + Text( + text = destination.title, + color = if (selected) MaterialTheme.colorScheme.secondary else MaterialTheme.colorScheme.onBackground + ) } }, alwaysShowLabel = false, @@ -65,8 +69,6 @@ fun BottomNavigationBar(navController: NavHostController) { colors = NavigationBarItemDefaults.colors( selectedIconColor = MaterialTheme.colorScheme.primary, unselectedIconColor = MaterialTheme.colorScheme.onBackground, - selectedTextColor = MaterialTheme.colorScheme.secondary, - unselectedTextColor = MaterialTheme.colorScheme.onBackground, indicatorColor = MaterialTheme.colorScheme.background.copy(alpha = 0f) ) ) From 2af8acc3bc26fadc3a7a2e5d1418bd27db4bfd12 Mon Sep 17 00:00:00 2001 From: "brian.orwe" Date: Mon, 30 Oct 2023 00:54:47 +0300 Subject: [PATCH 3/3] Almost forgot about the padding --- .../presentation/common/bottomnav/BottomNavigationBar.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/android254/presentation/common/bottomnav/BottomNavigationBar.kt b/presentation/src/main/java/com/android254/presentation/common/bottomnav/BottomNavigationBar.kt index 1a77726e..03870c21 100644 --- a/presentation/src/main/java/com/android254/presentation/common/bottomnav/BottomNavigationBar.kt +++ b/presentation/src/main/java/com/android254/presentation/common/bottomnav/BottomNavigationBar.kt @@ -17,12 +17,15 @@ package com.android254.presentation.common.bottomnav import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.padding import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp import androidx.navigation.NavDestination.Companion.hierarchy import androidx.navigation.NavHostController import androidx.navigation.compose.currentBackStackEntryAsState @@ -53,8 +56,10 @@ fun BottomNavigationBar(navController: NavHostController) { contentDescription = destination.title ) Text( + modifier = Modifier.padding(top = 8.dp), text = destination.title, - color = if (selected) MaterialTheme.colorScheme.secondary else MaterialTheme.colorScheme.onBackground + color = if (selected) MaterialTheme.colorScheme.secondary else MaterialTheme.colorScheme.onBackground, + fontSize = MaterialTheme.typography.labelMedium.fontSize ) } },