Skip to content

Commit

Permalink
Merge pull request #40 from icerockdev/develop
Browse files Browse the repository at this point in the history
Release 0.9.0
  • Loading branch information
Alex009 authored Apr 21, 2023
2 parents 8af5387 + 39a861f commit 4881dc1
Show file tree
Hide file tree
Showing 20 changed files with 126 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ allprojects {
project build.gradle
```groovy
dependencies {
commonMainApi("dev.icerock.moko:parcelize:0.8.0")
commonMainApi("dev.icerock.moko:parcelize:0.9.0")
}
```

Expand Down
5 changes: 0 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,3 @@ allprojects {
version = libs.versions.mokoParcelizeVersion.get()
}
}

// temporary fix for Apple Silicon (remove after 1.6.20 update)
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "16.0.0"
}
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ org.gradle.parallel=true
kotlin.code.style=official

kotlin.mpp.stability.nowarn=true
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.mpp.enableCompatibilityMetadataVariant=true
kotlin.mpp.androidSourceSetLayoutVersion=2

android.useAndroidX=true
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
androidAppCompatVersion = "1.2.0"
mokoParcelizeVersion = "0.8.0"
mokoParcelizeVersion = "0.9.0"

[libraries]
appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions parcelize-build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {

dependencies {
api("dev.icerock:mobile-multiplatform:0.13.0")
api("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
api("com.android.tools.build:gradle:7.0.4")
api("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.19.0")
api("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20")
api("com.android.tools.build:gradle:7.4.2")
api("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.22.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import com.android.build.gradle.BaseExtension

configure<BaseExtension> {
compileSdkVersion(30)
compileSdkVersion(33)

defaultConfig {
minSdkVersion(16)
targetSdkVersion(30)
minSdk = 16
targetSdk = 33
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ tasks.register("detektWithoutTests") {
}

dependencies {
"detektPlugins"("io.gitlab.arturbosch.detekt:detekt-formatting:1.19.0")
"detektPlugins"("io.gitlab.arturbosch.detekt:detekt-formatting:1.22.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ kotlin {
wasm32()

sourceSets {
all {
languageSettings.apply {
useExperimentalAnnotation("kotlin.RequiresOptIn")
}
}

val commonMain by getting

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ package dev.icerock.moko.parcelize
import android.os.Parcelable
import kotlinx.android.parcel.IgnoredOnParcel
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parceler
import kotlinx.parcelize.TypeParceler

actual typealias Parcelize = Parcelize

actual typealias Parcelable = Parcelable

actual typealias IgnoredOnParcel = IgnoredOnParcel

actual typealias Parceler<P> = Parceler<P>

actual typealias TypeParceler<T, P> = TypeParceler<T, P>

actual typealias Parcel = android.os.Parcel
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,31 @@ expect annotation class Parcelize()

expect interface Parcelable

expect annotation class IgnoredOnParcel()
expect annotation class IgnoredOnParcel()

expect interface Parceler<P> {
fun create(parcel: Parcel): P

fun P.write(parcel: Parcel, flags: Int)
}

expect annotation class TypeParceler<T, P : Parceler<in T>>()

expect class Parcel {
fun readByte(): Byte
fun readInt(): Int

fun readFloat(): Float
fun readDouble(): Double
fun readString(): String?

fun writeByte(value: Byte)
fun writeInt(value: Int)

fun writeFloat(value: Float)

fun writeDouble(value: Double)
fun writeString(value: String?)


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,36 @@ package dev.icerock.moko.parcelize

actual interface Parcelable
actual annotation class IgnoredOnParcel
actual annotation class Parcelize
actual annotation class Parcelize
actual interface Parceler<P> {
actual fun create(parcel: Parcel): P
actual fun P.write(parcel: Parcel, flags: Int)
}

actual annotation class TypeParceler<T, P : Parceler<in T>>

actual class Parcel {
actual fun readString(): String? = null
actual fun readByte(): Byte = 1

actual fun readInt(): Int = 1

actual fun readFloat(): Float = 1f

actual fun readDouble(): Double = 1.0

actual fun writeByte(value: Byte) {
}

actual fun writeInt(value: Int) {
}

actual fun writeFloat(value: Float) {
}

actual fun writeDouble(value: Double) {
}

actual fun writeString(value: String?) {
}
}
2 changes: 1 addition & 1 deletion sample/android-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:theme="@style/Theme.AppCompat.DayNight"
tools:ignore="GoogleAppIndexingWarning">

<activity android:name=".MainActivity">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
12 changes: 5 additions & 7 deletions sample/android-app/src/main/java/com/icerockdev/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
package com.icerockdev

import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.icerockdev.library.TestUsers
import com.icerockdev.library.User
import kotlinx.datetime.LocalDateTime

class MainActivity : AppCompatActivity() {

private val userInstanceKey = "user"
private var user: User = User(
firstName = "Aleksey",
lastName = "Mikhailov",
phone = "+79000000000",
age = 26
)
private var user: User = TestUsers.user

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -26,14 +24,14 @@ class MainActivity : AppCompatActivity() {

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)

outState.putParcelable(userInstanceKey, user)
}

override fun onRestoreInstanceState(savedInstanceState: Bundle) {
super.onRestoreInstanceState(savedInstanceState)

savedInstanceState.getParcelable<User>(userInstanceKey)?.let {
Log.d("MainActivity", "Read user: $it")
this.user = it
}
}
Expand Down
9 changes: 1 addition & 8 deletions sample/ios-app/src/TestViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@ class TestViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

let user = User(
firstName: "Aleksey",
lastName: "Mikhailov",
phone: "+79000000000",
age: 26
)

label.text = "Hello, \(user.firstName)!"
label.text = "Hello, \(TestUsers.shared.user.firstName)!"
}
}
9 changes: 1 addition & 8 deletions sample/macos-app/mokoSampleParcelize/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,9 @@
import SwiftUI
import MultiPlatformLibrary

let user = User(
firstName: "Aleksey",
lastName: "Mikhailov",
phone: "+79000000000",
age: 26
)

struct ContentView: View {
var body: some View {
Text("Hello, \(user.firstName)!")
Text("Hello, \(TestUsers.shared.user.firstName)!")
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
Expand Down
1 change: 1 addition & 0 deletions sample/mpp-library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ kotlin {

dependencies {
commonMainApi(projects.parcelize)
commonMainApi("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.icerockdev.library

import dev.icerock.moko.parcelize.Parcel
import dev.icerock.moko.parcelize.Parceler
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.toLocalDateTime

object LocalDateTimeParceler :
Parceler<LocalDateTime> {
override fun create(parcel: Parcel): LocalDateTime {
val date = parcel.readString()
return date?.toLocalDateTime()
?: LocalDateTime(0, 0, 0, 0, 0)
}

override fun LocalDateTime.write(parcel: Parcel, flags: Int) {
parcel.writeString(this.toString())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.icerockdev.library

import kotlinx.datetime.LocalDateTime

object TestUsers {
val user: User = User(
firstName = "Aleksey",
lastName = "Mikhailov",
phone = "+79000000000",
age = 26,
birthday = LocalDateTime(1970, 1, 1, 0, 0, 0, 0)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ package com.icerockdev.library

import dev.icerock.moko.parcelize.Parcelable
import dev.icerock.moko.parcelize.Parcelize
import dev.icerock.moko.parcelize.TypeParceler
import kotlinx.datetime.LocalDateTime

@Parcelize
data class User(
val firstName: String,
val lastName: String,
val phone: String,
val age: Int
val age: Int,
@TypeParceler<LocalDateTime, LocalDateTimeParceler>()
val birthday : LocalDateTime
) : Parcelable

0 comments on commit 4881dc1

Please sign in to comment.