├── .gitignore ├── LICENSE ├── README.md ├── androidApp ├── build.gradle.kts └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── qamar │ │ └── composemultiplatform │ │ └── android │ │ ├── MainActivity.kt │ │ └── MyApplicationTheme.kt │ └── res │ └── values │ └── styles.xml ├── build.gradle.kts ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── iosApp ├── Podfile ├── Podfile.lock ├── Pods │ ├── Manifest.lock │ └── Target Support Files │ │ └── Pods-iosApp │ │ ├── Pods-iosApp-Info.plist │ │ ├── Pods-iosApp-acknowledgements.markdown │ │ ├── Pods-iosApp-acknowledgements.plist │ │ ├── Pods-iosApp-dummy.m │ │ ├── Pods-iosApp-umbrella.h │ │ ├── Pods-iosApp.debug.xcconfig │ │ ├── Pods-iosApp.modulemap │ │ └── Pods-iosApp.release.xcconfig ├── iosApp.xcodeproj │ └── project.pbxproj ├── iosApp.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── iosApp │ ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json │ ├── ContentView.swift │ ├── Info.plist │ ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json │ └── iOSApp.swift ├── settings.gradle.kts └── shared ├── build.gradle.kts ├── shared.podspec └── src ├── androidMain └── kotlin │ └── com │ └── qamar │ └── composemultiplatform │ └── main.android.kt ├── commonMain ├── kotlin │ └── com │ │ └── qamar │ │ └── composemultiplatform │ │ ├── App.kt │ │ ├── components │ │ ├── CategoryTabs.kt │ │ ├── CircularProgress.kt │ │ ├── CustomIndicator.kt │ │ ├── ItemPager.kt │ │ ├── item │ │ │ └── TabItem.kt │ │ └── plant │ │ │ ├── PlantImage.kt │ │ │ └── PlantProperty.kt │ │ └── model │ │ └── Plant.kt └── resources │ ├── Plants.png │ ├── Plants1.jpg │ ├── Plants2.jpg │ ├── Plants3.jpg │ └── Plants4.png └── iosMain └── kotlin └── com └── qamar └── composemultiplatform └── main.ios.kt /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | .idea 4 | .DS_Store 5 | build 6 | captures 7 | .externalNativeBuild 8 | .cxx 9 | local.properties 10 | xcuserdata -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ![Logo](https://user-images.githubusercontent.com/30949634/221370655-d88d6aa4-73b8-448c-8834-79a34cabdec8.svg) 3 | 4 | 5 | # Compose Multiplatform 6 | 7 | Compose 8 | 9 | https://user-images.githubusercontent.com/30949634/236697673-dbf52629-9809-41a9-b9fd-8363ea527b99.mov 10 | 11 | Multiplatform simplifies and accelerates UI and share it between Android, IOS, Desktop and Web. 12 | 13 | 14 |
15 | 16 | # Repositroy 17 | 18 | This repository will contain instructions to start your first Compose Multiplatform Project. 19 | 20 | 21 | 22 | 23 | ## Plugin 24 | 25 | Install 26 | [KMM](https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile) 27 | plugin in Android Studio 28 | 29 | ## Instructions 30 | - Create a new KMM project using the plugin above 31 | 32 | Screenshot 2023-02-25 at 6 58 46 PM 34 | Screenshot 2023-05-08 at 9 17 35 PM 35 | 36 | ### Setup Compose for KMM 37 | 38 | in your `settings.gradle` file add the following dependency 39 | 40 | ```kotlin 41 | pluginManagement { 42 | repositories { 43 | google() 44 | gradlePluginPortal() 45 | mavenCentral() 46 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") // this one 47 | } 48 | 49 | plugins { 50 | kotlin("jvm").version("1.8.21") 51 | kotlin("multiplatform").version("1.8.21") 52 | kotlin("android").version("1.8.21") 53 | id("com.android.application").version("7.4.2") 54 | id("com.android.library").version("7.4.2") 55 | id("org.jetbrains.compose").version("1.4.3") 56 | } 57 | } 58 | ``` 59 | 60 | in your `build.gradle.kts` add compose plugin 61 | ```kotlin 62 | plugins { 63 | //trick: for the same plugin versions in all sub-modules 64 | id("com.android.application").version("8.2.0-alpha06").apply(false) 65 | id("com.android.library").version("8.2.0-alpha06").apply(false) 66 | kotlin("android").version("1.8.21").apply(false) 67 | kotlin("multiplatform").version("1.8.21").apply(false) 68 | } 69 | 70 | 71 | 72 | ``` 73 | 74 | now inside `shared module` `build.gradle.kts` add these two plugins 75 | ```kotlin 76 | plugins { 77 | kotlin("multiplatform") 78 | id("com.android.library") 79 | kotlin("native.cocoapods") // this 80 | id("org.jetbrains.compose") // and this 81 | } 82 | 83 | ``` 84 | 85 | in your `kotlin` block add the following lines 86 | ```kotlin 87 | iosX64() 88 | iosArm64() 89 | iosSimulatorArm64() 90 | cocoapods { 91 | version = "1.0.0" 92 | summary = "Some description for the Shared Module" 93 | homepage = "Link to the Shared Module homepage" 94 | ios.deploymentTarget = "14.1" 95 | podfile = project.file("../iosApp/Podfile") 96 | framework { 97 | baseName = "shared" 98 | isStatic = true 99 | } 100 | extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']" // this is for images 101 | } 102 | 103 | // in android block add these lines to support common resources 104 | 105 | sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") 106 | sourceSets["main"].res.srcDirs("src/androidMain/res") 107 | sourceSets["main"].resources.srcDirs("src/commonMain/resources") 108 | 109 | ``` 110 | 111 | now BEFORE you sync you need to make sure about the following: 112 | 113 | - Install cocoapods 114 | ```termial 115 | brew install cocoapods 116 | 117 | ``` 118 | - cd to iosApp and init pod 119 | ```terminal 120 | pod init 121 | ``` 122 | - install your pods 123 | ```terminal 124 | pod install 125 | ``` 126 | 127 | In `sourceSets` 128 | 129 | ```kotlin 130 | sourceSets { 131 | val commonMain by getting { 132 | dependencies { 133 | implementation(compose.runtime) 134 | implementation(compose.foundation) 135 | implementation(compose.material) 136 | @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) 137 | implementation(compose.components.resources) 138 | } 139 | } 140 | val androidMain by getting { 141 | dependencies { 142 | api("androidx.activity:activity-compose:1.6.1") 143 | api("androidx.appcompat:appcompat:1.6.1") 144 | api("androidx.core:core-ktx:1.9.0") 145 | } 146 | } 147 | val iosX64Main by getting 148 | val iosArm64Main by getting 149 | val iosSimulatorArm64Main by getting 150 | val iosMain by getting { 151 | dependsOn(commonMain) 152 | iosX64Main.dependsOn(this) 153 | iosArm64Main.dependsOn(this) 154 | iosSimulatorArm64Main.dependsOn(this) 155 | } 156 | } 157 | ``` 158 | 159 | and to avoid Compose targets '[uikit]' are experimental and may have bugs! Error add this in `gradle.properties` 160 | ```groovy 161 | org.jetbrains.compose.experimental.uikit.enabled=true 162 | 163 | ``` 164 | 165 | Sync now ! 166 | 167 | ## Let the magic begin 168 | 169 | Inside your `shared module` commonMain directory create your first Composable function to use it for Android and IOS 170 | 171 | ```kotlin 172 | @Composable 173 | internal fun App(){ 174 | Text(Greeting().greet()) 175 | } 176 | ``` 177 | 178 | In your `AndroidMain` make `main.android` class to use your App function 179 | ```kotlin 180 | @Composable 181 | fun Application(){ 182 | App() 183 | } 184 | ``` 185 | 186 | 187 | In your `IosMain` make `main.ios` class to use your App function 188 | ```kotlin 189 | import androidx.compose.ui.window.ComposeUIViewController 190 | 191 | fun MainViewController() = ComposeUIViewController { App() } 192 | 193 | ``` 194 | 195 | Now go to `AndoroidApp` module to use the function we made in main.android class 196 | ```kotlin 197 | Surface( 198 | modifier = Modifier.fillMaxSize(), 199 | color = MaterialTheme.colors.background 200 | ) { 201 | Application() 202 | } 203 | ``` 204 | 205 | Next go to `IosApp` module to use the function we made in main.ios class 206 | 207 | 208 | ```swift 209 | import shared // this important to import don't forget it! 210 | 211 | @main 212 | struct iOSApp: App { 213 | var body: some Scene { 214 | WindowGroup { 215 | ContentView() 216 | } 217 | } 218 | } 219 | 220 | // inside your ContentView class 221 | 222 | import SwiftUI 223 | import shared 224 | 225 | struct ComposeView: UIViewControllerRepresentable { 226 | func makeUIViewController(context: Context) -> UIViewController { 227 | Main_iosKt.MainViewController() 228 | } 229 | 230 | func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} 231 | } 232 | 233 | struct ContentView: View { 234 | var body: some View { 235 | ComposeView() 236 | .ignoresSafeArea(.keyboard) // Compose has own keyboard handler 237 | } 238 | } 239 | 240 | ``` 241 | 242 | ## Run 243 | 244 | Add this to solve dependencies conflicts in `gradle.properties` 245 | ```groovy 246 | kotlin.native.cacheKind=none 247 | ``` 248 | 249 | now you can run your android normally, for `IOS` you need to run the following command first 250 | 251 | ```terminal 252 | ./gradlew build 253 | ./gradlew :shared:linkPodDebugFrameworkIosSimulatorArm64 254 | 255 | ``` 256 | 257 | Now open `iosApp.xcworkspace` inside xcode and run the app! or Run it inside Android Studio itself 258 | 259 | 260 | 261 | ## Resources 262 | 263 | [JetBrains Compose](https://github.com/JetBrains/compose-jb/tree/master/tutorials/Getting_Started) 264 | 265 | [Compose Mutliplatofrom Examples](https://github.com/JetBrains/compose-jb/tree/master/experimental/examples) 266 | 267 | [Compose Mutliplatofrom Template](https://github.com/JetBrains/compose-multiplatform-ios-android-template) 268 | 269 | 270 | 271 |
272 |
273 | 274 | Happy Kotlin 🚀! 275 | 276 | 277 | -------------------------------------------------------------------------------- /androidApp/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | kotlin("android") 4 | } 5 | 6 | android { 7 | namespace = "com.qamar.composemultiplatform.android" 8 | compileSdk = 33 9 | defaultConfig { 10 | applicationId = "com.qamar.composemultiplatform.android" 11 | minSdk = 24 12 | targetSdk = 33 13 | versionCode = 1 14 | versionName = "1.0" 15 | } 16 | buildFeatures { 17 | compose = true 18 | } 19 | composeOptions { 20 | kotlinCompilerExtensionVersion = "1.4.0" 21 | } 22 | packagingOptions { 23 | resources { 24 | excludes += "/META-INF/{AL2.0,LGPL2.1}" 25 | } 26 | } 27 | buildTypes { 28 | getByName("release") { 29 | isMinifyEnabled = false 30 | } 31 | } 32 | compileOptions { 33 | sourceCompatibility = JavaVersion.VERSION_1_8 34 | targetCompatibility = JavaVersion.VERSION_1_8 35 | } 36 | kotlinOptions { 37 | jvmTarget = "1.8" 38 | } 39 | } 40 | 41 | dependencies { 42 | implementation(project(":shared")) 43 | implementation("androidx.compose.ui:ui:1.4.3") 44 | implementation("androidx.compose.ui:ui-tooling:1.4.3") 45 | implementation("androidx.compose.ui:ui-tooling-preview:1.4.3") 46 | implementation("androidx.compose.foundation:foundation:1.4.3") 47 | implementation("androidx.compose.material:material:1.4.3") 48 | implementation("androidx.activity:activity-compose:1.7.1") 49 | } -------------------------------------------------------------------------------- /androidApp/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /androidApp/src/main/java/com/qamar/composemultiplatform/android/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.qamar.composemultiplatform.android 2 | 3 | import android.os.Bundle 4 | import androidx.activity.ComponentActivity 5 | import androidx.activity.compose.setContent 6 | import androidx.compose.foundation.layout.fillMaxSize 7 | import androidx.compose.material.* 8 | import androidx.compose.runtime.Composable 9 | import androidx.compose.ui.Modifier 10 | import androidx.compose.ui.tooling.preview.Preview 11 | import com.qamar.composemultiplatform.Application 12 | 13 | class MainActivity : ComponentActivity() { 14 | override fun onCreate(savedInstanceState: Bundle?) { 15 | super.onCreate(savedInstanceState) 16 | setContent { 17 | MyApplicationTheme { 18 | Surface( 19 | modifier = Modifier.fillMaxSize(), 20 | color = MaterialTheme.colors.background 21 | ) { 22 | Application() 23 | } 24 | } 25 | } 26 | } 27 | } 28 | 29 | @Composable 30 | fun GreetingView(text: String) { 31 | Text(text = text) 32 | } 33 | 34 | @Preview 35 | @Composable 36 | fun DefaultPreview() { 37 | MyApplicationTheme { 38 | GreetingView("Hello, Android!") 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /androidApp/src/main/java/com/qamar/composemultiplatform/android/MyApplicationTheme.kt: -------------------------------------------------------------------------------- 1 | package com.qamar.composemultiplatform.android 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 | 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 | colors = colors, 51 | typography = typography, 52 | shapes = shapes, 53 | content = content 54 | ) 55 | } 56 | -------------------------------------------------------------------------------- /androidApp/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 |