Skip to content

Commit

Permalink
kotlin 1.9.20
Browse files Browse the repository at this point in the history
  • Loading branch information
joelkanyi committed Nov 1, 2023
1 parent 4523a05 commit 68eeeaa
Show file tree
Hide file tree
Showing 20 changed files with 170 additions and 194 deletions.
12 changes: 1 addition & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ plugins {
alias(libs.plugins.compose.multiplatform)
alias(libs.plugins.spotless)
alias(libs.plugins.ktlint)
alias(libs.plugins.detekt)
alias(libs.plugins.gradleVersionUpdates)
}

allprojects {
Expand All @@ -29,7 +27,7 @@ subprojects {
ktlint().userData(mapOf("disabled_rules" to "filename"))
licenseHeaderFile(
rootProject.file("${project.rootDir}/spotless/copyright.kt"),
"^(package|object|import|interface)"
"^(package|object|import|interface)",
)
trimTrailingWhitespace()
endWithNewline()
Expand All @@ -47,11 +45,3 @@ subprojects {
}
}
}

task("addPreCommitGitHookOnBuild") {
println("⚈ ⚈ ⚈ Running Add Pre Commit Git Hook Script on Build ⚈ ⚈ ⚈")
exec {
commandLine("cp", "./.scripts/pre-commit", "./.git/hooks")
}
println("✅ Added Pre Commit Git Hook Script.")
}
24 changes: 10 additions & 14 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
[versions]
componentsResources = "1.5.3"
kotlin = "1.9.20"
compose = "1.5.10"
koinCore = "3.5.0"
koinAndroid = "3.5.0"
gradle = "8.1.2"
sqlDelight = "2.0.0"
voyager = "1.0.0-rc08"
componentsResources = "1.5.10"
multiplatformSettings = "1.1.0"
koin-compose = "1.1.0"
core = "1.12.0"
jna = "5.13.0"
koalaplotCore = "0.4.0"
kotlin = "1.9.10"
gradle = "8.1.2"
kotlinxCoroutinesSwing = "1.7.3"
detekt = "1.23.1"
gradleVersionUpdate = "0.49.0"
koinCore = "3.5.0"
koinAndroid = "3.5.0"
kotlinxSerializationJson = "1.6.0"
kotlinxDateTime = "0.4.1"
material3WindowSizeClassMultiplatform = "0.3.1"
napier = "2.6.1"
sqlDelight = "2.0.0"
multiplatformSettings = "1.1.0"
compose = "1.5.10-rc02"
core-library-desugaring = "2.0.3"
toast4j = "0.2.0"
voyager = "1.0.0-rc08"
compose-activity = "1.8.0"
koin-compose = "1.1.0"
spotless = "5.17.1"
ktlint = "11.6.1"
accompanist-systemUIController = "0.32.0"
annotationJvm = "1.7.0"

[plugins]
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
compose-multiplatform = { id = "org.jetbrains.compose", version.ref = "compose" }
gradleVersionUpdates = { id = "com.github.ben-manes.versions", version.ref = "gradleVersionUpdate" }
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
nativeCocoapod = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
android-kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
Expand Down
11 changes: 11 additions & 0 deletions shared/shared.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ Pod::Spec.new do |spec|
spec.ios.deployment_target = '14.1'


if !Dir.exist?('build/cocoapods/framework/shared.framework') || Dir.empty?('build/cocoapods/framework/shared.framework')
raise "
Kotlin framework 'shared' doesn't exist yet, so a proper Xcode project can't be generated.
'pod install' should be executed after running ':generateDummyFramework' Gradle task:
./gradlew :shared:generateDummyFramework
Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)"
end

