Skip to content

Commit

Permalink
Merge pull request #53 from DroidKaigi/takahirom/fix-detekt/2024-06-15
Browse files Browse the repository at this point in the history
Fix ./gradlew detekt --auto-correct
  • Loading branch information
takahirom authored Jun 15, 2024
2 parents 08f1617 + 66dd855 commit f9dec20
Show file tree
Hide file tree
Showing 39 changed files with 127 additions and 199 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ fun KaigiApp(
@Composable
private fun KaigiNavHost(
windowSize: WindowSizeClass,
@Suppress("UnusedParameter")
displayFeatures: PersistentList<DisplayFeature>,
navController: NavHostController = rememberNavController(),
externalNavController: ExternalNavController = rememberExternalNavController(),
Expand Down Expand Up @@ -96,6 +97,7 @@ private fun KaigiNavHost(
private fun NavGraphBuilder.mainScreen(
windowSize: WindowSizeClass,
navController: NavHostController,
@Suppress("UnusedParameter")
externalNavController: ExternalNavController,
) {
mainScreen(
Expand Down
4 changes: 3 additions & 1 deletion ci.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh
./gradlew testDebugUnitTest
# this is now in GHA
# ./gradlew testDebugUnitTest
./gradlew detekt --auto-correct
./gradlew assembleSharedXCFramework --no-configuration-cache
./gradlew iosSimulatorArm64Test --no-configuration-cache

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import kotlin.coroutines.EmptyCoroutineContext

@Composable
@OptIn(InternalComposeApi::class)
fun <T> CompositionLocalProviderWithReturnValue(
@Suppress("ComposeCompositionLocalUsage")
fun <T> compositionLocalProviderWithReturnValue(
value: ProvidedValue<*>,
content: @Composable () -> T,
): T {
Expand All @@ -32,6 +33,7 @@ interface ComposeEffectErrorHandler {
suspend fun emit(throwable: Throwable)
}

@Suppress("CompositionLocalAllowlist")
val LocalComposeEffectErrorHandler = staticCompositionLocalOf<ComposeEffectErrorHandler> {
object : ComposeEffectErrorHandler {
override suspend fun emit(throwable: Throwable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ public class RepositoryProvider @Inject constructor(
.map { (k, v) ->
k.kotlin to v as Any
}.toMap()

@Composable
public fun Provide(content: @Composable () -> Unit) {
CompositionLocalProvider(
LocalRepositories provides repositoriesMap
LocalRepositories provides repositoriesMap,
) {
content()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public abstract class AchievementRepositoryModule {
@RepositoryQualifier
@IntoMap
@ClassKey(AchievementRepository::class)
public abstract fun bindAchievementRepository(
public abstract fun bindAchievementRepository(
repository: AchievementRepository,
): Any

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.droidkaigi.confsched.data.achievements

import io.github.droidkaigi.confsched.model.AchievementRepository
import io.github.droidkaigi.confsched.data.remoteconfig.RemoteConfigApi
import io.github.droidkaigi.confsched.model.Achievement
import io.github.droidkaigi.confsched.model.AchievementRepository
import kotlinx.collections.immutable.PersistentSet
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@ public class DefaultSessionsRepository(
var first = true
combine(
sessionCacheDataStore.getTimetableStream().catch { e ->
Logger.d(
"DefaultSessionsRepository sessionCacheDataStore.getTimetableStream catch",
e,
)
sessionCacheDataStore.save(sessionsApi.sessionsAllResponse())
emitAll(sessionCacheDataStore.getTimetableStream())
},
Logger.d(
"DefaultSessionsRepository sessionCacheDataStore.getTimetableStream catch",
e,
)
sessionCacheDataStore.save(sessionsApi.sessionsAllResponse())
emitAll(sessionCacheDataStore.getTimetableStream())
},
userDataStore.getFavoriteSessionStream(),
) { timetable, favorites ->
timetable.copy(bookmarks = favorites)
}.collect {
if (!it.isEmpty()) {
emit(it)
}
if (first) {
first = false
Logger.d("DefaultSessionsRepository onStart getTimetableStream()")
sessionCacheDataStore.save(sessionsApi.sessionsAllResponse())
Logger.d("DefaultSessionsRepository onStart fetched")
}
if (!it.isEmpty()) {
emit(it)
}
if (first) {
first = false
Logger.d("DefaultSessionsRepository onStart getTimetableStream()")
sessionCacheDataStore.save(sessionsApi.sessionsAllResponse())
Logger.d("DefaultSessionsRepository onStart fetched")
}
}
}

override fun getTimetableItemWithBookmarkStream(id: TimetableItemId): Flow<Pair<TimetableItem, Boolean>> {
Expand All @@ -75,13 +75,13 @@ public class DefaultSessionsRepository(

val timetable by remember {
sessionCacheDataStore.getTimetableStream().catch { e ->
Logger.d(
"DefaultSessionsRepository sessionCacheDataStore.getTimetableStream catch",
e,
)
sessionCacheDataStore.save(sessionsApi.sessionsAllResponse())
emitAll(sessionCacheDataStore.getTimetableStream())
}
Logger.d(
"DefaultSessionsRepository sessionCacheDataStore.getTimetableStream catch",
e,
)
sessionCacheDataStore.save(sessionsApi.sessionsAllResponse())
emitAll(sessionCacheDataStore.getTimetableStream())
}
}.safeCollectAsState(Timetable())
val favoriteSessions by remember {
userDataStore.getFavoriteSessionStream()
Expand All @@ -99,7 +99,9 @@ public class DefaultSessionsRepository(
timetable.timetableItems.firstOrNull { it.id == id } ?: return@remember null
timetableItem to timetable.bookmarks.contains(id)
}
Logger.d { "DefaultSessionsRepository timetableItemWithBookmark() timetableSize:${timetable.timetableItems.size} id:$id itemWithBookmark=$itemWithBookmark" }
Logger.d {
"DefaultSessionsRepository timetableItemWithBookmark() timetableSize:${timetable.timetableItems.size} id:$id itemWithBookmark=$itemWithBookmark"
}
return itemWithBookmark
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import io.github.droidkaigi.confsched.data.achievements.AchievementsDataStore
import io.github.droidkaigi.confsched.data.achievements.DefaultAchievementRepository
import io.github.droidkaigi.confsched.data.auth.AuthApi
import io.github.droidkaigi.confsched.data.auth.DefaultAuthApi
import io.github.droidkaigi.confsched.model.AchievementRepository
import io.github.droidkaigi.confsched.data.contributors.ContributorsApiClient
import io.github.droidkaigi.confsched.data.contributors.DefaultContributorsApiClient
import io.github.droidkaigi.confsched.data.contributors.DefaultContributorsRepository
Expand All @@ -22,6 +21,7 @@ import io.github.droidkaigi.confsched.data.staff.DefaultStaffApiClient
import io.github.droidkaigi.confsched.data.staff.DefaultStaffRepository
import io.github.droidkaigi.confsched.data.staff.StaffApiClient
import io.github.droidkaigi.confsched.data.user.UserDataStore
import io.github.droidkaigi.confsched.model.AchievementRepository
import io.github.droidkaigi.confsched.model.ContributorsRepository
import io.github.droidkaigi.confsched.model.SessionsRepository
import io.github.droidkaigi.confsched.model.SponsorsRepository
Expand Down Expand Up @@ -53,7 +53,7 @@ public interface Repositories {

public class DefaultRepositories(
public override val map: Map<KClass<*>, Any>,
): Repositories
) : Repositories

@OptIn(ExperimentalForeignApi::class)
public val dataModule: Module = module {
Expand Down Expand Up @@ -144,13 +144,14 @@ public val dataModule: Module = module {
singleOf(::DefaultStaffRepository) bind StaffRepository::class
singleOf(::DefaultSponsorsRepository) bind SponsorsRepository::class
single<Repositories> {
DefaultRepositories(mapOf(
DefaultRepositories(
mapOf(
AchievementRepository::class to get<AchievementRepository>(),
SessionsRepository::class to get<SessionsRepository>(),
ContributorsRepository::class to get<ContributorsRepository>(),
StaffRepository::class to get<StaffRepository>(),
SponsorsRepository::class to get<SponsorsRepository>(),
)
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package androidx.compose.ui.tooling.preview
@Retention(AnnotationRetention.BINARY)
@Target(
AnnotationTarget.ANNOTATION_CLASS,
AnnotationTarget.FUNCTION
AnnotationTarget.FUNCTION,
)
@Repeatable
annotation class Preview(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,3 @@ val surfaceContainerLowDarkHighContrast = Color(0xFF1A1C1C)
val surfaceContainerDarkHighContrast = Color(0xFF1F2020)
val surfaceContainerHighDarkHighContrast = Color(0xFF292A2A)
val surfaceContainerHighestDarkHighContrast = Color(0xFF343535)







Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@file:Suppress("UnusedPrivateProperty")

package io.github.droidkaigi.confsched.designsystem.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
Expand Down Expand Up @@ -241,18 +242,23 @@ data class ColorFamily(
val color: Color,
val onColor: Color,
val colorContainer: Color,
val onColorContainer: Color
val onColorContainer: Color,
)

val unspecified_scheme = ColorFamily(
Color.Unspecified, Color.Unspecified, Color.Unspecified, Color.Unspecified
Color.Unspecified,
Color.Unspecified,
Color.Unspecified,
Color.Unspecified,
)

@Composable
fun KaigiTheme(
content: @Composable() () -> Unit
content:
@Composable()
() -> Unit,
) {
val colorScheme = darkScheme
val colorScheme = darkScheme
// val view = LocalView.current
// if (!view.isInEditMode) {
// SideEffect {
Expand All @@ -262,10 +268,9 @@ fun KaigiTheme(
// }
// }

MaterialTheme(
colorScheme = colorScheme,
typography = AppTypography,
content = content
)
MaterialTheme(
colorScheme = colorScheme,
typography = AppTypography,
content = content,
)
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package io.github.droidkaigi.confsched.designsystem.theme

import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp

val AppTypography = Typography()
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.github.droidkaigi.confsched.model.compositionlocal
import androidx.compose.runtime.compositionLocalOf
import kotlin.reflect.KClass

@Suppress("CompositionLocalAllowlist")
val LocalRepositories = compositionLocalOf<Map<KClass<*>, Any>> {
error("No LocalRepository provided")
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interface CaptureScreenRobot {

@Deprecated(
message = "Use captureScreenWithChecks instead and add checks to ensure screen contents are correct",
replaceWith = ReplaceWith("captureScreenWithChecks(checks)")
replaceWith = ReplaceWith("captureScreenWithChecks(checks)"),
)
fun captureScreenWithChecks()
}
Expand All @@ -69,7 +69,7 @@ class DefaultCaptureScreenRobot @Inject constructor(private val robotTestRule: R

@Deprecated(
"Use captureScreenWithChecks instead and add checks to ensure screen contents are correct",
replaceWith = ReplaceWith("captureScreenWithChecks(checks)")
replaceWith = ReplaceWith("captureScreenWithChecks(checks)"),
)
override fun captureScreenWithChecks() {
robotTestRule.captureScreen()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class RobotTestRule(
fun setContent(content: @Composable () -> Unit) {
val repositoryProvider = EntryPoints.get(
composeTestRule.activity.application,
RepositoryProviderEntryPoint::class.java
RepositoryProviderEntryPoint::class.java,
)
.getRepositoryProvider()
composeTestRule.setContent {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
package io.github.droidkaigi.confsched.testing.robot

import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.onFirst
import androidx.compose.ui.test.performClick
import io.github.droidkaigi.confsched.main.MainScreenTab
import io.github.droidkaigi.confsched.testing.DefaultScreenRobot
import io.github.droidkaigi.confsched.testing.DefaultWaitRobot
import io.github.droidkaigi.confsched.testing.RobotTestRule
import io.github.droidkaigi.confsched.testing.ScreenRobot
import kotlinx.coroutines.test.TestDispatcher
import javax.inject.Inject

class KaigiAppRobot @Inject constructor(
robotTestRule: RobotTestRule,
private val defaultScreenRobot: DefaultScreenRobot,
): ScreenRobot by defaultScreenRobot {
) : ScreenRobot by defaultScreenRobot {
@Inject lateinit var timetableScreenRobot: TimetableScreenRobot

fun goToAbout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TimetableItemDetailScreenRobot @Inject constructor(
suspend fun setupScreenContent() {
val firstSessionId = SessionsAllResponse.Companion.fake().sessions.first().id
robotTestRule.setContentWithNavigation(
startDestination = "timetableItemDetail/${firstSessionId}",
startDestination = "timetableItemDetail/$firstSessionId",
route = timetableItemDetailScreenRoute,
) {
KaigiTheme {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import javax.inject.Inject

class TimetableScreenRobot @Inject constructor(
private val screenRobot: DefaultScreenRobot,
private val timetableServerRobot: DefaultTimetableServerRobot
private val timetableServerRobot: DefaultTimetableServerRobot,
) : ScreenRobot by screenRobot,
TimetableServerRobot by timetableServerRobot{
TimetableServerRobot by timetableServerRobot {
fun setupTimetableScreenContent() {
robotTestRule.setContent {
CompositionLocalProvider(LocalClock provides FakeClock) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ actual fun getScreenSizeInfo(): ScreenInfo {
// val hDp = config.screenHeightDp.dp
// val wDp = config.screenWidthDp.dp
return ScreenInfo(
isPort = LocalConfiguration.current.orientation == Configuration.ORIENTATION_PORTRAIT
isPort = LocalConfiguration.current.orientation == Configuration.ORIENTATION_PORTRAIT,
)
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package io.github.droidkaigi.confsched.ui

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import io.github.droidkaigi.confsched.compose.ComposeEffectErrorHandler
import io.github.droidkaigi.confsched.compose.CompositionLocalProviderWithReturnValue
import io.github.droidkaigi.confsched.compose.LocalComposeEffectErrorHandler
import io.github.droidkaigi.confsched.designsystem.strings.Strings
import io.github.droidkaigi.confsched.ui.UserMessageResult.ActionPerformed
import kotlinx.coroutines.flow.Flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package io.github.droidkaigi.confsched.ui
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import io.github.droidkaigi.confsched.compose.ComposeEffectErrorHandler
import io.github.droidkaigi.confsched.compose.CompositionLocalProviderWithReturnValue
import io.github.droidkaigi.confsched.compose.LocalComposeEffectErrorHandler
import io.github.droidkaigi.confsched.compose.compositionLocalProviderWithReturnValue

@Composable
fun <T> providePresenterDefaults(
Expand All @@ -22,7 +22,7 @@ fun <T> providePresenterDefaults(
}
}
}
return CompositionLocalProviderWithReturnValue(LocalComposeEffectErrorHandler provides handler) {
return compositionLocalProviderWithReturnValue(LocalComposeEffectErrorHandler provides handler) {
block(userMessageStateHolder)
}
}
Loading

0 comments on commit f9dec20

Please sign in to comment.