Skip to content

Commit

Permalink
completes theming
Browse files Browse the repository at this point in the history
  • Loading branch information
brandyodhiambo committed Oct 17, 2023
1 parent fa78e59 commit 91b2d3e
Show file tree
Hide file tree
Showing 41 changed files with 572 additions and 541 deletions.
18 changes: 9 additions & 9 deletions app/src/main/java/com/brandyodhiambo/quench/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,24 @@ class MainActivity : ComponentActivity() {
setContent {
createChannel(this)
QuenchTheme(
theme = Theme.FOLLOW_SYSTEM.themeValue,
theme = Theme.FOLLOW_SYSTEM.themeValue
) {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background,
color = MaterialTheme.colors.background
) {
startAchievementOnetimeWorkRequest(applicationContext)
startDailyOnetimeWorkRequest(applicationContext)
startMonthlyOnetimeWorkRequest(applicationContext)
startWeeklyOnetimeWorkRequest(applicationContext)

val reminderTimeFromDb = viewModel.reminderTime.observeAsState()
val hours = reminderTimeFromDb.value?.hour ?: 0
val minutes = reminderTimeFromDb.value?.minute ?: 0
val reminderTimeFromDb = viewModel.reminderTime?.observeAsState()
val hours = reminderTimeFromDb?.value?.hour ?: 0
val minutes = reminderTimeFromDb?.value?.minute ?: 0
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 @@ -90,9 +90,9 @@ class MainActivity : ComponentActivity() {
engine = navHostEngine,
dependenciesContainerBuilder = {
dependency(
currentNavigator(),
currentNavigator()
)
},
}
)
}
}
Expand All @@ -103,7 +103,7 @@ class MainActivity : ComponentActivity() {
fun DestinationScope<*>.currentNavigator(): FeatureNavigator {
return FeatureNavigator(
navController = navController,
navGraph = navBackStackEntry.destination.navGraph(),
navGraph = navBackStackEntry.destination.navGraph()
)
}

Expand Down
31 changes: 17 additions & 14 deletions app/src/main/java/com/brandyodhiambo/quench/ui/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,38 +51,38 @@ import kotlinx.coroutines.launch
@Destination
fun MainScreen(
navigator: DestinationsNavigator,
settingsNavigator: SettingsNavigator,
settingsNavigator: SettingsNavigator
) {
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",
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onPrimary,
color = MaterialTheme.colorScheme.onPrimary
)
},
modifier = Modifier.fillMaxWidth(),
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.primary,
titleContentColor = MaterialTheme.colorScheme.onPrimary,
),
titleContentColor = MaterialTheme.colorScheme.onPrimary
)
)
CustomTab(tabs = tabs, pagerState = pagerState)
TabContent(
tabs = tabs,
pagerState = pagerState,
pagerState = pagerState
)
}
}
Expand All @@ -92,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 @@ -105,7 +105,7 @@ fun TabContent(
@Composable
fun CustomTab(
tabs: List<TabItem>,
pagerState: PagerState,
pagerState: PagerState
) {
val scope = rememberCoroutineScope()

Expand All @@ -116,15 +116,17 @@ fun CustomTab(
indicator = { tabPositions ->
TabRowDefaults.Indicator(
Modifier.pagerTabIndicatorOffset(pagerState, tabPositions),
color = MaterialTheme.colorScheme.onPrimary
)
},
}
) {
tabs.forEachIndexed { index, tabItem ->
LeadingIconTab(
icon = {
Icon(
painter = painterResource(id = tabItem.icon),
contentDescription = "",
tint = MaterialTheme.colorScheme.onPrimary,
contentDescription = ""
)
},
selected = pagerState.currentPage == index,
Expand All @@ -138,9 +140,10 @@ fun CustomTab(
text = tabItem.title,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.titleMedium,
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onPrimary
)
},
}
)
}
}
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 buildSrc/src/main/java/AndroidConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ object AndroidConfig {
const val minSdk = 26
const val targetSdk = 33
const val compileSdk = 33
const val versionCode = 2
const val versionName = "0.0.2"
const val versionCode = 3
const val versionName = "0.0.3"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package com.brandyodhiambo.common.domain.model

data class ReminderTime(
val hour: Int,
val minute: Int,
val ampm: String,
val isRepeated: Boolean,
val isAllDay: Boolean,
val days: List<Days>
val hour: Int?,
val minute: Int?,
val ampm: String?,
val isRepeated: Boolean?,
val isAllDay: Boolean?,
val days: List<Days>?
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.Card
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ExposedDropdownMenuBox
import androidx.compose.material.ExposedDropdownMenuDefaults
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.material.TextFieldDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExposedDropdownMenuBox
import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
Expand All @@ -53,7 +54,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.brandyodhiambo.common.R

@OptIn(ExperimentalMaterialApi::class)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun WaterIntakeDialog(
modifier: Modifier = Modifier,
Expand All @@ -62,31 +63,29 @@ fun WaterIntakeDialog(
currentWaterIntakeFormText: String,
onCurrentWaterIntakeTextChange: (String) -> Unit,
onCurrentWaterIntakeFormTextChange: (String) -> Unit,
onOkayClick: () -> Unit,
onOkayClick: () -> Unit

) {
Card(
shape = MaterialTheme.shapes.medium,
modifier = Modifier.padding(10.dp, 5.dp, 10.dp, 10.dp),
elevation = 0.dp,
backgroundColor = MaterialTheme.colorScheme.background,
colors = CardDefaults.cardColors(MaterialTheme.colorScheme.background)
) {
Column(
) {
Column() {
Image(
painter = painterResource(id = R.drawable.ic_cup),
contentScale = ContentScale.Fit,
colorFilter = ColorFilter.tint(
color = MaterialTheme.colorScheme.secondary,
color = MaterialTheme.colorScheme.secondary
),
contentDescription = null,
modifier = Modifier
.padding(top = 35.dp)
.height(70.dp)
.fillMaxWidth(),
.fillMaxWidth()
)
Column(
modifier = Modifier.padding(16.dp),
modifier = Modifier.padding(16.dp)
) {
Text(
text = "Water intake goal",
Expand All @@ -97,13 +96,14 @@ fun WaterIntakeDialog(
maxLines = 2,
style = MaterialTheme.typography.labelLarge,
overflow = TextOverflow.Ellipsis,
color = MaterialTheme.colorScheme.onBackground
)
Spacer(modifier = Modifier.height(8.dp))
Row(
Modifier
.fillMaxWidth()
.padding(top = 10.dp),
horizontalArrangement = Arrangement.SpaceBetween,
horizontalArrangement = Arrangement.SpaceBetween
) {
OutlinedTextField(
modifier = Modifier
Expand All @@ -112,19 +112,19 @@ fun WaterIntakeDialog(
value = currentWaterIntakeText,
onValueChange = onCurrentWaterIntakeTextChange,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Number,
keyboardType = KeyboardType.Number
),
label = {
Text(
"2810",
color = MaterialTheme.colorScheme.onBackground,
color = MaterialTheme.colorScheme.onBackground
)
},
shape = RoundedCornerShape(30.dp),
colors = TextFieldDefaults.outlinedTextFieldColors(
focusedBorderColor = MaterialTheme.colorScheme.primary,
unfocusedBorderColor = MaterialTheme.colorScheme.onBackground,
),
unfocusedBorderColor = MaterialTheme.colorScheme.onBackground
)
)

val options = listOf("ml", "l")
Expand All @@ -134,7 +134,7 @@ fun WaterIntakeDialog(
expanded = expanded,
onExpandedChange = {
expanded = !expanded
},
}
) {
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
Expand All @@ -146,27 +146,27 @@ fun WaterIntakeDialog(
label = { Text("ml") },
trailingIcon = {
ExposedDropdownMenuDefaults.TrailingIcon(
expanded = expanded,
expanded = expanded
)
},
shape = RoundedCornerShape(45.dp),
colors = TextFieldDefaults.outlinedTextFieldColors(
focusedBorderColor = MaterialTheme.colorScheme.primary,
unfocusedBorderColor = MaterialTheme.colorScheme.onBackground,
),
unfocusedBorderColor = MaterialTheme.colorScheme.onBackground
)
)
ExposedDropdownMenu(
expanded = expanded,
onDismissRequest = {
expanded = false
},
}
) {
options.forEach { selectionOption ->
DropdownMenuItem(
onClick = {
onCurrentWaterIntakeFormTextChange(selectionOption)
expanded = false
},
}
) {
Text(text = selectionOption)
}
Expand All @@ -180,7 +180,7 @@ fun WaterIntakeDialog(
.fillMaxWidth()
.padding(top = 10.dp)
.background(Color.White),
horizontalArrangement = Arrangement.SpaceAround,
horizontalArrangement = Arrangement.SpaceAround
) {
TextButton(onClick = {
openCustomDialog.value = false
Expand All @@ -189,7 +189,7 @@ fun WaterIntakeDialog(
"Cancel",
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onBackground,
modifier = Modifier.padding(top = 5.dp, bottom = 5.dp),
modifier = Modifier.padding(top = 5.dp, bottom = 5.dp)
)
}
TextButton(onClick = {
Expand All @@ -200,7 +200,7 @@ fun WaterIntakeDialog(
"Okay",
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(top = 5.dp, bottom = 5.dp),
modifier = Modifier.padding(top = 5.dp, bottom = 5.dp)
)
}
}
Expand Down
Loading

0 comments on commit 91b2d3e

Please sign in to comment.