Skip to content

Commit

Permalink
Merge pull request #807 from Corvus400/feature/share_session_compose_…
Browse files Browse the repository at this point in the history
…multiplatform

✨ Implemented session sharing functionality from Compose Multiplatform as well.
  • Loading branch information
takahirom committed Aug 26, 2024
2 parents 4a0ebc3 + f2a4283 commit 681baa2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import io.github.droidkaigi.confsched.staff.staffScreens
import io.github.droidkaigi.confsched.droidkaigiui.NavHostWithSharedAxisX
import io.github.droidkaigi.confsched.eventmap.eventMapScreenRoute
import io.github.droidkaigi.confsched.favorites.favoritesScreenRoute
import io.github.droidkaigi.confsched.model.TimetableItem
import io.github.droidkaigi.confsched.profilecard.profileCardScreenRoute
import platform.Foundation.NSURL
import platform.UIKit.UIApplication
Expand Down Expand Up @@ -114,11 +115,7 @@ private fun KaigiNavHost(
onNavigationIconClick = navController::popBackStack,
onLinkClick = externalNavController::navigate,
onCalendarRegistrationClick = {},//externalNavController::navigateToCalendarRegistration,
// For debug
// onShareClick = externalNavController::onShareClick,
onShareClick = {
navController.navigate(contributorsScreenRoute)
},
onShareClick = externalNavController::onShareClick,
onFavoriteListClick = {} // { navController.navigate(favoritesScreenRoute) }
)

Expand Down Expand Up @@ -271,6 +268,14 @@ private class ExternalNavController(
UIApplication.sharedApplication.openURL(nsUrl)
}

fun onShareClick(timetableItem: TimetableItem) {
shareNavigator.share(
"[${timetableItem.room.name.currentLangTitle}] ${timetableItem.startsTimeString} - ${timetableItem.endsTimeString}\n" +
"${timetableItem.title.currentLangTitle}\n" +
timetableItem.url,
)
}

fun onShareProfileCardClick(
text: String,
imageBitmap: ImageBitmap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ import platform.UIKit.UIActivityViewController
import platform.UIKit.UIApplication

class ShareNavigator {
fun share(text: String) {
val items = mutableListOf<Any>(text)

val activityViewController = UIActivityViewController(items, null)
val keyWindow = UIApplication.sharedApplication.keyWindow
val rootViewController = keyWindow?.rootViewController

rootViewController?.presentViewController(
viewControllerToPresent = activityViewController,
animated = true,
completion = null,
)
}

fun shareTextWithImage(text: String, image: ImageBitmap) {
val items = mutableListOf<Any>(text)
image.toUiImage()?.let {
Expand Down

0 comments on commit 681baa2

Please sign in to comment.