spec.pod_target_xcconfig = {
'KOTLIN_PROJECT_PATH' => ':shared',
'PRODUCT_MODULE_NAME' => 'shared',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,47 +30,51 @@ import com.joelkanyi.focusbloom.main.MainScreen
import com.joelkanyi.focusbloom.main.MainViewModel
import com.joelkanyi.focusbloom.main.OnBoardingState
import com.joelkanyi.focusbloom.platform.StatusBarColors
import org.koin.compose.rememberKoinInject
import org.koin.compose.KoinContext
import org.koin.compose.koinInject

@Composable
fun FocusBloomApp() {
val mainViewModel = rememberKoinInject<MainViewModel>()
fun FocusBloomApp(
mainViewModel: MainViewModel = koinInject(),
) {
val darkTheme = when (mainViewModel.appTheme.collectAsState().value) {
1 -> true
else -> false
}
val onBoardingCompleted = mainViewModel.onBoardingCompleted.collectAsState().value

FocusBloomTheme(
useDarkTheme = darkTheme,
) {
StatusBarColors(
statusBarColor = MaterialTheme.colorScheme.background,
navBarColor = MaterialTheme.colorScheme.background,
)
when (onBoardingCompleted) {
is OnBoardingState.Success -> {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
Navigator(
screen = if (onBoardingCompleted.completed) {
MainScreen()
} else {
OnboardingScreen()
},
content = { navigator ->
ProvideAppNavigator(
navigator = navigator,
content = { SlideTransition(navigator = navigator) },
)
},
)
KoinContext {
FocusBloomTheme(
useDarkTheme = darkTheme,
) {
StatusBarColors(
statusBarColor = MaterialTheme.colorScheme.background,
navBarColor = MaterialTheme.colorScheme.background,
)
when (onBoardingCompleted) {
is OnBoardingState.Success -> {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
Navigator(
screen = if (onBoardingCompleted.completed) {
MainScreen()
} else {
OnboardingScreen()
},
content = { navigator ->
ProvideAppNavigator(
navigator = navigator,
content = { SlideTransition(navigator = navigator) },
)
},
)
}
}
}

else -> {}
else -> {}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ import androidx.compose.material3.rememberTimePickerState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment.Companion.CenterVertically
Expand Down Expand Up @@ -93,22 +91,20 @@ import com.joelkanyi.focusbloom.core.utils.toLocalDateTime
import com.joelkanyi.focusbloom.core.utils.today
import com.joelkanyi.focusbloom.platform.StatusBarColors
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.withContext
import kotlinx.datetime.Clock
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.LocalTime
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource
import org.koin.compose.rememberKoinInject
import org.koin.compose.koinInject

@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
@Composable
fun AddTaskScreen(
taskId: Int? = null,
screenModel: AddTaskScreenModel = koinInject(),
) {
val screenModel: AddTaskScreenModel = rememberKoinInject()

StatusBarColors(
statusBarColor = MaterialTheme.colorScheme.background,
navBarColor = MaterialTheme.colorScheme.background,
Expand Down Expand Up @@ -139,23 +135,6 @@ fun AddTaskScreen(
val datePickerState = rememberDatePickerState(
initialSelectedDateMillis = Clock.System.now().toEpochMilliseconds(),
)
val calculatedFocusTime by remember {
mutableStateOf(
calculateFromFocusSessions(
focusSessions = focusSessions,
sessionTime = sessionTime,
shortBreakTime = shortBreakTime,
longBreakTime = longBreakTime,
currentLocalDateTime = LocalDateTime(
year = taskDate.year,
month = taskDate.month,
dayOfMonth = taskDate.dayOfMonth,
hour = startTime.hour,
minute = startTime.minute,
),
),
)
}

LaunchedEffect(key1 = true) {
screenModel.getTask(taskId)
Expand Down Expand Up @@ -238,7 +217,6 @@ fun AddTaskScreen(
AddTaskScreenContent(
snackbarHostState = snackbarHostState,
hourFormat = hourFormat,
calculatedFocusTime = calculatedFocusTime,
taskOptions = taskTypes,
selectedTaskType = selectedTaskType,
taskName = taskName,
Expand Down Expand Up @@ -328,7 +306,6 @@ fun AddTaskScreen(
@Composable
private fun AddTaskScreenContent(
snackbarHostState: SnackbarHostState,
calculatedFocusTime: LocalTime,
hourFormat: Int,
taskOptions: List<TaskType>,
selectedTaskType: TaskType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.joelkanyi.focusbloom.feature.addtask
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
import cafe.adriel.voyager.core.model.ScreenModel
import cafe.adriel.voyager.core.model.coroutineScope
import cafe.adriel.voyager.core.model.screenModelScope
import com.joelkanyi.focusbloom.core.domain.model.Task
import com.joelkanyi.focusbloom.core.domain.model.TaskType
import com.joelkanyi.focusbloom.core.domain.model.taskTypes
Expand Down Expand Up @@ -51,28 +51,28 @@ class AddTaskScreenModel(
it
}
.stateIn(
scope = coroutineScope,
scope = screenModelScope,
started = SharingStarted.WhileSubscribed(5_000),
initialValue = null,
)
val shortBreakTime = settingsRepository.getShortBreakTime()
.map { it }
.stateIn(
scope = coroutineScope,
scope = screenModelScope,
started = SharingStarted.WhileSubscribed(5_000),
initialValue = null,
)
val longBreakTime = settingsRepository.getLongBreakTime()
.map { it }
.stateIn(
scope = coroutineScope,
scope = screenModelScope,
started = SharingStarted.WhileSubscribed(5_000),
initialValue = null,
)
val hourFormat = settingsRepository.getHourFormat()
.map { it }
.stateIn(
scope = coroutineScope,
scope = screenModelScope,
started = SharingStarted.WhileSubscribed(5_000),
initialValue = null,
)
Expand Down Expand Up @@ -119,7 +119,7 @@ class AddTaskScreenModel(
}
}

fun setFocusSessions(sessions: Int) {
private fun setFocusSessions(sessions: Int) {
_focusSessions.value = sessions
}

Expand Down Expand Up @@ -172,7 +172,7 @@ class AddTaskScreenModel(
}

fun addTask(task: Task) {
coroutineScope.launch {
screenModelScope.launch {
tasksRepository.addTask(task)
reset()
setEndTime(today().time)
Expand All @@ -199,7 +199,7 @@ class AddTaskScreenModel(
private val _task = MutableStateFlow<Task?>(null)
val task = _task.asStateFlow()
fun getTask(taskId: Int?) {
coroutineScope.launch {
screenModelScope.launch {
if (taskId != null) {
tasksRepository.getTask(taskId).collectLatest {
_task.value = it
Expand Down Expand Up @@ -240,7 +240,7 @@ class AddTaskScreenModel(
}

fun updateTask(task: Task) {
coroutineScope.launch {
screenModelScope.launch {
tasksRepository.updateTask(task)
reset()
setEndTime(today().time)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource
import org.koin.compose.rememberKoinInject
import org.koin.compose.koinInject
import kotlin.math.roundToInt

@OptIn(ExperimentalMaterial3WindowSizeClassApi::class, ExperimentalMaterial3Api::class)
@Composable
fun CalendarScreen() {
val screenModel: CalendarScreenModel = rememberKoinInject()

fun CalendarScreen(
screenModel: CalendarScreenModel = koinInject(),
) {
StatusBarColors(
statusBarColor = MaterialTheme.colorScheme.background,
navBarColor = MaterialTheme.colorScheme.background,
Expand Down
Loading

0 comments on commit 68eeeaa

Please sign in to comment.