diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/ui/FeedListItem.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/ui/FeedListItem.kt index 1af52d4f9..5cbd46c48 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/ui/FeedListItem.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/ui/FeedListItem.kt @@ -274,8 +274,8 @@ private fun FeedLabelInput( @Composable internal expect fun ShareIconButton(content: () -> String) @Composable -internal fun ShareIconButtonInternal(onClick: () -> Unit) { - IconButton(onClick = onClick) { +internal fun ShareIconButtonInternal(modifier: Modifier = Modifier, onClick: () -> Unit) { + IconButton(modifier = modifier, onClick = onClick) { Icon( imageVector = TwineIcons.Share, contentDescription = null, diff --git a/shared/src/iosMain/kotlin/dev/sasikanth/rss/reader/feeds/ui/ShareIconButton.kt b/shared/src/iosMain/kotlin/dev/sasikanth/rss/reader/feeds/ui/ShareIconButton.kt index d3800a36b..3a15bb453 100644 --- a/shared/src/iosMain/kotlin/dev/sasikanth/rss/reader/feeds/ui/ShareIconButton.kt +++ b/shared/src/iosMain/kotlin/dev/sasikanth/rss/reader/feeds/ui/ShareIconButton.kt @@ -16,9 +16,17 @@ package dev.sasikanth.rss.reader.feeds.ui import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.setValue import androidx.compose.ui.interop.LocalUIViewController +import kotlinx.cinterop.ExperimentalForeignApi +import platform.CoreGraphics.CGRectGetMaxY +import platform.CoreGraphics.CGRectGetMidX +import platform.CoreGraphics.CGRectMake import platform.UIKit.UIActivityViewController +import platform.UIKit.popoverPresentationController +@OptIn(ExperimentalForeignApi::class) @Composable internal actual fun ShareIconButton(content: () -> String) { val viewController = LocalUIViewController.current @@ -26,6 +34,15 @@ internal actual fun ShareIconButton(content: () -> String) { ShareIconButtonInternal { val items = listOf(content()) val activityController = UIActivityViewController(items, null) + activityController.popoverPresentationController?.setSourceView(viewController.view) + activityController.popoverPresentationController?.setSourceRect( + CGRectMake( + x = CGRectGetMidX(viewController.view.bounds), + y = CGRectGetMaxY(viewController.view.bounds), + width = 0.0, + height = 0.0 + ) + ) viewController.presentViewController(activityController, true, null) } } diff --git a/shared/src/iosMain/kotlin/dev/sasikanth/rss/reader/home/ui/PostOptionShareIconButton.kt b/shared/src/iosMain/kotlin/dev/sasikanth/rss/reader/home/ui/PostOptionShareIconButton.kt index 07b9c01b1..6ce4e03e1 100644 --- a/shared/src/iosMain/kotlin/dev/sasikanth/rss/reader/home/ui/PostOptionShareIconButton.kt +++ b/shared/src/iosMain/kotlin/dev/sasikanth/rss/reader/home/ui/PostOptionShareIconButton.kt @@ -16,21 +16,39 @@ package dev.sasikanth.rss.reader.home.ui import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.setValue import androidx.compose.ui.interop.LocalUIViewController import dev.sasikanth.rss.reader.resources.icons.Share import dev.sasikanth.rss.reader.resources.icons.TwineIcons import dev.sasikanth.rss.reader.resources.strings.LocalStrings +import kotlinx.cinterop.ExperimentalForeignApi +import platform.CoreGraphics.CGRectGetMaxY +import platform.CoreGraphics.CGRectGetMidX +import platform.CoreGraphics.CGRectMake import platform.UIKit.UIActivityViewController +import platform.UIKit.popoverPresentationController +@OptIn(ExperimentalForeignApi::class) @Composable internal actual fun PostOptionShareIconButton(postLink: String) { val viewController = LocalUIViewController.current + PostOptionIconButton( icon = TwineIcons.Share, contentDescription = LocalStrings.current.share, onClick = { val items = listOf(postLink) val activityController = UIActivityViewController(items, null) + activityController.popoverPresentationController?.setSourceView(viewController.view) + activityController.popoverPresentationController?.setSourceRect( + CGRectMake( + x = CGRectGetMidX(viewController.view.bounds), + y = CGRectGetMaxY(viewController.view.bounds), + width = 0.0, + height = 0.0 + ) + ) viewController.presentViewController(activityController, true, null) } )