Skip to content

Commit ce30845

Browse files
authored
Merge pull request #80 from teogor/feature/compose-demo-module
Update Demo Module to Use Jetpack Compose
2 parents 494f443 + 3f98dfc commit ce30845

File tree

44 files changed

+2900
-157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2900
-157
lines changed

build.gradle.kts

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,18 @@ import dev.teogor.winds.ktx.createVersion
2727
import dev.teogor.winds.ktx.person
2828
import dev.teogor.winds.ktx.scm
2929
import dev.teogor.winds.ktx.ticketSystem
30+
import org.gradle.api.internal.catalog.DelegatingProjectDependency
3031
import org.jetbrains.dokka.gradle.DokkaPlugin
3132
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
3233
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3334

3435
plugins {
36+
alias(libs.plugins.jetbrains.compose) apply false
37+
alias(libs.plugins.jetbrains.compose.compiler) apply false
3538
alias(libs.plugins.jetbrains.kotlin.jvm)
3639
alias(libs.plugins.jetbrains.kotlin.multiplatform) apply false
40+
alias(libs.plugins.android.application) apply false
41+
3742
alias(libs.plugins.teogor.winds)
3843
alias(libs.plugins.vanniktech.maven)
3944
alias(libs.plugins.jetbrains.dokka)
@@ -47,11 +52,6 @@ tasks.withType<KotlinCompile>().configureEach {
4752
dependsOn("updateGitHooks")
4853
}
4954

50-
val excludedProjects = listOf(
51-
project.name,
52-
"demo",
53-
)
54-
5555
allprojects {
5656
if (extensions.findByType<JavaPluginExtension>() != null) {
5757
java {
@@ -150,30 +150,6 @@ subprojects {
150150
"**/dev/teogor/sudoklify/presets/**",
151151
)
152152

153-
ktlint()
154-
.editorConfigOverride(
155-
mapOf(
156-
"ktlint_code_style" to "ktlint_official",
157-
"ij_kotlin_allow_trailing_comma" to "true",
158-
"disabled_rules" to
159-
"filename," +
160-
"annotation,annotation-spacing," +
161-
"argument-list-wrapping," +
162-
"double-colon-spacing," +
163-
"enum-entry-name-case," +
164-
"multiline-if-else," +
165-
"no-empty-first-line-in-method-block," +
166-
"package-name," +
167-
"trailing-comma," +
168-
"spacing-around-angle-brackets," +
169-
"spacing-between-declarations-with-annotations," +
170-
"spacing-between-declarations-with-comments," +
171-
"unary-op-spacing," +
172-
"no-trailing-spaces," +
173-
"no-wildcard-imports," +
174-
"max-line-length",
175-
),
176-
)
177153
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
178154
trimTrailingWhitespace()
179155
endWithNewline()
@@ -193,16 +169,22 @@ subprojects {
193169
}
194170
}
195171

172+
val excludedProjects = listOf<DelegatingProjectDependency>(
173+
projects.sudoklify,
174+
projects.sudoklify.demo.composeApp,
175+
)
176+
196177
apiValidation {
197178
/**
198179
* Subprojects that are excluded from API validation
199180
*/
200-
ignoredProjects.addAll(excludedProjects)
181+
ignoredProjects.addAll(excludedProjects.map { it.name })
201182
}
202183

203-
204184
subprojects {
205-
if (!excludedProjects.contains(this.name)) {
185+
val paths = excludedProjects.map { it.identityPath.path }
186+
println("This is the path: $path for subproject: $path")
187+
if (!paths.contains(this.path)) {
206188
apply<DokkaPlugin>()
207189
}
208190
}

demo/composeApp/build.gradle.kts

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/*
2+
* Copyright 2024 Teogor (Teodor Grigor)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
17+
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
18+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
19+
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
20+
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
21+
22+
plugins {
23+
alias(libs.plugins.jetbrains.kotlin.multiplatform)
24+
alias(libs.plugins.android.application)
25+
alias(libs.plugins.jetbrains.compose)
26+
alias(libs.plugins.jetbrains.compose.compiler)
27+
}
28+
29+
kotlin {
30+
@OptIn(ExperimentalWasmDsl::class)
31+
wasmJs {
32+
moduleName = "composeApp"
33+
browser {
34+
val projectDirPath = project.projectDir.path
35+
commonWebpackConfig {
36+
outputFileName = "composeApp.js"
37+
devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
38+
static = (static ?: mutableListOf()).apply {
39+
// Serve sources to debug inside browser
40+
add(projectDirPath)
41+
}
42+
}
43+
}
44+
}
45+
binaries.executable()
46+
}
47+
48+
androidTarget {
49+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
50+
compilerOptions {
51+
jvmTarget.set(JvmTarget.JVM_11)
52+
}
53+
}
54+
55+
jvm("desktop")
56+
57+
listOf(
58+
iosX64(),
59+
iosArm64(),
60+
iosSimulatorArm64(),
61+
).forEach { iosTarget ->
62+
iosTarget.binaries.framework {
63+
baseName = "ComposeApp"
64+
isStatic = true
65+
}
66+
}
67+
68+
sourceSets {
69+
val desktopMain by getting
70+
71+
androidMain.dependencies {
72+
implementation(compose.preview)
73+
74+
implementation(libs.androidx.activity.compose)
75+
}
76+
commonMain.dependencies {
77+
implementation(compose.runtime)
78+
implementation(compose.foundation)
79+
implementation(compose.material3)
80+
implementation(compose.ui)
81+
implementation(compose.components.resources)
82+
implementation(compose.components.uiToolingPreview)
83+
84+
implementation(libs.teogor.paletteon.core)
85+
86+
implementation(libs.androidx.lifecycle.viewmodel)
87+
implementation(libs.androidx.lifecycle.runtime.compose)
88+
implementation(libs.androidx.lifecycle.viewmodel.compose)
89+
90+
implementation(libs.jetbrains.kotlinx.coroutines.core)
91+
92+
implementation(projects.sudoklifyCore)
93+
implementation(projects.sudoklifyPresets)
94+
implementation(projects.sudoklifySolver)
95+
}
96+
desktopMain.dependencies {
97+
implementation(compose.desktop.currentOs)
98+
99+
implementation(libs.jetbrains.kotlinx.coroutines.swing)
100+
}
101+
}
102+
}
103+
104+
android {
105+
namespace = "dev.teogor.sudoklify.multiplatform"
106+
compileSdk = libs.versions.android.compileSdk.get().toInt()
107+
108+
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
109+
sourceSets["main"].res.srcDirs("src/androidMain/res")
110+
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
111+
112+
defaultConfig {
113+
applicationId = "dev.teogor.sudoklify.multiplatform"
114+
minSdk = libs.versions.android.minSdk.get().toInt()
115+
targetSdk = libs.versions.android.targetSdk.get().toInt()
116+
versionCode = 1
117+
versionName = "1.0"
118+
}
119+
packaging {
120+
resources {
121+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
122+
}
123+
}
124+
buildTypes {
125+
getByName("release") {
126+
isMinifyEnabled = false
127+
}
128+
}
129+
compileOptions {
130+
sourceCompatibility = JavaVersion.VERSION_11
131+
targetCompatibility = JavaVersion.VERSION_11
132+
}
133+
buildFeatures {
134+
compose = true
135+
}
136+
dependencies {
137+
debugImplementation(compose.uiTooling)
138+
}
139+
}
140+
141+
compose.desktop {
142+
application {
143+
mainClass = "dev.teogor.sudoklify.multiplatform.MainKt"
144+
145+
nativeDistributions {
146+
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
147+
packageName = "dev.teogor.sudoklify.multiplatform"
148+
packageVersion = "1.0.0"
149+
}
150+
}
151+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
Copyright 2024 Teogor (Teodor Grigor)
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
17+
18+
<application
19+
android:allowBackup="true"
20+
android:icon="@mipmap/ic_launcher"
21+
android:label="@string/app_name"
22+
android:roundIcon="@mipmap/ic_launcher_round"
23+
android:supportsRtl="true"
24+
android:theme="@android:style/Theme.Material.Light.NoActionBar">
25+
<activity
26+
android:exported="true"
27+
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode"
28+
android:name=".MainActivity">
29+
<intent-filter>
30+
<action android:name="android.intent.action.MAIN"/>
31+
32+
<category android:name="android.intent.category.LAUNCHER"/>
33+
</intent-filter>
34+
</activity>
35+
</application>
36+
37+
</manifest>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2024 Teogor (Teodor Grigor)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package dev.teogor.sudoklify.multiplatform
18+
19+
import android.os.Bundle
20+
import androidx.activity.ComponentActivity
21+
import androidx.activity.compose.setContent
22+
import androidx.compose.runtime.Composable
23+
import androidx.compose.ui.tooling.preview.Preview
24+
25+
class MainActivity : ComponentActivity() {
26+
override fun onCreate(savedInstanceState: Bundle?) {
27+
super.onCreate(savedInstanceState)
28+
29+
setContent {
30+
App()
31+
}
32+
}
33+
}
34+
35+
@Preview
36+
@Composable
37+
fun AppAndroidPreview() {
38+
App()
39+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
Copyright 2024 Teogor (Teodor Grigor)
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
17+
xmlns:aapt="http://schemas.android.com/aapt"
18+
android:width="108dp"
19+
android:height="108dp"
20+
android:viewportWidth="108"
21+
android:viewportHeight="108">
22+
<path
23+
android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
24+
<aapt:attr name="android:fillColor">
25+
<gradient
26+
android:endX="85.84757"
27+
android:endY="92.4963"
28+
android:startX="42.9492"
29+
android:startY="49.59793"
30+
android:type="linear">
31+
<item
32+
android:color="#44000000"
33+
android:offset="0.0"/>
34+
<item
35+
android:color="#00000000"
36+
android:offset="1.0"/>
37+
</gradient>
38+
</aapt:attr>
39+
</path>
40+
<path
41+
android:fillColor="#FFFFFF"
42+
android:fillType="nonZero"
43+
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
44+
android:strokeWidth="1"
45+
android:strokeColor="#00000000"/>
46+
</vector>

0 commit comments

Comments
 (0)