ToastUtils 工具类
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package com.taskttl.core.utils
|
||||
|
||||
import android.widget.Toast
|
||||
import com.taskttl.MainApplication
|
||||
|
||||
actual object ToastUtils {
|
||||
actual fun show(message: String) {
|
||||
Toast.makeText(MainApplication.instance.applicationContext, message, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package com.taskttl.core.utils
|
||||
|
||||
expect object ToastUtils {
|
||||
fun show(message: String)
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.taskttl.core.utils
|
||||
|
||||
import platform.UIKit.*
|
||||
|
||||
actual object ToastUtils {
|
||||
actual fun show(message: String) {
|
||||
val alert = UIAlertController.alertControllerWithTitle(
|
||||
title = "",
|
||||
message = message,
|
||||
preferredStyle = UIAlertControllerStyleAlert
|
||||
)
|
||||
val okAction = UIAlertAction.actionWithTitle("OK", UIAlertActionStyleDefault, null)
|
||||
alert.addAction(okAction)
|
||||
|
||||
val rootVC = UIApplication.sharedApplication.keyWindow?.rootViewController
|
||||
rootVC?.presentViewController(alert, animated = true, completion = null)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user