Skip to content

Commit

Permalink
Merge branch 'main' into enhancement/implement_loading_ui_state_spons…
Browse files Browse the repository at this point in the history
…or_screen
  • Loading branch information
Corvus400 authored Sep 6, 2024
2 parents eb53e52 + a44ef3f commit 120e262
Show file tree
Hide file tree
Showing 22 changed files with 92 additions and 56 deletions.
6 changes: 6 additions & 0 deletions app-android/src/main/res/values-v35/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.KaigiApp.Licenses" parent="Theme.AppCompat.DayNight.DarkActionBar">
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
</style>
</resources>
2 changes: 1 addition & 1 deletion app-android/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
</style>

<style name="Theme.KaigiApp.Licenses" parent="Theme.AppCompat.DayNight.DarkActionBar">
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
<!-- Overridden by v35 -->
</style>
</resources>
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package io.github.droidkaigi.confsched.shared

import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
import androidx.compose.material3.windowsizeclass.WindowSizeClass.Companion.calculateFromSize
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.platform.LocalDensity
import androidx.lifecycle.compose.LocalLifecycleOwner
Expand All @@ -17,6 +19,7 @@ import io.github.droidkaigi.confsched.data.Repositories
import io.github.droidkaigi.confsched.data.auth.Authenticator
import io.github.droidkaigi.confsched.data.auth.User
import io.github.droidkaigi.confsched.data.remoteconfig.FakeRemoteConfigApi
import io.github.droidkaigi.confsched.droidkaigiui.compositionlocal.LocalSnackbarHostState
import io.github.droidkaigi.confsched.model.compositionlocal.LocalRepositories
import io.github.takahirom.roborazzi.captureRoboImage
import kotlin.test.Test
Expand Down Expand Up @@ -45,12 +48,16 @@ class IosComposeKaigiTest {
)
runComposeUiTest {
setContent {
val snackbarHostState = remember { SnackbarHostState() }

CompositionLocalProvider(
LocalLifecycleOwner provides object : LifecycleOwner {
override val lifecycle: Lifecycle = LifecycleRegistry(this)
},
LocalRepositories provides kmpEntryPoint.get<Repositories>().map,
LocalSnackbarHostState provides snackbarHostState
) {

KaigiApp(
windowSize = calculateFromSize(
size = Size(
Expand All @@ -60,6 +67,8 @@ class IosComposeKaigiTest {
density = LocalDensity.current,
),
fontFamily = null,
snackbarHostState = snackbarHostState,
onLicenseScreenRequest = {},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class ContributorFeatureTests: XCTestCase {
}

await store.send(.onAppear)
await store.receive(\.response) {
await store.receive(\.response.success) {
$0.contributors = [
.init(id: 0, userName: "hoge", profileUrl: URL(string: "https://2024.droidkaigi.jp/"), iconUrl: URL(string: "https://avatars.githubusercontent.com/u/10727543?s=200&v=4")!),
.init(id: 0, userName: "fuga", profileUrl: nil, iconUrl: URL(string: "https://avatars.githubusercontent.com/u/10727543?s=200&v=4")!),
Expand All @@ -47,7 +47,7 @@ final class ContributorFeatureTests: XCTestCase {
}

await store.send(.onAppear)
await store.receive(\.response)
await store.receive(\.response.failure)
}

@MainActor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ComposableArchitecture
final class SponsorFeatureTests: XCTestCase {

@MainActor
func testExample() async throws {
func testOnAppear() async throws {
let store = TestStore(initialState: SponsorReducer.State()) {
SponsorReducer()
} withDependencies: {
Expand Down
2 changes: 1 addition & 1 deletion app-ios/Tests/StaffFeatureTests/StaffFeatureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ComposableArchitecture
final class StaffFeatureTests: XCTestCase {

@MainActor
func testExample() async throws {
func testOnAppear() async throws {
let store = TestStore(initialState: StaffReducer.State()) {
StaffReducer()
} withDependencies: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ final class TimetableDetail_iosTests: XCTestCase {

// add favorite
await store.send(.view(.favoriteButtonTapped))
await store.receive(\.favoriteResponse) {
await store.receive(\.favoriteResponse.success) {
$0.isFavorited = !isFavorited
$0.toast = .init(text: String(localized: "TimetableDetailAddBookmark", bundle: .module))
}

// remove favorite
await store.send(.view(.favoriteButtonTapped))
await store.receive(\.favoriteResponse) {
await store.receive(\.favoriteResponse.success) {
$0.isFavorited = isFavorited
}

Expand All @@ -36,7 +36,7 @@ final class TimetableDetail_iosTests: XCTestCase {
}

await store.send(.view(.favoriteButtonTapped))
await store.receive(\.favoriteResponse)
await store.receive(\.favoriteResponse.failure)
}

@MainActor func testTappedURL() async throws {
Expand All @@ -58,7 +58,7 @@ final class TimetableDetail_iosTests: XCTestCase {
}

await store.send(.view(.calendarButtonTapped))
await store.receive(\.requestEventAccessResponse) {
await store.receive(\.requestEventAccessResponse.success) {
$0.confirmationDialog = ConfirmationDialogState(title: {
TextState("")
}, actions: {
Expand All @@ -71,7 +71,7 @@ final class TimetableDetail_iosTests: XCTestCase {
await store.send(.confirmationDialog(.presented(.addEvent))) {
$0.confirmationDialog = nil
}
await store.receive(\.addEventResponse)
await store.receive(\.addEventResponse.success)
}

@MainActor func testTappedVideoButton() async throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class AndroidFeaturePlugin : Plugin<Project> {
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + buildComposeMetricsParameters()
compilerOptions {
freeCompilerArgs.addAll(buildComposeMetricsParameters())
}
}
}
Expand All @@ -35,20 +35,20 @@ fun Project.buildComposeMetricsParameters(): List<String> {

val enableMetrics = (enableMetricsProvider.orNull == "true")
if (enableMetrics) {
val metricsFolder = rootProject.buildDir.resolve("compose-metrics").resolve(relativePath)
val metricsFolder = rootProject.layout.buildDirectory.orNull?.asFile?.resolve("compose-metrics")?.resolve(relativePath)
metricParameters.add("-P")
metricParameters.add(
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + metricsFolder.absolutePath
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + metricsFolder?.absolutePath
)
}

val enableReportsProvider = project.providers.gradleProperty("enableComposeCompilerReports")
val enableReports = (enableReportsProvider.orNull == "true")
if (enableReports) {
val reportsFolder = rootProject.buildDir.resolve("compose-reports").resolve(relativePath)
val reportsFolder = rootProject.layout.buildDirectory.orNull?.asFile?.resolve("compose-reports")?.resolve(relativePath)
metricParameters.add("-P")
metricParameters.add(
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + reportsFolder.absolutePath
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + reportsFolder?.absolutePath
)
}
return metricParameters.toList()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.droidkaigi.confsched.primitive

import com.android.build.api.dsl.CommonExtension
import com.android.build.api.variant.LibraryAndroidComponentsExtension
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.TestedExtension
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
Expand All @@ -13,6 +14,7 @@ import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension

fun Project.androidApplication(action: BaseAppModuleExtension.() -> Unit) {
extensions.configure(action)
Expand All @@ -26,6 +28,14 @@ fun Project.android(action: TestedExtension.() -> Unit) {
extensions.configure(action)
}

fun Project.kotlinAndroidOptions(configure: KotlinAndroidProjectExtension.() -> Unit) {
extensions.configure(configure)
}

fun Project.libraryAndroidOptions(configure: LibraryAndroidComponentsExtension.() -> Unit) {
extensions.configure(configure)
}

fun Project.setupAndroid() {
android {
namespace?.let {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.github.droidkaigi.confsched.primitive

import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11

@Suppress("unused")
class AndroidKotlinPlugin : Plugin<Project> {
Expand All @@ -13,22 +13,26 @@ class AndroidKotlinPlugin : Plugin<Project> {
apply("org.jetbrains.kotlin.android")
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java) {
kotlinOptions.jvmTarget = "11"
compilerOptions {
jvmTarget.set(JVM_11)
}
}

android {
kotlinOptions {
// Treat all Kotlin warnings as errors (disabled by default)
allWarningsAsErrors = properties["warningsAsErrors"] as? Boolean ?: false
kotlinAndroidOptions {
compilerOptions {
// Treat all Kotlin warnings as errors (disabled by default)
allWarningsAsErrors.set(properties["warningsAsErrors"] as? Boolean ?: false)

freeCompilerArgs = freeCompilerArgs + listOf(
// "-opt-in=kotlin.RequiresOptIn",
// Enable experimental coroutines APIs, including Flow
// "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xcontext-receivers"
)
freeCompilerArgs.addAll(listOf(
// "-opt-in=kotlin.RequiresOptIn",
// Enable experimental coroutines APIs, including Flow
// "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xcontext-receivers"
))

jvmTarget = JavaVersion.VERSION_11.toString()
jvmTarget.set(JVM_11)
}
}
}
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.google.devtools.ksp.gradle.KspTaskMetadata
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11

@Suppress("unused")
class KmpAndroidPlugin : Plugin<Project> {
Expand All @@ -15,8 +16,12 @@ class KmpAndroidPlugin : Plugin<Project> {
kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "11"
libraryAndroidOptions {
compileTaskProvider.configure {
compilerOptions {
jvmTarget.set(JVM_11)
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class KmpComposePlugin : Plugin<Project> {
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + buildComposeMetricsParameters()
compilerOptions {
freeCompilerArgs.addAll(buildComposeMetricsParameters())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

@Suppress("unused")
class KmpIosPlugin : Plugin<Project> {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
Expand Down Expand Up @@ -56,9 +58,15 @@ class KmpIosPlugin : Plugin<Project> {
applyDefaultHierarchyTemplate()

targets.withType<KotlinNativeTarget> {
// export kdoc to header file
// https://kotlinlang.org/docs/native-objc-interop.html#export-of-kdoc-comments-to-generated-objective-c-headers
compilations["main"].kotlinOptions.freeCompilerArgs += "-Xexport-kdoc"
compilations["main"].apply {
kotlin {
compilerOptions {
// export kdoc to header file
// https://kotlinlang.org/docs/native-objc-interop.html#export-of-kdoc-comments-to-generated-objective-c-headers
freeCompilerArgs.add("-Xexport-kdoc")
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.droidkaigi.confsched.primitive

import com.google.devtools.ksp.gradle.KspTaskNative
import io.github.droidkaigi.confsched.primitive.Arch.ALL
import io.github.droidkaigi.confsched.primitive.Arch.ARM
import io.github.droidkaigi.confsched.primitive.Arch.ARM_SIMULATOR_DEBUG
Expand All @@ -10,8 +9,6 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink

@Suppress("unused")
class KmpKtorfitPlugin : Plugin<Project> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension

@Suppress("unused")
class KmpPlugin : Plugin<Project> {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
Expand All @@ -21,7 +24,7 @@ class KmpPlugin : Plugin<Project> {
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java) {
kotlinOptions.jvmTarget = "11"
compilerOptions.jvmTarget.set(JVM_11)
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink>().configureEach {
notCompatibleWithConfigurationCache("Configuration chache not supported for a system property read at configuration time")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
package io.github.droidkaigi.confsched.primitive

import com.android.build.gradle.TestedExtension
import org.gradle.api.artifacts.MinimalExternalModuleDependency
import org.gradle.api.plugins.ExtensionAware
import org.gradle.kotlin.dsl.DependencyHandlerScope
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions

fun TestedExtension.kotlinOptions(block: KotlinJvmOptions.() -> Unit) {
(this as ExtensionAware).extensions.configure("kotlinOptions", block)
}

fun DependencyHandlerScope.ksp(
artifact: MinimalExternalModuleDependency,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private fun EventMap(

@Composable
@Preview
fun PreviewEventMapScreen() {
fun EventMapScreenPreview() {
EventMapScreen(
uiState = EventMapUiState.Exists(
userMessageStateHolder = rememberUserMessageStateHolder(),
Expand Down
Loading

0 comments on commit 120e262

Please sign in to comment.