|
|
@ -1,46 +1,22 @@ |
|
|
|
package example.imageviewer |
|
|
|
package example.imageviewer |
|
|
|
|
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.WindowInsets |
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.windowInsetsPadding |
|
|
|
|
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
|
|
|
|
import androidx.compose.ui.graphics.vector.ImageVector |
|
|
|
import androidx.compose.ui.graphics.vector.ImageVector |
|
|
|
import androidx.compose.ui.unit.Density |
|
|
|
|
|
|
|
import androidx.compose.ui.unit.LayoutDirection |
|
|
|
|
|
|
|
import example.imageviewer.icon.IconIosShare |
|
|
|
import example.imageviewer.icon.IconIosShare |
|
|
|
import kotlinx.cinterop.useContents |
|
|
|
import kotlinx.cinterop.ExperimentalForeignApi |
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
import kotlinx.coroutines.IO |
|
|
|
import kotlinx.coroutines.IO |
|
|
|
import platform.CoreFoundation.CFUUIDCreate |
|
|
|
import platform.CoreFoundation.CFUUIDCreate |
|
|
|
import platform.CoreFoundation.CFUUIDCreateString |
|
|
|
import platform.CoreFoundation.CFUUIDCreateString |
|
|
|
import platform.Foundation.CFBridgingRelease |
|
|
|
import platform.Foundation.CFBridgingRelease |
|
|
|
import platform.UIKit.UIApplication |
|
|
|
|
|
|
|
import platform.UIKit.UIImage |
|
|
|
import platform.UIKit.UIImage |
|
|
|
|
|
|
|
|
|
|
|
private val iosNotchInset = object : WindowInsets { |
|
|
|
|
|
|
|
override fun getTop(density: Density): Int { |
|
|
|
|
|
|
|
val safeAreaInsets = UIApplication.sharedApplication.keyWindow?.safeAreaInsets |
|
|
|
|
|
|
|
return if (safeAreaInsets != null) { |
|
|
|
|
|
|
|
val topInset = safeAreaInsets.useContents { this.top } |
|
|
|
|
|
|
|
(topInset * density.density).toInt() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun getLeft(density: Density, layoutDirection: LayoutDirection): Int = 0 |
|
|
|
|
|
|
|
override fun getRight(density: Density, layoutDirection: LayoutDirection): Int = 0 |
|
|
|
|
|
|
|
override fun getBottom(density: Density): Int = 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
actual fun Modifier.notchPadding(): Modifier = |
|
|
|
|
|
|
|
this.windowInsetsPadding(iosNotchInset) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class IosStorableImage( |
|
|
|
class IosStorableImage( |
|
|
|
val rawValue: UIImage |
|
|
|
val rawValue: UIImage |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
actual typealias PlatformStorableImage = IosStorableImage |
|
|
|
actual typealias PlatformStorableImage = IosStorableImage |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalForeignApi::class) |
|
|
|
actual fun createUUID(): String = |
|
|
|
actual fun createUUID(): String = |
|
|
|
CFBridgingRelease(CFUUIDCreateString(null, CFUUIDCreate(null))) as String |
|
|
|
CFBridgingRelease(CFUUIDCreateString(null, CFUUIDCreate(null))) as String |
|
|
|
|
|
|
|
|
|
|
|