├── .gitignore ├── README.MD ├── art ├── android 1.png ├── android 2.png ├── iOS1.png └── iOS2.png ├── build.gradle.kts ├── composeApp ├── build.gradle.kts ├── composeApp.podspec └── src │ ├── androidMain │ ├── AndroidManifest.xml │ └── kotlin │ │ └── com │ │ └── adikmt │ │ └── notesapp │ │ ├── App.android.kt │ │ ├── data │ │ └── createDriver.kt │ │ └── ui │ │ └── krouter │ │ └── ViewModel.kt │ ├── commonMain │ ├── kotlin │ │ └── com │ │ │ └── adikmt │ │ │ └── notesapp │ │ │ ├── App.kt │ │ │ ├── Color.kt │ │ │ ├── Theme.kt │ │ │ ├── data │ │ │ ├── DatabaseDriverFactory.kt │ │ │ ├── NotesLocalDataSource.kt │ │ │ └── model │ │ │ │ ├── NoteDataModel.kt │ │ │ │ └── NoteMapper.kt │ │ │ ├── di │ │ │ ├── KoinModules.kt │ │ │ └── initKoin.kt │ │ │ ├── ui │ │ │ ├── components │ │ │ │ ├── HeadingTextFieldComponent.kt │ │ │ │ ├── NoteListItemComponent.kt │ │ │ │ ├── SearchTextFieldComponent.kt │ │ │ │ └── VerticalStaggeredGrid.kt │ │ │ ├── krouter │ │ │ │ ├── DecomposeNavigator.kt │ │ │ │ ├── KRouter.kt │ │ │ │ ├── SavedState.kt │ │ │ │ └── ViewModel.kt │ │ │ ├── screens │ │ │ │ ├── RootComponent.kt │ │ │ │ ├── detailsScreen │ │ │ │ │ ├── NoteDetailScreen.kt │ │ │ │ │ └── NoteDetailViewModel.kt │ │ │ │ └── listScreen │ │ │ │ │ ├── NoteListScreen.kt │ │ │ │ │ └── NoteListViewModel.kt │ │ │ └── theme │ │ │ │ ├── Colors.kt │ │ │ │ └── MyApplicationTheme.kt │ │ │ └── utils │ │ │ └── DateTimeUtil.kt │ └── sqldelight │ │ └── com │ │ └── adikmt │ │ └── notesapp │ │ └── note.sq │ ├── desktopMain │ └── kotlin │ │ ├── com │ │ └── adikmt │ │ │ └── notesapp │ │ │ ├── data │ │ │ └── createDriver.kt │ │ │ └── ui │ │ │ └── krouter │ │ │ └── ViewModel.kt │ │ └── main.kt │ └── iosMain │ └── kotlin │ ├── com │ └── adikmt │ │ └── notesapp │ │ ├── data │ │ └── createDriver.kt │ │ └── ui │ │ └── krouter │ │ └── ViewModel.kt │ └── main.kt ├── gradle.bat ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── iosApp ├── Podfile ├── Podfile.lock ├── iosApp.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── iosApp.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── iosApp │ ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json │ ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json │ └── iosApp.swift └── settings.gradle.kts /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.iml 3 | .gradle 4 | .idea 5 | .DS_Store 6 | build 7 | */build 8 | captures 9 | .externalNativeBuild 10 | .cxx 11 | local.properties 12 | xcuserdata/ 13 | Pods/ 14 | *.jks 15 | *yarn.lock 16 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # Notes App 2 | Simple Notes app built using 100% shared UI code with Jetpack Compose, SQL Delight to store 3 | data and Decompose + Essenty to manage navigation. 4 | 5 | ## Compose Template 6 | Used the compose template from [Compose Multiplatform Wizard](https://terrakok.github.io/Compose-Multiplatform-Wizard/) 7 | Thanks to them, project setup was considerably easier. 8 | Also large help from xxFast's [Krouter library](https://github.com/xxfast/KRouter) 9 | 10 | ## Before running! 11 | - check your system with [KDoctor](https://github.com/Kotlin/kdoctor) 12 | - install JDK 8 on your machine 13 | - add `local.properties` file to the project root and set a path to Android SDK there 14 | - run `./gradlew podInstall` in the project root 15 | 16 | ### To build the SQL Delight Kotlin bindings 17 | Don't rebuild the project 18 |

19 | 20 | 21 | Instead just run only the sqldelight tasks from the gradle tab 22 | - generateCommonMainNotesDBInterface 23 | - generateSqlDelightInterface
24 | (Can also run the verify tasks for good measure.) 25 | 26 | ### Android 27 | To run the application on android device/emulator: 28 | - open project in Android Studio and run imported android run configuration 29 | 30 | To build the application bundle: 31 | - run `./gradlew :composeApp:assembleDebug` 32 | - find `.apk` file in `composeApp/build/outputs/apk/debug/composeApp-debug.apk` 33 | 34 | ### Desktop 35 | Run the desktop application: `./gradlew :composeApp:run` 36 | 37 | ### iOS 38 | To run the application on iPhone device/simulator: 39 | - Add linker flags for SQL delight as `-lsqlite3` in Xcode under other linker flags. (Only if sqlite error shows) 40 | - Open `iosApp/iosApp.xcworkspace` in Xcode and run standard configuration. 41 | - Or can also be run using the KMM Jetbrains plugin that can be readily downloaded from the plugins marketplace. 42 | ## 🏗️️ Built with ❤️ using Kotlin 43 | | What | How | 44 | |-----------------|---------------------------------------------------------------------------| 45 | | 🎭 All UI | [Jetbrains Compose](https://github.com/JetBrains/compose-multiplatform) | 46 | | 💉 DI | [Koin](https://insert-koin.io/) | 47 | | 🧭 Navigation | [Decompose](https://github.com/arkivanov/Decompose) | 48 | | ð Storage | [SqlDelight](https://github.com/russhwolf/multiplatform-settings) | 49 |

[Back to top]

