mirror of
https://github.com/fromchat-messenger/app.git
synced 2026-09-22 19:15:05 +03:00
Make a robust sending system
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.pr0gramm3r101.utils
|
||||
|
||||
import androidx.compose.ui.platform.Clipboard
|
||||
import platform.UIKit.UIPasteboard
|
||||
|
||||
actual fun Clipboard.toSupport(): SupportClipboardManager {
|
||||
return object : SupportClipboardManager {
|
||||
private var listener: ((String) -> Unit)? = null
|
||||
|
||||
override suspend fun setText(string: String) {
|
||||
UIPasteboard.generalPasteboard.string = string
|
||||
listener?.invoke(string)
|
||||
}
|
||||
|
||||
override suspend fun getText(): String? =
|
||||
UIPasteboard.generalPasteboard.string
|
||||
|
||||
override fun setTextListener(listener: (String) -> Unit) {
|
||||
this.listener = listener
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -19,6 +19,10 @@ internal actual fun expectExists(path: String): Boolean =
|
||||
|
||||
@OptIn(ExperimentalForeignApi::class)
|
||||
internal actual fun expectWriteBytes(path: String, bytes: ByteArray) {
|
||||
val parent = path.substringBeforeLast('/', missingDelimiterValue = "")
|
||||
if (parent.isNotEmpty()) {
|
||||
NSFileManager.defaultManager.createDirectoryAtPath(parent, true, null, null)
|
||||
}
|
||||
val nsData = bytes.usePinned { pinned ->
|
||||
NSData.create(bytes = pinned.addressOf(0), length = bytes.size.toULong())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user