Skip to content

Commit

Permalink
Merge branch 'main' into bugfix_text_style_profile_edit_screen
Browse files Browse the repository at this point in the history
  • Loading branch information
takahirom authored Sep 1, 2024
2 parents 3498da7 + ac68d35 commit 62693fd
Show file tree
Hide file tree
Showing 27 changed files with 571 additions and 116 deletions.
4 changes: 2 additions & 2 deletions app-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
buildConfig = true
}
defaultConfig {
versionCode = 3
versionName = "1.0.1"
versionCode = 4
versionName = "1.1.0"
}
signingConfigs {
create("dev") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ private class ExternalNavController(

fun onShareClick(timetableItem: TimetableItem) {
shareNavigator.share(
"[${timetableItem.room.name.currentLangTitle}] ${timetableItem.startsTimeString} - ${timetableItem.endsTimeString}\n" +
"[${timetableItem.room.name.currentLangTitle}] ${timetableItem.formattedMonthAndDayString} " +
"${timetableItem.startsTimeString} - ${timetableItem.endsTimeString}\n" +
"${timetableItem.title.currentLangTitle}\n" +
timetableItem.url,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="permission_required">セッションを予定として追加するには、カレンダーへのアクセス権限が必要です。</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="permission_required">To add a session as a scheduled event, you need access permission to the calendar.</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.github.droidkaigi.confsched.shared

import conference_app_2024.app_ios_shared.generated.resources.Res

object AppIosSharedRes {
val drawable = Res.drawable
val string = Res.string
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.github.droidkaigi.confsched.shared
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Surface
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
import androidx.compose.material3.windowsizeclass.WindowSizeClass
Expand All @@ -20,15 +21,20 @@ import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import co.touchlab.kermit.Logger
import conference_app_2024.app_ios_shared.generated.resources.permission_required
import io.github.droidkaigi.confsched.about.aboutScreen
import io.github.droidkaigi.confsched.about.aboutScreenRoute
import io.github.droidkaigi.confsched.about.navigateAboutScreen
import io.github.droidkaigi.confsched.compose.rememberEventFlow
import io.github.droidkaigi.confsched.contributors.contributorsScreenRoute
import io.github.droidkaigi.confsched.contributors.contributorsScreens
import io.github.droidkaigi.confsched.data.Repositories
import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme
import io.github.droidkaigi.confsched.designsystem.theme.dotGothic16FontFamily
import io.github.droidkaigi.confsched.droidkaigiui.NavHostWithSharedAxisX
import io.github.droidkaigi.confsched.droidkaigiui.SnackbarMessageEffect
import io.github.droidkaigi.confsched.droidkaigiui.UserMessageStateHolder
import io.github.droidkaigi.confsched.droidkaigiui.compositionlocal.LocalSnackbarHostState
import io.github.droidkaigi.confsched.eventmap.eventMapScreenRoute
import io.github.droidkaigi.confsched.eventmap.eventMapScreens
import io.github.droidkaigi.confsched.eventmap.navigateEventMapScreen
Expand Down Expand Up @@ -76,6 +82,7 @@ import io.github.droidkaigi.confsched.staff.staffScreenRoute
import io.github.droidkaigi.confsched.staff.staffScreens
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.jetbrains.compose.resources.stringResource
import platform.EventKit.EKEntityType.EKEntityTypeEvent
import platform.EventKit.EKEvent
import platform.EventKit.EKEventStore
Expand All @@ -89,20 +96,21 @@ import platform.UIKit.UIApplication
import platform.UIKit.UIViewController
import platform.darwin.NSObject

private object ExternalNavControllerLink {
var onLicenseScreenRequest: (() -> Unit)? = null
}
data class IosComposeKaigiAppUiState(
val userMessageStateHolder: UserMessageStateHolder,
)

@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
@Suppress("UNUSED")
fun kaigiAppController(
repositories: Repositories,
onLicenseScreenRequest: () -> Unit,
): UIViewController = ComposeUIViewController {
ExternalNavControllerLink.onLicenseScreenRequest = onLicenseScreenRequest
val snackbarHostState = remember { SnackbarHostState() }

CompositionLocalProvider(
LocalRepositories provides repositories.map
LocalRepositories provides repositories.map,
LocalSnackbarHostState provides snackbarHostState
) {
val windowSizeClass = calculateWindowSizeClass()

Expand All @@ -121,6 +129,8 @@ fun kaigiAppController(
KaigiApp(
windowSize = windowSizeClass,
fontFamily = fontFamily,
snackbarHostState = snackbarHostState,
onLicenseScreenRequest = onLicenseScreenRequest,
)
}
}
Expand All @@ -129,17 +139,36 @@ fun kaigiAppController(
fun KaigiApp(
windowSize: WindowSizeClass,
fontFamily: FontFamily?,
snackbarHostState: SnackbarHostState,
onLicenseScreenRequest: () -> Unit,
modifier: Modifier = Modifier,
) {
val eventFlow = rememberEventFlow<IosComposeKaigiAppEvent>()
val uiState = iosComposeKaigiAppPresenter(events = eventFlow)

SnackbarMessageEffect(
snackbarHostState = snackbarHostState,
userMessageStateHolder = uiState.userMessageStateHolder,
)

KaigiTheme(
fontFamily = fontFamily,
) {
Surface(
modifier = modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
val snackbarMessage = stringResource(AppIosSharedRes.string.permission_required)
KaigiNavHost(
windowSize = windowSize,
onLicenseScreenRequest = onLicenseScreenRequest,
onAccessCalendarIsDenied = {
eventFlow.tryEmit(
IosComposeKaigiAppEvent.ShowRequiresAuthorization(
snackbarMessage = snackbarMessage,
)
)
}
)
}
}
Expand All @@ -148,19 +177,27 @@ fun KaigiApp(
@Composable
private fun KaigiNavHost(
windowSize: WindowSizeClass,
onLicenseScreenRequest: () -> Unit,
onAccessCalendarIsDenied: () -> Unit,
navController: NavHostController = rememberNavController(),
externalNavController: ExternalNavController = rememberExternalNavController()
externalNavController: ExternalNavController = rememberExternalNavController(),
) {
NavHostWithSharedAxisX(navController = navController, startDestination = mainScreenRoute) {
mainScreen(
windowSize = windowSize,
navController = navController,
externalNavController = externalNavController,
onLicenseScreenRequest = onLicenseScreenRequest,
)
sessionScreens(
onNavigationIconClick = navController::popBackStack,
onLinkClick = externalNavController::navigate,
onCalendarRegistrationClick = externalNavController::navigateToCalendarRegistration,
onCalendarRegistrationClick = { timetableItem ->
externalNavController.navigateToCalendarRegistration(
timetableItem = timetableItem,
onAccessCalendarIsDenied = onAccessCalendarIsDenied,
)
},
onShareClick = externalNavController::onShareClick,
onFavoriteListClick = {
navController.navigate(
Expand Down Expand Up @@ -205,6 +242,7 @@ private fun NavGraphBuilder.mainScreen(
windowSize: WindowSizeClass,
navController: NavHostController,
externalNavController: ExternalNavController,
onLicenseScreenRequest: () -> Unit,
) {
mainScreen(
windowSize = windowSize,
Expand Down Expand Up @@ -246,7 +284,7 @@ private fun NavGraphBuilder.mainScreen(
}

AboutItem.Contributors -> navController.navigate(contributorsScreenRoute)
AboutItem.License -> externalNavController.navigateToLicenseScreen()
AboutItem.License -> onLicenseScreenRequest()
AboutItem.Medium -> externalNavController.navigate(
url = "https://medium.com/droidkaigi",
)
Expand Down Expand Up @@ -334,20 +372,18 @@ private class ExternalNavController(
UIApplication.sharedApplication.openURL(nsUrl)
}

fun navigateToLicenseScreen() {
ExternalNavControllerLink.onLicenseScreenRequest?.invoke()
}

/**
* Navigate to Calendar Registration
*/
fun navigateToCalendarRegistration(timetableItem: TimetableItem) {
fun navigateToCalendarRegistration(
timetableItem: TimetableItem,
onAccessCalendarIsDenied: () -> Unit,
) {
val eventStore = EKEventStore()

eventStore.requestAccessToEntityType(EKEntityTypeEvent) { granted, error ->
if (granted.not()) {
// TODO Display a message asking the user to add permissions.
// TODO Otherwise, the privileges will remain permanently denied.
onAccessCalendarIsDenied()
Logger.e("Calendar access was denied by the user.")
return@requestAccessToEntityType
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.github.droidkaigi.confsched.shared

import androidx.compose.runtime.Composable
import io.github.droidkaigi.confsched.compose.EventEffect
import io.github.droidkaigi.confsched.compose.EventFlow
import io.github.droidkaigi.confsched.droidkaigiui.providePresenterDefaults
import io.github.droidkaigi.confsched.shared.IosComposeKaigiAppEvent.ShowRequiresAuthorization

sealed interface IosComposeKaigiAppEvent {
val snackbarMessage: String

data class ShowRequiresAuthorization(
override val snackbarMessage: String,
) : IosComposeKaigiAppEvent
}

@Composable
fun iosComposeKaigiAppPresenter(
events: EventFlow<IosComposeKaigiAppEvent>
) : IosComposeKaigiAppUiState = providePresenterDefaults { userMessageStateHolder ->
EventEffect(events) { event ->
when (event) {
is ShowRequiresAuthorization -> {
userMessageStateHolder.showMessage(
message = event.snackbarMessage,
// TODO Add code to transition to the settings screen when the action button is pressed.
// TODO Perhaps UIApplication.openSettingsURLString can be used to achieve this.
actionLabel = null,
)
}
}
}
IosComposeKaigiAppUiState(userMessageStateHolder)
}
6 changes: 3 additions & 3 deletions app-ios/.swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ opt_in_rules:

included:
- App/DroidKaigi2024
- Modules/Package.swift
- Modules/Sources
- Modules/Tests
- Package.swift
- Sources
- Tests

identifier_name:
min_length: 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ class KmpKtorfitPlugin : Plugin<Project> {
add("ksp$it", libs.library("ktorfitKsp"))
}
}

// https://github.com/DroidKaigi/conference-app-2024/issues/485#issuecomment-2304251937
tasks.withType<KspTaskNative>().configureEach {
notCompatibleWithConfigurationCache("Configuration chache not supported for a system property read at configuration time")

}
tasks.withType<KotlinNativeLink>().configureEach {
notCompatibleWithConfigurationCache("Configuration chache not supported for a system property read at configuration time")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.droidkaigi.confsched.primitive

import com.google.devtools.ksp.gradle.KspTaskNative
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
Expand All @@ -13,6 +14,11 @@ class KmpPlugin : Plugin<Project> {
with(pluginManager) {
apply("org.jetbrains.kotlin.multiplatform")

withPlugin(libs.plugin("kspGradlePlugin").pluginId) {
tasks.withType<KspTaskNative>().configureEach {
notCompatibleWithConfigurationCache("Configuration chache not supported for a system property read at configuration time")
}
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java) {
kotlinOptions.jvmTarget = "11"
Expand Down
Loading

0 comments on commit 62693fd

Please sign in to comment.