Skip to content

Commit

Permalink
Kotlin Multiplatform project playground
Browse files Browse the repository at this point in the history
  • Loading branch information
Anselmo Alexandre committed Nov 4, 2024
0 parents commit 0270c60
Show file tree
Hide file tree
Showing 234 changed files with 1,587 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Summary

<!--Provide a summary of this Pull Request. -->

## How It Was Tested

<!-- Explain how you tested this change before merging. -->

## Screenshot/Gif

<!-- If applicable, show off the user facing changes. -->

<details>

<summary>Screenshot Name</summary>

<!-- file here -->

</details>
32 changes: 32 additions & 0 deletions .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Android Build

# This will cancel any in progress workflows for the same PR, if
# multiple pushes happen in quick succession.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on: pull_request

jobs:
android-build:
runs-on: macos-14
steps:
- uses: actions/checkout@v4

- name: Set Up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v3
with:
# Only write to the cache for builds on the 'development' branch
cache-read-only: ${{ github.ref != 'refs/heads/development' }}

# assembleDebug is used to improve build times by only building
# the debug Android artifacts. https://touchlab.co/touchlab-build-only-what-you-need
- name: Build Project
run: ./gradlew assembleDebug
36 changes: 36 additions & 0 deletions .github/workflows/ios_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: iOS Build

# This will cancel any in progress workflows for the same PR, if
# multiple pushes happen in quick succession.
#concurrency:
# group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# cancel-in-progress: true
#
#on: pull_request
#
#jobs:
# ios-build:
# runs-on: macos-14
# steps:
# - uses: actions/checkout@v4
#
# - name: Set Up JDK
# uses: actions/setup-java@v4
# with:
# distribution: 'zulu'
# java-version: 17
#
# - name: Run tests
# run: ./gradlew :shared:iosX64Test
#
# - name: Build
# uses: sersoft-gmbh/xcodebuild-action@v3
# with:
# project: iosApp/templateIOS.xcodeproj
# scheme: templateIOS
# destination: name=iPhone 8
# sdk: iphoneos
# configuration: Debug
# action: build
# use-xcpretty: false
# build-settings: CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.iml
.gradle
.idea
.DS_Store
build
captures
.externalNativeBuild
.cxx
local.properties
xcuserdata
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
46 changes: 46 additions & 0 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.compose.compiler)
}

android {
namespace = "mz.co.bilheteira.kmp.android"
compileSdk = 34
defaultConfig {
applicationId = "mz.co.bilheteira.kmp.android"
minSdk = 29
targetSdk = 34
versionCode = 1
versionName = "1.0"
}
buildFeatures {
compose = true
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
implementation(projects.shared)
implementation(libs.compose.ui)
implementation(libs.compose.ui.tooling.preview)
implementation(libs.compose.material3)
implementation(libs.androidx.activity.compose)
debugImplementation(libs.compose.ui.tooling)
}
17 changes: 17 additions & 0 deletions androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="false"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package mz.co.bilheteira.kmp.android

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import mz.co.bilheteira.kmp.Greeting

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyApplicationTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
GreetingView(Greeting().greet())
}
}
}
}
}

@Composable
fun GreetingView(text: String) {
Text(text = text)
}

@Preview
@Composable
fun DefaultPreview() {
MyApplicationTheme {
GreetingView("Hello, Android!")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package mz.co.bilheteira.kmp.android

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Shapes
import androidx.compose.material3.Typography
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
fun MyApplicationTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
) {
val colors = if (darkTheme) {
darkColorScheme(
primary = Color(0xFFBB86FC),
secondary = Color(0xFF03DAC5),
tertiary = Color(0xFF3700B3)
)
} else {
lightColorScheme(
primary = Color(0xFF6200EE),
secondary = Color(0xFF03DAC5),
tertiary = Color(0xFF3700B3)
)
}
val typography = Typography(
bodyMedium = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp
)
)
val shapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp),
large = RoundedCornerShape(0.dp)
)

MaterialTheme(
colorScheme = colors,
typography = typography,
shapes = shapes,
content = content
)
}
3 changes: 3 additions & 0 deletions androidApp/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<style name="AppTheme" parent="android:Theme.Material.NoActionBar"/>
</resources>
23 changes: 23 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
//trick: for the same plugin versions in all sub-modules
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.compose.multiplatform) apply false
// alias(libs.plugins.apollo.graphql) apply false
// alias(libs.plugins.benmanes.versions) apply false
alias(libs.plugins.cash.paparazzi) apply false
alias(libs.plugins.cash.sqldelight) apply false
// alias(libs.plugins.detekt) apply false
// alias(libs.plugins.kotlinter) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.kotlinx.serialization) apply false
alias(libs.plugins.square.sort.dependencies) apply false
}

subprojects {
apply(plugin = "com.squareup.sort-dependencies")
//apply(plugin = "org.jmailen.kotlinter")
}
11 changes: 11 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Gradle
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M"
org.gradle.caching=true
org.gradle.configuration-cache=true

#Kotlin
kotlin.code.style=official

#Android
android.useAndroidX=true
android.nonTransitiveRClass=true
Loading

0 comments on commit 0270c60

Please sign in to comment.