50 | 51 | 52 | ## Screenshots 53 | 54 | ### Android 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 |
Note List ScreenNote Details Screen
66 | 67 | ### iOS 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |
Note List ScreenNote Details Screen
79 | 80 | ### 🤝 Contributors 81 | [![kmm Contributors](https://contrib.rocks/image?repo=kamathis4/NotesAppKMM)](https://github.com/kamathis4/NotesAppKMM/graphs/contributors) 82 | 83 | ### 💬 Want to discuss? 84 | 85 | Have any questions, doubts or want to present your opinions, views? You're always welcome. 86 | 87 | ### Find this project useful ? 88 | 89 | Support it by clicking the ⭐️ button on the upper right of this page. 90 | 91 | ### License 92 | 93 | ``` 94 | MIT License 95 | 96 | Copyright (c) 2023 Adithya Kamath 97 | 98 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 99 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation 100 | the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 101 | to permit persons to whom the Software is furnished to do so, subject to the following conditions: 102 | 103 | The above copyright notice and this permission notice shall be included in all copies or substantial 104 | portions of the Software. 105 | 106 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 107 | THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 108 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 109 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 110 | ``` 111 | -------------------------------------------------------------------------------- /art/android 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adi-kmt/NotesAppKMM/3ecd1be408a134d28b6bf1ab4e6b34d39e63bb2b/art/android 1.png -------------------------------------------------------------------------------- /art/android 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adi-kmt/NotesAppKMM/3ecd1be408a134d28b6bf1ab4e6b34d39e63bb2b/art/android 2.png -------------------------------------------------------------------------------- /art/iOS1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adi-kmt/NotesAppKMM/3ecd1be408a134d28b6bf1ab4e6b34d39e63bb2b/art/iOS1.png -------------------------------------------------------------------------------- /art/iOS2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adi-kmt/NotesAppKMM/3ecd1be408a134d28b6bf1ab4e6b34d39e63bb2b/art/iOS2.png -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | alias(libs.plugins.multiplatform).apply(false) 3 | alias(libs.plugins.compose).apply(false) 4 | alias(libs.plugins.cocoapods).apply(false) 5 | alias(libs.plugins.android.application).apply(false) 6 | alias(libs.plugins.kotlinx.serialization).apply(false) 7 | alias(libs.plugins.sqlDelight).apply(false) 8 | } 9 | -------------------------------------------------------------------------------- /composeApp/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.compose.desktop.application.dsl.TargetFormat 2 | 3 | plugins { 4 | alias(libs.plugins.multiplatform) 5 | alias(libs.plugins.compose) 6 | alias(libs.plugins.cocoapods) 7 | alias(libs.plugins.android.application) 8 | alias(libs.plugins.kotlinx.serialization) 9 | alias(libs.plugins.sqlDelight) 10 | id("kotlin-parcelize") 11 | } 12 | 13 | kotlin { 14 | android { 15 | compilations.all { 16 | kotlinOptions { 17 | jvmTarget = "1.8" 18 | } 19 | } 20 | } 21 | 22 | jvm("desktop"){ 23 | compilations.all { 24 | kotlinOptions { 25 | jvmTarget = "1.8" 26 | } 27 | } 28 | } 29 | 30 | iosX64() 31 | iosArm64() 32 | iosSimulatorArm64() 33 | 34 | cocoapods { 35 | version = "1.0.0" 36 | summary = "Compose application framework" 37 | homepage = "empty" 38 | ios.deploymentTarget = "16.2" 39 | podfile = project.file("../iosApp/Podfile") 40 | framework { 41 | baseName = "ComposeApp" 42 | isStatic = true 43 | } 44 | extraSpecAttributes["resources"] = "['src/commonMain/resources/**']" 45 | } 46 | 47 | sourceSets { 48 | all { 49 | languageSettings { 50 | optIn("org.jetbrains.compose.resources.ExperimentalResourceApi") 51 | } 52 | } 53 | val commonMain by getting { 54 | dependencies { 55 | implementation(compose.runtime) 56 | implementation(compose.foundation) 57 | implementation(compose.material) 58 | @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) 59 | implementation(compose.components.resources) 60 | implementation(libs.kotlinx.coroutines.core) 61 | implementation(libs.kotlinx.serialization.json) 62 | implementation(libs.kotlinx.datetime) 63 | implementation(libs.koin.core) 64 | implementation(libs.sqlDelight.runtime) 65 | implementation(libs.essenty.parcelable) 66 | api(libs.decompose) 67 | implementation(libs.decompose.compose.multiplatform) 68 | } 69 | } 70 | 71 | val commonTest by getting { 72 | dependencies { 73 | implementation(kotlin("test")) 74 | } 75 | } 76 | 77 | val androidMain by getting { 78 | dependencies { 79 | implementation(libs.androidx.appcompat) 80 | implementation(libs.androidx.activityCompose) 81 | implementation(libs.compose.uitooling) 82 | implementation(libs.kotlinx.coroutines.android) 83 | implementation(libs.sqlDelight.driver.android) 84 | 85 | api(libs.koin.android) 86 | } 87 | } 88 | 89 | val desktopMain by getting { 90 | dependencies { 91 | implementation(compose.desktop.common) 92 | implementation(compose.desktop.currentOs) 93 | implementation(libs.sqlDelight.driver.sqlite) 94 | } 95 | } 96 | 97 | val iosX64Main by getting 98 | val iosArm64Main by getting 99 | val iosSimulatorArm64Main by getting 100 | val iosMain by creating { 101 | dependsOn(commonMain) 102 | iosX64Main.dependsOn(this) 103 | iosArm64Main.dependsOn(this) 104 | iosSimulatorArm64Main.dependsOn(this) 105 | dependencies { 106 | implementation(libs.sqlDelight.driver.native) 107 | } 108 | } 109 | 110 | val iosX64Test by getting 111 | val iosArm64Test by getting 112 | val iosSimulatorArm64Test by getting 113 | val iosTest by creating { 114 | dependsOn(commonTest) 115 | iosX64Test.dependsOn(this) 116 | iosArm64Test.dependsOn(this) 117 | iosSimulatorArm64Test.dependsOn(this) 118 | } 119 | } 120 | } 121 | 122 | android { 123 | namespace = "com.adikmt.notesapp" 124 | compileSdk = 33 125 | 126 | defaultConfig { 127 | minSdk = 21 128 | targetSdk = 33 129 | 130 | applicationId = "com.adikmt.notesapp.androidApp" 131 | versionCode = 1 132 | versionName = "1.0.0" 133 | } 134 | sourceSets["main"].apply { 135 | manifest.srcFile("src/androidMain/AndroidManifest.xml") 136 | res.srcDirs("src/androidMain/resources") 137 | resources.srcDirs("src/commonMain/resources") 138 | } 139 | compileOptions { 140 | sourceCompatibility = JavaVersion.VERSION_1_8 141 | targetCompatibility = JavaVersion.VERSION_1_8 142 | } 143 | packagingOptions { 144 | resources.excludes.add("META-INF/**") 145 | } 146 | } 147 | 148 | compose.desktop { 149 | application { 150 | mainClass = "MainKt" 151 | 152 | nativeDistributions { 153 | targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) 154 | packageName = "com.adikmt.notesapp.desktopApp" 155 | packageVersion = "1.0.0" 156 | } 157 | } 158 | } 159 | 160 | sqldelight { 161 | databases { 162 | create("NotesDB") { 163 | // Database configuration here. 164 | // https://cashapp.github.io/sqldelight 165 | packageName.set("com.adikmt.notesapp") 166 | } 167 | } 168 | } -------------------------------------------------------------------------------- /composeApp/composeApp.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | spec.name = 'composeApp' 3 | spec.version = '1.0.0' 4 | spec.homepage = 'empty' 5 | spec.source = { :http=> ''} 6 | spec.authors = '' 7 | spec.license = '' 8 | spec.summary = 'Compose application framework' 9 | spec.vendored_frameworks = 'build/cocoapods/framework/ComposeApp.framework' 10 | spec.libraries = 'c++' 11 | spec.ios.deployment_target = '16.2' 12 | 13 | 14 | spec.pod_target_xcconfig = { 15 | 'KOTLIN_PROJECT_PATH' => ':composeApp', 16 | 'PRODUCT_MODULE_NAME' => 'ComposeApp', 17 | } 18 | 19 | spec.script_phases = [ 20 | { 21 | :name => 'Build composeApp', 22 | :execution_position => :before_compile, 23 | :shell_path => '/bin/sh', 24 | :script => <<-SCRIPT 25 | if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then 26 | echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" 27 | exit 0 28 | fi 29 | set -ev 30 | REPO_ROOT="$PODS_TARGET_SRCROOT" 31 | "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ 32 | -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ 33 | -Pkotlin.native.cocoapods.archs="$ARCHS" \ 34 | -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" 35 | SCRIPT 36 | } 37 | ] 38 | spec.resources = ['src/commonMain/resources/**'] 39 | end -------------------------------------------------------------------------------- /composeApp/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /composeApp/src/androidMain/kotlin/com/adikmt/notesapp/App.android.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp 2 | 3 | import android.app.Application 4 | import android.content.Intent 5 | import android.net.Uri 6 | import android.os.Bundle 7 | import androidx.activity.ComponentActivity 8 | import androidx.activity.compose.setContent 9 | import androidx.compose.runtime.CompositionLocalProvider 10 | import com.adikmt.notesapp.di.initKoin 11 | import com.adikmt.notesapp.ui.krouter.LocalComponentContext 12 | import com.arkivanov.decompose.DefaultComponentContext 13 | import com.arkivanov.decompose.defaultComponentContext 14 | import org.koin.android.ext.koin.androidContext 15 | 16 | class AndroidApp : Application() { 17 | companion object { 18 | lateinit var INSTANCE: AndroidApp 19 | } 20 | 21 | override fun onCreate() { 22 | super.onCreate() 23 | INSTANCE = this 24 | } 25 | } 26 | 27 | class AppActivity : ComponentActivity() { 28 | override fun onCreate(savedInstanceState: Bundle?) { 29 | super.onCreate(savedInstanceState) 30 | 31 | val rootComponentContext: DefaultComponentContext = defaultComponentContext() 32 | 33 | initKoin { 34 | androidContext(applicationContext) 35 | } 36 | 37 | 38 | setContent { 39 | CompositionLocalProvider(LocalComponentContext provides rootComponentContext) { 40 | App() 41 | } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /composeApp/src/androidMain/kotlin/com/adikmt/notesapp/data/createDriver.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.data 2 | 3 | import app.cash.sqldelight.db.SqlDriver 4 | import app.cash.sqldelight.driver.android.AndroidSqliteDriver 5 | import com.adikmt.notesapp.NotesDB 6 | import org.koin.android.ext.koin.androidContext 7 | import org.koin.core.scope.Scope 8 | 9 | actual fun Scope.createDriver(): SqlDriver { 10 | return AndroidSqliteDriver(NotesDB.Schema, androidContext(), "note.db") 11 | } -------------------------------------------------------------------------------- /composeApp/src/androidMain/kotlin/com/adikmt/notesapp/ui/krouter/ViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.krouter 2 | 3 | import androidx.compose.ui.platform.AndroidUiDispatcher 4 | import com.arkivanov.essenty.instancekeeper.InstanceKeeper 5 | import kotlinx.coroutines.CoroutineScope 6 | import kotlinx.coroutines.SupervisorJob 7 | import kotlinx.coroutines.cancel 8 | import kotlin.coroutines.CoroutineContext 9 | 10 | actual open class ViewModel : InstanceKeeper.Instance, CoroutineScope { 11 | actual override val coroutineContext: CoroutineContext = AndroidUiDispatcher.Main + SupervisorJob() 12 | override fun onDestroy() { coroutineContext.cancel() } 13 | } -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/App.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp 2 | 3 | import androidx.compose.foundation.layout.Column 4 | import androidx.compose.foundation.layout.fillMaxSize 5 | import androidx.compose.foundation.layout.fillMaxWidth 6 | import androidx.compose.foundation.layout.padding 7 | import androidx.compose.material.Button 8 | import androidx.compose.material.MaterialTheme 9 | import androidx.compose.material.OutlinedTextField 10 | import androidx.compose.material.Text 11 | import androidx.compose.material.TextButton 12 | import androidx.compose.runtime.Composable 13 | import androidx.compose.runtime.getValue 14 | import androidx.compose.runtime.mutableStateOf 15 | import androidx.compose.runtime.remember 16 | import androidx.compose.runtime.setValue 17 | import androidx.compose.ui.Modifier 18 | import androidx.compose.ui.unit.dp 19 | import com.adikmt.notesapp.ui.screens.RootComponent 20 | 21 | @Composable 22 | internal fun App() = AppTheme { 23 | RootComponent() 24 | } 25 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/Color.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp 2 | 3 | import androidx.compose.ui.graphics.Color 4 | 5 | //generated by https://m3.material.io/theme-builder#/custom 6 | //Color palette was taken here: https://colorhunt.co/palettes/popular 7 | 8 | internal val md_theme_light_primary = Color(0xFF00687A) 9 | internal val md_theme_light_onPrimary = Color(0xFFFFFFFF) 10 | internal val md_theme_light_primaryContainer = Color(0xFFABEDFF) 11 | internal val md_theme_light_onPrimaryContainer = Color(0xFF001F26) 12 | internal val md_theme_light_secondary = Color(0xFF00696E) 13 | internal val md_theme_light_onSecondary = Color(0xFFFFFFFF) 14 | internal val md_theme_light_secondaryContainer = Color(0xFF6FF6FE) 15 | internal val md_theme_light_onSecondaryContainer = Color(0xFF002022) 16 | internal val md_theme_light_tertiary = Color(0xFF904D00) 17 | internal val md_theme_light_onTertiary = Color(0xFFFFFFFF) 18 | internal val md_theme_light_tertiaryContainer = Color(0xFFFFDCC2) 19 | internal val md_theme_light_onTertiaryContainer = Color(0xFF2E1500) 20 | internal val md_theme_light_error = Color(0xFFBA1A1A) 21 | internal val md_theme_light_errorContainer = Color(0xFFFFDAD6) 22 | internal val md_theme_light_onError = Color(0xFFFFFFFF) 23 | internal val md_theme_light_onErrorContainer = Color(0xFF410002) 24 | internal val md_theme_light_background = Color(0xFFFFFBFF) 25 | internal val md_theme_light_onBackground = Color(0xFF221B00) 26 | internal val md_theme_light_surface = Color(0xFFFFFBFF) 27 | internal val md_theme_light_onSurface = Color(0xFF221B00) 28 | internal val md_theme_light_surfaceVariant = Color(0xFFDBE4E7) 29 | internal val md_theme_light_onSurfaceVariant = Color(0xFF3F484B) 30 | internal val md_theme_light_outline = Color(0xFF70797B) 31 | internal val md_theme_light_inverseOnSurface = Color(0xFFFFF0C0) 32 | internal val md_theme_light_inverseSurface = Color(0xFF3A3000) 33 | internal val md_theme_light_inversePrimary = Color(0xFF55D6F4) 34 | internal val md_theme_light_shadow = Color(0xFF000000) 35 | internal val md_theme_light_surfaceTint = Color(0xFF00687A) 36 | internal val md_theme_light_outlineVariant = Color(0xFFBFC8CB) 37 | internal val md_theme_light_scrim = Color(0xFF000000) 38 | 39 | internal val md_theme_dark_primary = Color(0xFF55D6F4) 40 | internal val md_theme_dark_onPrimary = Color(0xFF003640) 41 | internal val md_theme_dark_primaryContainer = Color(0xFF004E5C) 42 | internal val md_theme_dark_onPrimaryContainer = Color(0xFFABEDFF) 43 | internal val md_theme_dark_secondary = Color(0xFF4CD9E2) 44 | internal val md_theme_dark_onSecondary = Color(0xFF00373A) 45 | internal val md_theme_dark_secondaryContainer = Color(0xFF004F53) 46 | internal val md_theme_dark_onSecondaryContainer = Color(0xFF6FF6FE) 47 | internal val md_theme_dark_tertiary = Color(0xFFFFB77C) 48 | internal val md_theme_dark_onTertiary = Color(0xFF4D2700) 49 | internal val md_theme_dark_tertiaryContainer = Color(0xFF6D3900) 50 | internal val md_theme_dark_onTertiaryContainer = Color(0xFFFFDCC2) 51 | internal val md_theme_dark_error = Color(0xFFFFB4AB) 52 | internal val md_theme_dark_errorContainer = Color(0xFF93000A) 53 | internal val md_theme_dark_onError = Color(0xFF690005) 54 | internal val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6) 55 | internal val md_theme_dark_background = Color(0xFF221B00) 56 | internal val md_theme_dark_onBackground = Color(0xFFFFE264) 57 | internal val md_theme_dark_surface = Color(0xFF221B00) 58 | internal val md_theme_dark_onSurface = Color(0xFFFFE264) 59 | internal val md_theme_dark_surfaceVariant = Color(0xFF3F484B) 60 | internal val md_theme_dark_onSurfaceVariant = Color(0xFFBFC8CB) 61 | internal val md_theme_dark_outline = Color(0xFF899295) 62 | internal val md_theme_dark_inverseOnSurface = Color(0xFF221B00) 63 | internal val md_theme_dark_inverseSurface = Color(0xFFFFE264) 64 | internal val md_theme_dark_inversePrimary = Color(0xFF00687A) 65 | internal val md_theme_dark_shadow = Color(0xFF000000) 66 | internal val md_theme_dark_surfaceTint = Color(0xFF55D6F4) 67 | internal val md_theme_dark_outlineVariant = Color(0xFF3F484B) 68 | internal val md_theme_dark_scrim = Color(0xFF000000) 69 | 70 | 71 | internal val seed = Color(0xFF2C3639) 72 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/Theme.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp 2 | 3 | import androidx.compose.foundation.isSystemInDarkTheme 4 | import androidx.compose.material.MaterialTheme 5 | import androidx.compose.material.Surface 6 | import androidx.compose.material.darkColors 7 | import androidx.compose.material.lightColors 8 | import androidx.compose.runtime.Composable 9 | 10 | private val LightColors = lightColors( 11 | primary = md_theme_light_primary, 12 | onPrimary = md_theme_light_onPrimary, 13 | secondary = md_theme_light_secondary, 14 | onSecondary = md_theme_light_onSecondary, 15 | error = md_theme_light_error, 16 | onError = md_theme_light_onError, 17 | background = md_theme_light_background, 18 | onBackground = md_theme_light_onBackground, 19 | surface = md_theme_light_surface, 20 | onSurface = md_theme_light_onSurface, 21 | ) 22 | 23 | private val DarkColors = darkColors( 24 | primary = md_theme_dark_primary, 25 | onPrimary = md_theme_dark_onPrimary, 26 | secondary = md_theme_dark_secondary, 27 | onSecondary = md_theme_dark_onSecondary, 28 | error = md_theme_dark_error, 29 | onError = md_theme_dark_onError, 30 | background = md_theme_dark_background, 31 | onBackground = md_theme_dark_onBackground, 32 | surface = md_theme_dark_surface, 33 | onSurface = md_theme_dark_onSurface, 34 | ) 35 | 36 | @Composable 37 | internal fun AppTheme( 38 | useDarkTheme: Boolean = isSystemInDarkTheme(), 39 | content: @Composable() () -> Unit 40 | ) { 41 | val colors = if (!useDarkTheme) { 42 | LightColors 43 | } else { 44 | DarkColors 45 | } 46 | 47 | MaterialTheme( 48 | colors = colors, 49 | content = { 50 | Surface(content = content) 51 | } 52 | ) 53 | } 54 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/data/DatabaseDriverFactory.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.data 2 | 3 | import app.cash.sqldelight.db.SqlDriver 4 | import org.koin.core.scope.Scope 5 | 6 | expect fun Scope.createDriver(): SqlDriver 7 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/data/NotesLocalDataSource.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.data 2 | 3 | import com.adikmt.notesapp.NotesDB 4 | import com.adikmt.notesapp.data.model.NoteDataModel 5 | import com.adikmt.notesapp.data.model.toNoteModel 6 | import com.adikmt.notesapp.utils.DateTimeUtil 7 | 8 | class NotesLocalDataSourceImpl(private val database: NotesDB) : NoteLocalDataSource { 9 | 10 | private val queries = database.noteQueries 11 | override suspend fun insertNote(note: NoteDataModel) { 12 | queries.insertNote( 13 | id = note.id, 14 | title = note.title, 15 | content = note.content, 16 | color = note.colorHex, 17 | created = DateTimeUtil.toEpochMillis(note.createdAt) 18 | ) 19 | } 20 | 21 | override suspend fun getNote(id: Long): NoteDataModel? { 22 | return queries.getNote(id = id).executeAsOneOrNull()?.toNoteModel() 23 | } 24 | 25 | override suspend fun getAllNotes(): List { 26 | return queries.getAllNotes().executeAsList().map { it.toNoteModel() } 27 | } 28 | 29 | override suspend fun deleteNote(id: Long) { 30 | return queries.deleteNote(id = id) 31 | } 32 | 33 | override suspend fun searchNotes(title: String): List { 34 | return queries.searchNotes(title = title).executeAsList().map { it.toNoteModel() } 35 | } 36 | 37 | override suspend fun updateNote(id: Long, title: String, content: String, createdAt: Long) { 38 | return queries.updateNotes(title = title, content = content, createdat = createdAt, id = id) 39 | } 40 | } 41 | 42 | interface NoteLocalDataSource { 43 | 44 | suspend fun insertNote(note: NoteDataModel) 45 | 46 | suspend fun getNote(id: Long): NoteDataModel? 47 | 48 | suspend fun getAllNotes(): List 49 | 50 | suspend fun deleteNote(id: Long) 51 | 52 | suspend fun searchNotes(title: String): List 53 | 54 | suspend fun updateNote(id: Long, title: String, content: String, createdAt: Long) 55 | } -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/data/model/NoteDataModel.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.data.model 2 | 3 | import com.adikmt.notesapp.ui.theme.BabyBlueHex 4 | import com.adikmt.notesapp.ui.theme.LightGreenHex 5 | import com.adikmt.notesapp.ui.theme.RedOrangeHex 6 | import com.adikmt.notesapp.ui.theme.RedPinkHex 7 | import com.adikmt.notesapp.ui.theme.VioletHex 8 | import com.adikmt.notesapp.utils.DateTimeUtil 9 | import kotlinx.datetime.LocalDateTime 10 | 11 | data class NoteDataModel( 12 | val id: Long?, 13 | val title: String, 14 | val content: String, 15 | val colorHex: Long, 16 | val createdAt: LocalDateTime = DateTimeUtil.now(), 17 | ) { 18 | companion object { 19 | private val colors = listOf(RedOrangeHex, RedPinkHex, BabyBlueHex, VioletHex, LightGreenHex) 20 | 21 | fun generateRandomColor() = colors.random() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/data/model/NoteMapper.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.data.model 2 | 3 | import com.adikmt.notesapp.NoteEntity 4 | import kotlinx.datetime.Instant 5 | import kotlinx.datetime.TimeZone 6 | import kotlinx.datetime.toLocalDateTime 7 | 8 | fun NoteEntity.toNoteModel(): NoteDataModel = NoteDataModel( 9 | id = this.Id, 10 | title = this.Title, 11 | content = this.Content, 12 | colorHex = this.ColorHex, 13 | createdAt = Instant.fromEpochMilliseconds(this.CreatedAt).toLocalDateTime(TimeZone.UTC), 14 | ) 15 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/di/KoinModules.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.di 2 | 3 | import app.cash.sqldelight.db.SqlDriver 4 | import com.adikmt.notesapp.NotesDB 5 | import com.adikmt.notesapp.data.NoteLocalDataSource 6 | import com.adikmt.notesapp.data.NotesLocalDataSourceImpl 7 | import com.adikmt.notesapp.data.createDriver 8 | import org.koin.dsl.module 9 | 10 | val koinModule = module { 11 | 12 | single { createDriver() } 13 | single { NotesLocalDataSourceImpl(NotesDB(get())) } 14 | } 15 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/di/initKoin.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.di 2 | 3 | import org.koin.core.context.startKoin 4 | import org.koin.dsl.KoinAppDeclaration 5 | 6 | fun initKoin(appDeclaration: KoinAppDeclaration = {}) { 7 | startKoin { 8 | appDeclaration() 9 | modules(koinModule) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/components/HeadingTextFieldComponent.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.components 2 | 3 | import androidx.compose.foundation.layout.fillMaxWidth 4 | import androidx.compose.material.Text 5 | import androidx.compose.material.TextField 6 | import androidx.compose.material.TextFieldDefaults 7 | import androidx.compose.runtime.Composable 8 | import androidx.compose.ui.Modifier 9 | import androidx.compose.ui.graphics.Color 10 | import androidx.compose.ui.text.TextStyle 11 | 12 | @Composable 13 | fun HeadingTextFieldComponent( 14 | value: String, 15 | onValueChanged: (String) -> Unit, 16 | hint: String, 17 | textStyle: TextStyle, 18 | modifier: Modifier = Modifier, 19 | isSingleLine: Boolean = true, 20 | ) { 21 | TextField( 22 | value = value, 23 | colors = TextFieldDefaults.textFieldColors( 24 | backgroundColor = Color.Transparent, 25 | focusedIndicatorColor = Color.Transparent, 26 | unfocusedIndicatorColor = Color.Transparent, 27 | ), 28 | onValueChange = onValueChanged, 29 | placeholder = { Text(hint) }, 30 | singleLine = isSingleLine, 31 | textStyle = textStyle, 32 | modifier = modifier.fillMaxWidth(), 33 | ) 34 | } 35 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/components/NoteListItemComponent.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.components 2 | 3 | import androidx.compose.foundation.background 4 | import androidx.compose.foundation.clickable 5 | import androidx.compose.foundation.interaction.MutableInteractionSource 6 | import androidx.compose.foundation.layout.Arrangement 7 | import androidx.compose.foundation.layout.Column 8 | import androidx.compose.foundation.layout.Row 9 | import androidx.compose.foundation.layout.Spacer 10 | import androidx.compose.foundation.layout.fillMaxWidth 11 | import androidx.compose.foundation.layout.height 12 | import androidx.compose.foundation.layout.padding 13 | import androidx.compose.foundation.shape.RoundedCornerShape 14 | import androidx.compose.material.Icon 15 | import androidx.compose.material.Text 16 | import androidx.compose.material.icons.Icons 17 | import androidx.compose.material.icons.filled.Close 18 | import androidx.compose.runtime.Composable 19 | import androidx.compose.runtime.remember 20 | import androidx.compose.ui.Alignment 21 | import androidx.compose.ui.Modifier 22 | import androidx.compose.ui.draw.clip 23 | import androidx.compose.ui.graphics.Color 24 | import androidx.compose.ui.text.font.FontWeight 25 | import androidx.compose.ui.text.style.TextOverflow 26 | import androidx.compose.ui.unit.dp 27 | import androidx.compose.ui.unit.sp 28 | import com.adikmt.notesapp.data.model.NoteDataModel 29 | import com.adikmt.notesapp.utils.DateTimeUtil 30 | 31 | @Composable 32 | fun NoteListItemComponent( 33 | noteDataModel: NoteDataModel, 34 | maxLines: Int = 5, 35 | modifier: Modifier = Modifier, 36 | onNoteClick: () -> Unit, 37 | onNoteDeleted: () -> Unit 38 | ) { 39 | val formattedDate = remember(noteDataModel.createdAt) { 40 | DateTimeUtil.formatNoteDate(noteDataModel.createdAt) 41 | } 42 | 43 | Column( 44 | modifier = modifier 45 | .clip(RoundedCornerShape(8.dp)) 46 | .background(Color(noteDataModel.colorHex)) 47 | .clickable { onNoteClick.invoke() } 48 | .padding(20.dp) 49 | ) { 50 | Row( 51 | horizontalArrangement = Arrangement.SpaceBetween, 52 | verticalAlignment = Alignment.CenterVertically, 53 | modifier = Modifier.fillMaxWidth() 54 | ) { 55 | Text( 56 | text = noteDataModel.title, 57 | fontWeight = FontWeight.Bold, 58 | fontSize = 20.sp, 59 | modifier = Modifier.weight(1f), 60 | maxLines = 1, 61 | overflow = TextOverflow.Ellipsis 62 | ) 63 | Icon( 64 | imageVector = Icons.Default.Close, 65 | contentDescription = "Delete Note", 66 | modifier = Modifier 67 | .clickable(MutableInteractionSource(), null) { 68 | onNoteDeleted.invoke() 69 | } 70 | .weight(0.3f) 71 | ) 72 | } 73 | 74 | Spacer(modifier = Modifier.height(16.dp)) 75 | 76 | Text( 77 | text = noteDataModel.content, 78 | fontWeight = FontWeight.Normal, 79 | maxLines = maxLines, 80 | fontSize = 14.sp, 81 | overflow = TextOverflow.Ellipsis 82 | ) 83 | 84 | Spacer(modifier = Modifier.height(16.dp)) 85 | 86 | Text( 87 | text = formattedDate, 88 | color = Color.DarkGray, 89 | modifier = Modifier.align(Alignment.End) 90 | ) 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/components/SearchTextFieldComponent.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.components 2 | 3 | import androidx.compose.animation.AnimatedVisibility 4 | import androidx.compose.animation.fadeIn 5 | import androidx.compose.animation.fadeOut 6 | import androidx.compose.foundation.layout.Box 7 | import androidx.compose.foundation.layout.fillMaxWidth 8 | import androidx.compose.foundation.layout.padding 9 | import androidx.compose.foundation.shape.RoundedCornerShape 10 | import androidx.compose.material.Icon 11 | import androidx.compose.material.IconButton 12 | import androidx.compose.material.OutlinedTextField 13 | import androidx.compose.material.Text 14 | import androidx.compose.material.TextFieldDefaults 15 | import androidx.compose.material.icons.Icons 16 | import androidx.compose.material.icons.filled.Close 17 | import androidx.compose.material.icons.filled.Search 18 | import androidx.compose.runtime.Composable 19 | import androidx.compose.ui.Alignment 20 | import androidx.compose.ui.Modifier 21 | import androidx.compose.ui.graphics.Color 22 | import androidx.compose.ui.unit.dp 23 | 24 | @Composable 25 | internal fun SearchTextFieldComponent( 26 | text: String, 27 | onTextChange: (String) -> Unit, 28 | isSearchActive: Boolean, 29 | onSearchClick: () -> Unit, 30 | onCloseClick: () -> Unit, 31 | modifier: Modifier = Modifier, 32 | ) { 33 | Box(modifier = modifier) { 34 | AnimatedVisibility( 35 | visible = isSearchActive, 36 | enter = fadeIn(), 37 | exit = fadeOut(), 38 | ) { 39 | OutlinedTextField( 40 | value = text, 41 | onValueChange = onTextChange, 42 | shape = RoundedCornerShape(30.dp), 43 | placeholder = { Text(text = "Search") }, 44 | colors = TextFieldDefaults.textFieldColors( 45 | backgroundColor = Color.Transparent, 46 | focusedIndicatorColor = Color.Black, 47 | unfocusedIndicatorColor = Color.Black, 48 | ), 49 | modifier = Modifier 50 | .fillMaxWidth() 51 | .padding(16.dp) 52 | .padding(end = 40.dp), 53 | ) 54 | } 55 | AnimatedVisibility( 56 | visible = isSearchActive, 57 | enter = fadeIn(), 58 | exit = fadeOut(), 59 | modifier = Modifier.align(Alignment.CenterEnd), 60 | ) { 61 | IconButton( 62 | onClick = onCloseClick, 63 | content = { 64 | Icon( 65 | imageVector = Icons.Default.Close, 66 | contentDescription = "Close Search", 67 | ) 68 | }, 69 | ) 70 | } 71 | AnimatedVisibility( 72 | visible = !isSearchActive, 73 | enter = fadeIn(), 74 | exit = fadeOut(), 75 | modifier = Modifier.align(Alignment.CenterEnd), 76 | ) { 77 | IconButton( 78 | onClick = onSearchClick, 79 | content = { 80 | Icon( 81 | imageVector = Icons.Default.Search, 82 | contentDescription = "Open Search", 83 | ) 84 | }, 85 | ) 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/components/VerticalStaggeredGrid.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.components 2 | 3 | import androidx.compose.runtime.Composable 4 | import androidx.compose.ui.Modifier 5 | import androidx.compose.ui.layout.Layout 6 | 7 | // Ref - https://github.com/AdamMc331/StaggeredGridCompose 8 | @Composable 9 | fun VerticalStaggeredGrid( 10 | modifier: Modifier = Modifier, 11 | numColumns: Int = 2, 12 | content: @Composable () -> Unit, 13 | ) { 14 | Layout( 15 | content = content, 16 | modifier = modifier, 17 | ) { measurables, constraints -> 18 | 19 | // Width per column based on constraints 20 | val columnWidth = (constraints.maxWidth / numColumns) 21 | 22 | // Make sure items can't be wider than column width 23 | val itemConstraints = constraints.copy(maxWidth = columnWidth) 24 | 25 | // Track the height of each column in an array. 26 | val columnHeights = IntArray(numColumns) { 0 } 27 | 28 | // For each item to place, figure out the shortest column so we know where to place it 29 | // and keep track of how large that column is going to be. 30 | val placeables = measurables.map { measurable -> 31 | val column = shortestColumn(columnHeights) 32 | val placeable = measurable.measure(itemConstraints) 33 | columnHeights[column] += placeable.height 34 | placeable 35 | } 36 | 37 | // Get the height of the entire grid, by using the largest column, 38 | // ensuring that it does not go out of the bounds 39 | // of this container. 40 | // If something went wrong, default to min height. 41 | val height = columnHeights.maxOrNull() 42 | ?.coerceIn(constraints.minHeight, constraints.maxHeight) 43 | ?: constraints.minHeight 44 | 45 | layout( 46 | width = constraints.maxWidth, 47 | height = height, 48 | ) { 49 | // Keep track of the current Y position for each column 50 | val columnYPointers = IntArray(numColumns) { 0 } 51 | 52 | placeables.forEach { placeable -> 53 | // Determine which column to place this item in 54 | val column = shortestColumn(columnYPointers) 55 | 56 | placeable.place( 57 | x = columnWidth * column, 58 | y = columnYPointers[column], 59 | ) 60 | 61 | // Update the pointer for this column based on the item 62 | // we just placed. 63 | columnYPointers[column] += placeable.height 64 | } 65 | } 66 | } 67 | } 68 | 69 | /** 70 | * Loop through all of the column heights, and determine which one is the shortest. This is how 71 | * we determine which column to add the next item to. 72 | */ 73 | private fun shortestColumn(columnHeights: IntArray): Int { 74 | var minHeight = Int.MAX_VALUE 75 | var columnIndex = 0 76 | 77 | columnHeights.forEachIndexed { index, height -> 78 | if (height < minHeight) { 79 | minHeight = height 80 | columnIndex = index 81 | } 82 | } 83 | 84 | return columnIndex 85 | } 86 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/krouter/DecomposeNavigator.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.krouter 2 | 3 | import androidx.compose.runtime.Composable 4 | import androidx.compose.runtime.ProvidableCompositionLocal 5 | import androidx.compose.runtime.State 6 | import androidx.compose.runtime.remember 7 | import androidx.compose.runtime.staticCompositionLocalOf 8 | import com.arkivanov.decompose.ComponentContext 9 | import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState 10 | import com.arkivanov.decompose.router.stack.ChildStack 11 | import com.arkivanov.decompose.router.stack.StackNavigationSource 12 | import com.arkivanov.decompose.router.stack.childStack 13 | import com.arkivanov.essenty.parcelable.Parcelable 14 | import kotlin.reflect.KClass 15 | 16 | /** 17 | * Based off from https://proandroiddev.com/a-comprehensive-hundred-line-navigation-for-jetpack-desktop-compose-5b723c4f256e 18 | * https://github.com/arkivanov/ComposeNavigatorExample/blob/d786d92632fe22e4d7874645ba2071fb813f9ace/navigator/src/commonMain/kotlin/com/arkivanov/composenavigatorexample/navigator/Navigator.kt 19 | */ 20 | val LocalComponentContext: ProvidableCompositionLocal = 21 | staticCompositionLocalOf { error("Root component context was not provided") } 22 | 23 | @Composable 24 | internal fun rememberChildStack( 25 | type: KClass, 26 | source: StackNavigationSource, 27 | initialStack: () -> List, 28 | key: String = "DefaultChildStack", 29 | handleBackButton: Boolean = false, 30 | ): State> { 31 | val componentContext = LocalComponentContext.current 32 | 33 | return remember { 34 | componentContext.childStack( 35 | source = source, 36 | initialStack = initialStack, 37 | configurationClass = type, 38 | key = key, 39 | handleBackButton = handleBackButton, 40 | childFactory = { _, childComponentContext -> childComponentContext }, 41 | ) 42 | }.subscribeAsState() 43 | } 44 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/krouter/KRouter.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.krouter 2 | 3 | import androidx.compose.runtime.Composable 4 | import androidx.compose.runtime.CompositionLocalProvider 5 | import androidx.compose.runtime.DisallowComposableCalls 6 | import androidx.compose.runtime.LaunchedEffect 7 | import androidx.compose.runtime.ProvidableCompositionLocal 8 | import androidx.compose.runtime.State 9 | import androidx.compose.runtime.remember 10 | import androidx.compose.runtime.staticCompositionLocalOf 11 | import androidx.compose.ui.Modifier 12 | import com.arkivanov.decompose.ComponentContext 13 | import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children 14 | import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.StackAnimation 15 | import com.arkivanov.decompose.router.stack.ChildStack 16 | import com.arkivanov.decompose.router.stack.StackNavigation 17 | import com.arkivanov.essenty.instancekeeper.InstanceKeeper 18 | import com.arkivanov.essenty.instancekeeper.getOrCreate 19 | import com.arkivanov.essenty.parcelable.Parcelable 20 | import com.arkivanov.essenty.statekeeper.StateKeeper 21 | import kotlin.reflect.KClass 22 | 23 | /** 24 | * From xxFast's Krouter library 25 | */ 26 | 27 | class Router( 28 | private val navigator: StackNavigation, 29 | val stack: State>, 30 | ) : StackNavigation by navigator 31 | 32 | val LocalRouter: ProvidableCompositionLocal?> = 33 | staticCompositionLocalOf { null } 34 | 35 | @Composable 36 | fun rememberRouter( 37 | type: KClass, 38 | stack: List, 39 | handleBackButton: Boolean = true, 40 | ): Router { 41 | val navigator: StackNavigation = remember { StackNavigation() } 42 | 43 | val packageName: String = 44 | requireNotNull(type.simpleName) { "Unable to retain anonymous instance of $type" } 45 | 46 | val childStackState: State> = rememberChildStack( 47 | source = navigator, 48 | initialStack = { stack }, 49 | key = packageName, 50 | handleBackButton = handleBackButton, 51 | type = type, 52 | ) 53 | 54 | return remember { Router(navigator = navigator, stack = childStackState) } 55 | } 56 | 57 | @Composable 58 | fun RoutedContent( 59 | router: Router, 60 | modifier: Modifier = Modifier, 61 | animation: StackAnimation? = null, 62 | content: @Composable (C) -> Unit, 63 | ) { 64 | CompositionLocalProvider(LocalRouter provides router) { 65 | Children( 66 | stack = router.stack.value, 67 | modifier = modifier, 68 | animation = animation, 69 | ) { child -> 70 | CompositionLocalProvider(LocalComponentContext provides child.instance) { 71 | content(child.configuration) 72 | } 73 | } 74 | } 75 | } 76 | 77 | @Suppress("UNCHECKED_CAST") // ViewModels must be Instances 78 | @Composable 79 | fun rememberViewModel( 80 | viewModelClass: KClass, 81 | block: @DisallowComposableCalls (savedState: SavedStateHandle) -> T, 82 | ): T { 83 | val component: ComponentContext = LocalComponentContext.current 84 | val stateKeeper: StateKeeper = component.stateKeeper 85 | val instanceKeeper: InstanceKeeper = component.instanceKeeper 86 | 87 | val packageName: String = 88 | requireNotNull(viewModelClass.simpleName) { "Unable to retain anonymous instance of $viewModelClass" } 89 | val viewModelKey = "$packageName.viewModel" 90 | val stateKey = "$packageName.savedState" 91 | 92 | val (viewModel, savedState) = remember(viewModelClass) { 93 | val savedState: SavedStateHandle = instanceKeeper 94 | .getOrCreate(stateKey) { 95 | SavedStateHandle( 96 | stateKeeper.consume( 97 | stateKey, 98 | SavedState::class, 99 | ), 100 | ) 101 | } 102 | var viewModel: T? = instanceKeeper.get(viewModelKey) as T? 103 | if (viewModel == null) { 104 | viewModel = block(savedState) 105 | instanceKeeper.put(viewModelKey, viewModel) 106 | } 107 | viewModel to savedState 108 | } 109 | 110 | LaunchedEffect(Unit) { 111 | if (!stateKeeper.isRegistered(stateKey)) { 112 | stateKeeper.register(stateKey) { savedState.value } 113 | } 114 | } 115 | 116 | return viewModel 117 | } 118 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/krouter/SavedState.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.krouter 2 | 3 | import com.arkivanov.essenty.instancekeeper.InstanceKeeper 4 | import com.arkivanov.essenty.parcelable.Parcelable 5 | import com.arkivanov.essenty.parcelable.Parcelize 6 | 7 | /** 8 | * From xxFast's Krouter library 9 | */ 10 | @Parcelize 11 | data class SavedState(val value: Parcelable) : Parcelable 12 | 13 | @Suppress("UNCHECKED_CAST") // I know what i'm doing 14 | class SavedStateHandle(default: SavedState?) : InstanceKeeper.Instance { 15 | private var savedState: SavedState? = default 16 | val value: Parcelable? get() = savedState 17 | fun get(): T? = savedState?.value as? T? 18 | fun set(value: Parcelable) { 19 | this.savedState = SavedState(value) 20 | } 21 | 22 | override fun onDestroy() { 23 | savedState = null 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/krouter/ViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.krouter 2 | 3 | import com.arkivanov.essenty.instancekeeper.InstanceKeeper 4 | import kotlinx.coroutines.CoroutineScope 5 | import kotlin.coroutines.CoroutineContext 6 | 7 | /** 8 | * From xxFast's Krouter library 9 | */ 10 | expect open class ViewModel() : InstanceKeeper.Instance, CoroutineScope { 11 | override val coroutineContext: CoroutineContext 12 | } 13 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/screens/RootComponent.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.screens 2 | 3 | import androidx.compose.runtime.Composable 4 | import com.adikmt.notesapp.data.model.NoteDataModel 5 | import com.adikmt.notesapp.ui.krouter.RoutedContent 6 | import com.adikmt.notesapp.ui.krouter.Router 7 | import com.adikmt.notesapp.ui.krouter.rememberRouter 8 | import com.adikmt.notesapp.ui.screens.detailsScreen.NoteDetailScreen 9 | import com.adikmt.notesapp.ui.screens.listScreen.NoteListScreen 10 | import com.adikmt.notesapp.ui.theme.MyApplicationTheme 11 | import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.slide 12 | import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.stackAnimation 13 | import com.arkivanov.decompose.router.stack.pop 14 | import com.arkivanov.decompose.router.stack.push 15 | import com.arkivanov.essenty.parcelable.Parcelable 16 | import com.arkivanov.essenty.parcelable.Parcelize 17 | 18 | @Composable 19 | fun RootComponent() { 20 | val router: Router = 21 | rememberRouter(RootStateModel::class, listOf(RootStateModel.NoteList)) 22 | 23 | MyApplicationTheme { 24 | RoutedContent( 25 | router = router, 26 | animation = stackAnimation(animator = slide()), 27 | content = { screen -> 28 | when (screen) { 29 | is RootStateModel.NoteDetails -> NoteDetailScreen( 30 | noteId = screen.noteId, 31 | onBack = { router.pop() }, 32 | ) 33 | 34 | RootStateModel.NoteList -> NoteListScreen( 35 | onAddOrItemClicked = { noteDataModel: NoteDataModel? -> 36 | router.push(RootStateModel.NoteDetails(noteDataModel?.id)) 37 | }, 38 | ) 39 | } 40 | }, 41 | ) 42 | } 43 | } 44 | 45 | @Parcelize 46 | sealed class RootStateModel : Parcelable { 47 | object NoteList : RootStateModel() 48 | data class NoteDetails(val noteId: Long?) : RootStateModel() 49 | } 50 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/screens/detailsScreen/NoteDetailScreen.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.screens.detailsScreen 2 | 3 | import androidx.compose.foundation.background 4 | import androidx.compose.foundation.layout.Column 5 | import androidx.compose.foundation.layout.Spacer 6 | import androidx.compose.foundation.layout.fillMaxSize 7 | import androidx.compose.foundation.layout.height 8 | import androidx.compose.foundation.layout.padding 9 | import androidx.compose.material.FloatingActionButton 10 | import androidx.compose.material.Icon 11 | import androidx.compose.material.IconButton 12 | import androidx.compose.material.Scaffold 13 | import androidx.compose.material.Text 14 | import androidx.compose.material.TopAppBar 15 | import androidx.compose.material.icons.Icons 16 | import androidx.compose.material.icons.filled.ArrowBack 17 | import androidx.compose.material.icons.filled.Check 18 | import androidx.compose.runtime.Composable 19 | import androidx.compose.runtime.LaunchedEffect 20 | import androidx.compose.runtime.collectAsState 21 | import androidx.compose.runtime.getValue 22 | import androidx.compose.runtime.mutableStateOf 23 | import androidx.compose.runtime.remember 24 | import androidx.compose.runtime.setValue 25 | import androidx.compose.ui.Modifier 26 | import androidx.compose.ui.graphics.Color 27 | import androidx.compose.ui.text.TextStyle 28 | import androidx.compose.ui.unit.dp 29 | import androidx.compose.ui.unit.sp 30 | import com.adikmt.notesapp.ui.components.HeadingTextFieldComponent 31 | import com.adikmt.notesapp.ui.krouter.rememberViewModel 32 | 33 | @Composable 34 | fun NoteDetailScreen( 35 | noteId: Long?, 36 | onBack: () -> Unit, 37 | modifier: Modifier = Modifier, 38 | ) { 39 | val viewModel: NoteDetailViewModel = 40 | rememberViewModel(NoteDetailViewModel::class) { NoteDetailViewModel() } 41 | 42 | /** 43 | * State stored here instead of the VM as the transfer of data was causing 44 | * poor writing effort in the text fields especially in iOS 45 | */ 46 | 47 | val noteDetailState by viewModel.noteMutableStateFlow.collectAsState() 48 | val isSaved by viewModel.hasNoteBeenSaved.collectAsState() 49 | val onBackClicked by viewModel.onBackMutableState.collectAsState() 50 | 51 | var stateTitle by remember { 52 | mutableStateOf(noteDetailState.title) 53 | } 54 | 55 | var stateContent by remember { 56 | mutableStateOf(noteDetailState.content) 57 | } 58 | 59 | LaunchedEffect(Unit) { 60 | viewModel.getNote(noteId) 61 | } 62 | 63 | LaunchedEffect(noteDetailState) { 64 | stateTitle = noteDetailState.title 65 | stateContent = noteDetailState.content 66 | } 67 | 68 | LaunchedEffect(isSaved, onBackClicked) { 69 | if (isSaved || onBackClicked) { 70 | onBack.invoke() 71 | } 72 | } 73 | 74 | Scaffold( 75 | modifier = modifier, 76 | floatingActionButton = { 77 | FloatingActionButton( 78 | onClick = { 79 | if (!isSaved) { 80 | viewModel.saveNote( 81 | noteId = noteId, 82 | title = stateTitle, 83 | content = stateContent, 84 | ) 85 | } 86 | }, 87 | backgroundColor = Color.Black, 88 | ) { 89 | Icon( 90 | imageVector = Icons.Default.Check, 91 | contentDescription = "Save Note", 92 | tint = Color.White, 93 | ) 94 | } 95 | }, 96 | topBar = { 97 | TopAppBar( 98 | title = { Text("Note Detail") }, 99 | navigationIcon = { 100 | IconButton( 101 | onClick = { 102 | if (!isSaved) { 103 | viewModel.saveNote( 104 | noteId = noteId, 105 | title = stateTitle, 106 | content = stateContent, 107 | ) 108 | } 109 | }, 110 | content = { 111 | Icon( 112 | imageVector = Icons.Filled.ArrowBack, 113 | contentDescription = "Back", 114 | ) 115 | }, 116 | ) 117 | }, 118 | backgroundColor = Color.White, 119 | ) 120 | }, 121 | ) { padding -> 122 | Column( 123 | modifier = Modifier 124 | .background(Color(noteDetailState.color)) 125 | .fillMaxSize() 126 | .padding(padding) 127 | .padding(16.dp), 128 | ) { 129 | HeadingTextFieldComponent( 130 | hint = "Enter a Title...", 131 | value = stateTitle, 132 | onValueChanged = { 133 | stateTitle = it 134 | }, 135 | isSingleLine = true, 136 | textStyle = TextStyle(fontSize = 20.sp), 137 | ) 138 | 139 | Spacer(modifier = Modifier.height(16.dp)) 140 | 141 | HeadingTextFieldComponent( 142 | value = stateContent, 143 | hint = "Enter some content...", 144 | onValueChanged = { 145 | stateContent = it 146 | }, 147 | textStyle = TextStyle(fontSize = 20.sp), 148 | modifier = Modifier.weight(1f), 149 | isSingleLine = false, 150 | ) 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/screens/detailsScreen/NoteDetailViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.screens.detailsScreen 2 | 3 | import com.adikmt.notesapp.data.NoteLocalDataSource 4 | import com.adikmt.notesapp.data.model.NoteDataModel 5 | import com.adikmt.notesapp.ui.krouter.ViewModel 6 | import com.adikmt.notesapp.utils.DateTimeUtil 7 | import kotlinx.coroutines.CoroutineScope 8 | import kotlinx.coroutines.flow.MutableStateFlow 9 | import kotlinx.coroutines.flow.StateFlow 10 | import kotlinx.coroutines.flow.asStateFlow 11 | import kotlinx.coroutines.flow.update 12 | import kotlinx.coroutines.launch 13 | import kotlinx.datetime.toInstant 14 | import org.koin.core.component.KoinComponent 15 | import org.koin.core.component.get 16 | 17 | class NoteDetailViewModel : ViewModel(), KoinComponent { 18 | private val _hasNoteBeenSaved = MutableStateFlow(false) 19 | val hasNoteBeenSaved: StateFlow = _hasNoteBeenSaved.asStateFlow() 20 | 21 | val onBackMutableState = MutableStateFlow(false) 22 | 23 | private val _noteMutableStateFlow = MutableStateFlow(NoteDetailState()) 24 | val noteMutableStateFlow: StateFlow = _noteMutableStateFlow.asStateFlow() 25 | 26 | private val noteLocalDataSource = get() 27 | 28 | fun getNote(noteId: Long?) { 29 | CoroutineScope(coroutineContext).launch { 30 | if (noteId == null) { 31 | _noteMutableStateFlow.update { 32 | it.copy( 33 | color = NoteDataModel.generateRandomColor(), 34 | ) 35 | } 36 | } else { 37 | val note = noteLocalDataSource.getNote(noteId) 38 | note?.let { nnNote -> 39 | _noteMutableStateFlow.update { noteDetail -> 40 | noteDetail.copy( 41 | title = nnNote.title, 42 | content = nnNote.content, 43 | color = nnNote.colorHex, 44 | ) 45 | } 46 | } 47 | } 48 | } 49 | } 50 | 51 | fun saveNote( 52 | noteId: Long?, 53 | title: String, 54 | content: String, 55 | ) { 56 | CoroutineScope(coroutineContext).launch { 57 | if (title.checkNotEmptyOrBlank()) { 58 | noteId?.let { 59 | noteLocalDataSource.updateNote( 60 | id = noteId, 61 | title = title, 62 | content = content, 63 | createdAt = DateTimeUtil.toEpochMillis(DateTimeUtil.now()) 64 | ) 65 | } ?: noteLocalDataSource.insertNote( 66 | NoteDataModel( 67 | id = noteId, 68 | title = title, 69 | content = content, 70 | colorHex = _noteMutableStateFlow.value.color, 71 | createdAt = DateTimeUtil.now(), 72 | ), 73 | ) 74 | _hasNoteBeenSaved.value = true 75 | } 76 | onBackMutableState.value = true 77 | } 78 | } 79 | } 80 | 81 | data class NoteDetailState( 82 | val title: String = "", 83 | val content: String = "", 84 | val color: Long = 0xFFFFFFFF, 85 | ) 86 | 87 | fun String.checkNotEmptyOrBlank(): Boolean { 88 | return isNotEmpty() && isNotBlank() 89 | } 90 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/screens/listScreen/NoteListScreen.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.screens.listScreen 2 | 3 | import androidx.compose.animation.AnimatedVisibility 4 | import androidx.compose.animation.fadeIn 5 | import androidx.compose.animation.fadeOut 6 | import androidx.compose.foundation.ExperimentalFoundationApi 7 | import androidx.compose.foundation.isSystemInDarkTheme 8 | import androidx.compose.foundation.layout.Box 9 | import androidx.compose.foundation.layout.Column 10 | import androidx.compose.foundation.layout.fillMaxSize 11 | import androidx.compose.foundation.layout.fillMaxWidth 12 | import androidx.compose.foundation.layout.height 13 | import androidx.compose.foundation.layout.padding 14 | import androidx.compose.material.FloatingActionButton 15 | import androidx.compose.material.Icon 16 | import androidx.compose.material.Scaffold 17 | import androidx.compose.material.Text 18 | import androidx.compose.material.icons.Icons 19 | import androidx.compose.material.icons.filled.Add 20 | import androidx.compose.runtime.Composable 21 | import androidx.compose.runtime.LaunchedEffect 22 | import androidx.compose.runtime.collectAsState 23 | import androidx.compose.runtime.getValue 24 | import androidx.compose.ui.Alignment 25 | import androidx.compose.ui.Modifier 26 | import androidx.compose.ui.graphics.Color 27 | import androidx.compose.ui.text.font.FontWeight 28 | import androidx.compose.ui.unit.dp 29 | import androidx.compose.ui.unit.sp 30 | import com.adikmt.notesapp.data.model.NoteDataModel 31 | import com.adikmt.notesapp.ui.components.NoteListItemComponent 32 | import com.adikmt.notesapp.ui.components.SearchTextFieldComponent 33 | import com.adikmt.notesapp.ui.components.VerticalStaggeredGrid 34 | import com.adikmt.notesapp.ui.krouter.rememberViewModel 35 | 36 | @OptIn(ExperimentalFoundationApi::class) 37 | @Composable 38 | fun NoteListScreen( 39 | onAddOrItemClicked: (NoteDataModel?) -> Unit, 40 | modifier: Modifier = Modifier, 41 | ) { 42 | val viewModel: NoteListViewModel = 43 | rememberViewModel(NoteListViewModel::class) { 44 | NoteListViewModel() 45 | } 46 | 47 | val noteListState by viewModel.noteListStateFlow.collectAsState() 48 | val isSearchActive by viewModel.isSearchActive.collectAsState() 49 | 50 | LaunchedEffect(true) { 51 | viewModel.getAllNotes() 52 | } 53 | 54 | Scaffold( 55 | modifier = modifier, 56 | floatingActionButton = { 57 | FloatingActionButton( 58 | onClick = { 59 | onAddOrItemClicked(null) 60 | }, 61 | backgroundColor = if (isSystemInDarkTheme()) Color.Black else Color.White, 62 | content = { 63 | Icon( 64 | imageVector = Icons.Default.Add, 65 | contentDescription = "Add Note", 66 | tint = Color.Black, 67 | ) 68 | }, 69 | ) 70 | }, 71 | ) { padding -> 72 | Column( 73 | modifier = Modifier 74 | .fillMaxSize() 75 | .padding(padding), 76 | ) { 77 | Box( 78 | modifier = Modifier.fillMaxWidth(), 79 | contentAlignment = Alignment.Center, 80 | ) { 81 | SearchTextFieldComponent( 82 | text = noteListState.searchText, 83 | modifier = Modifier 84 | .fillMaxWidth() 85 | .height(100.dp), 86 | onTextChange = viewModel::searchTextChanged, 87 | isSearchActive = isSearchActive, 88 | onSearchClick = viewModel::toggleSearchFocus, 89 | onCloseClick = viewModel::toggleSearchFocus, 90 | ) 91 | this@Column.AnimatedVisibility( 92 | visible = !isSearchActive, 93 | enter = fadeIn(), 94 | exit = fadeOut(), 95 | ) { 96 | Text( 97 | text = "All Notes", 98 | fontSize = 30.sp, 99 | fontWeight = FontWeight.Bold, 100 | ) 101 | } 102 | } 103 | 104 | VerticalStaggeredGrid( 105 | modifier = Modifier.padding(8.dp), 106 | content = { 107 | noteListState.notes.forEach { note -> 108 | NoteListItemComponent( 109 | noteDataModel = note, 110 | onNoteClick = { onAddOrItemClicked.invoke(note) }, 111 | onNoteDeleted = { viewModel.deleteNote(note.id) }, 112 | modifier = modifier.padding(4.dp), 113 | ) 114 | } 115 | }, 116 | ) 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/screens/listScreen/NoteListViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.screens.listScreen 2 | 3 | import com.adikmt.notesapp.data.NoteLocalDataSource 4 | import com.adikmt.notesapp.data.model.NoteDataModel 5 | import com.adikmt.notesapp.ui.krouter.ViewModel 6 | import kotlinx.coroutines.CoroutineScope 7 | import kotlinx.coroutines.flow.MutableStateFlow 8 | import kotlinx.coroutines.flow.StateFlow 9 | import kotlinx.coroutines.flow.asStateFlow 10 | import kotlinx.coroutines.flow.update 11 | import kotlinx.coroutines.launch 12 | import org.koin.core.component.KoinComponent 13 | import org.koin.core.component.get 14 | 15 | class NoteListViewModel : ViewModel(), KoinComponent { 16 | 17 | private val _isSearchActive = MutableStateFlow(false) 18 | val isSearchActive: StateFlow = _isSearchActive.asStateFlow() 19 | 20 | private val _noteListStateFlow = MutableStateFlow(NoteListState()) 21 | val noteListStateFlow: StateFlow = _noteListStateFlow.asStateFlow() 22 | 23 | private val noteLocalDataSource = get() 24 | 25 | fun getAllNotes() { 26 | CoroutineScope(coroutineContext).launch { 27 | _noteListStateFlow.update { noteListState -> 28 | noteListState.copy( 29 | notes = noteLocalDataSource.getAllNotes(), 30 | ) 31 | } 32 | } 33 | } 34 | 35 | fun deleteNote(id: Long?) { 36 | CoroutineScope(coroutineContext).launch { 37 | id?.let { 38 | noteLocalDataSource.deleteNote(it) 39 | _noteListStateFlow.update { noteListState -> 40 | noteListState.copy( 41 | notes = noteLocalDataSource.getAllNotes(), 42 | ) 43 | } 44 | } 45 | } 46 | } 47 | 48 | fun searchTextChanged(text: String) { 49 | CoroutineScope(coroutineContext).launch { 50 | _noteListStateFlow.update { noteListState -> 51 | noteListState.copy( 52 | notes = noteLocalDataSource.searchNotes(text), 53 | searchText = text, 54 | ) 55 | } 56 | } 57 | } 58 | 59 | fun toggleSearchFocus() { 60 | _isSearchActive.value = !_isSearchActive.value 61 | if (!_isSearchActive.value) { 62 | _noteListStateFlow.update { noteListState -> 63 | noteListState.copy( 64 | searchText = "", 65 | ) 66 | } 67 | getAllNotes() 68 | } 69 | } 70 | } 71 | 72 | data class NoteListState( 73 | val notes: List = emptyList(), 74 | val searchText: String = "", 75 | ) 76 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/theme/Colors.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.theme 2 | 3 | const val RedOrangeHex = 0xffffab91 4 | const val RedPinkHex = 0xfff48fb1 5 | const val BabyBlueHex = 0xff81deea 6 | const val VioletHex = 0xffcf94da 7 | const val LightGreenHex = 0xffe7ed9b 8 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/ui/theme/MyApplicationTheme.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.theme 2 | 3 | import androidx.compose.foundation.isSystemInDarkTheme 4 | import androidx.compose.foundation.shape.RoundedCornerShape 5 | import androidx.compose.material.MaterialTheme 6 | import androidx.compose.material.Shapes 7 | import androidx.compose.material.Typography 8 | import androidx.compose.material.darkColors 9 | import androidx.compose.material.lightColors 10 | import androidx.compose.runtime.Composable 11 | import androidx.compose.ui.graphics.Color 12 | import androidx.compose.ui.text.TextStyle 13 | import androidx.compose.ui.text.font.FontFamily 14 | import androidx.compose.ui.text.font.FontWeight 15 | import androidx.compose.ui.unit.dp 16 | import androidx.compose.ui.unit.sp 17 | 18 | @Composable 19 | internal fun MyApplicationTheme( 20 | darkTheme: Boolean = isSystemInDarkTheme(), 21 | content: @Composable () -> Unit, 22 | ) { 23 | val colors = if (darkTheme) { 24 | darkColors( 25 | primary = Color(0xFFBB86FC), 26 | primaryVariant = Color(0xFF3700B3), 27 | secondary = Color(0xFF03DAC5), 28 | ) 29 | } else { 30 | lightColors( 31 | primary = Color(0xFF6200EE), 32 | primaryVariant = Color(0xFF3700B3), 33 | secondary = Color(0xFF03DAC5), 34 | ) 35 | } 36 | val typography = Typography( 37 | body1 = TextStyle( 38 | fontFamily = FontFamily.Default, 39 | fontWeight = FontWeight.Normal, 40 | fontSize = 16.sp, 41 | ), 42 | ) 43 | val shapes = Shapes( 44 | small = RoundedCornerShape(4.dp), 45 | medium = RoundedCornerShape(4.dp), 46 | large = RoundedCornerShape(0.dp), 47 | ) 48 | 49 | MaterialTheme( 50 | 51 | colors = colors, 52 | typography = typography, 53 | shapes = shapes, 54 | content = content, 55 | ) 56 | } 57 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/com/adikmt/notesapp/utils/DateTimeUtil.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.utils 2 | 3 | import kotlinx.datetime.Clock 4 | import kotlinx.datetime.LocalDateTime 5 | import kotlinx.datetime.TimeZone 6 | import kotlinx.datetime.toInstant 7 | import kotlinx.datetime.toLocalDateTime 8 | 9 | /** 10 | * Mostly picked uo from Philip Lackner's KMM project 11 | */ 12 | object DateTimeUtil { 13 | 14 | fun now(): LocalDateTime { 15 | return Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()) 16 | } 17 | 18 | fun toEpochMillis(dateTime: LocalDateTime): Long { 19 | return dateTime.toInstant(TimeZone.currentSystemDefault()).toEpochMilliseconds() 20 | } 21 | 22 | fun formatNoteDate(dateTime: LocalDateTime): String { 23 | val month = dateTime.month.name.lowercase().take(3).replaceFirstChar { it.uppercase() } 24 | val day = if (dateTime.dayOfMonth < 10) "0${dateTime.dayOfMonth}" else dateTime.dayOfMonth 25 | val year = dateTime.year 26 | val hour = if (dateTime.hour < 10) "0${dateTime.hour}" else dateTime.hour 27 | val minute = if (dateTime.minute < 10) "0${dateTime.minute}" else dateTime.minute 28 | 29 | return buildString { 30 | append(month) 31 | append(" ") 32 | append(day) 33 | append(" ") 34 | append(year) 35 | append(", ") 36 | append(hour) 37 | append(":") 38 | append(minute) 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/sqldelight/com/adikmt/notesapp/note.sq: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS NoteEntity( 2 | Id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 3 | Title TEXT NOT NULL, 4 | Content TEXT NOT NULL, 5 | ColorHex INTEGER NOT NULL, 6 | CreatedAt INTEGER NOT NULL 7 | ); 8 | 9 | getAllNotes: 10 | SELECT * 11 | FROM NoteEntity; 12 | 13 | getNote: 14 | SELECT * 15 | FROM NoteEntity 16 | WHERE Id = :id; 17 | 18 | searchNotes: 19 | SELECT * 20 | FROM NoteEntity 21 | WHERE Title LIKE ("%" || :title) 22 | OR Title LIKE (:title || "%"); 23 | 24 | updateNotes: 25 | UPDATE NoteEntity 26 | SET Title = :title, 27 | Content = :content, 28 | CreatedAt = :createdat 29 | WHERE Id = :id; 30 | 31 | insertNote: 32 | INSERT OR REPLACE 33 | INTO NoteEntity( 34 | Id, 35 | Title, 36 | Content, 37 | ColorHex, 38 | CreatedAt 39 | ) VALUES(:id, :title, :content, :color, :created); 40 | 41 | deleteNote: 42 | DELETE FROM NoteEntity 43 | WHERE Id = :id; -------------------------------------------------------------------------------- /composeApp/src/desktopMain/kotlin/com/adikmt/notesapp/data/createDriver.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.data 2 | 3 | import app.cash.sqldelight.db.SqlDriver 4 | import org.koin.core.scope.Scope 5 | import com.adikmt.notesapp.NotesDB 6 | import app.cash.sqldelight.driver.jdbc.sqlite.JdbcSqliteDriver 7 | 8 | actual fun Scope.createDriver(): SqlDriver { 9 | val driver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY) 10 | NotesDB.Schema.create(driver) 11 | return driver 12 | } -------------------------------------------------------------------------------- /composeApp/src/desktopMain/kotlin/com/adikmt/notesapp/ui/krouter/ViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.krouter 2 | 3 | import com.arkivanov.essenty.instancekeeper.InstanceKeeper 4 | import kotlinx.coroutines.CoroutineScope 5 | import kotlinx.coroutines.Dispatchers 6 | import kotlinx.coroutines.SupervisorJob 7 | import kotlinx.coroutines.cancel 8 | import kotlin.coroutines.CoroutineContext 9 | 10 | actual open class ViewModel : InstanceKeeper.Instance, CoroutineScope { 11 | actual override val coroutineContext: CoroutineContext = Dispatchers.Unconfined + SupervisorJob() 12 | override fun onDestroy() { coroutineContext.cancel() } 13 | } -------------------------------------------------------------------------------- /composeApp/src/desktopMain/kotlin/main.kt: -------------------------------------------------------------------------------- 1 | import androidx.compose.runtime.CompositionLocalProvider 2 | import androidx.compose.ui.unit.dp 3 | import androidx.compose.ui.window.Window 4 | import androidx.compose.ui.window.application 5 | import androidx.compose.ui.window.rememberWindowState 6 | import com.adikmt.notesapp.App 7 | import com.adikmt.notesapp.di.initKoin 8 | import com.adikmt.notesapp.ui.krouter.LocalComponentContext 9 | import com.arkivanov.decompose.DefaultComponentContext 10 | import com.arkivanov.essenty.lifecycle.LifecycleRegistry 11 | 12 | fun main() = application { 13 | 14 | initKoin() 15 | val lifecycle = LifecycleRegistry() 16 | 17 | val rootComponentContext = DefaultComponentContext(lifecycle = lifecycle) 18 | Window( 19 | title = "NotesApp", 20 | state = rememberWindowState(width = 800.dp, height = 600.dp), 21 | onCloseRequest = ::exitApplication, 22 | ) { 23 | CompositionLocalProvider(LocalComponentContext provides rootComponentContext) { 24 | App() 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /composeApp/src/iosMain/kotlin/com/adikmt/notesapp/data/createDriver.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.data 2 | 3 | import app.cash.sqldelight.db.SqlDriver 4 | import app.cash.sqldelight.driver.native.NativeSqliteDriver 5 | import com.adikmt.notesapp.NotesDB 6 | import org.koin.core.scope.Scope 7 | 8 | actual fun Scope.createDriver(): SqlDriver { 9 | return NativeSqliteDriver(NotesDB.Schema, "note.db") 10 | } -------------------------------------------------------------------------------- /composeApp/src/iosMain/kotlin/com/adikmt/notesapp/ui/krouter/ViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.adikmt.notesapp.ui.krouter 2 | 3 | import com.arkivanov.essenty.instancekeeper.InstanceKeeper 4 | import kotlinx.coroutines.CoroutineScope 5 | import kotlinx.coroutines.Dispatchers 6 | import kotlinx.coroutines.SupervisorJob 7 | import kotlinx.coroutines.cancel 8 | import kotlin.coroutines.CoroutineContext 9 | 10 | actual open class ViewModel : InstanceKeeper.Instance, CoroutineScope { 11 | actual override val coroutineContext: CoroutineContext = Dispatchers.Main + SupervisorJob() 12 | override fun onDestroy() { coroutineContext.cancel() } 13 | } -------------------------------------------------------------------------------- /composeApp/src/iosMain/kotlin/main.kt: -------------------------------------------------------------------------------- 1 | import androidx.compose.runtime.CompositionLocalProvider 2 | import androidx.compose.ui.window.ComposeUIViewController 3 | import com.adikmt.notesapp.App 4 | import com.adikmt.notesapp.di.initKoin 5 | import com.adikmt.notesapp.ui.krouter.LocalComponentContext 6 | import com.arkivanov.decompose.DefaultComponentContext 7 | import com.arkivanov.essenty.lifecycle.LifecycleRegistry 8 | import platform.UIKit.UIViewController 9 | 10 | fun MainViewController(): UIViewController { 11 | 12 | initKoin() 13 | val lifecycle = LifecycleRegistry() 14 | 15 | val rootComponentContext = DefaultComponentContext(lifecycle = lifecycle) 16 | 17 | return ComposeUIViewController { 18 | CompositionLocalProvider(LocalComponentContext provides rootComponentContext) { 19 | App() 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gradle.bat: -------------------------------------------------------------------------------- 1 | 2 | @rem 3 | @rem Copyright 2015 the original author or authors. 4 | @rem 5 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 6 | @rem you may not use this file except in compliance with the License. 7 | @rem You may obtain a copy of the License at 8 | @rem 9 | @rem https://www.apache.org/licenses/LICENSE-2.0 10 | @rem 11 | @rem Unless required by applicable law or agreed to in writing, software 12 | @rem distributed under the License is distributed on an "AS IS" BASIS, 13 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | @rem See the License for the specific language governing permissions and 15 | @rem limitations under the License. 16 | @rem 17 | 18 | @if "%DEBUG%" == "" @echo off 19 | @rem ########################################################################## 20 | @rem 21 | @rem Gradle startup script for Windows 22 | @rem 23 | @rem ########################################################################## 24 | 25 | @rem Set local scope for the variables with windows NT shell 26 | if "%OS%"=="Windows_NT" setlocal 27 | 28 | set DIRNAME=%~dp0 29 | if "%DIRNAME%" == "" set DIRNAME=. 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if "%ERRORLEVEL%" == "0" goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | 2 | #Gradle 3 | org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M" 4 | 5 | #Kotlin 6 | kotlin.code.style=official 7 | kotlin.js.compiler=ir 8 | 9 | #MPP 10 | kotlin.mpp.enableCInteropCommonization=true 11 | kotlin.mpp.androidSourceSetLayoutVersion=2 12 | 13 | #Compose 14 | org.jetbrains.compose.experimental.uikit.enabled=true 15 | kotlin.native.cacheKind=none 16 | 17 | #Android 18 | android.useAndroidX=true 19 | android.nonTransitiveRClass=true 20 | -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | 3 | kotlin = "1.8.20" 4 | agp = "7.4.2" 5 | compose = "1.4.0" 6 | androidx-appcompat = "1.6.1" 7 | androidx-activityCompose = "1.7.0" 8 | compose-uitooling = "1.4.1" 9 | kotlinx-coroutines = "1.6.4" 10 | kotlinx-serialization = "1.5.0" 11 | kotlinx-datetime = "0.4.0" 12 | koin = "3.4.0" 13 | sqlDelight = "2.0.0-alpha05" 14 | decompose = "2.0.0-alpha-02" 15 | essenty = "1.1.0" 16 | decompose-compose-experimental = "2.0.0-compose-experimental-alpha-02" 17 | 18 | [libraries] 19 | 20 | androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } 21 | androidx-activityCompose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" } 22 | compose-uitooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose-uitooling" } 23 | 24 | kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } 25 | kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" } 26 | 27 | kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } 28 | kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" } 29 | 30 | koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" } 31 | koin_android = { module = "io.insert-koin:koin-android", version.ref = "koin" } 32 | 33 | sqlDelight-driver-sqlite = { module = "app.cash.sqldelight:sqlite-driver", version.ref = "sqlDelight" } 34 | sqlDelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqlDelight" } 35 | sqlDelight-driver-native = { module = "app.cash.sqldelight:native-driver", version.ref = "sqlDelight" } 36 | sqlDelight-driver-sqljs = { module = "app.cash.sqldelight:sqljs-driver", version.ref = "sqlDelight" } 37 | sqlDelight_runtime = { module = "app.cash.sqldelight:runtime", version.ref = "sqlDelight" } 38 | 39 | decompose = { module = "com.arkivanov.decompose:decompose", version.ref = "decompose-compose-experimental" } 40 | decompose-compose-multiplatform = { module = "com.arkivanov.decompose:extensions-compose-jetbrains", version.ref = "decompose-compose-experimental" } 41 | decompose_extensions = { module = "com.arkivanov.decompose:extensions-compose-jetbrains", version.ref = "decompose-compose-experimental" } 42 | essenty_parcelable = {module = "com.arkivanov.essenty:parcelable", version.ref = "essenty"} 43 | 44 | [plugins] 45 | 46 | multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } 47 | cocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" } 48 | compose = { id = "org.jetbrains.compose", version.ref = "compose" } 49 | android-application = { id = "com.android.application", version.ref = "agp" } 50 | kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } 51 | sqlDelight = { id = "app.cash.sqldelight", version.ref = "sqlDelight" } 52 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adi-kmt/NotesAppKMM/3ecd1be408a134d28b6bf1ab4e6b34d39e63bb2b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | 2 | #!/usr/bin/env sh 3 | 4 | # 5 | # Copyright 2015 the original author or authors. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | ############################################################################## 21 | ## 22 | ## Gradle start up script for UN*X 23 | ## 24 | ############################################################################## 25 | 26 | # Attempt to set APP_HOME 27 | # Resolve links: ${'$'}0 may be a link 28 | PRG="$0" 29 | # Need this for relative symlinks. 30 | while [ -h "$PRG" ] ; do 31 | ls=`ls -ld "$PRG"` 32 | link=`expr "$ls" : '.*-> \(.*\)${'$'}'` 33 | if expr "$link" : '/.*' > /dev/null; then 34 | PRG="$link" 35 | else 36 | PRG=`dirname "$PRG"`"/$link" 37 | fi 38 | done 39 | SAVED="`pwd`" 40 | cd "`dirname \"$PRG\"`/" >/dev/null 41 | APP_HOME="`pwd -P`" 42 | cd "$SAVED" >/dev/null 43 | 44 | APP_NAME="Gradle" 45 | APP_BASE_NAME=`basename "$0"` 46 | 47 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 48 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 49 | 50 | # Use the maximum available, or set MAX_FD != -1 to use that value. 51 | MAX_FD="maximum" 52 | 53 | warn () { 54 | echo "${'$'}*" 55 | } 56 | 57 | die () { 58 | echo 59 | echo "${'$'}*" 60 | echo 61 | exit 1 62 | } 63 | 64 | # OS specific support (must be 'true' or 'false'). 65 | cygwin=false 66 | msys=false 67 | darwin=false 68 | nonstop=false 69 | case "`uname`" in 70 | CYGWIN* ) 71 | cygwin=true 72 | ;; 73 | Darwin* ) 74 | darwin=true 75 | ;; 76 | MSYS* | MINGW* ) 77 | msys=true 78 | ;; 79 | NONSTOP* ) 80 | nonstop=true 81 | ;; 82 | esac 83 | 84 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 85 | 86 | 87 | # Determine the Java command to use to start the JVM. 88 | if [ -n "$JAVA_HOME" ] ; then 89 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 90 | # IBM's JDK on AIX uses strange locations for the executables 91 | JAVACMD="$JAVA_HOME/jre/sh/java" 92 | else 93 | JAVACMD="$JAVA_HOME/bin/java" 94 | fi 95 | if [ ! -x "$JAVACMD" ] ; then 96 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 97 | 98 | Please set the JAVA_HOME variable in your environment to match the 99 | location of your Java installation." 100 | fi 101 | else 102 | JAVACMD="java" 103 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 104 | 105 | Please set the JAVA_HOME variable in your environment to match the 106 | location of your Java installation." 107 | fi 108 | 109 | # Increase the maximum file descriptors if we can. 110 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 111 | MAX_FD_LIMIT=`ulimit -H -n` 112 | if [ $? -eq 0 ] ; then 113 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 114 | MAX_FD="$MAX_FD_LIMIT" 115 | fi 116 | ulimit -n $MAX_FD 117 | if [ $? -ne 0 ] ; then 118 | warn "Could not set maximum file descriptor limit: $MAX_FD" 119 | fi 120 | else 121 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 122 | fi 123 | fi 124 | 125 | # For Darwin, add options to specify how the application appears in the dock 126 | if $darwin; then 127 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 128 | fi 129 | 130 | # For Cygwin or MSYS, switch paths to Windows format before running java 131 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 132 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 133 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 134 | 135 | JAVACMD=`cygpath --unix "$JAVACMD"` 136 | 137 | # We build the pattern for arguments to be converted via cygpath 138 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 139 | SEP="" 140 | for dir in $ROOTDIRSRAW ; do 141 | ROOTDIRS="$ROOTDIRS$SEP$dir" 142 | SEP="|" 143 | done 144 | OURCYGPATTERN="(^($ROOTDIRS))" 145 | # Add a user-defined pattern to the cygpath arguments 146 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 147 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 148 | fi 149 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 150 | i=0 151 | for arg in "$@" ; do 152 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 153 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 154 | 155 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 156 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 157 | else 158 | eval `echo args$i`="\"$arg\"" 159 | fi 160 | i=`expr $i + 1` 161 | done 162 | case $i in 163 | 0) set -- ;; 164 | 1) set -- "$args0" ;; 165 | 2) set -- "$args0" "$args1" ;; 166 | 3) set -- "$args0" "$args1" "$args2" ;; 167 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 168 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 169 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 170 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 171 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 172 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 173 | esac 174 | fi 175 | 176 | # Escape application args 177 | save () { 178 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 179 | echo " " 180 | } 181 | APP_ARGS=`save "$@"` 182 | 183 | # Collect all arguments for the java command, following the shell quoting and substitution rules 184 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 185 | 186 | exec "$JAVACMD" "$@" 187 | -------------------------------------------------------------------------------- /iosApp/Podfile: -------------------------------------------------------------------------------- 1 | target 'iosApp' do 2 | use_frameworks! 3 | platform :ios, '16.2' 4 | pod 'composeApp', :path => '../composeApp' 5 | end 6 | -------------------------------------------------------------------------------- /iosApp/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - composeApp (1.0.0) 3 | 4 | DEPENDENCIES: 5 | - composeApp (from `../composeApp`) 6 | 7 | EXTERNAL SOURCES: 8 | composeApp: 9 | :path: "../composeApp" 10 | 11 | SPEC CHECKSUMS: 12 | composeApp: c81fad20a4efd7b13bdce466d21b41f0cebb2686 13 | 14 | PODFILE CHECKSUM: 3313a530e4ca4361dd2a9b97cf3c536967731c31 15 | 16 | COCOAPODS: 1.11.3 17 | -------------------------------------------------------------------------------- /iosApp/iosApp.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 56; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A93A953B29CC810C00F8E227 /* iosApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93A953A29CC810C00F8E227 /* iosApp.swift */; }; 11 | A93A953F29CC810D00F8E227 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A93A953E29CC810D00F8E227 /* Assets.xcassets */; }; 12 | A93A954229CC810D00F8E227 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A93A954129CC810D00F8E227 /* Preview Assets.xcassets */; }; 13 | D51586C6B134BDB93BE1DFFB /* Pods_iosApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE080622DF072CBDC3D9C873 /* Pods_iosApp.framework */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXFileReference section */ 17 | 05E67C72B2BDBC81379103CB /* Pods-iosApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.release.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.release.xcconfig"; sourceTree = ""; }; 18 | 73FFDDCA9C728FEE3DFEF2F4 /* Pods-iosApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.debug.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.debug.xcconfig"; sourceTree = ""; }; 19 | A93A953729CC810C00F8E227 /* NotesApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NotesApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | A93A953A29CC810C00F8E227 /* iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = ""; }; 21 | A93A953E29CC810D00F8E227 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 22 | A93A954129CC810D00F8E227 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 23 | EE080622DF072CBDC3D9C873 /* Pods_iosApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iosApp.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | /* End PBXFileReference section */ 25 | 26 | /* Begin PBXFrameworksBuildPhase section */ 27 | A93A953429CC810C00F8E227 /* Frameworks */ = { 28 | isa = PBXFrameworksBuildPhase; 29 | buildActionMask = 2147483647; 30 | files = ( 31 | D51586C6B134BDB93BE1DFFB /* Pods_iosApp.framework in Frameworks */, 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | 979913F6AE5D271756D4649D /* Pods */ = { 39 | isa = PBXGroup; 40 | children = ( 41 | 73FFDDCA9C728FEE3DFEF2F4 /* Pods-iosApp.debug.xcconfig */, 42 | 05E67C72B2BDBC81379103CB /* Pods-iosApp.release.xcconfig */, 43 | ); 44 | path = Pods; 45 | sourceTree = ""; 46 | }; 47 | A93A952E29CC810C00F8E227 = { 48 | isa = PBXGroup; 49 | children = ( 50 | A93A953929CC810C00F8E227 /* iosApp */, 51 | A93A953829CC810C00F8E227 /* Products */, 52 | 979913F6AE5D271756D4649D /* Pods */, 53 | C4127409AE3703430489E7BC /* Frameworks */, 54 | ); 55 | sourceTree = ""; 56 | }; 57 | A93A953829CC810C00F8E227 /* Products */ = { 58 | isa = PBXGroup; 59 | children = ( 60 | A93A953729CC810C00F8E227 /* NotesApp.app */, 61 | ); 62 | name = Products; 63 | sourceTree = ""; 64 | }; 65 | A93A953929CC810C00F8E227 /* iosApp */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | A93A953A29CC810C00F8E227 /* iosApp.swift */, 69 | A93A953E29CC810D00F8E227 /* Assets.xcassets */, 70 | A93A954029CC810D00F8E227 /* Preview Content */, 71 | ); 72 | path = iosApp; 73 | sourceTree = ""; 74 | }; 75 | A93A954029CC810D00F8E227 /* Preview Content */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | A93A954129CC810D00F8E227 /* Preview Assets.xcassets */, 79 | ); 80 | path = "Preview Content"; 81 | sourceTree = ""; 82 | }; 83 | C4127409AE3703430489E7BC /* Frameworks */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | EE080622DF072CBDC3D9C873 /* Pods_iosApp.framework */, 87 | ); 88 | name = Frameworks; 89 | sourceTree = ""; 90 | }; 91 | /* End PBXGroup section */ 92 | 93 | /* Begin PBXNativeTarget section */ 94 | A93A953629CC810C00F8E227 /* iosApp */ = { 95 | isa = PBXNativeTarget; 96 | buildConfigurationList = A93A954529CC810D00F8E227 /* Build configuration list for PBXNativeTarget "iosApp" */; 97 | buildPhases = ( 98 | D3665D361753A60B1A6EEEB7 /* [CP] Check Pods Manifest.lock */, 99 | A93A953329CC810C00F8E227 /* Sources */, 100 | A93A953429CC810C00F8E227 /* Frameworks */, 101 | A93A953529CC810C00F8E227 /* Resources */, 102 | ); 103 | buildRules = ( 104 | ); 105 | dependencies = ( 106 | ); 107 | name = iosApp; 108 | productName = iosApp; 109 | productReference = A93A953729CC810C00F8E227 /* NotesApp.app */; 110 | productType = "com.apple.product-type.application"; 111 | }; 112 | /* End PBXNativeTarget section */ 113 | 114 | /* Begin PBXProject section */ 115 | A93A952F29CC810C00F8E227 /* Project object */ = { 116 | isa = PBXProject; 117 | attributes = { 118 | LastSwiftUpdateCheck = 1420; 119 | LastUpgradeCheck = 1420; 120 | TargetAttributes = { 121 | A93A953629CC810C00F8E227 = { 122 | CreatedOnToolsVersion = 14.2; 123 | }; 124 | }; 125 | }; 126 | buildConfigurationList = A93A953229CC810C00F8E227 /* Build configuration list for PBXProject "iosApp" */; 127 | compatibilityVersion = "Xcode 14.0"; 128 | developmentRegion = en; 129 | hasScannedForEncodings = 0; 130 | knownRegions = ( 131 | en, 132 | Base, 133 | ); 134 | mainGroup = A93A952E29CC810C00F8E227; 135 | productRefGroup = A93A953829CC810C00F8E227 /* Products */; 136 | projectDirPath = ""; 137 | projectRoot = ""; 138 | targets = ( 139 | A93A953629CC810C00F8E227 /* iosApp */, 140 | ); 141 | }; 142 | /* End PBXProject section */ 143 | 144 | /* Begin PBXResourcesBuildPhase section */ 145 | A93A953529CC810C00F8E227 /* Resources */ = { 146 | isa = PBXResourcesBuildPhase; 147 | buildActionMask = 2147483647; 148 | files = ( 149 | A93A954229CC810D00F8E227 /* Preview Assets.xcassets in Resources */, 150 | A93A953F29CC810D00F8E227 /* Assets.xcassets in Resources */, 151 | ); 152 | runOnlyForDeploymentPostprocessing = 0; 153 | }; 154 | /* End PBXResourcesBuildPhase section */ 155 | 156 | /* Begin PBXShellScriptBuildPhase section */ 157 | D3665D361753A60B1A6EEEB7 /* [CP] Check Pods Manifest.lock */ = { 158 | isa = PBXShellScriptBuildPhase; 159 | buildActionMask = 2147483647; 160 | files = ( 161 | ); 162 | inputFileListPaths = ( 163 | ); 164 | inputPaths = ( 165 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 166 | "${PODS_ROOT}/Manifest.lock", 167 | ); 168 | name = "[CP] Check Pods Manifest.lock"; 169 | outputFileListPaths = ( 170 | ); 171 | outputPaths = ( 172 | "$(DERIVED_FILE_DIR)/Pods-iosApp-checkManifestLockResult.txt", 173 | ); 174 | runOnlyForDeploymentPostprocessing = 0; 175 | shellPath = /bin/sh; 176 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 177 | showEnvVarsInLog = 0; 178 | }; 179 | /* End PBXShellScriptBuildPhase section */ 180 | 181 | /* Begin PBXSourcesBuildPhase section */ 182 | A93A953329CC810C00F8E227 /* Sources */ = { 183 | isa = PBXSourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | A93A953B29CC810C00F8E227 /* iosApp.swift in Sources */, 187 | ); 188 | runOnlyForDeploymentPostprocessing = 0; 189 | }; 190 | /* End PBXSourcesBuildPhase section */ 191 | 192 | /* Begin XCBuildConfiguration section */ 193 | A93A954329CC810D00F8E227 /* Debug */ = { 194 | isa = XCBuildConfiguration; 195 | buildSettings = { 196 | ALWAYS_SEARCH_USER_PATHS = NO; 197 | CLANG_ANALYZER_NONNULL = YES; 198 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 199 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 200 | CLANG_ENABLE_MODULES = YES; 201 | CLANG_ENABLE_OBJC_ARC = YES; 202 | CLANG_ENABLE_OBJC_WEAK = YES; 203 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 204 | CLANG_WARN_BOOL_CONVERSION = YES; 205 | CLANG_WARN_COMMA = YES; 206 | CLANG_WARN_CONSTANT_CONVERSION = YES; 207 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 208 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 209 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 210 | CLANG_WARN_EMPTY_BODY = YES; 211 | CLANG_WARN_ENUM_CONVERSION = YES; 212 | CLANG_WARN_INFINITE_RECURSION = YES; 213 | CLANG_WARN_INT_CONVERSION = YES; 214 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 215 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 216 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 217 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 218 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 219 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 220 | CLANG_WARN_STRICT_PROTOTYPES = YES; 221 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 222 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 223 | CLANG_WARN_UNREACHABLE_CODE = YES; 224 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 225 | COPY_PHASE_STRIP = NO; 226 | DEBUG_INFORMATION_FORMAT = dwarf; 227 | ENABLE_STRICT_OBJC_MSGSEND = YES; 228 | ENABLE_TESTABILITY = YES; 229 | GCC_C_LANGUAGE_STANDARD = gnu11; 230 | GCC_DYNAMIC_NO_PIC = NO; 231 | GCC_NO_COMMON_BLOCKS = YES; 232 | GCC_OPTIMIZATION_LEVEL = 0; 233 | GCC_PREPROCESSOR_DEFINITIONS = ( 234 | "DEBUG=1", 235 | "$(inherited)", 236 | ); 237 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 238 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 239 | GCC_WARN_UNDECLARED_SELECTOR = YES; 240 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 241 | GCC_WARN_UNUSED_FUNCTION = YES; 242 | GCC_WARN_UNUSED_VARIABLE = YES; 243 | IPHONEOS_DEPLOYMENT_TARGET = 16.2; 244 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 245 | MTL_FAST_MATH = YES; 246 | ONLY_ACTIVE_ARCH = YES; 247 | OTHER_LDFLAGS = "-lsqlite3"; 248 | SDKROOT = iphoneos; 249 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 250 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 251 | }; 252 | name = Debug; 253 | }; 254 | A93A954429CC810D00F8E227 /* Release */ = { 255 | isa = XCBuildConfiguration; 256 | buildSettings = { 257 | ALWAYS_SEARCH_USER_PATHS = NO; 258 | CLANG_ANALYZER_NONNULL = YES; 259 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 260 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 261 | CLANG_ENABLE_MODULES = YES; 262 | CLANG_ENABLE_OBJC_ARC = YES; 263 | CLANG_ENABLE_OBJC_WEAK = YES; 264 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 265 | CLANG_WARN_BOOL_CONVERSION = YES; 266 | CLANG_WARN_COMMA = YES; 267 | CLANG_WARN_CONSTANT_CONVERSION = YES; 268 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 269 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 270 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 271 | CLANG_WARN_EMPTY_BODY = YES; 272 | CLANG_WARN_ENUM_CONVERSION = YES; 273 | CLANG_WARN_INFINITE_RECURSION = YES; 274 | CLANG_WARN_INT_CONVERSION = YES; 275 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 276 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 277 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 278 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 279 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 280 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 281 | CLANG_WARN_STRICT_PROTOTYPES = YES; 282 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 283 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 284 | CLANG_WARN_UNREACHABLE_CODE = YES; 285 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 286 | COPY_PHASE_STRIP = NO; 287 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 288 | ENABLE_NS_ASSERTIONS = NO; 289 | ENABLE_STRICT_OBJC_MSGSEND = YES; 290 | GCC_C_LANGUAGE_STANDARD = gnu11; 291 | GCC_NO_COMMON_BLOCKS = YES; 292 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 293 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 294 | GCC_WARN_UNDECLARED_SELECTOR = YES; 295 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 296 | GCC_WARN_UNUSED_FUNCTION = YES; 297 | GCC_WARN_UNUSED_VARIABLE = YES; 298 | IPHONEOS_DEPLOYMENT_TARGET = 16.2; 299 | MTL_ENABLE_DEBUG_INFO = NO; 300 | MTL_FAST_MATH = YES; 301 | OTHER_LDFLAGS = "-lsqlite3"; 302 | SDKROOT = iphoneos; 303 | SWIFT_COMPILATION_MODE = wholemodule; 304 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 305 | VALIDATE_PRODUCT = YES; 306 | }; 307 | name = Release; 308 | }; 309 | A93A954629CC810D00F8E227 /* Debug */ = { 310 | isa = XCBuildConfiguration; 311 | baseConfigurationReference = 73FFDDCA9C728FEE3DFEF2F4 /* Pods-iosApp.debug.xcconfig */; 312 | buildSettings = { 313 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 314 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 315 | CODE_SIGN_STYLE = Automatic; 316 | CURRENT_PROJECT_VERSION = 1; 317 | DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; 318 | ENABLE_PREVIEWS = YES; 319 | GENERATE_INFOPLIST_FILE = YES; 320 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 321 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 322 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 323 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 324 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 325 | LD_RUNPATH_SEARCH_PATHS = ( 326 | "$(inherited)", 327 | "@executable_path/Frameworks", 328 | ); 329 | MARKETING_VERSION = 1.0; 330 | PRODUCT_BUNDLE_IDENTIFIER = com.adikmt.notesapp.iosApp; 331 | PRODUCT_NAME = NotesApp; 332 | SWIFT_EMIT_LOC_STRINGS = YES; 333 | SWIFT_VERSION = 5.0; 334 | TARGETED_DEVICE_FAMILY = "1,2"; 335 | }; 336 | name = Debug; 337 | }; 338 | A93A954729CC810D00F8E227 /* Release */ = { 339 | isa = XCBuildConfiguration; 340 | baseConfigurationReference = 05E67C72B2BDBC81379103CB /* Pods-iosApp.release.xcconfig */; 341 | buildSettings = { 342 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 343 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 344 | CODE_SIGN_STYLE = Automatic; 345 | CURRENT_PROJECT_VERSION = 1; 346 | DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; 347 | ENABLE_PREVIEWS = YES; 348 | GENERATE_INFOPLIST_FILE = YES; 349 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 350 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 351 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 352 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 353 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 354 | LD_RUNPATH_SEARCH_PATHS = ( 355 | "$(inherited)", 356 | "@executable_path/Frameworks", 357 | ); 358 | MARKETING_VERSION = 1.0; 359 | PRODUCT_BUNDLE_IDENTIFIER = com.adikmt.notesapp.iosApp; 360 | PRODUCT_NAME = NotesApp; 361 | SWIFT_EMIT_LOC_STRINGS = YES; 362 | SWIFT_VERSION = 5.0; 363 | TARGETED_DEVICE_FAMILY = "1,2"; 364 | }; 365 | name = Release; 366 | }; 367 | /* End XCBuildConfiguration section */ 368 | 369 | /* Begin XCConfigurationList section */ 370 | A93A953229CC810C00F8E227 /* Build configuration list for PBXProject "iosApp" */ = { 371 | isa = XCConfigurationList; 372 | buildConfigurations = ( 373 | A93A954329CC810D00F8E227 /* Debug */, 374 | A93A954429CC810D00F8E227 /* Release */, 375 | ); 376 | defaultConfigurationIsVisible = 0; 377 | defaultConfigurationName = Release; 378 | }; 379 | A93A954529CC810D00F8E227 /* Build configuration list for PBXNativeTarget "iosApp" */ = { 380 | isa = XCConfigurationList; 381 | buildConfigurations = ( 382 | A93A954629CC810D00F8E227 /* Debug */, 383 | A93A954729CC810D00F8E227 /* Release */, 384 | ); 385 | defaultConfigurationIsVisible = 0; 386 | defaultConfigurationName = Release; 387 | }; 388 | /* End XCConfigurationList section */ 389 | }; 390 | rootObject = A93A952F29CC810C00F8E227 /* Project object */; 391 | } 392 | -------------------------------------------------------------------------------- /iosApp/iosApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /iosApp/iosApp.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /iosApp/iosApp.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "platform" : "ios", 6 | "size" : "1024x1024" 7 | } 8 | ], 9 | "info" : { 10 | "author" : "xcode", 11 | "version" : 1 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /iosApp/iosApp/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /iosApp/iosApp/iosApp.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import SwiftUI 3 | import ComposeApp 4 | 5 | @main 6 | struct iosApp: App { 7 | var body: some Scene { 8 | WindowGroup { 9 | ContentView() 10 | } 11 | } 12 | } 13 | 14 | struct ContentView: View { 15 | var body: some View { 16 | ComposeView().ignoresSafeArea(.keyboard) 17 | } 18 | } 19 | 20 | struct ComposeView: UIViewControllerRepresentable { 21 | func makeUIViewController(context: Context) -> UIViewController { 22 | MainKt.MainViewController() 23 | } 24 | 25 | func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} 26 | } 27 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "NotesApp" 2 | include(":composeApp") 3 | 4 | pluginManagement { 5 | repositories { 6 | google() 7 | gradlePluginPortal() 8 | mavenCentral() 9 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") 10 | } 11 | } 12 | 13 | dependencyResolutionManagement { 14 | repositories { 15 | google() 16 | mavenCentral() 17 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") 18 | } 19 | } 20 | --------------------------------------------------------------------------------