Skip to content

Commit

Permalink
adds material 3
Browse files Browse the repository at this point in the history
  • Loading branch information
brandyodhiambo committed Oct 16, 2023
1 parent f0ee698 commit fa78e59
Show file tree
Hide file tree
Showing 49 changed files with 839 additions and 730 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id("kotlin-kapt")
id("dagger.hilt.android.plugin")
id("kotlin-parcelize")
id("com.google.devtools.ksp") version ("1.7.10-1.0.6")
id("com.google.devtools.ksp") version ("1.8.10-1.0.9")
}

apply {
Expand Down
15 changes: 9 additions & 6 deletions app/src/main/java/com/brandyodhiambo/quench/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.navigation.NavDestination
import androidx.navigation.NavDestination.Companion.hierarchy
import com.brandyodhiambo.common.domain.model.AlarmData
import com.brandyodhiambo.designsystem.theme.QuenchTheme
import com.brandyodhiambo.designsystem.theme.Theme
import com.brandyodhiambo.home.presentation.homeScreen.HomeViewModel
import com.brandyodhiambo.quench.R
import com.brandyodhiambo.quench.navigation.FeatureNavigator
Expand Down Expand Up @@ -59,10 +60,12 @@ class MainActivity : ComponentActivity() {
val viewModel: HomeViewModel by viewModels()
setContent {
createChannel(this)
QuenchTheme {
QuenchTheme(
theme = Theme.FOLLOW_SYSTEM.themeValue,
) {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
color = MaterialTheme.colors.background,
) {
startAchievementOnetimeWorkRequest(applicationContext)
startDailyOnetimeWorkRequest(applicationContext)
Expand All @@ -75,7 +78,7 @@ class MainActivity : ComponentActivity() {
val scheduler = AlarmSchedularImpl(this)
val alarmItem = AlarmData(
time = LocalDateTime.now().withHour(hours).withMinute(minutes),
message = getString(R.string.it_s_time_to_drink_water)
message = getString(R.string.it_s_time_to_drink_water),
)
alarmItem.let(scheduler::schedule)
val navController = rememberAnimatedNavController()
Expand All @@ -87,9 +90,9 @@ class MainActivity : ComponentActivity() {
engine = navHostEngine,
dependenciesContainerBuilder = {
dependency(
currentNavigator()
currentNavigator(),
)
}
},
)
}
}
Expand All @@ -100,7 +103,7 @@ class MainActivity : ComponentActivity() {
fun DestinationScope<*>.currentNavigator(): FeatureNavigator {
return FeatureNavigator(
navController = navController,
navGraph = navBackStackEntry.destination.navGraph()
navGraph = navBackStackEntry.destination.navGraph(),
)
}

Expand Down
70 changes: 37 additions & 33 deletions app/src/main/java/com/brandyodhiambo/quench/ui/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,22 @@ package com.brandyodhiambo.quench.ui
import android.annotation.SuppressLint
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.Icon
import androidx.compose.material.LeadingIconTab
import androidx.compose.material.Scaffold
import androidx.compose.material.TabRow
import androidx.compose.material.TabRowDefaults
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.LeadingIconTab
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.TabRowDefaults
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.brandyodhiambo.designsystem.theme.primaryColor
import com.brandyodhiambo.designsystem.theme.roboto
import com.brandyodhiambo.quench.models.TabItem
import com.brandyodhiambo.settings.presentation.SettingsNavigator
import com.google.accompanist.pager.ExperimentalPagerApi
Expand All @@ -48,44 +45,44 @@ import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import kotlinx.coroutines.launch

@OptIn(ExperimentalPagerApi::class)
@OptIn(ExperimentalPagerApi::class, ExperimentalMaterial3Api::class)
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
@Composable
@Destination
fun MainScreen(
navigator: DestinationsNavigator,
settingsNavigator: SettingsNavigator
settingsNavigator: SettingsNavigator,
) {
Scaffold {
Scaffold { paddingValue ->
val tabs = listOf(
TabItem.Home(navigator = navigator),
TabItem.Statistic(navigator = navigator),
TabItem.Settings(navigator = settingsNavigator)
TabItem.Settings(navigator = settingsNavigator),
)
val pagerState = rememberPagerState()

Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
horizontalAlignment = Alignment.CenterHorizontally,
) {
TopAppBar(
title = {
Text(
text = "Quench",
fontSize = 30.sp,
textAlign = TextAlign.Center,
fontFamily = roboto
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onPrimary,
)
},
modifier = Modifier.fillMaxWidth(),
backgroundColor = primaryColor,
contentColor = Color.White,
elevation = 4.dp
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.primary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
),
)
CustomTab(tabs = tabs, pagerState = pagerState)
TabContent(
tabs = tabs,
pagerState = pagerState
pagerState = pagerState,
)
}
}
Expand All @@ -95,11 +92,11 @@ fun MainScreen(
@Composable
fun TabContent(
tabs: List<TabItem>,
pagerState: PagerState
pagerState: PagerState,
) {
HorizontalPager(count = tabs.size, state = pagerState) { page ->
tabs[page].screen(
onClick = { }
onClick = { },
)
}
}
Expand All @@ -108,26 +105,26 @@ fun TabContent(
@Composable
fun CustomTab(
tabs: List<TabItem>,
pagerState: PagerState
pagerState: PagerState,
) {
val scope = rememberCoroutineScope()

TabRow(
selectedTabIndex = pagerState.currentPage,
backgroundColor = primaryColor,
contentColor = Color.White,
backgroundColor = MaterialTheme.colorScheme.primary,
contentColor = MaterialTheme.colorScheme.onPrimary,
indicator = { tabPositions ->
TabRowDefaults.Indicator(
Modifier.pagerTabIndicatorOffset(pagerState, tabPositions)
Modifier.pagerTabIndicatorOffset(pagerState, tabPositions),
)
}
},
) {
tabs.forEachIndexed { index, tabItem ->
LeadingIconTab(
icon = {
Icon(
painter = painterResource(id = tabItem.icon),
contentDescription = ""
contentDescription = "",
)
},
selected = pagerState.currentPage == index,
Expand All @@ -136,7 +133,14 @@ fun CustomTab(
pagerState.animateScrollToPage(index)
}
},
text = { Text(text = tabItem.title, maxLines = 1, overflow = TextOverflow.Ellipsis, fontFamily = roboto) }
text = {
Text(
text = tabItem.title,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.titleMedium,
)
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import com.brandyodhiambo.common.domain.model.AlarmData
import java.time.ZoneId

class AlarmSchedularImpl(
private val context: Context
private val context: Context,
) : AlarmSchedular {

private val alarmManager = context.getSystemService(AlarmManager::class.java)
Expand All @@ -39,8 +39,8 @@ class AlarmSchedularImpl(
context,
item.hashCode(),
intent,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
),
)
}

Expand All @@ -50,8 +50,8 @@ class AlarmSchedularImpl(
context,
item.hashCode(),
Intent(context, AlarmReceiver::class.java),
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
),
)
}
}
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.google.dagger:hilt-android-gradle-plugin:2.42")
classpath("com.google.dagger:hilt-android-gradle-plugin:2.44")
classpath("com.diffplug.spotless:spotless-plugin-gradle:6.19.0")
}
} // Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version ("7.2.1") apply false
id("com.android.library") version ("7.2.1") apply false
id("org.jetbrains.kotlin.android") version ("1.7.0") apply false
id("org.jetbrains.kotlin.android") version ("1.8.10") apply false

id("org.jlleitschuh.gradle.ktlint") version "11.3.1" apply false
id("com.diffplug.spotless") version "6.19.0" apply false
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object Versions {
const val compose_version = "1.2.0"
const val compose_version = "1.4.2"
const val room_version = "2.4.3"
const val work_version = "2.7.1"
const val lottie_version = "5.2.0"
Expand Down
Binary file removed core/build/intermediates/ktLint/reporterProviders.bin
Binary file not shown.
Binary file removed core/build/intermediates/ktLint/reporters.bin
Binary file not shown.
Loading

0 comments on commit fa78e59

Please sign in to comment.