Skip to content

Commit

Permalink
Merge pull request #203 from icerockdev/develop
Browse files Browse the repository at this point in the history
Release 0.1.0-dev-19
  • Loading branch information
Alex009 authored Mar 24, 2020
2 parents 897a299 + 8f06d4b commit 751235e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is a Kotlin MultiPlatform library that provides declarative UI and applicat
in common code. You can implement full application for Android and iOS only from common code with it.

## Current status
Current version - `0.1.0-dev-18`. Dev version is not tested in production tasks yet, API can be changed and
Current version - `0.1.0-dev-19`. Dev version is not tested in production tasks yet, API can be changed and
bugs may be found. But dev version is chance to test limits of API and concepts to feedback and improve lib.
We open for any feedback and ideas (go to issues or #moko at [kotlinlang.slack.com](https://kotlinlang.slack.com))!

Expand Down Expand Up @@ -227,6 +227,7 @@ val loginScreen = Theme(baseTheme) {
- 0.1.0-dev-16
- 0.1.0-dev-17
- 0.1.0-dev-18
- 0.1.0-dev-19

## Installation
root build.gradle
Expand All @@ -241,7 +242,7 @@ allprojects {
project build.gradle
```groovy
dependencies {
commonMainApi("dev.icerock.moko:widgets:0.1.0-dev-18")
commonMainApi("dev.icerock.moko:widgets:0.1.0-dev-19")
}
```

Expand All @@ -254,7 +255,7 @@ buildscript {
}
dependencies {
classpath "dev.icerock.moko.widgets:gradle-plugin:0.1.0-dev-18"
classpath "dev.icerock.moko.widgets:gradle-plugin:0.1.0-dev-19"
}
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object Versions {
}

const val kotlin = "1.3.70"
private const val mokoWidgets = "0.1.0-dev-18"
private const val mokoWidgets = "0.1.0-dev-19"
private const val mokoResources = "0.9.0"

object Plugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import platform.UIKit.UIControlEventTouchUpInside
import platform.UIKit.UIApplication
import platform.Foundation.NSBundle
import platform.Foundation.NSDate
import platform.Foundation.NSTimeIntervalSince1970

actual class DatePickerDialogHandler(
val positive: ((dialogId: Int, date: DateTime) -> Unit)?,
Expand Down Expand Up @@ -212,35 +213,31 @@ class DatePickerController(
anchor = controlPanel.topAnchor
).active = true

val nsDate = NSDate()
val date = DateTime.nowUnix()
val diffDate = date - nsDate.timeIntervalSinceReferenceDate

if (startDate != null) {
startDate.unixMillis
datePicker.minimumDate = NSDate(startDate.unixMillis - diffDate)
}

if (endDate != null) {
endDate.unixMillis
datePicker.maximumDate = NSDate(endDate.unixMillis - diffDate)
}
datePicker.minimumDate = startDate?.toNSDate()
datePicker.maximumDate = endDate?.toNSDate()

if (selectedDate != null) {
datePicker.setDate(NSDate(selectedDate.unixMillis - diffDate))
datePicker.setDate(selectedDate.toNSDate())
}

doneButton.setEventHandler(UIControlEventTouchUpInside) {
this.dismissViewControllerAnimated(flag = true, completion = null)
handler.positive?.invoke(
dialogId,
DateTime(diffDate + datePicker.date.timeIntervalSinceReferenceDate)
datePicker.date.toKlock()
)
}
cancelButton.setEventHandler(UIControlEventTouchUpInside) {
this.dismissViewControllerAnimated(flag = true, completion = null)
handler.negative?.invoke(dialogId)
}
}
}

internal fun DateTime.toNSDate(): NSDate {
return NSDate((unixMillis / 1000) - NSTimeIntervalSince1970)
}

internal fun NSDate.toKlock(): DateTime {
return DateTime(unixMillis = (this.timeIntervalSinceReferenceDate() + NSTimeIntervalSince1970) * 1000)
}

0 comments on commit 751235e

Please sign in to comment.