Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 751235e

Browse files
authored
Merge pull request #203 from icerockdev/develop
Release 0.1.0-dev-19
2 parents 897a299 + 8f06d4b commit 751235e

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This is a Kotlin MultiPlatform library that provides declarative UI and applicat
66
in common code. You can implement full application for Android and iOS only from common code with it.
77

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

@@ -227,6 +227,7 @@ val loginScreen = Theme(baseTheme) {
227227
- 0.1.0-dev-16
228228
- 0.1.0-dev-17
229229
- 0.1.0-dev-18
230+
- 0.1.0-dev-19
230231

231232
## Installation
232233
root build.gradle
@@ -241,7 +242,7 @@ allprojects {
241242
project build.gradle
242243
```groovy
243244
dependencies {
244-
commonMainApi("dev.icerock.moko:widgets:0.1.0-dev-18")
245+
commonMainApi("dev.icerock.moko:widgets:0.1.0-dev-19")
245246
}
246247
```
247248

@@ -254,7 +255,7 @@ buildscript {
254255
}
255256
256257
dependencies {
257-
classpath "dev.icerock.moko.widgets:gradle-plugin:0.1.0-dev-18"
258+
classpath "dev.icerock.moko.widgets:gradle-plugin:0.1.0-dev-19"
258259
}
259260
}
260261

buildSrc/src/main/kotlin/Versions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Versions {
1010
}
1111

1212
const val kotlin = "1.3.70"
13-
private const val mokoWidgets = "0.1.0-dev-18"
13+
private const val mokoWidgets = "0.1.0-dev-19"
1414
private const val mokoResources = "0.9.0"
1515

1616
object Plugins {

widgets-datetime-picker/src/iosMain/kotlin/dev/icerock/moko/widgets/datetimepicker/ShowDatePickerExt.kt

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import platform.UIKit.UIControlEventTouchUpInside
3030
import platform.UIKit.UIApplication
3131
import platform.Foundation.NSBundle
3232
import platform.Foundation.NSDate
33+
import platform.Foundation.NSTimeIntervalSince1970
3334

3435
actual class DatePickerDialogHandler(
3536
val positive: ((dialogId: Int, date: DateTime) -> Unit)?,
@@ -212,35 +213,31 @@ class DatePickerController(
212213
anchor = controlPanel.topAnchor
213214
).active = true
214215

215-
val nsDate = NSDate()
216-
val date = DateTime.nowUnix()
217-
val diffDate = date - nsDate.timeIntervalSinceReferenceDate
218-
219-
if (startDate != null) {
220-
startDate.unixMillis
221-
datePicker.minimumDate = NSDate(startDate.unixMillis - diffDate)
222-
}
223-
224-
if (endDate != null) {
225-
endDate.unixMillis
226-
datePicker.maximumDate = NSDate(endDate.unixMillis - diffDate)
227-
}
216+
datePicker.minimumDate = startDate?.toNSDate()
217+
datePicker.maximumDate = endDate?.toNSDate()
228218

229219
if (selectedDate != null) {
230-
datePicker.setDate(NSDate(selectedDate.unixMillis - diffDate))
220+
datePicker.setDate(selectedDate.toNSDate())
231221
}
232222

233223
doneButton.setEventHandler(UIControlEventTouchUpInside) {
234224
this.dismissViewControllerAnimated(flag = true, completion = null)
235225
handler.positive?.invoke(
236226
dialogId,
237-
DateTime(diffDate + datePicker.date.timeIntervalSinceReferenceDate)
227+
datePicker.date.toKlock()
238228
)
239229
}
240230
cancelButton.setEventHandler(UIControlEventTouchUpInside) {
241231
this.dismissViewControllerAnimated(flag = true, completion = null)
242232
handler.negative?.invoke(dialogId)
243233
}
244234
}
235+
}
236+
237+
internal fun DateTime.toNSDate(): NSDate {
238+
return NSDate((unixMillis / 1000) - NSTimeIntervalSince1970)
239+
}
245240

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

0 commit comments

Comments
 (0)