diff --git a/.gitignore b/.gitignore index bfabf4d2..747b908f 100644 --- a/.gitignore +++ b/.gitignore @@ -114,6 +114,7 @@ obj/ .idea/assetWizardSettings.xml .idea/.gitignore .idea/gradle.xml +.idea/codeStyles/ deploymentTargetDropDown.xml diff --git a/app/.gitignore b/app/.gitignore index f9e0c6a6..7ddf34f0 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1,4 +1,5 @@ /build +/release .kotlin/ # Created by https://www.gitignore.io/api/kotlin,androidstudio diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 463c8a04..511729a6 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -2,24 +2,18 @@ import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { - alias(libs.plugins.android.application) - alias(libs.plugins.jetbrains.kotlin.android) - alias(libs.plugins.hilt.android) - alias(libs.plugins.kotlin.ksp) + id("missionmate.android.application") } android { namespace = "com.goalpanzi.mission_mate" - compileSdk = 34 defaultConfig { applicationId = "com.goalpanzi.mission_mate" - minSdk = 26 targetSdk = 34 - versionCode = 5 - versionName = "1.0.2" + versionCode = 6 + versionName = "1.0.3" - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true } @@ -46,23 +40,6 @@ android { isDebuggable = false } } - buildFeatures { - buildConfig = true - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlin { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_17) - } - } - packaging { - resources { - excludes += "/META-INF/{AL2.0,LGPL2.1}" - } - } } dependencies { diff --git a/build-logic/.gitignore b/build-logic/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/build-logic/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts new file mode 100644 index 00000000..087b57da --- /dev/null +++ b/build-logic/build.gradle.kts @@ -0,0 +1,27 @@ +plugins { + `kotlin-dsl` +} + +dependencies { + implementation(libs.android.gradle.plugin) + implementation(libs.kotlin.gradle.plugin) + compileOnly(libs.ksp.gradle.plugin) + compileOnly(libs.compose.compiler.gradle.plugin) +} + +gradlePlugin { + plugins { + register("androidApplication") { + id = "missionmate.android.application" + implementationClass = "MissionmateAndroidApplicationPlugin" + } + register("androidLibrary") { + id = "missionmate.android.library" + implementationClass = "MissionmateAndroidLibrary" + } + register("androidHilt") { + id = "missionmate.android.hilt" + implementationClass = "com.goalpanzi.mission_mate.convention.HiltAndroidPlugin" + } + } +} \ No newline at end of file diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts new file mode 100644 index 00000000..24909824 --- /dev/null +++ b/build-logic/settings.gradle.kts @@ -0,0 +1,14 @@ +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") +@Suppress("UnstableApiUsage") +dependencyResolutionManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} \ No newline at end of file diff --git a/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/AppNameExtension.kt b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/AppNameExtension.kt new file mode 100644 index 00000000..c9f1c957 --- /dev/null +++ b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/AppNameExtension.kt @@ -0,0 +1,9 @@ +package com.goalpanzi.mission_mate.convention + +import org.gradle.api.Project + +fun Project.setNamespace(name: String) { + androidExtension.apply { + namespace = "com.goalpanzi.mission_mate.$name" + } +} \ No newline at end of file diff --git a/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/ComposeAndroid.kt b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/ComposeAndroid.kt new file mode 100644 index 00000000..3e365d81 --- /dev/null +++ b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/ComposeAndroid.kt @@ -0,0 +1,41 @@ +package com.goalpanzi.mission_mate.convention + +import org.gradle.api.Project +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.getByType +import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension + +internal fun Project.configureComposeAndroid() { + with(plugins) { + apply("org.jetbrains.kotlin.plugin.compose") + } + + val libs = extensions.libs + androidExtension.apply { + buildFeatures { + compose = true + } + + dependencies { + val bom = libs.findLibrary("androidx-compose-bom").get() + implementation(platform(bom)) + implementation(libs.findLibrary("androidx.ui").get()) + implementation(libs.findLibrary("androidx.ui.graphics").get()) + implementation(libs.findLibrary("androidx.ui.tooling.preview").get()) + implementation(libs.findLibrary("androidx.material3").get()) + implementation(libs.findLibrary("androidx.material").get()) + implementation(libs.findLibrary("androidx.navigation.compose").get()) + implementation(libs.findLibrary("androidx.hilt.navigation.compose").get()) + + debugImplementation(libs.findLibrary("androidx.ui.tooling").get()) + debugImplementation(libs.findLibrary("androidx.ui.test.manifest").get()) + + androidTestImplementation(platform(bom)) + androidTestImplementation(libs.findLibrary("androidx.ui.test.junit4").get()) + } + } + + extensions.getByType().apply { + enableStrongSkippingMode.set(true) + } +} \ No newline at end of file diff --git a/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/CoroutineAndroid.kt b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/CoroutineAndroid.kt new file mode 100644 index 00000000..1549ebc6 --- /dev/null +++ b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/CoroutineAndroid.kt @@ -0,0 +1,20 @@ +package com.goalpanzi.mission_mate.convention + +import org.gradle.api.Project +import org.gradle.kotlin.dsl.dependencies + +internal fun Project.configureCoroutineAndroid() { + val libs = extensions.libs + configureCoroutineKotlin() + dependencies { + implementation(libs.findLibrary("coroutines.android").get()) + } +} + +internal fun Project.configureCoroutineKotlin() { + val libs = extensions.libs + dependencies { + implementation(libs.findLibrary("coroutines.core").get()) + testImplementation(libs.findLibrary("coroutines.test").get()) + } +} \ No newline at end of file diff --git a/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/Extension.kt b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/Extension.kt new file mode 100644 index 00000000..811bcd0b --- /dev/null +++ b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/Extension.kt @@ -0,0 +1,46 @@ +package com.goalpanzi.mission_mate.convention + +import com.android.build.api.dsl.ApplicationExtension +import com.android.build.api.dsl.CommonExtension +import com.android.build.api.dsl.LibraryExtension +import org.gradle.api.Project +import org.gradle.api.artifacts.VersionCatalog +import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.api.artifacts.dsl.DependencyHandler +import org.gradle.api.plugins.ExtensionContainer +import org.gradle.kotlin.dsl.getByType + +internal val ExtensionContainer.libs: VersionCatalog + get() = getByType().named("libs") + +internal val Project.androidExtension: CommonExtension<*, *, *, *, *, *> + get() = runCatching { libraryExtension } + .recoverCatching { applicationExtension } + .onFailure { println("Could not find Library or Application extension from this project") } + .getOrThrow() + +internal val Project.applicationExtension: CommonExtension<*, *, *, *, *, *> + get() = extensions.getByType() + +internal val Project.libraryExtension: CommonExtension<*, *, *, *, *, *> + get() = extensions.getByType() + +internal fun DependencyHandler.implementation(dependencyNotation: Any) { + add("implementation", dependencyNotation) +} + +internal fun DependencyHandler.testImplementation(dependencyNotation: Any) { + add("testImplementation", dependencyNotation) +} + +internal fun DependencyHandler.androidTestImplementation(dependencyNotation: Any) { + add("androidTestImplementation", dependencyNotation) +} + +internal fun DependencyHandler.debugImplementation(dependencyNotation: Any) { + add("debugImplementation", dependencyNotation) +} + +internal fun DependencyHandler.ksp(dependencyNotation: Any) { + add("ksp", dependencyNotation) +} diff --git a/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/HiltAndroid.kt b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/HiltAndroid.kt new file mode 100644 index 00000000..6fae6d10 --- /dev/null +++ b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/HiltAndroid.kt @@ -0,0 +1,26 @@ +package com.goalpanzi.mission_mate.convention + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.dependencies + +internal fun Project.configureHiltAndroid() { + with(pluginManager) { + apply("dagger.hilt.android.plugin") + apply("com.google.devtools.ksp") + } + + val libs = extensions.libs + dependencies { + implementation(libs.findLibrary("hilt.android").get()) + ksp(libs.findLibrary("hilt.compiler").get()) + } +} + +internal class HiltAndroidPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + configureHiltAndroid() + } + } +} \ No newline at end of file diff --git a/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/KotlinAndroid.kt b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/KotlinAndroid.kt new file mode 100644 index 00000000..8bc202db --- /dev/null +++ b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/KotlinAndroid.kt @@ -0,0 +1,51 @@ +package com.goalpanzi.mission_mate.convention + +import org.gradle.api.JavaVersion +import org.gradle.api.Project +import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +internal fun Project.configureKotlinAndroid() { + + pluginManager.apply("org.jetbrains.kotlin.android") + + androidExtension.apply { + compileSdk = 34 + + defaultConfig { + minSdk = 26 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + getByName("release") { + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + + buildFeatures { + buildConfig = true + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + tasks.withType().configureEach { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) + } + } + + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } + } +} \ No newline at end of file diff --git a/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/NetworkAndroid.kt b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/NetworkAndroid.kt new file mode 100644 index 00000000..09250390 --- /dev/null +++ b/build-logic/src/main/kotlin/com/goalpanzi/mission_mate/convention/NetworkAndroid.kt @@ -0,0 +1,15 @@ +package com.goalpanzi.mission_mate.convention + +import org.gradle.api.Project +import org.gradle.kotlin.dsl.dependencies + +internal fun Project.configureNetworkAndroid() { + val libs = extensions.libs + + dependencies { + implementation(libs.findLibrary("retrofit").get()) + implementation(libs.findLibrary("retrofit.kotlinx.serialization").get()) + implementation(libs.findLibrary("okhttp3").get()) + implementation(libs.findLibrary("okhttp3.logging.interceptor").get()) + } +} \ No newline at end of file diff --git a/build-logic/src/main/kotlin/missionmate.android.application.gradle.kts b/build-logic/src/main/kotlin/missionmate.android.application.gradle.kts new file mode 100644 index 00000000..e412c43b --- /dev/null +++ b/build-logic/src/main/kotlin/missionmate.android.application.gradle.kts @@ -0,0 +1,9 @@ +import com.goalpanzi.mission_mate.convention.configureHiltAndroid +import com.goalpanzi.mission_mate.convention.configureKotlinAndroid + +plugins { + id("com.android.application") +} + +configureKotlinAndroid() +configureHiltAndroid() diff --git a/build-logic/src/main/kotlin/missionmate.android.compose.gradle.kts b/build-logic/src/main/kotlin/missionmate.android.compose.gradle.kts new file mode 100644 index 00000000..4505dd59 --- /dev/null +++ b/build-logic/src/main/kotlin/missionmate.android.compose.gradle.kts @@ -0,0 +1,3 @@ +import com.goalpanzi.mission_mate.convention.configureComposeAndroid + +configureComposeAndroid() \ No newline at end of file diff --git a/build-logic/src/main/kotlin/missionmate.android.feature.gradle.kts b/build-logic/src/main/kotlin/missionmate.android.feature.gradle.kts new file mode 100644 index 00000000..9f74ffe0 --- /dev/null +++ b/build-logic/src/main/kotlin/missionmate.android.feature.gradle.kts @@ -0,0 +1,33 @@ +import com.goalpanzi.mission_mate.convention.configureHiltAndroid +import com.goalpanzi.mission_mate.convention.libs + +plugins { + id("missionmate.android.library") + id("missionmate.android.compose") +} + +android { + packaging { + resources { + excludes.add("META-INF/**") + } + } + defaultConfig { + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + +} + +configureHiltAndroid() + +dependencies { + implementation(project(":core:designsystem")) + implementation(project(":core:navigation")) + implementation(project(":core:domain:user")) + implementation(project(":core:domain:setting")) + implementation(project(":core:domain:mission")) + implementation(project(":core:domain:common")) + implementation(project(":core:domain:auth")) + implementation(project(":core:ui")) + +} \ No newline at end of file diff --git a/build-logic/src/main/kotlin/missionmate.android.library.gradle.kts b/build-logic/src/main/kotlin/missionmate.android.library.gradle.kts new file mode 100644 index 00000000..14e2b79d --- /dev/null +++ b/build-logic/src/main/kotlin/missionmate.android.library.gradle.kts @@ -0,0 +1,11 @@ +import com.goalpanzi.mission_mate.convention.configureCoroutineAndroid +import com.goalpanzi.mission_mate.convention.configureHiltAndroid +import com.goalpanzi.mission_mate.convention.configureKotlinAndroid + +plugins { + id("com.android.library") +} + +configureKotlinAndroid() +configureCoroutineAndroid() +configureHiltAndroid() diff --git a/build.gradle.kts b/build.gradle.kts index 344707f2..ea0083a2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,12 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. +@file:Suppress("DSL_SCOPE_VIOLATION") + +buildscript { + repositories { + google() + mavenCentral() + } +} + plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.jetbrains.kotlin.android) apply false diff --git a/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/AuthTokenProvider.kt b/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/AuthTokenProvider.kt index 034d3ced..684170f1 100644 --- a/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/AuthTokenProvider.kt +++ b/core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/AuthTokenProvider.kt @@ -2,6 +2,7 @@ package com.goalpanzi.mission_mate.core.data.auth import com.goalpanzi.mission_mate.core.datastore.datasource.AuthDataSource import com.goalpanzi.mission_mate.core.network.TokenProvider +import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.firstOrNull import javax.inject.Inject @@ -17,12 +18,10 @@ class AuthTokenProvider @Inject constructor( } override suspend fun setAccessToken(accessToken: String) { - authDataSource.setAccessToken(accessToken) + authDataSource.setAccessToken(accessToken).collect() } override suspend fun setRefreshToken(refreshToken: String) { - authDataSource.setRefreshToken(refreshToken) + authDataSource.setRefreshToken(refreshToken).collect() } - - } diff --git a/core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/board/di/MissionDataModule.kt b/core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/mission/di/MissionDataModule.kt similarity index 75% rename from core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/board/di/MissionDataModule.kt rename to core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/mission/di/MissionDataModule.kt index f84c0d61..9286ac0a 100644 --- a/core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/board/di/MissionDataModule.kt +++ b/core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/mission/di/MissionDataModule.kt @@ -1,7 +1,7 @@ -package com.goalpanzi.mission_mate.core.board.di +package com.goalpanzi.mission_mate.core.mission.di -import com.goalpanzi.mission_mate.core.board.repository.MissionRepositoryImpl import com.goalpanzi.mission_mate.core.domain.mission.repository.MissionRepository +import com.goalpanzi.mission_mate.core.mission.repository.MissionRepositoryImpl import dagger.Binds import dagger.Module import dagger.hilt.InstallIn diff --git a/core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/board/mapper/MissionMapper.kt b/core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/mission/mapper/MissionMapper.kt similarity index 94% rename from core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/board/mapper/MissionMapper.kt rename to core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/mission/mapper/MissionMapper.kt index 832cfb1a..84a185bd 100644 --- a/core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/board/mapper/MissionMapper.kt +++ b/core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/mission/mapper/MissionMapper.kt @@ -1,4 +1,4 @@ -package com.goalpanzi.mission_mate.core.board.mapper +package com.goalpanzi.mission_mate.core.mission.mapper import com.goalpanzi.mission_mate.core.data.common.mapper.toModel import com.goalpanzi.mission_mate.core.domain.mission.model.BoardReward @@ -43,6 +43,7 @@ fun MissionBoardResponse.toModel() : MissionBoard { fun MissionBoardMembersResponse.toModel() : MissionBoardMembers { return MissionBoardMembers( + memberId = memberId, nickname = nickname, characterType = characterType.toModel() ) @@ -69,7 +70,9 @@ fun MissionVerificationResponse.toModel() : MissionVerification { nickname = nickname, characterType = characterType.toModel(), imageUrl = imageUrl, - verifiedAt = verifiedAt + verifiedAt = verifiedAt, + viewedAt = viewedAt, + missionVerificationId = missionVerificationId ) } diff --git a/core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/board/repository/MissionRepositoryImpl.kt b/core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/mission/repository/MissionRepositoryImpl.kt similarity index 81% rename from core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/board/repository/MissionRepositoryImpl.kt rename to core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/mission/repository/MissionRepositoryImpl.kt index 996d7a44..00ac2bb4 100644 --- a/core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/board/repository/MissionRepositoryImpl.kt +++ b/core/data/mission/src/main/java/com/goalpanzi/mission_mate/core/mission/repository/MissionRepositoryImpl.kt @@ -1,8 +1,7 @@ -package com.goalpanzi.mission_mate.core.board.repository +package com.goalpanzi.mission_mate.core.mission.repository -import com.goalpanzi.mission_mate.core.board.mapper.toModel +import com.goalpanzi.mission_mate.core.mission.mapper.toModel import com.goalpanzi.mission_mate.core.data.common.handleResult -import com.goalpanzi.mission_mate.core.data.common.mapper.toModel import com.goalpanzi.mission_mate.core.datastore.datasource.MissionDataSource import com.goalpanzi.mission_mate.core.domain.common.DomainResult import com.goalpanzi.mission_mate.core.domain.common.convert @@ -12,6 +11,8 @@ import com.goalpanzi.mission_mate.core.domain.mission.model.MissionRank import com.goalpanzi.mission_mate.core.domain.mission.model.MissionVerification import com.goalpanzi.mission_mate.core.domain.mission.model.MissionVerifications import com.goalpanzi.mission_mate.core.domain.mission.repository.MissionRepository +import com.goalpanzi.mission_mate.core.network.model.request.CompleteMissionRequest +import com.goalpanzi.mission_mate.core.network.model.request.MissionVerificationsViewRequest import com.goalpanzi.mission_mate.core.network.service.MissionService import kotlinx.coroutines.flow.Flow import okhttp3.MediaType.Companion.toMediaTypeOrNull @@ -78,6 +79,18 @@ class MissionRepositoryImpl @Inject constructor( it.toModel() } + override suspend fun viewVerification(missionVerificationId: Long): DomainResult = handleResult { + missionService.viewVerification(MissionVerificationsViewRequest(missionVerificationId)) + }.convert { + it.toModel() + } + + override suspend fun completeMission(missionId: Long): DomainResult = handleResult { + missionService.completeMission( + CompleteMissionRequest(missionId) + ) + } + override fun clearMissionData(): Flow = missionDataSource.clearMissionData() override fun setIsMissionJoined(data: Boolean): Flow = missionDataSource.setIsMissionJoined(data) diff --git a/core/data/onboarding/src/main/java/com/goalpanzi/mission_mate/core/data/onboarding/mapper/OnboardingMapper.kt b/core/data/onboarding/src/main/java/com/goalpanzi/mission_mate/core/data/onboarding/mapper/OnboardingMapper.kt index 368afc65..09258e0b 100644 --- a/core/data/onboarding/src/main/java/com/goalpanzi/mission_mate/core/data/onboarding/mapper/OnboardingMapper.kt +++ b/core/data/onboarding/src/main/java/com/goalpanzi/mission_mate/core/data/onboarding/mapper/OnboardingMapper.kt @@ -1,11 +1,13 @@ package com.goalpanzi.mission_mate.core.data.onboarding.mapper import com.goalpanzi.mission_mate.core.data.common.mapper.toModel +import com.goalpanzi.mission_mate.core.domain.common.model.mission.MissionStatus import com.goalpanzi.mission_mate.core.domain.onboarding.model.CreateMissionBody import com.goalpanzi.mission_mate.core.domain.onboarding.model.Mission import com.goalpanzi.mission_mate.core.domain.onboarding.model.Missions import com.goalpanzi.mission_mate.core.network.model.request.CreateMissionRequest import com.goalpanzi.mission_mate.core.network.model.response.MissionResponse +import com.goalpanzi.mission_mate.core.network.model.response.MissionStatusResponse import com.goalpanzi.mission_mate.core.network.model.response.MissionsResponse fun CreateMissionBody.toRequest() : CreateMissionRequest { @@ -23,7 +25,7 @@ fun MissionResponse.toModel() : Mission { return Mission( missionId = missionId, description = description, - missionStatus = missionStatus + missionStatus = missionStatus.toModel() ) } @@ -36,3 +38,11 @@ fun MissionsResponse.toModel() : Missions { } ) } + +fun MissionStatusResponse.toModel() : MissionStatus { + return try{ + MissionStatus.valueOf(this.name) + }catch (e : Exception){ + MissionStatus.COMPLETED + } +} diff --git a/core/data/onboarding/src/main/java/com/goalpanzi/mission_mate/core/data/onboarding/repository/OnboardingRepositoryImpl.kt b/core/data/onboarding/src/main/java/com/goalpanzi/mission_mate/core/data/onboarding/repository/OnboardingRepositoryImpl.kt index b88aba05..bdd8a954 100644 --- a/core/data/onboarding/src/main/java/com/goalpanzi/mission_mate/core/data/onboarding/repository/OnboardingRepositoryImpl.kt +++ b/core/data/onboarding/src/main/java/com/goalpanzi/mission_mate/core/data/onboarding/repository/OnboardingRepositoryImpl.kt @@ -1,6 +1,6 @@ package com.goalpanzi.mission_mate.core.data.onboarding.repository -import com.goalpanzi.mission_mate.core.board.mapper.toModel +import com.goalpanzi.mission_mate.core.mission.mapper.toModel import com.goalpanzi.mission_mate.core.data.common.handleResult import com.goalpanzi.mission_mate.core.data.onboarding.mapper.toModel import com.goalpanzi.mission_mate.core.data.onboarding.mapper.toRequest @@ -34,7 +34,7 @@ class OnboardingRepositoryImpl @Inject constructor( onboardingService.joinMission(JoinMissionRequest(invitationCode)) } - override suspend fun getJoinedMissions(): DomainResult = handleResult { - onboardingService.getJoinedMissions() + override suspend fun getJoinedMissions(filter : String): DomainResult = handleResult { + onboardingService.getJoinedMissions(filter) }.convert { it.toModel() } } diff --git a/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/component/TextField.kt b/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/component/TextField.kt index ea87518e..a0024c6b 100644 --- a/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/component/TextField.kt +++ b/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/component/TextField.kt @@ -34,7 +34,6 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.goalpanzi.mission_mate.core.designsystem.R import com.goalpanzi.mission_mate.core.designsystem.theme.ColorGray1_FF404249 -import com.goalpanzi.mission_mate.core.designsystem.theme.ColorGray2_FF4F505C import com.goalpanzi.mission_mate.core.designsystem.theme.ColorGray3_FF727484 import com.goalpanzi.mission_mate.core.designsystem.theme.ColorGray4_FFE5E5E5 import com.goalpanzi.mission_mate.core.designsystem.theme.ColorGray5_FFF5F6F9 diff --git a/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/ext/Modifier.kt b/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/ext/Modifier.kt index be858e39..aa43a700 100644 --- a/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/ext/Modifier.kt +++ b/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/ext/Modifier.kt @@ -1,9 +1,12 @@ package com.goalpanzi.mission_mate.core.designsystem.ext import android.graphics.BlurMaskFilter +import androidx.compose.foundation.LocalIndication import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.composed import androidx.compose.ui.draw.drawBehind import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.Color @@ -11,8 +14,11 @@ import androidx.compose.ui.graphics.Paint import androidx.compose.ui.graphics.Shape import androidx.compose.ui.graphics.drawOutline import androidx.compose.ui.graphics.drawscope.drawIntoCanvas +import androidx.compose.ui.semantics.Role import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import com.goalpanzi.mission_mate.core.designsystem.util.MultipleEventsCutter +import com.goalpanzi.mission_mate.core.designsystem.util.get fun Modifier.dropShadow( shape: Shape, @@ -54,4 +60,21 @@ fun Modifier.clickableWithoutRipple( ) ) -} \ No newline at end of file +} + +fun Modifier.clickableSingle( + enabled: Boolean = true, + onClickLabel: String? = null, + role: Role? = null, + onClick: () -> Unit +) = composed { + val multipleEventsCutter = remember { MultipleEventsCutter.get() } + Modifier.clickable( + enabled = enabled, + onClickLabel = onClickLabel, + onClick = { multipleEventsCutter.processEvent { onClick() } }, + role = role, + indication = LocalIndication.current, + interactionSource = remember { MutableInteractionSource() } + ) +} diff --git a/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/util/MultipleEventsCutter.kt b/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/util/MultipleEventsCutter.kt new file mode 100644 index 00000000..15783cfc --- /dev/null +++ b/core/designsystem/src/main/java/com/goalpanzi/mission_mate/core/designsystem/util/MultipleEventsCutter.kt @@ -0,0 +1,25 @@ +package com.goalpanzi.mission_mate.core.designsystem.util + + +interface MultipleEventsCutter { + fun processEvent(event: () -> Unit) + + companion object +} + +fun MultipleEventsCutter.Companion.get(): MultipleEventsCutter = + MultipleEventsCutterImpl() + +private class MultipleEventsCutterImpl : MultipleEventsCutter { + private val now: Long + get() = System.currentTimeMillis() + + private var lastEventTimeMs: Long = 0 + + override fun processEvent(event: () -> Unit) { + if (now - lastEventTimeMs >= 300L) { + event.invoke() + } + lastEventTimeMs = now + } +} diff --git a/core/domain/auth/src/main/java/com/goalpanzi/mission_mate/core/domain/auth/usecase/LoginUseCase.kt b/core/domain/auth/src/main/java/com/goalpanzi/mission_mate/core/domain/auth/usecase/LoginUseCase.kt index 42f40bc4..31208cd1 100644 --- a/core/domain/auth/src/main/java/com/goalpanzi/mission_mate/core/domain/auth/usecase/LoginUseCase.kt +++ b/core/domain/auth/src/main/java/com/goalpanzi/mission_mate/core/domain/auth/usecase/LoginUseCase.kt @@ -22,7 +22,7 @@ class LoginUseCase @Inject constructor( authRepository.setRefreshToken(it.refreshToken).first() userRepository.setMemberId(it.memberId).first() (it.nickname to it.characterType).let { (nickname, character) -> - if (nickname != null && character != null) { + if (nickname != null) { userRepository.setUserProfile( UserProfile(nickname, character) ).first() diff --git a/core/domain/common/src/main/java/com/goalpanzi/mission_mate/core/domain/common/model/mission/MissionStatus.kt b/core/domain/common/src/main/java/com/goalpanzi/mission_mate/core/domain/common/model/mission/MissionStatus.kt new file mode 100644 index 00000000..02c4ac56 --- /dev/null +++ b/core/domain/common/src/main/java/com/goalpanzi/mission_mate/core/domain/common/model/mission/MissionStatus.kt @@ -0,0 +1,17 @@ +package com.goalpanzi.mission_mate.core.domain.common.model.mission + +enum class MissionStatus { + CREATED, + CANCELED, + IN_PROGRESS, + DELETED, + PENDING_COMPLETION, + COMPLETED; + + companion object { + val statusString: String = listOf(CREATED, CANCELED, IN_PROGRESS, PENDING_COMPLETION) + .joinToString(",") { it.name } + } +} + + diff --git a/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/model/MissionBoardMembers.kt b/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/model/MissionBoardMembers.kt index 4883a4cd..399e22fb 100644 --- a/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/model/MissionBoardMembers.kt +++ b/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/model/MissionBoardMembers.kt @@ -3,6 +3,7 @@ package com.goalpanzi.mission_mate.core.domain.mission.model import com.goalpanzi.mission_mate.core.domain.common.model.user.CharacterType data class MissionBoardMembers( + val memberId : Long, val nickname : String, val characterType : CharacterType = CharacterType.RABBIT ) diff --git a/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/model/MissionVerification.kt b/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/model/MissionVerification.kt index 288c5530..d3091741 100644 --- a/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/model/MissionVerification.kt +++ b/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/model/MissionVerification.kt @@ -6,5 +6,7 @@ data class MissionVerification( val nickname : String, val characterType : CharacterType = CharacterType.RABBIT, val imageUrl : String = "", - val verifiedAt : String = "" + val verifiedAt : String = "", + val missionVerificationId : Long = 0, + val viewedAt : String = "" ) diff --git a/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/repository/MissionRepository.kt b/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/repository/MissionRepository.kt index 1bc04455..ba07c562 100644 --- a/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/repository/MissionRepository.kt +++ b/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/repository/MissionRepository.kt @@ -24,6 +24,10 @@ interface MissionRepository { suspend fun getMyMissionVerification(missionId: Long, number : Int) : DomainResult + suspend fun completeMission(missionId : Long) : DomainResult + + suspend fun viewVerification(missionVerificationId : Long) : DomainResult + fun clearMissionData() : Flow fun setIsMissionJoined(data: Boolean) : Flow fun getIsMissionJoined() : Flow diff --git a/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/usecase/CompleteMissionUseCase.kt b/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/usecase/CompleteMissionUseCase.kt new file mode 100644 index 00000000..3ad33a3e --- /dev/null +++ b/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/usecase/CompleteMissionUseCase.kt @@ -0,0 +1,16 @@ +package com.goalpanzi.mission_mate.core.domain.mission.usecase + +import com.goalpanzi.mission_mate.core.domain.common.DomainResult +import com.goalpanzi.mission_mate.core.domain.mission.repository.MissionRepository +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow +import javax.inject.Inject + +class CompleteMissionUseCase @Inject constructor( + private val missionRepository: MissionRepository +) { + operator fun invoke(missionId: Long) : Flow> = flow { + emit(missionRepository.completeMission(missionId)) + } +} + diff --git a/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/usecase/VerifyMissionUseCase.kt b/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/usecase/VerifyMissionUseCase.kt index 17c12fd3..4cb28491 100644 --- a/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/usecase/VerifyMissionUseCase.kt +++ b/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/usecase/VerifyMissionUseCase.kt @@ -10,7 +10,7 @@ import javax.inject.Inject class VerifyMissionUseCase @Inject constructor( private val missionRepository: MissionRepository ) { - suspend operator fun invoke(missionId: Long, image: File) : Flow> = flow { + operator fun invoke(missionId: Long, image: File) : Flow> = flow { emit(missionRepository.verifyMission(missionId, image)) } } diff --git a/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/usecase/ViewVerificationUseCase.kt b/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/usecase/ViewVerificationUseCase.kt new file mode 100644 index 00000000..f040dc62 --- /dev/null +++ b/core/domain/mission/src/main/java/com/goalpanzi/mission_mate/core/domain/mission/usecase/ViewVerificationUseCase.kt @@ -0,0 +1,17 @@ +package com.goalpanzi.mission_mate.core.domain.mission.usecase + +import com.goalpanzi.mission_mate.core.domain.common.DomainResult +import com.goalpanzi.mission_mate.core.domain.mission.model.MissionVerification +import com.goalpanzi.mission_mate.core.domain.mission.repository.MissionRepository +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow +import javax.inject.Inject + +class ViewVerificationUseCase @Inject constructor( + private val missionRepository: MissionRepository +) { + operator fun invoke(missionVerificationId: Long) : Flow> = flow { + emit(missionRepository.viewVerification(missionVerificationId)) + } +} + diff --git a/core/domain/onboarding/src/main/java/com/goalpanzi/mission_mate/core/domain/onboarding/model/Mission.kt b/core/domain/onboarding/src/main/java/com/goalpanzi/mission_mate/core/domain/onboarding/model/Mission.kt index d38bd377..9ed9f17a 100644 --- a/core/domain/onboarding/src/main/java/com/goalpanzi/mission_mate/core/domain/onboarding/model/Mission.kt +++ b/core/domain/onboarding/src/main/java/com/goalpanzi/mission_mate/core/domain/onboarding/model/Mission.kt @@ -1,7 +1,9 @@ package com.goalpanzi.mission_mate.core.domain.onboarding.model +import com.goalpanzi.mission_mate.core.domain.common.model.mission.MissionStatus + data class Mission( val missionId : Long, val description : String, - val missionStatus : String + val missionStatus : MissionStatus ) diff --git a/core/domain/onboarding/src/main/java/com/goalpanzi/mission_mate/core/domain/onboarding/repository/OnboardingRepository.kt b/core/domain/onboarding/src/main/java/com/goalpanzi/mission_mate/core/domain/onboarding/repository/OnboardingRepository.kt index 79ce0bcb..f7c4901b 100644 --- a/core/domain/onboarding/src/main/java/com/goalpanzi/mission_mate/core/domain/onboarding/repository/OnboardingRepository.kt +++ b/core/domain/onboarding/src/main/java/com/goalpanzi/mission_mate/core/domain/onboarding/repository/OnboardingRepository.kt @@ -18,5 +18,5 @@ interface OnboardingRepository { invitationCode: String ) : DomainResult - suspend fun getJoinedMissions() : DomainResult + suspend fun getJoinedMissions(filter : String) : DomainResult } diff --git a/core/domain/onboarding/src/main/java/com/goalpanzi/mission_mate/core/domain/onboarding/usecase/GetJoinedMissionsUseCase.kt b/core/domain/onboarding/src/main/java/com/goalpanzi/mission_mate/core/domain/onboarding/usecase/GetJoinedMissionsUseCase.kt index 0b4f43a5..7f8ed255 100644 --- a/core/domain/onboarding/src/main/java/com/goalpanzi/mission_mate/core/domain/onboarding/usecase/GetJoinedMissionsUseCase.kt +++ b/core/domain/onboarding/src/main/java/com/goalpanzi/mission_mate/core/domain/onboarding/usecase/GetJoinedMissionsUseCase.kt @@ -10,7 +10,7 @@ import javax.inject.Inject class GetJoinedMissionsUseCase @Inject constructor( private val onboardingRepository: OnboardingRepository ) { - operator fun invoke(): Flow> = flow { - emit(onboardingRepository.getJoinedMissions()) + operator fun invoke(filter : String): Flow> = flow { + emit(onboardingRepository.getJoinedMissions(filter)) } } diff --git a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/CompleteMissionRequest.kt b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/CompleteMissionRequest.kt new file mode 100644 index 00000000..8fc31113 --- /dev/null +++ b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/CompleteMissionRequest.kt @@ -0,0 +1,8 @@ +package com.goalpanzi.mission_mate.core.network.model.request + +import kotlinx.serialization.Serializable + +@Serializable +data class CompleteMissionRequest( + val missionId : Long +) diff --git a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/MissionVerificationsViewRequest.kt b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/MissionVerificationsViewRequest.kt new file mode 100644 index 00000000..7d8626f7 --- /dev/null +++ b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/request/MissionVerificationsViewRequest.kt @@ -0,0 +1,8 @@ +package com.goalpanzi.mission_mate.core.network.model.request + +import kotlinx.serialization.Serializable + +@Serializable +data class MissionVerificationsViewRequest( + val missionVerificationId : Long +) diff --git a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionBoardMembersResponse.kt b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionBoardMembersResponse.kt index 6183efe5..a673c1af 100644 --- a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionBoardMembersResponse.kt +++ b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionBoardMembersResponse.kt @@ -4,7 +4,7 @@ import kotlinx.serialization.Serializable @Serializable data class MissionBoardMembersResponse( - //val memberId : Long, + val memberId : Long, val nickname : String, val characterType : CharacterTypeResponse = CharacterTypeResponse.RABBIT ) diff --git a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionResponse.kt b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionResponse.kt index 6da3156c..245f3ace 100644 --- a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionResponse.kt +++ b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionResponse.kt @@ -6,5 +6,5 @@ import kotlinx.serialization.Serializable data class MissionResponse( val missionId : Long, val description : String, - val missionStatus : String + val missionStatus : MissionStatusResponse ) diff --git a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionStatusResponse.kt b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionStatusResponse.kt new file mode 100644 index 00000000..fc15064c --- /dev/null +++ b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionStatusResponse.kt @@ -0,0 +1,10 @@ +package com.goalpanzi.mission_mate.core.network.model.response + +enum class MissionStatusResponse { + CREATED, + CANCELED, + IN_PROGRESS, + DELETED, + PENDING_COMPLETION, + COMPLETED +} diff --git a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionVerificationResponse.kt b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionVerificationResponse.kt index c3b3dbdb..f067ddd7 100644 --- a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionVerificationResponse.kt +++ b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/model/response/MissionVerificationResponse.kt @@ -7,5 +7,7 @@ data class MissionVerificationResponse( val nickname : String, val characterType : CharacterTypeResponse =CharacterTypeResponse.RABBIT, val imageUrl : String = "", - val verifiedAt : String = "" + val verifiedAt : String = "", + val missionVerificationId : Long = 0, + val viewedAt : String = "" ) diff --git a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/service/MissionService.kt b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/service/MissionService.kt index 1880a5fa..46b2a072 100644 --- a/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/service/MissionService.kt +++ b/core/network/src/main/java/com/goalpanzi/mission_mate/core/network/service/MissionService.kt @@ -1,5 +1,7 @@ package com.goalpanzi.mission_mate.core.network.service +import com.goalpanzi.mission_mate.core.network.model.request.CompleteMissionRequest +import com.goalpanzi.mission_mate.core.network.model.request.MissionVerificationsViewRequest import com.goalpanzi.mission_mate.core.network.model.response.MissionBoardsResponse import com.goalpanzi.mission_mate.core.network.model.response.MissionDetailResponse import com.goalpanzi.mission_mate.core.network.model.response.MissionRankResponse @@ -7,6 +9,7 @@ import com.goalpanzi.mission_mate.core.network.model.response.MissionVerificatio import com.goalpanzi.mission_mate.core.network.model.response.MissionVerificationsResponse import okhttp3.MultipartBody import retrofit2.Response +import retrofit2.http.Body import retrofit2.http.DELETE import retrofit2.http.GET import retrofit2.http.Multipart @@ -32,6 +35,11 @@ interface MissionService { @Path("missionId") missionId: Long ) : Response + @POST("/api/missions/verifications/view") + suspend fun viewVerification( + @Body body : MissionVerificationsViewRequest + ) : Response + @DELETE("/api/missions/{missionId}") suspend fun deleteMission( @Path("missionId") missionId: Long @@ -54,4 +62,9 @@ interface MissionService { @Path("missionId") missionId: Long, @Path("number") number: Int ) : Response + + @POST("/api/mission-members/complete") + suspend fun completeMission( + @Body request: CompleteMissionRequest + ): Response } diff --git a/feature/main/src/test/java/com/goalpanzi/mission_mate/core/main/ExampleUnitTest.kt b/core/network/src/test/java/com/goalpanzi/mission_mate/feature/network/ExampleUnitTest.kt similarity index 86% rename from feature/main/src/test/java/com/goalpanzi/mission_mate/core/main/ExampleUnitTest.kt rename to core/network/src/test/java/com/goalpanzi/mission_mate/feature/network/ExampleUnitTest.kt index 0babf065..d052bb4d 100644 --- a/feature/main/src/test/java/com/goalpanzi/mission_mate/core/main/ExampleUnitTest.kt +++ b/core/network/src/test/java/com/goalpanzi/mission_mate/feature/network/ExampleUnitTest.kt @@ -1,4 +1,4 @@ -package com.goalpanzi.mission_mate.core.main +package com.goalpanzi.mission_mate.feature.network import org.junit.Test diff --git a/core/ui/src/androidTest/java/com/goalpanzi/mission_mate/core/ui/ExampleInstrumentedTest.kt b/core/ui/src/androidTest/java/com/goalpanzi/mission_mate/feature/ui/ExampleInstrumentedTest.kt similarity index 93% rename from core/ui/src/androidTest/java/com/goalpanzi/mission_mate/core/ui/ExampleInstrumentedTest.kt rename to core/ui/src/androidTest/java/com/goalpanzi/mission_mate/feature/ui/ExampleInstrumentedTest.kt index 885813eb..e8c5ea84 100644 --- a/core/ui/src/androidTest/java/com/goalpanzi/mission_mate/core/ui/ExampleInstrumentedTest.kt +++ b/core/ui/src/androidTest/java/com/goalpanzi/mission_mate/feature/ui/ExampleInstrumentedTest.kt @@ -1,4 +1,4 @@ -package com.goalpanzi.mission_mate.core.ui +package com.goalpanzi.mission_mate.feature.ui import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 diff --git a/core/ui/src/test/java/com/goalpanzi/mission_mate/core/ui/ExampleUnitTest.kt b/core/ui/src/test/java/com/goalpanzi/mission_mate/feature/ui/ExampleUnitTest.kt similarity index 87% rename from core/ui/src/test/java/com/goalpanzi/mission_mate/core/ui/ExampleUnitTest.kt rename to core/ui/src/test/java/com/goalpanzi/mission_mate/feature/ui/ExampleUnitTest.kt index 923e3365..c317e760 100644 --- a/core/ui/src/test/java/com/goalpanzi/mission_mate/core/ui/ExampleUnitTest.kt +++ b/core/ui/src/test/java/com/goalpanzi/mission_mate/feature/ui/ExampleUnitTest.kt @@ -1,4 +1,4 @@ -package com.goalpanzi.mission_mate.core.ui +package com.goalpanzi.mission_mate.feature.ui import org.junit.Test diff --git a/feature/board/build.gradle.kts b/feature/board/build.gradle.kts index b930ed82..50f932da 100644 --- a/feature/board/build.gradle.kts +++ b/feature/board/build.gradle.kts @@ -1,76 +1,24 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import com.goalpanzi.mission_mate.convention.setNamespace plugins { - alias(libs.plugins.android.library) - alias(libs.plugins.jetbrains.kotlin.android) - alias(libs.plugins.compose.compiler) - alias(libs.plugins.kotlin.ksp) - alias(libs.plugins.hilt.android) + id("missionmate.android.feature") } android { - namespace = "com.goalpanzi.mission_mate.feature.board" - compileSdk = 34 - - defaultConfig { - minSdk = 26 - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" - ) - } - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlin { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_17) - } - } - buildFeatures { - compose = true - } - composeCompiler { - enableStrongSkippingMode = true - } + setNamespace("feature.board") } dependencies { implementation(libs.androidx.core.ktx) implementation(libs.bundles.lifecycle) - implementation(platform(libs.androidx.compose.bom)) - implementation(libs.bundles.compose) implementation(libs.bundles.coroutines) - testImplementation(libs.bundles.test) androidTestImplementation(libs.bundles.android.test) - androidTestImplementation(platform(libs.androidx.compose.bom)) - debugImplementation(libs.androidx.ui.tooling) - debugImplementation(libs.androidx.ui.test.manifest) - - implementation(libs.androidx.hilt.navigation.compose) - implementation(libs.hilt.android) - ksp(libs.hilt.compiler) implementation(libs.balloon) implementation(libs.coil.compose) - implementation(project(":core:designsystem")) - implementation(project(":core:navigation")) - implementation(project(":core:domain:user")) - implementation(project(":core:domain:setting")) - implementation(project(":core:domain:mission")) - implementation(project(":core:domain:common")) - implementation(project(":core:ui")) implementation(project(":feature:onboarding")) } diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/BoardNavigation.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/BoardNavigation.kt index 7b8abd5a..2cf14bb0 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/BoardNavigation.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/BoardNavigation.kt @@ -101,8 +101,8 @@ fun NavGraphBuilder.boardFinishNavGraph( arguments = listOf(navArgument(missionIdArg) { type = NavType.LongType }) ) { BoardFinishRoute( - onClickSetting = onClickSetting, - onClickOk = onClickOk + onSettingClick = onClickSetting, + onOkClick = onClickOk ) } } diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/Block.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/Block.kt index 0feb5a71..1524d168 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/Block.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/Block.kt @@ -125,15 +125,9 @@ fun BlockImage( Spacer(modifier = modifier) }else { StableImage( - modifier = modifier.then( - if (isStartedMission && isPassed) { - Modifier.clickable { - onClickPassedBlock(index) - } - } else { - Modifier - } - ), + modifier = modifier.clickable(isStartedMission && isPassed && index != 0){ + onClickPassedBlock(index) + } , drawableResId = drawableRes, contentScale = ContentScale.FillWidth ) diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/Board.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/Board.kt index 610e734b..7c6e82bc 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/Board.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/Board.kt @@ -2,8 +2,8 @@ package com.goalpanzi.mission_mate.feature.board.component import android.annotation.SuppressLint import androidx.compose.animation.core.animateDpAsState -import androidx.compose.animation.core.tween import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.LocalOverscrollConfiguration import androidx.compose.foundation.ScrollState import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxWithConstraints @@ -19,7 +19,6 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.verticalScroll @@ -29,6 +28,7 @@ import androidx.compose.material.pullrefresh.PullRefreshState import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue @@ -58,7 +58,7 @@ import com.goalpanzi.mission_mate.feature.board.util.BoardManager import com.goalpanzi.mission_mate.feature.board.util.BoardManager.getPositionScrollToMyIndex import kotlin.math.min -@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterialApi::class) +@OptIn(ExperimentalMaterialApi::class, ExperimentalFoundationApi::class) @Composable fun Board( scrollState: ScrollState, @@ -102,7 +102,7 @@ fun Board( LaunchedEffect(myIndex) { scrollState.animateScrollTo( getPositionScrollToMyIndex( - myIndex = myIndex, + myIndex = if(myIndex in 3 .. 5) myIndex - 3 else myIndex, numberOfColumns = numberOfColumns, blockSize = (configuration.screenWidthDp - 48) / numberOfColumns, localDensity = localDensity @@ -176,33 +176,39 @@ fun Board( modifier ) } + if (isVisiblePieces) { - Column( - modifier = modifier.modifierWithClipRect( - scrollState = scrollState, - isVisiblePieces = isVisiblePieces, - innerModifier = Modifier - .drawWithContent { - clipRect(top = (size.height + navigationBarHeight.toPx() - bottomViewHeight.toPx() + 1.dp.toPx())) { - this@drawWithContent.drawContent() - } - } - .blur(10.dp, 10.dp) - ) - ) { - Spacer(modifier = Modifier.height(refreshingSpacerSize)) - BoardContent( - missionBoards, - missionDetail, - numberOfColumns, - boardPieces, - profile, - missionState, - isVisiblePieces = isVisiblePieces, - onClickPassedBlock = onClickPassedBlock, - modifier - ) - } + CompositionLocalProvider( + LocalOverscrollConfiguration provides null, + content = { + Column( + modifier = modifier.modifierWithClipRect( + scrollState = scrollState, + isVisiblePieces = isVisiblePieces, + innerModifier = Modifier + .drawWithContent { + clipRect(top = (size.height + navigationBarHeight.toPx() - bottomViewHeight.toPx() + 1.dp.toPx())) { + this@drawWithContent.drawContent() + } + } + .blur(10.dp, 10.dp) + ) + ) { + Spacer(modifier = Modifier.height(refreshingSpacerSize)) + BoardContent( + missionBoards, + missionDetail, + numberOfColumns, + boardPieces, + profile, + missionState, + isVisiblePieces = isVisiblePieces, + onClickPassedBlock = onClickPassedBlock, + modifier + ) + } + } + ) } PullRefreshIndicator( refreshing = isRefreshLoading, @@ -285,7 +291,7 @@ fun ColumnScope.BoardContent( } if (isVisiblePieces) { boardPieces.forEach { piece -> - key(piece.nickname) { + key(piece.memberId,piece.needToDraw) { Piece( boardPiece = piece, sizePerBlock = width / numberOfColumns, @@ -298,7 +304,6 @@ fun ColumnScope.BoardContent( } } -@OptIn(ExperimentalFoundationApi::class) @SuppressLint("ModifierFactoryUnreferencedReceiver") fun Modifier.modifierWithClipRect( scrollState: ScrollState, diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/BoardTopStory.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/BoardTopStory.kt index 3d7705b1..92d65735 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/BoardTopStory.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/BoardTopStory.kt @@ -1,7 +1,6 @@ package com.goalpanzi.mission_mate.feature.board.component import android.annotation.SuppressLint -import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable @@ -41,13 +40,11 @@ import com.goalpanzi.mission_mate.core.designsystem.theme.MissionMateTypography import com.goalpanzi.mission_mate.core.designsystem.theme.MissionmateTheme import com.goalpanzi.mission_mate.core.designsystem.theme.OrangeGradient_FFFF5F3C_FFFFAE50 import com.goalpanzi.mission_mate.feature.board.model.CharacterUiModel -import com.goalpanzi.mission_mate.feature.board.model.MissionState import com.goalpanzi.mission_mate.feature.board.model.UserStory @Composable fun BoardTopStory( userList: List, - missionState : MissionState, modifier: Modifier = Modifier, onClickStory: (UserStory) -> Unit, ) { @@ -98,7 +95,10 @@ fun UserStoryItem( .then( if (userStory.isVerified) { Modifier - .border(3.dp, OrangeGradient_FFFF5F3C_FFFFAE50, CircleShape) + .then( + if(userStory.isViewed) Modifier.border(3.dp, ColorWhite_FFFFFFFF, CircleShape) + else Modifier.border(3.dp, OrangeGradient_FFFF5F3C_FFFFAE50, CircleShape) + ) .clickable( interactionSource = MutableInteractionSource(), indication = null, @@ -106,8 +106,9 @@ fun UserStoryItem( ) } else { Modifier + .alpha(userStory.userStoryAlpha) .border(3.dp, ColorWhite_FFFFFFFF, CircleShape) - .alpha(if (userStory.isMe) 1f else 0.5f) + } ) .paint( @@ -163,7 +164,31 @@ private fun VerifiedUserStoryItemPreview() { characterUiModelType = CharacterUiModel.CAT, imageUrl = "", isVerified = true, - verifiedAt = "" + verifiedAt = "", + viewedAt = "", + missionVerificationId = 0 + ), + onClickStory = { + + } + ) + } +} + + +@Preview +@Composable +private fun VerifiedViewedUserStoryItemPreview() { + MissionmateTheme { + UserStoryItem( + userStory = UserStory( + nickname = "닉네임", + characterUiModelType = CharacterUiModel.CAT, + imageUrl = "", + isVerified = true, + verifiedAt = "", + viewedAt = "2024-10-31T09:48:18.399Z", + missionVerificationId = 0 ), onClickStory = { @@ -182,7 +207,9 @@ private fun NotVerifiedUserStoryItemPreview() { characterUiModelType = CharacterUiModel.CAT, imageUrl = "", isVerified = false, - verifiedAt = "" + verifiedAt = "", + viewedAt = "", + missionVerificationId = 0 ), onClickStory = { @@ -203,7 +230,31 @@ private fun MyVerifiedUserStoryItemPreview() { imageUrl = "", isVerified = true, verifiedAt = "", - isMe = true + isMe = true, + viewedAt = "", + missionVerificationId = 0 + ), + onClickStory = { + + } + ) + } +} + +@Preview +@Composable +private fun MyVerifiedViewedUserStoryItemPreview() { + MissionmateTheme { + UserStoryItem( + userStory = UserStory( + nickname = "닉네임", + characterUiModelType = CharacterUiModel.CAT, + imageUrl = "", + isVerified = true, + verifiedAt = "", + isMe = true, + viewedAt = "2024-10-31T09:48:18.399Z", + missionVerificationId = 0 ), onClickStory = { @@ -223,7 +274,9 @@ private fun MyNotVerifiedUserStoryItemPreview() { imageUrl = "", isVerified = false, verifiedAt = "", - isMe = true + isMe = true, + viewedAt = "", + missionVerificationId = 0 ), onClickStory = { diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/BoardTopView.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/BoardTopView.kt index 5e78d3a9..da5f151c 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/BoardTopView.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/BoardTopView.kt @@ -78,7 +78,6 @@ fun BoardTopView( BoardTopStory( modifier = Modifier.padding(top = 56.dp), userList = userList, - missionState = missionState, onClickStory = onClickStory ) if(!viewedTooltip){ diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/Piece.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/Piece.kt index f06ad432..d37bf6f6 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/Piece.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/component/Piece.kt @@ -1,8 +1,14 @@ package com.goalpanzi.mission_mate.feature.board.component +import android.util.Log import androidx.annotation.DrawableRes +import androidx.compose.animation.core.Animatable +import androidx.compose.animation.core.AnimationSpec +import androidx.compose.animation.core.LinearEasing import androidx.compose.animation.core.LinearOutSlowInEasing import androidx.compose.animation.core.animateDpAsState +import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.animation.core.keyframes import androidx.compose.animation.core.tween import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement @@ -12,18 +18,23 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.absoluteOffset import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue +import androidx.compose.runtime.produceState import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip +import androidx.compose.ui.geometry.Offset import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.Dp @@ -37,6 +48,8 @@ import com.goalpanzi.mission_mate.feature.board.model.BoardPieceType import com.goalpanzi.mission_mate.feature.board.util.PieceGenerator import com.goalpanzi.mission_mate.core.designsystem.component.OutlinedChip import com.goalpanzi.mission_mate.core.designsystem.component.StableImage +import com.goalpanzi.mission_mate.feature.board.model.MotionType +import kotlinx.coroutines.delay @Composable fun BoxScope.Piece( @@ -45,28 +58,38 @@ fun BoxScope.Piece( sizePerBlock: Dp, modifier: Modifier = Modifier ) { - val isAnimated by remember(boardPiece) { - derivedStateOf { boardPiece.boardPieceType == BoardPieceType.MOVED } + val isAnimated by remember { + derivedStateOf { + boardPiece.motionType in setOf( + MotionType.MOVE_FADE_IN, + MotionType.MOVE, + MotionType.MOVE_FADE_OUT, + MotionType.FADE_IN_MOVE_FADE_OUT + ) + } } + + val alpha = animatedFloatByMotionType(boardPiece.motionType, 600) + val x = animateDpAsState( targetValue = if (isAnimated) PieceGenerator.getXOffset( - boardPiece.index + 1, + boardPiece.index, numberOfColumn, sizePerBlock - ) else PieceGenerator.getXOffset(boardPiece.index , numberOfColumn, sizePerBlock), + ) else PieceGenerator.getXOffset(boardPiece.index, numberOfColumn, sizePerBlock), animationSpec = tween( - durationMillis = 500, + durationMillis = 650, easing = LinearOutSlowInEasing ) ) val y = animateDpAsState( targetValue = if (isAnimated) PieceGenerator.getYOffset( - boardPiece.index + 1, + boardPiece.index, numberOfColumn, sizePerBlock - ) else PieceGenerator.getYOffset(boardPiece.index , numberOfColumn, sizePerBlock), + ) else PieceGenerator.getYOffset(boardPiece.index, numberOfColumn, sizePerBlock), animationSpec = tween( - durationMillis = 500, + durationMillis = 650, easing = LinearOutSlowInEasing ) ) @@ -82,45 +105,108 @@ fun BoxScope.Piece( sizePerBlock ) ) { - if(boardPiece.boardPieceType != BoardPieceType.HIDDEN){ - StableImage( - modifier = Modifier - .padding(top = 4.dp) - .fillMaxWidth(88f / 114f) - .aspectRatio(1f) - .align(Alignment.TopCenter), - drawableResId = boardPiece.drawableRes, + if (boardPiece.boardPieceType == BoardPieceType.HIDDEN && boardPiece.motionType in setOf(MotionType.HIDE,MotionType.STATIC)) return + StableImage( + modifier = Modifier + .padding(top = 4.dp) + .fillMaxWidth(88f / 114f) + .alpha(alpha) + .aspectRatio(1f) + .align(Alignment.TopCenter), + drawableResId = boardPiece.drawableRes, + ) + if (boardPiece.count > 1 && boardPiece.boardPieceType != BoardPieceType.HIDDEN) { + PieceCountChip( + modifier = Modifier.align(Alignment.TopEnd), + count = boardPiece.count, + imageId = boardPiece.drawableRes ) - if(boardPiece.count > 1){ - PieceCountChip( - modifier = Modifier.align(Alignment.TopEnd), - count = boardPiece.count, - imageId = boardPiece.drawableRes + } + if(boardPiece.boardPieceType != BoardPieceType.HIDDEN) + PieceNameChip( + modifier = Modifier + .align( + Alignment.BottomCenter ) + .padding(bottom = 7.dp), + name = boardPiece.nickname, + isMe = boardPiece.isMe + ) + } +} + + +@Composable +fun animatedFloatByMotionType( + motionType: MotionType, + durationMillis: Int +): Float { + val animatable = remember { Animatable(1f) } + + LaunchedEffect(motionType) { + when (motionType) { + MotionType.STATIC, MotionType.MOVE, MotionType.HIDE -> { + animatable.snapTo(if (motionType == MotionType.HIDE) 0f else 1f) } - PieceNameChip( - modifier = Modifier - .align( - Alignment.BottomCenter + MotionType.FADE_IN, MotionType.MOVE_FADE_IN -> { + animatable.animateTo( + targetValue = 1f, + animationSpec = tween( + durationMillis = durationMillis * 1 / 5, + easing = LinearEasing ) - .padding(bottom = 7.dp), - name = boardPiece.nickname, - isMe = boardPiece.isMe - ) + ) + animatable.animateTo( + targetValue = 1f, + animationSpec = tween(durationMillis = durationMillis * 4 / 5) + ) + } + MotionType.FADE_OUT, MotionType.MOVE_FADE_OUT -> { + animatable.animateTo( + targetValue = 1f, + animationSpec = tween(durationMillis = durationMillis * 3 / 5) + ) + animatable.animateTo( + targetValue = 0f, + animationSpec = tween( + durationMillis = durationMillis * 2 / 5, + easing = LinearEasing + ) + ) + } + MotionType.FADE_IN_MOVE_FADE_OUT -> { + animatable.animateTo( + targetValue = 1f, + animationSpec = tween( + durationMillis = durationMillis * 1 / 5, + easing = LinearEasing + ) + ) + animatable.animateTo( + targetValue = 1f, + animationSpec = tween(durationMillis = durationMillis * 3 / 5) + ) + animatable.animateTo( + targetValue = 0f, + animationSpec = tween( + durationMillis = durationMillis * 1 / 5, + easing = LinearEasing + ) + ) + } } - } - + return animatable.value } @Composable fun PieceNameChip( - name : String, + name: String, modifier: Modifier = Modifier, - isMe : Boolean = false, - textStyle : TextStyle = MissionMateTypography.body_md_bold -){ + isMe: Boolean = false, + textStyle: TextStyle = MissionMateTypography.body_md_bold +) { Text( modifier = modifier .padding(horizontal = 12.dp) @@ -130,11 +216,10 @@ fun PieceNameChip( .background( if (isMe) ColorOrange_FFFF5732 else ColorWhite_FFFFFFFF ) - .padding(horizontal = 8.5.dp, 0.85.dp) - , + .padding(horizontal = 8.5.dp, 0.85.dp), text = name, style = textStyle, - color = if(isMe) ColorWhite_FFFFFFFF else ColorGray1_FF404249, + color = if (isMe) ColorWhite_FFFFFFFF else ColorGray1_FF404249, textAlign = TextAlign.Center ) } @@ -142,17 +227,17 @@ fun PieceNameChip( @Composable fun PieceCountChip( @DrawableRes imageId: Int, - count : Int, + count: Int, modifier: Modifier = Modifier, - textStyle : TextStyle = MissionMateTypography.body_md_bold -){ + textStyle: TextStyle = MissionMateTypography.body_md_bold +) { OutlinedChip( modifier = modifier - ){ + ) { Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(5.dp) - ){ + ) { StableImage( modifier = Modifier.size(22.dp), drawableResId = imageId, diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/model/BoardPiece.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/model/BoardPiece.kt index 2c5baddf..9f78676c 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/model/BoardPiece.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/model/BoardPiece.kt @@ -1,17 +1,31 @@ package com.goalpanzi.mission_mate.feature.board.model data class BoardPiece( + val memberId : Long, val index : Int, val count : Int, val nickname : String, val isMe : Boolean, val drawableRes: Int, - val boardPieceType: BoardPieceType = BoardPieceType.INITIAL -) + val boardPieceType: BoardPieceType = BoardPieceType.INITIAL, + val motionType : MotionType = MotionType.STATIC, + val order : Int = 0 +){ + val needToDraw = boardPieceType == BoardPieceType.HIDDEN && motionType in setOf(MotionType.STATIC,MotionType.HIDE,MotionType.FADE_OUT) +} enum class BoardPieceType { INITIAL, - MOVED, - NOT_CHANGED, HIDDEN -} \ No newline at end of file +} + +enum class MotionType { + STATIC, + MOVE, + HIDE, + FADE_IN, + FADE_OUT, + MOVE_FADE_IN, + MOVE_FADE_OUT, + FADE_IN_MOVE_FADE_OUT +} diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/model/MissionBoardsUiModel.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/model/MissionBoardsUiModel.kt index 7a29f89f..b31d8001 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/model/MissionBoardsUiModel.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/model/MissionBoardsUiModel.kt @@ -17,11 +17,18 @@ data class MissionBoardsUiModel( } -fun MissionBoards.toUiModel() : MissionBoardsUiModel { +fun MissionBoards.toUiModel(myMemberId : Long?) : MissionBoardsUiModel { return MissionBoardsUiModel( progressCount = progressCount, rank = rank, - missionBoardList = missionBoards, + missionBoardList = missionBoards.map { board -> + if(board.isMyPosition) board.copy( + missionBoardMembers = board.missionBoardMembers.sortedByDescending { + it.memberId == myMemberId + } + ) + else board + }, passedCountByMe = missionBoards.find { it.isMyPosition }?.number ?: 0 ) } @@ -29,17 +36,19 @@ fun MissionBoards.toUiModel() : MissionBoardsUiModel { fun MissionBoardsUiModel.toBoardPieces( profile: UserProfile? ) : List { - return missionBoardList.filter { block -> - block.missionBoardMembers.isNotEmpty() - }.map { block -> - BoardPiece( - index = block.number, - count = block.missionBoardMembers.size, - nickname = if(block.isMyPosition && profile != null) profile.nickname - else block.missionBoardMembers.first().nickname, - isMe = block.isMyPosition, - drawableRes = if(block.isMyPosition && profile != null) profile.characterType.toCharacterUiModel().imageId - else block.missionBoardMembers.first().characterType.toCharacterUiModel().imageId - ) - } + return missionBoardList.map { block -> + block.missionBoardMembers.mapIndexed { index, member -> + BoardPiece( + memberId = member.memberId, + index = block.number, + count = block.missionBoardMembers.size, + nickname = member.nickname, + isMe = block.isMyPosition, + drawableRes = member.characterType.toCharacterUiModel().imageId, + boardPieceType = if(block.missionBoardMembers.firstOrNull()?.memberId == member.memberId) BoardPieceType.INITIAL + else BoardPieceType.HIDDEN, + order = index + ) + }.reversed() + }.flatten() } diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/model/UserStory.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/model/UserStory.kt index 954fecb2..540cf218 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/model/UserStory.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/model/UserStory.kt @@ -2,22 +2,54 @@ package com.goalpanzi.mission_mate.feature.board.model import com.goalpanzi.mission_mate.core.domain.mission.model.MissionVerification +enum class UserStoryType { + COLORED, + TRANSPARENT, + NORMAL +} data class UserStory( - val nickname : String, - val characterUiModelType : CharacterUiModel, - val imageUrl : String, - val isVerified : Boolean, - val isMe : Boolean = false, - val verifiedAt : String -) - -fun MissionVerification.toUserStory(isMe: Boolean = false) : UserStory = + val nickname: String, + val characterUiModelType: CharacterUiModel, + val imageUrl: String, + val isVerified: Boolean, + val isMe: Boolean = false, + val verifiedAt: String, + val viewedAt: String, + val missionVerificationId: Long +) { + val isViewed = viewedAt.isNotEmpty() + + val userStoryType: UserStoryType = if (isVerified) { + if (isViewed) { + UserStoryType.NORMAL + } else { + UserStoryType.COLORED + } + } else { + if (isMe) { + UserStoryType.NORMAL + } else { + UserStoryType.TRANSPARENT + } + } + + val userStoryAlpha = when (userStoryType) { + UserStoryType.TRANSPARENT -> 0.4f + else -> 1f + } + + +} + +fun MissionVerification.toUserStory(isMe: Boolean = false): UserStory = UserStory( nickname = nickname, characterUiModelType = characterType.toCharacterUiModel(), imageUrl = imageUrl, isVerified = imageUrl.isNotEmpty(), isMe = isMe, - verifiedAt = verifiedAt + verifiedAt = verifiedAt, + viewedAt = viewedAt, + missionVerificationId = missionVerificationId ) diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardDetailViewModel.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardDetailViewModel.kt index c06c814d..75fe4228 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardDetailViewModel.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardDetailViewModel.kt @@ -36,7 +36,7 @@ class BoardDetailViewModel @Inject constructor( private val memberId : StateFlow = getCachedMemberIdUseCase().stateIn( viewModelScope, - started = SharingStarted.WhileSubscribed(500), + started = SharingStarted.WhileSubscribed(5000), initialValue = null ) diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardFinishScreen.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardFinishScreen.kt index 272ce06c..062d74fa 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardFinishScreen.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardFinishScreen.kt @@ -1,8 +1,10 @@ package com.goalpanzi.mission_mate.feature.board.screen +import android.widget.Toast import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -17,12 +19,18 @@ import androidx.compose.material3.IconButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource import androidx.compose.ui.text.style.TextAlign @@ -33,25 +41,31 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.goalpanzi.mission_mate.core.designsystem.component.LottieImage import com.goalpanzi.mission_mate.core.designsystem.component.MissionMateButtonType import com.goalpanzi.mission_mate.core.designsystem.component.MissionMateTextButton +import com.goalpanzi.mission_mate.core.designsystem.component.MissionMateTopAppBar +import com.goalpanzi.mission_mate.core.designsystem.component.NavigationType +import com.goalpanzi.mission_mate.core.designsystem.component.StableImage import com.goalpanzi.mission_mate.core.designsystem.theme.ColorGray1_FF404249 import com.goalpanzi.mission_mate.core.designsystem.theme.ColorWhite_FFFFFFFF import com.goalpanzi.mission_mate.core.designsystem.theme.MissionMateTypography -import com.goalpanzi.mission_mate.core.designsystem.component.MissionMateTopAppBar -import com.goalpanzi.mission_mate.core.designsystem.component.NavigationType import com.goalpanzi.mission_mate.feature.board.R import com.goalpanzi.mission_mate.feature.board.model.CharacterUiModel import com.goalpanzi.mission_mate.feature.board.model.toCharacterUiModel -import com.goalpanzi.mission_mate.core.designsystem.component.StableImage +import kotlinx.coroutines.flow.collectLatest @Composable fun BoardFinishRoute( - onClickSetting: () -> Unit, - onClickOk : () -> Unit, + onSettingClick: () -> Unit, + onOkClick : () -> Unit, modifier: Modifier = Modifier, viewModel : BoardFinishViewModel = hiltViewModel() ) { + val context = LocalContext.current val rank by viewModel.rank.collectAsStateWithLifecycle() val userProfile by viewModel.profile.collectAsStateWithLifecycle() + var showProgress by rememberSaveable { mutableStateOf(false) } + val isLoading by remember { + derivedStateOf { rank == null || userProfile == null || showProgress } + } LaunchedEffect(key1 = Unit) { viewModel.getRankByMissionId() @@ -62,32 +76,45 @@ fun BoardFinishRoute( viewModel.setMissionFinished() } - - if(rank != null && userProfile != null){ - BoardFinishScreen( - modifier = modifier, - rank = rank!!, - characterUiModel = userProfile!!.characterType.toCharacterUiModel(), - onClickOk = onClickOk, - onClickSetting = onClickSetting - ) - }else { - Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center - ){ - CircularProgressIndicator() + LaunchedEffect(Unit){ + viewModel.completeMissionResultEvent.collectLatest { + when(it){ + CompleteMissionEvent.Success -> { + showProgress = false + onOkClick() + } + CompleteMissionEvent.Error -> { + showProgress = false + Toast.makeText( + context, + context.getString(R.string.board_complete_error), + Toast.LENGTH_SHORT + ).show() + } + CompleteMissionEvent.Loading -> { + showProgress = true + } + } } } + BoardFinishScreen( + modifier = modifier, + rank = rank, + isLoading = isLoading, + characterUiModel = userProfile?.characterType?.toCharacterUiModel(), + onOkClick = viewModel::completeMission, + onSettingClick = onSettingClick + ) } @Composable fun BoardFinishScreen( - characterUiModel : CharacterUiModel, - rank : Int, - onClickSetting: () -> Unit, - onClickOk : () -> Unit, + characterUiModel : CharacterUiModel?, + rank : Int?, + isLoading : Boolean, + onSettingClick: () -> Unit, + onOkClick : () -> Unit, modifier: Modifier = Modifier ) { Box( @@ -111,7 +138,7 @@ fun BoardFinishScreen( navigationType = NavigationType.NONE, rightActionButtons = { IconButton( - onClick = onClickSetting, + onClick = onSettingClick, modifier = Modifier.wrapContentSize() ) { Icon( @@ -123,79 +150,112 @@ fun BoardFinishScreen( }, containerColor = Color.Transparent ) - Box( - modifier = Modifier - .fillMaxWidth() - .weight(1f), - contentAlignment = Alignment.BottomCenter - ){ - Box( - modifier = Modifier.fillMaxWidth(), - contentAlignment = Alignment.Center - ){ - StableImage( - modifier = Modifier.fillMaxWidth(), - drawableResId = R.drawable.img_mission_finish, - contentScale = ContentScale.Crop - ) - StableImage( - modifier = Modifier - .fillMaxWidth(212f / 390f) - .aspectRatio(1f), - drawableResId = characterUiModel.imageId - ) - } - LottieImage( - modifier = Modifier.wrapContentSize().align(Alignment.Center), - lottieRes = com.goalpanzi.mission_mate.core.designsystem.R.raw.animation_celebration - ) - } - Column( - modifier = Modifier.background(color = ColorWhite_FFFFFFFF), - horizontalAlignment = Alignment.CenterHorizontally - ) { - Text( - modifier = Modifier.padding(top = 8.dp), - text = stringResource(id = R.string.board_finish_rank, rank), - color = ColorGray1_FF404249, - style = MissionMateTypography.heading_xl_bold - ) - Text( - modifier = Modifier.padding(top = 20.dp, bottom = 4.dp), - text = stringResource(id = R.string.board_finish_description), - color = ColorGray1_FF404249, - style = MissionMateTypography.title_xl_bold - ) - Text( - text = stringResource(id = R.string.board_finish_sub_description), - color = ColorGray1_FF404249, - style = MissionMateTypography.body_xl_regular, - textAlign = TextAlign.Center - ) - MissionMateTextButton( + BoardFinishCharacter( + characterUiModel = characterUiModel + ) + BoardFinishBottom( + rank = rank, + onOkClick = onOkClick + ) + } + if(isLoading){ + CircularProgressIndicator( + modifier = Modifier.align(Alignment.Center) + ) + } + } + +} + +@Composable +fun ColumnScope.BoardFinishCharacter( + characterUiModel: CharacterUiModel?, + modifier: Modifier = Modifier +) { + Box( + modifier = modifier + .fillMaxWidth() + .weight(1f), + contentAlignment = Alignment.BottomCenter + ){ + Box( + modifier = Modifier.fillMaxWidth(), + contentAlignment = Alignment.Center + ){ + StableImage( + modifier = Modifier.fillMaxWidth(), + drawableResId = R.drawable.img_mission_finish, + contentScale = ContentScale.Crop + ) + characterUiModel?.let { + StableImage( modifier = Modifier - .padding(bottom = 36.dp, start = 24.dp, end = 24.dp, top = 68.dp) - .fillMaxWidth() - .wrapContentHeight(), - buttonType = MissionMateButtonType.ACTIVE, - textId = com.goalpanzi.mission_mate.feature.onboarding.R.string.start, - onClick = onClickOk + .fillMaxWidth(212f / 390f) + .aspectRatio(1f), + drawableResId = characterUiModel.imageId ) } - } + LottieImage( + modifier = Modifier + .wrapContentSize() + .align(Alignment.Center), + lottieRes = com.goalpanzi.mission_mate.core.designsystem.R.raw.animation_celebration + ) } +} +@Composable +fun BoardFinishBottom( + rank: Int?, + onOkClick: () -> Unit, + modifier: Modifier = Modifier +) { + Column( + modifier = modifier.background(color = ColorWhite_FFFFFFFF), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Text( + modifier = Modifier.padding(top = 8.dp), + text = rank?.let { stringResource(id = R.string.board_finish_rank, rank) } ?: "", + color = ColorGray1_FF404249, + style = MissionMateTypography.heading_xl_bold + ) + Text( + modifier = Modifier.padding(top = 20.dp, bottom = 4.dp), + text = stringResource(id = R.string.board_finish_description), + color = ColorGray1_FF404249, + style = MissionMateTypography.title_xl_bold + ) + Text( + text = stringResource(id = R.string.board_finish_sub_description), + color = ColorGray1_FF404249, + style = MissionMateTypography.body_xl_regular, + textAlign = TextAlign.Center + ) + MissionMateTextButton( + modifier = Modifier + .padding(bottom = 36.dp, start = 24.dp, end = 24.dp, top = 68.dp) + .fillMaxWidth() + .wrapContentHeight(), + buttonType = MissionMateButtonType.ACTIVE, + textId = com.goalpanzi.mission_mate.feature.onboarding.R.string.confirm, + onClick = onOkClick + ) + } } @Preview @Composable private fun PreviewBoardFinishScreen() { BoardFinishScreen( - characterUiModel = CharacterUiModel.RABBIT, + characterUiModel = null, rank = 10, - onClickSetting = {}, - onClickOk = {} + isLoading = false, + onSettingClick = {}, + onOkClick = {} ) } + + diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardFinishViewModel.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardFinishViewModel.kt index 4d12da6a..1fb47579 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardFinishViewModel.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardFinishViewModel.kt @@ -4,16 +4,22 @@ import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.goalpanzi.mission_mate.core.domain.common.DomainResult +import com.goalpanzi.mission_mate.core.domain.common.convert import com.goalpanzi.mission_mate.core.domain.common.model.user.UserProfile +import com.goalpanzi.mission_mate.core.domain.mission.usecase.CompleteMissionUseCase import com.goalpanzi.mission_mate.core.domain.mission.usecase.GetMissionRankUseCase import com.goalpanzi.mission_mate.core.domain.mission.usecase.SetMissionJoinedUseCase import com.goalpanzi.mission_mate.core.domain.user.usecase.ProfileUseCase import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch import javax.inject.Inject @@ -22,6 +28,7 @@ class BoardFinishViewModel @Inject constructor( private val getMissionRankUseCase : GetMissionRankUseCase, private val profileUseCase : ProfileUseCase, private val setMissionJoinedUseCase: SetMissionJoinedUseCase, + private val completeMissionUseCase : CompleteMissionUseCase, savedStateHandle: SavedStateHandle ) : ViewModel() { @@ -33,6 +40,10 @@ class BoardFinishViewModel @Inject constructor( private val _profile : MutableStateFlow = MutableStateFlow(null) val profile : StateFlow = _profile.asStateFlow() + private val _completeMissionResultEvent = MutableSharedFlow() + val completeMissionResultEvent: SharedFlow = _completeMissionResultEvent.asSharedFlow() + + fun setMissionFinished() { viewModelScope.launch { setMissionJoinedUseCase(false).collect() @@ -63,4 +74,27 @@ class BoardFinishViewModel @Inject constructor( } } + fun completeMission() { + viewModelScope.launch { + _completeMissionResultEvent.emit(CompleteMissionEvent.Loading) + completeMissionUseCase(missionId) + .collectLatest { + when (it) { + is DomainResult.Success -> { + _completeMissionResultEvent.emit(CompleteMissionEvent.Success) + } + + else -> { + _completeMissionResultEvent.emit(CompleteMissionEvent.Error) + } + } + } + } + } +} + +sealed interface CompleteMissionEvent { + data object Loading : CompleteMissionEvent + data object Success : CompleteMissionEvent + data object Error : CompleteMissionEvent } diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardScreen.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardScreen.kt index 6c004bf1..a849244d 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardScreen.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardScreen.kt @@ -141,12 +141,6 @@ fun BoardRoute( } } - LaunchedEffect(key1 = isUploadSuccess) { - if (isUploadSuccess) { - viewModel.onVerifySuccess() - } - } - if (isShownDeleteMissionDialog) { DeleteMissionDialog( onDismissRequest = { @@ -207,7 +201,12 @@ fun BoardRoute( onClickTooltip = { viewModel.setViewedTooltip() }, - onClickStory = onClickStory, + onClickStory = { story -> + onClickStory(story) + if(story.isVerified && !story.isViewed) { + viewModel.viewVerification(story.missionVerificationId) + } + }, onClickMyVerificationBoardBlock = { viewModel.getMyMissionVerification(it) } diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardViewModel.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardViewModel.kt index 1fe5b27f..e35552cc 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardViewModel.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/BoardViewModel.kt @@ -11,12 +11,12 @@ import com.goalpanzi.mission_mate.core.domain.mission.usecase.GetMissionUseCase import com.goalpanzi.mission_mate.core.domain.mission.usecase.GetMissionVerificationsUseCase import com.goalpanzi.mission_mate.core.domain.mission.usecase.GetMyMissionVerificationUseCase import com.goalpanzi.mission_mate.core.domain.mission.usecase.VerifyMissionUseCase +import com.goalpanzi.mission_mate.core.domain.mission.usecase.ViewVerificationUseCase import com.goalpanzi.mission_mate.core.domain.setting.usecase.GetViewedTooltipUseCase import com.goalpanzi.mission_mate.core.domain.setting.usecase.SetViewedTooltipUseCase import com.goalpanzi.mission_mate.core.domain.user.usecase.GetCachedMemberIdUseCase import com.goalpanzi.mission_mate.core.domain.user.usecase.ProfileUseCase import com.goalpanzi.mission_mate.feature.board.model.BoardPiece -import com.goalpanzi.mission_mate.feature.board.model.BoardPieceType import com.goalpanzi.mission_mate.feature.board.model.MissionError import com.goalpanzi.mission_mate.feature.board.model.MissionState import com.goalpanzi.mission_mate.feature.board.model.MissionState.Companion.getMissionState @@ -27,6 +27,7 @@ import com.goalpanzi.mission_mate.feature.board.model.toUiModel import com.goalpanzi.mission_mate.feature.board.model.uimodel.MissionBoardUiModel import com.goalpanzi.mission_mate.feature.board.model.uimodel.MissionUiModel import com.goalpanzi.mission_mate.feature.board.model.uimodel.MissionVerificationUiModel +import com.goalpanzi.mission_mate.feature.board.util.PieceManager import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableSharedFlow @@ -38,8 +39,10 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.joinAll import kotlinx.coroutines.launch @@ -48,8 +51,8 @@ import javax.inject.Inject @HiltViewModel class BoardViewModel @Inject constructor( savedStateHandle: SavedStateHandle, - getCachedMemberIdUseCase: GetCachedMemberIdUseCase, getViewedTooltipUseCase: GetViewedTooltipUseCase, + private val getCachedMemberIdUseCase: GetCachedMemberIdUseCase, private val getMissionUseCase: GetMissionUseCase, private val getMissionBoardsUseCase: GetMissionBoardsUseCase, private val getMissionVerificationsUseCase: GetMissionVerificationsUseCase, @@ -58,6 +61,7 @@ class BoardViewModel @Inject constructor( private val setViewedTooltipUseCase: SetViewedTooltipUseCase, private val verifyMissionUseCase: VerifyMissionUseCase, private val getMyMissionVerificationUseCase : GetMyMissionVerificationUseCase, + private val viewVerificationUseCase: ViewVerificationUseCase ) : ViewModel() { val missionId: Long = savedStateHandle.get("missionId")!! @@ -69,10 +73,10 @@ class BoardViewModel @Inject constructor( ) private val _missionError = MutableStateFlow(null) - val missionError : StateFlow =_missionError.asStateFlow() + val missionError: StateFlow = _missionError.asStateFlow() private val _myMissionVerification = MutableSharedFlow() - val myMissionVerification : SharedFlow = _myMissionVerification.asSharedFlow() + val myMissionVerification: SharedFlow = _myMissionVerification.asSharedFlow() private val _deleteMissionResultEvent = MutableSharedFlow() val deleteMissionResultEvent: SharedFlow = _deleteMissionResultEvent.asSharedFlow() @@ -91,7 +95,7 @@ class BoardViewModel @Inject constructor( _missionVerificationUiModel.asStateFlow() private val _isRefreshLoading = MutableStateFlow(false) - val isRefreshLoading : StateFlow = _isRefreshLoading.asStateFlow() + val isRefreshLoading: StateFlow = _isRefreshLoading.asStateFlow() val isHost: StateFlow = combine( @@ -124,7 +128,7 @@ class BoardViewModel @Inject constructor( private val _boardPieces = MutableStateFlow>(emptyList()) val boardPieces: StateFlow> = _boardPieces.asStateFlow() - fun fetchMissionData(){ + fun fetchMissionData() { viewModelScope.launch { getMissionBoards() getMission() @@ -132,7 +136,7 @@ class BoardViewModel @Inject constructor( } } - fun refreshMissionData(){ + fun refreshMissionData() { viewModelScope.launch { _isRefreshLoading.emit(true) joinAll( @@ -151,16 +155,33 @@ class BoardViewModel @Inject constructor( }.collect { when (it) { is DomainResult.Success -> { - _missionBoardUiModel.emit( - MissionBoardUiModel.Success( - it.data.toUiModel() + val myMemberId = getCachedMemberIdUseCase().first() + + _missionBoardUiModel.emit(MissionBoardUiModel.Success(it.data.toUiModel(myMemberId))) + + val boardPieceList = + it.data.toUiModel(myMemberId).toBoardPieces(profileUseCase.getProfile()) + + if (boardPieces.value.isEmpty()) { + _boardPieces.emit(boardPieceList) + } else { + val isMoved = + boardPieces.value.find { it.isMe }?.index?.plus(1) == boardPieceList.find { it.isMe }?.index + + val newList = PieceManager.getBoardPieces( + boardPieces.value, + boardPieceList ) - ) - _boardPieces.emit( - it.data.toUiModel().toBoardPieces( - profileUseCase.getProfile() + _boardPieces.emit( + newList ) - ) + if(isMoved){ + delay(550) + _boardRewardEvent.emit( + it.data.missionBoards.find { it.isMyPosition }?.reward + ) + } + } } else -> { @@ -222,77 +243,9 @@ class BoardViewModel @Inject constructor( } } - fun onVerifySuccess() { - if(missionState.value != MissionState.IN_PROGRESS_MISSION_DAY_BEFORE_CONFIRM) return - viewModelScope.launch { - // 내 캐릭터 - val myBoardPiece = boardPieces.value.find { it.isMe } - val missionBoard = missionBoardUiModel.value - if (myBoardPiece != null && missionBoard is MissionBoardUiModel.Success) { - val missionBoardList = missionBoard.missionBoards.missionBoardList - // 내 캐릭터보다 한칸 앞션 캐릭터 - val nextBoardPiece = missionBoardList.filter { block -> - block.missionBoardMembers.isNotEmpty() - }.find { - it.number == myBoardPiece.index + 1 - } - - // 내 캐릭터와 같이 있던 캐릭터 - val prevBoardPiece = missionBoardList.filter { block -> - block.missionBoardMembers.size >= 2 - }.find { - it.number == myBoardPiece.index - } - _boardPieces.emit( - buildList { - addAll( - boardPieces.value.map { - if (it.isMe) it.copy( - boardPieceType = BoardPieceType.MOVED, - count = if (nextBoardPiece != null) nextBoardPiece.missionBoardMembers.size + 1 else 1 - ) else if (nextBoardPiece != null && it.index == nextBoardPiece.number) { - it.copy(boardPieceType = BoardPieceType.HIDDEN) - } else it - } - ) - if (prevBoardPiece != null) { - val target = prevBoardPiece.missionBoardMembers.first { - it.nickname != myBoardPiece.nickname - } - add( - BoardPiece( - count = prevBoardPiece.missionBoardMembers.size - 1, - nickname = target.nickname, - drawableRes = target.characterType.toCharacterUiModel().imageId, - index = prevBoardPiece.number, - isMe = false - ) - ) - } - } - ) - - _missionBoardUiModel.emit( - missionBoard.copy( - missionBoards = missionBoard.missionBoards.copy( - passedCountByMe = missionBoard.missionBoards.passedCountByMe + 1 - ) - ) - ) - delay(400) - _boardRewardEvent.emit( - missionBoardList.find { - myBoardPiece.index + 1 == it.number - }?.reward - ) - } - fetchMissionData() - } - } - fun getMyMissionVerification( - number : Int - ){ + number: Int + ) { viewModelScope.launch { getMyMissionVerificationUseCase( missionId, @@ -300,7 +253,7 @@ class BoardViewModel @Inject constructor( ).catch { }.collect { - when(it){ + when (it) { is DomainResult.Success -> { _myMissionVerification.emit( UserStory( @@ -308,20 +261,27 @@ class BoardViewModel @Inject constructor( imageUrl = it.data.imageUrl, isVerified = true, nickname = it.data.nickname, - verifiedAt = it.data.verifiedAt + verifiedAt = it.data.verifiedAt, + viewedAt = it.data.viewedAt, + missionVerificationId = it.data.missionVerificationId ) ) } + else -> { } } - - - } - } } - + + fun viewVerification(missionVerificationId : Long){ + viewModelScope.launch { + viewVerificationUseCase(missionVerificationId) + .collectLatest { + getMissionVerification() + } + } + } } diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt index f87aea43..95b44804 100644 --- a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/screen/VerificationPreviewScreen.kt @@ -1,9 +1,14 @@ package com.goalpanzi.mission_mate.feature.board.screen +import android.content.Context +import android.net.Uri import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.focusable import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -23,6 +28,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment @@ -50,6 +56,8 @@ import com.goalpanzi.mission_mate.core.designsystem.component.StableImage import com.goalpanzi.mission_mate.core.designsystem.theme.ColorBlack_FF000000 import com.goalpanzi.mission_mate.core.designsystem.theme.ColorWhite_FFFFFFFF import com.goalpanzi.mission_mate.core.designsystem.theme.MissionMateTypography +import com.goalpanzi.mission_mate.core.designsystem.util.MultipleEventsCutter +import com.goalpanzi.mission_mate.core.designsystem.util.get import com.goalpanzi.mission_mate.feature.board.R import com.goalpanzi.mission_mate.feature.board.model.CharacterUiModel import com.goalpanzi.mission_mate.feature.board.util.ImageCompressor @@ -188,38 +196,56 @@ fun VerificationPreviewScreen( ) } } - - MissionMateButton( - modifier = Modifier - .align(Alignment.BottomCenter) - .padding(horizontal = 24.dp, vertical = 36.dp) - .fillMaxWidth() - .navigationBarsPadding(), - buttonType = MissionMateButtonType.ACTIVE, - onClick = { - val file = ImageCompressor.getCompressedImage(context, uiState.imageUrl.toUri()) - onClickUpload(file) - } - ) { - Text( - text = stringResource(id = R.string.upload), - style = MissionMateTypography.body_xl_bold, - color = ColorWhite_FFFFFFFF - ) - } + UploadButton( + context = context, + filePath = uiState.imageUrl.toUri(), + onClickUpload = onClickUpload + ) } } } } } +@Composable +fun BoxScope.UploadButton( + context: Context, + filePath: Uri, + onClickUpload: (File) -> Unit +) { + val multipleEventsCutter = remember { MultipleEventsCutter.get() } + MissionMateButton( + modifier = Modifier + .align(Alignment.BottomCenter) + .padding(horizontal = 24.dp, vertical = 36.dp) + .fillMaxWidth() + .navigationBarsPadding(), + buttonType = MissionMateButtonType.ACTIVE, + onClick = { + multipleEventsCutter.processEvent { + val file = ImageCompressor.getCompressedImage(context, filePath) + onClickUpload(file) + } + } + ) { + Text( + text = stringResource(id = R.string.upload), + style = MissionMateTypography.body_xl_bold, + color = ColorWhite_FFFFFFFF + ) + } +} + @Composable fun VerificationPreviewLoading() { Box( modifier = Modifier - .background(ColorWhite_FFFFFFFF) + .fillMaxSize() + .background(Color.Transparent) .statusBarsPadding() .navigationBarsPadding() + .focusable() + .clickable {} ) { CircularProgressIndicator( modifier = Modifier.align(Alignment.Center) @@ -253,3 +279,13 @@ fun VerificationPreviewScreenPreview() { onClickUpload = {} ) } + +@Preview +@Composable +fun VerificationPreviewScreenLoadingPreview() { + VerificationPreviewScreen( + onClickClose = {}, + uiState = VerificationPreviewUiState.Loading, + onClickUpload = {} + ) +} diff --git a/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/util/PieceManager.kt b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/util/PieceManager.kt new file mode 100644 index 00000000..51cc191a --- /dev/null +++ b/feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/util/PieceManager.kt @@ -0,0 +1,56 @@ +package com.goalpanzi.mission_mate.feature.board.util + +import com.goalpanzi.mission_mate.feature.board.model.BoardPiece +import com.goalpanzi.mission_mate.feature.board.model.BoardPieceType +import com.goalpanzi.mission_mate.feature.board.model.MotionType + +object PieceManager { + fun getBoardPieces( + prevBoardPieces: List, + newBoardPieces: List + ): List { + val result = newBoardPieces.map { new -> + val prevBoardPiece = prevBoardPieces.find { it.memberId == new.memberId } ?: new + val sameIndex = prevBoardPiece.index == new.index + + val motionType = when { + sameIndex -> when (prevBoardPiece.boardPieceType to new.boardPieceType) { + BoardPieceType.INITIAL to BoardPieceType.INITIAL -> MotionType.STATIC + BoardPieceType.INITIAL to BoardPieceType.HIDDEN -> MotionType.FADE_OUT + BoardPieceType.HIDDEN to BoardPieceType.INITIAL -> MotionType.FADE_IN + BoardPieceType.HIDDEN to BoardPieceType.HIDDEN -> MotionType.HIDE + else -> new.motionType + } + else -> when (prevBoardPiece.boardPieceType to new.boardPieceType) { + BoardPieceType.INITIAL to BoardPieceType.INITIAL -> MotionType.MOVE + BoardPieceType.INITIAL to BoardPieceType.HIDDEN -> MotionType.MOVE_FADE_OUT + BoardPieceType.HIDDEN to BoardPieceType.INITIAL -> MotionType.MOVE_FADE_IN + BoardPieceType.HIDDEN to BoardPieceType.HIDDEN -> MotionType.FADE_IN_MOVE_FADE_OUT + else -> new.motionType + } + } + new.copy(motionType = motionType) + } + + return result.map { item -> + if (item.motionType != MotionType.FADE_IN_MOVE_FADE_OUT) return@map item + val list = item.piecesWithAnimation(result) + item.copy( + motionType = if (list.isEmpty() || list.lastOrNull()?.memberId == item.memberId) { + item.motionType + } else { + MotionType.HIDE + } + ) + } + } + + private fun BoardPiece.piecesWithAnimation(targetList: List): List { + return targetList.filter { + it.index == this.index && it.motionType in setOf( + MotionType.FADE_IN_MOVE_FADE_OUT, + MotionType.MOVE + ) + } + } +} diff --git a/feature/board/src/main/res/values/strings.xml b/feature/board/src/main/res/values/strings.xml index 4ce61848..7d456135 100644 --- a/feature/board/src/main/res/values/strings.xml +++ b/feature/board/src/main/res/values/strings.xml @@ -54,9 +54,10 @@ 삭제하기 미션을 불러올 수 없습니다. + 에러가 발생하였습니다. 확인 취소 닫기 업로드 - \ No newline at end of file + diff --git a/feature/login/build.gradle.kts b/feature/login/build.gradle.kts index a947d881..b5ef4620 100644 --- a/feature/login/build.gradle.kts +++ b/feature/login/build.gradle.kts @@ -1,58 +1,19 @@ import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties +import com.goalpanzi.mission_mate.convention.setNamespace import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { - alias(libs.plugins.android.library) - alias(libs.plugins.jetbrains.kotlin.android) - alias(libs.plugins.compose.compiler) - alias(libs.plugins.kotlin.ksp) - alias(libs.plugins.hilt.android) + id("missionmate.android.feature") } android { - namespace = "com.goalpanzi.mission_mate.feature.login" - compileSdk = 34 - - defaultConfig { - minSdk = 26 - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - vectorDrawables { - useSupportLibrary = true - } - } - + setNamespace("feature.login") buildTypes { - debug { + getByName("debug") { buildConfigField("String", "CREDENTIAL_WEB_CLIENT_ID", getCredentialClientId()) } - release { + getByName("release") { buildConfigField("String", "CREDENTIAL_WEB_CLIENT_ID", getCredentialClientId()) - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" - ) - } - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlin { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_17) - } - } - buildFeatures { - compose = true - buildConfig = true - } - composeCompiler { - enableStrongSkippingMode = true - } - packaging { - resources { - excludes += "/META-INF/{AL2.0,LGPL2.1}" } } } @@ -60,32 +21,12 @@ android { dependencies { implementation(libs.androidx.core.ktx) implementation(libs.bundles.lifecycle) - implementation(platform(libs.androidx.compose.bom)) - implementation(libs.bundles.compose) - implementation(libs.androidx.activity.compose) implementation(libs.bundles.coroutines) - - testImplementation(libs.bundles.test) - androidTestImplementation(libs.bundles.android.test) - androidTestImplementation(platform(libs.androidx.compose.bom)) - debugImplementation(libs.androidx.ui.tooling) - debugImplementation(libs.androidx.ui.test.manifest) - - implementation(libs.androidx.hilt.navigation.compose) - implementation(libs.hilt.android) - ksp(libs.hilt.compiler) - - implementation(project(":core:designsystem")) - implementation(project(":core:navigation")) - implementation(project(":core:domain:common")) - implementation(project(":core:domain:auth")) - implementation(project(":core:domain:user")) - implementation(project(":core:ui")) - - implementation(libs.credentials) implementation(libs.credentials.auth) implementation(libs.google.id) + + testImplementation(libs.bundles.test) } fun getCredentialClientId(): String { diff --git a/feature/login/src/main/java/com/goalpanzi/mission_mate/feature/login/LoginNavigation.kt b/feature/login/src/main/java/com/goalpanzi/mission_mate/feature/login/LoginNavigation.kt index 0cc67b6a..b70aaf51 100644 --- a/feature/login/src/main/java/com/goalpanzi/mission_mate/feature/login/LoginNavigation.kt +++ b/feature/login/src/main/java/com/goalpanzi/mission_mate/feature/login/LoginNavigation.kt @@ -3,7 +3,6 @@ package com.goalpanzi.mission_mate.feature.login import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder import androidx.navigation.compose.composable -import com.goalpanzi.mission_mate.core.navigation.RouteModel fun NavController.navigateToLogin() { this.navigate("RouteModel.Login") { diff --git a/feature/login/src/main/java/com/goalpanzi/mission_mate/feature/login/LoginScreen.kt b/feature/login/src/main/java/com/goalpanzi/mission_mate/feature/login/LoginScreen.kt index 9e41d0a0..547dfc3e 100644 --- a/feature/login/src/main/java/com/goalpanzi/mission_mate/feature/login/LoginScreen.kt +++ b/feature/login/src/main/java/com/goalpanzi/mission_mate/feature/login/LoginScreen.kt @@ -1,6 +1,5 @@ package com.goalpanzi.mission_mate.feature.login -import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box @@ -25,7 +24,6 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview diff --git a/feature/login/src/main/java/com/goalpanzi/mission_mate/feature/login/LoginViewModel.kt b/feature/login/src/main/java/com/goalpanzi/mission_mate/feature/login/LoginViewModel.kt index 0ff81393..559cadd7 100644 --- a/feature/login/src/main/java/com/goalpanzi/mission_mate/feature/login/LoginViewModel.kt +++ b/feature/login/src/main/java/com/goalpanzi/mission_mate/feature/login/LoginViewModel.kt @@ -1,12 +1,10 @@ package com.goalpanzi.mission_mate.feature.login import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope import com.goalpanzi.mission_mate.core.domain.auth.usecase.LoginUseCase import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow -import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel diff --git a/feature/main/build.gradle.kts b/feature/main/build.gradle.kts index c369b1d1..bf1dc338 100644 --- a/feature/main/build.gradle.kts +++ b/feature/main/build.gradle.kts @@ -1,76 +1,19 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import com.goalpanzi.mission_mate.convention.setNamespace plugins { - alias(libs.plugins.android.library) - alias(libs.plugins.jetbrains.kotlin.android) - alias(libs.plugins.compose.compiler) - alias(libs.plugins.kotlin.ksp) - alias(libs.plugins.hilt.android) + id("missionmate.android.feature") } android { - namespace = "com.goalpanzi.mission_mate.core.main" - compileSdk = 34 - - defaultConfig { - minSdk = 26 - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" - ) - } - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlin { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_17) - } - } - buildFeatures { - compose = true - } - composeCompiler { - enableStrongSkippingMode = true - } - packaging { - resources { - excludes += "/META-INF/{AL2.0,LGPL2.1}" - } - } + setNamespace("feature.main") } dependencies { implementation(libs.androidx.core.ktx) implementation(libs.bundles.lifecycle) - implementation(platform(libs.androidx.compose.bom)) - implementation(libs.bundles.compose) - implementation(libs.androidx.activity.compose) - implementation(libs.bundles.coroutines) testImplementation(libs.bundles.test) androidTestImplementation(libs.bundles.android.test) - androidTestImplementation(platform(libs.androidx.compose.bom)) - debugImplementation(libs.androidx.ui.tooling) - debugImplementation(libs.androidx.ui.test.manifest) - - implementation(libs.androidx.hilt.navigation.compose) - implementation(libs.hilt.android) - ksp(libs.hilt.compiler) - - implementation(project(":core:designsystem")) - implementation(project(":core:navigation")) - implementation(project(":core:domain:common")) - implementation(project(":core:domain:auth")) - implementation(project(":core:ui")) implementation(project(":feature:login")) implementation(project(":feature:onboarding")) diff --git a/feature/main/src/androidTest/java/com/goalpanzi/mission_mate/core/main/ExampleInstrumentedTest.kt b/feature/main/src/androidTest/java/com/goalpanzi/mission_mate/feature/main/ExampleInstrumentedTest.kt similarity index 93% rename from feature/main/src/androidTest/java/com/goalpanzi/mission_mate/core/main/ExampleInstrumentedTest.kt rename to feature/main/src/androidTest/java/com/goalpanzi/mission_mate/feature/main/ExampleInstrumentedTest.kt index 74ee735c..42f7afc3 100644 --- a/feature/main/src/androidTest/java/com/goalpanzi/mission_mate/core/main/ExampleInstrumentedTest.kt +++ b/feature/main/src/androidTest/java/com/goalpanzi/mission_mate/feature/main/ExampleInstrumentedTest.kt @@ -1,4 +1,4 @@ -package com.goalpanzi.mission_mate.core.main +package com.goalpanzi.mission_mate.feature.main import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 diff --git a/feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/MainActivity.kt b/feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/MainActivity.kt similarity index 88% rename from feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/MainActivity.kt rename to feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/MainActivity.kt index b32a8178..07e6d389 100644 --- a/feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/MainActivity.kt +++ b/feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/MainActivity.kt @@ -1,4 +1,4 @@ -package com.goalpanzi.mission_mate.core.main +package com.goalpanzi.mission_mate.feature.main import android.graphics.Color import android.os.Bundle @@ -8,8 +8,8 @@ import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import com.goalpanzi.mission_mate.core.designsystem.theme.MissionmateTheme import com.goalpanzi.mission_mate.core.domain.auth.usecase.LoginUseCase -import com.goalpanzi.mission_mate.core.main.component.MainNavigator -import com.goalpanzi.mission_mate.core.main.component.rememberMainNavigator +import com.goalpanzi.mission_mate.feature.main.component.MainNavigator +import com.goalpanzi.mission_mate.feature.main.component.rememberMainNavigator import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject diff --git a/feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/MainScreen.kt b/feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/MainScreen.kt similarity index 84% rename from feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/MainScreen.kt rename to feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/MainScreen.kt index 040437c8..0272ee44 100644 --- a/feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/MainScreen.kt +++ b/feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/MainScreen.kt @@ -1,13 +1,13 @@ -package com.goalpanzi.mission_mate.core.main +package com.goalpanzi.mission_mate.feature.main import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Modifier import androidx.hilt.navigation.compose.hiltViewModel -import com.goalpanzi.mission_mate.core.main.component.MainNavHost -import com.goalpanzi.mission_mate.core.main.component.MainNavigator -import com.goalpanzi.mission_mate.core.main.component.rememberMainNavigator +import com.goalpanzi.mission_mate.feature.main.component.MainNavHost +import com.goalpanzi.mission_mate.feature.main.component.MainNavigator +import com.goalpanzi.mission_mate.feature.main.component.rememberMainNavigator import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.debounce diff --git a/feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/MainViewModel.kt b/feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/MainViewModel.kt similarity index 90% rename from feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/MainViewModel.kt rename to feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/MainViewModel.kt index 6b1d7898..158b5f35 100644 --- a/feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/MainViewModel.kt +++ b/feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/MainViewModel.kt @@ -1,4 +1,4 @@ -package com.goalpanzi.mission_mate.core.main +package com.goalpanzi.mission_mate.feature.main import androidx.lifecycle.ViewModel import com.goalpanzi.mission_mate.core.navigation.NavigationEventHandler diff --git a/feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/component/MainNavHost.kt b/feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/component/MainNavHost.kt similarity index 99% rename from feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/component/MainNavHost.kt rename to feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/component/MainNavHost.kt index 4a52ef9d..f5315ff4 100644 --- a/feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/component/MainNavHost.kt +++ b/feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/component/MainNavHost.kt @@ -1,4 +1,4 @@ -package com.goalpanzi.mission_mate.core.main.component +package com.goalpanzi.mission_mate.feature.main.component import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box diff --git a/feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/component/MainNavigator.kt b/feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/component/MainNavigator.kt similarity index 98% rename from feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/component/MainNavigator.kt rename to feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/component/MainNavigator.kt index c3413fe0..66362011 100644 --- a/feature/main/src/main/java/com/goalpanzi/mission_mate/core/main/component/MainNavigator.kt +++ b/feature/main/src/main/java/com/goalpanzi/mission_mate/feature/main/component/MainNavigator.kt @@ -1,4 +1,4 @@ -package com.goalpanzi.mission_mate.core.main.component +package com.goalpanzi.mission_mate.feature.main.component import android.net.Uri import androidx.compose.runtime.Composable diff --git a/core/network/src/test/java/com/goalpanzi/mission_mate/core/network/ExampleUnitTest.kt b/feature/main/src/test/java/com/goalpanzi/mission_mate/feature/main/ExampleUnitTest.kt similarity index 86% rename from core/network/src/test/java/com/goalpanzi/mission_mate/core/network/ExampleUnitTest.kt rename to feature/main/src/test/java/com/goalpanzi/mission_mate/feature/main/ExampleUnitTest.kt index c104b3f2..27aaab6a 100644 --- a/core/network/src/test/java/com/goalpanzi/mission_mate/core/network/ExampleUnitTest.kt +++ b/feature/main/src/test/java/com/goalpanzi/mission_mate/feature/main/ExampleUnitTest.kt @@ -1,4 +1,4 @@ -package com.goalpanzi.mission_mate.core.network +package com.goalpanzi.mission_mate.feature.main import org.junit.Test diff --git a/feature/onboarding/build.gradle.kts b/feature/onboarding/build.gradle.kts index 25e537cb..3f77748b 100644 --- a/feature/onboarding/build.gradle.kts +++ b/feature/onboarding/build.gradle.kts @@ -1,76 +1,20 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import com.goalpanzi.mission_mate.convention.setNamespace plugins { - alias(libs.plugins.android.library) - alias(libs.plugins.jetbrains.kotlin.android) - alias(libs.plugins.compose.compiler) - alias(libs.plugins.kotlin.ksp) - alias(libs.plugins.hilt.android) + id("missionmate.android.feature") } android { - namespace = "com.goalpanzi.mission_mate.feature.onboarding" - compileSdk = 34 - - defaultConfig { - minSdk = 26 - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles("consumer-rules.pro") - } - - buildTypes { - release { - isMinifyEnabled = false - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" - ) - } - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlin { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_17) - } - } - buildFeatures { - compose = true - } - composeCompiler { - enableStrongSkippingMode = true - } + setNamespace("feature.onboarding") } dependencies { implementation(libs.androidx.core.ktx) implementation(libs.bundles.lifecycle) - implementation(platform(libs.androidx.compose.bom)) - implementation(libs.bundles.compose) - implementation(libs.bundles.coroutines) - - testImplementation(libs.bundles.test) - androidTestImplementation(libs.bundles.android.test) - androidTestImplementation(platform(libs.androidx.compose.bom)) - debugImplementation(libs.androidx.ui.tooling) - debugImplementation(libs.androidx.ui.test.manifest) - - implementation(libs.androidx.hilt.navigation.compose) - implementation(libs.hilt.android) - ksp(libs.hilt.compiler) - implementation(libs.coil.compose) - - implementation(project(":core:designsystem")) - implementation(project(":core:navigation")) - implementation(project(":core:domain:common")) implementation(project(":core:domain:onboarding")) - implementation(project(":core:domain:mission")) - implementation(project(":core:domain:user")) - implementation(project(":core:ui")) + testImplementation(libs.bundles.test) + androidTestImplementation(libs.bundles.android.test) } diff --git a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/OnboardingViewModel.kt b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/OnboardingViewModel.kt index c39a28f8..0809d9dc 100644 --- a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/OnboardingViewModel.kt +++ b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/OnboardingViewModel.kt @@ -4,6 +4,7 @@ import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.goalpanzi.mission_mate.core.domain.common.DomainResult +import com.goalpanzi.mission_mate.core.domain.common.model.mission.MissionStatus import com.goalpanzi.mission_mate.core.domain.common.model.user.UserProfile import com.goalpanzi.mission_mate.core.domain.mission.usecase.GetMissionJoinedUseCase import com.goalpanzi.mission_mate.core.domain.onboarding.usecase.GetJoinedMissionsUseCase @@ -12,7 +13,6 @@ import com.goalpanzi.mission_mate.feature.onboarding.isAfterProfileCreateArg import com.goalpanzi.mission_mate.feature.onboarding.model.OnboardingResultEvent import com.goalpanzi.mission_mate.feature.onboarding.model.OnboardingUiModel import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow @@ -24,7 +24,6 @@ import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch import javax.inject.Inject -@OptIn(ExperimentalCoroutinesApi::class) @HiltViewModel class OnboardingViewModel @Inject constructor( private val getJoinedMissionsUseCase: GetJoinedMissionsUseCase, @@ -55,36 +54,35 @@ class OnboardingViewModel @Inject constructor( fun getJoinedMissions() { viewModelScope.launch { _onboardingUiModel.emit(OnboardingUiModel.Loading) - - val isJoined = getMissionJoinedUseCase().first() - - getJoinedMissionsUseCase() - .catch { - _onboardingResultEvent.emit(OnboardingResultEvent.Error) - }.collect { result -> - when (result) { - is DomainResult.Success -> { - result.data.missions.let { missions -> - val missionInProgress = missions.lastOrNull { it.missionStatus in setOf("IN_PROGRESS", "CREATED") } - if (missionInProgress != null) { - _onboardingResultEvent.emit( - OnboardingResultEvent.SuccessWithJoinedMissions(missionInProgress) - ) - } else { - _onboardingUiModel.emit( - OnboardingUiModel.Success(result.data.profile) + getJoinedMissionsUseCase( + filter = MissionStatus.statusString + ).catch { + _onboardingResultEvent.emit(OnboardingResultEvent.Error) + }.collect { result -> + when (result) { + is DomainResult.Success -> { + result.data.missions.let { missions -> + val missionInProgress = missions.lastOrNull() + if (missionInProgress != null) { + _onboardingResultEvent.emit( + OnboardingResultEvent.SuccessWithJoinedMissions( + missionInProgress ) + ) + } else { + _onboardingUiModel.emit( + OnboardingUiModel.Success(result.data.profile) + ) - } } } + } - else -> { - _onboardingResultEvent.emit(OnboardingResultEvent.Error) - } + else -> { + _onboardingResultEvent.emit(OnboardingResultEvent.Error) } } - + } } } } diff --git a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupSchedule.kt b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupSchedule.kt index d45369ae..024073dd 100644 --- a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupSchedule.kt +++ b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupSchedule.kt @@ -19,7 +19,6 @@ import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.alpha import androidx.compose.ui.graphics.Shape import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign diff --git a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupScreen.kt b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupScreen.kt index 9cc618d7..a0e0574c 100644 --- a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupScreen.kt +++ b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupScreen.kt @@ -52,7 +52,6 @@ import java.time.DayOfWeek import java.time.LocalDate @SuppressLint("UnrememberedMutableInteractionSource") -@OptIn(ExperimentalFoundationApi::class) @Composable fun BoardSetupRoute( onSuccess : () -> Unit, diff --git a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupSuccessScreen.kt b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupSuccessScreen.kt index fadeefce..b5685e5c 100644 --- a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupSuccessScreen.kt +++ b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupSuccessScreen.kt @@ -1,6 +1,5 @@ package com.goalpanzi.mission_mate.feature.onboarding.screen.boardsetup -import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -16,19 +15,18 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.goalpanzi.mission_mate.core.designsystem.component.MissionMateButtonType import com.goalpanzi.mission_mate.core.designsystem.component.MissionMateTextButton +import com.goalpanzi.mission_mate.core.designsystem.component.OutlinedTextChip +import com.goalpanzi.mission_mate.core.designsystem.component.StableImage import com.goalpanzi.mission_mate.core.designsystem.theme.ColorGray1_FF404249 import com.goalpanzi.mission_mate.core.designsystem.theme.ColorWhite_FFFFFFFF import com.goalpanzi.mission_mate.core.designsystem.theme.MissionMateTypography import com.goalpanzi.mission_mate.feature.onboarding.R -import com.goalpanzi.mission_mate.core.designsystem.component.OutlinedTextChip -import com.goalpanzi.mission_mate.core.designsystem.component.StableImage @Composable fun BoardSetupSuccessScreen( diff --git a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupViewModel.kt b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupViewModel.kt index ad25406c..1eadcb88 100644 --- a/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupViewModel.kt +++ b/feature/onboarding/src/main/java/com/goalpanzi/mission_mate/feature/onboarding/screen/boardsetup/BoardSetupViewModel.kt @@ -8,6 +8,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.goalpanzi.mission_mate.core.domain.common.DomainResult import com.goalpanzi.mission_mate.core.domain.mission.usecase.SetMissionJoinedUseCase +import com.goalpanzi.mission_mate.core.domain.onboarding.model.CreateMissionBody import com.goalpanzi.mission_mate.core.domain.onboarding.usecase.CreateMissionUseCase import com.goalpanzi.mission_mate.feature.onboarding.model.BoardSetupResult import com.goalpanzi.mission_mate.feature.onboarding.model.VerificationTimeType @@ -179,7 +180,7 @@ class BoardSetupViewModel @Inject constructor( } createMissionUseCase( - com.goalpanzi.mission_mate.core.domain.onboarding.model.CreateMissionBody( + CreateMissionBody( description = missionTitle, missionStartDate = formatLocalDateToString(startDate), missionEndDate = formatLocalDateToString(endDate), diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e5992c2c..18b46df2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -60,6 +60,12 @@ lottie-compose = "6.5.0" balloon = "1.6.6" [libraries] +## build-logic +android-gradle-plugin = { group = "com.android.tools.build", name = "gradle", version.ref = "agp" } +kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } +compose-compiler-gradle-plugin = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" } +ksp-gradle-plugin = { group = "com.google.devtools.ksp", name = "com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" } + ## Koitln kotlin-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 60df1575..a77bdfa6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -#Sat Jul 20 15:16:45 KST 2024 +#Sun Oct 13 16:30:39 KST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip diff --git a/settings.gradle.kts b/settings.gradle.kts index 2bad556c..9e3acd1f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,5 @@ pluginManagement { + includeBuild("build-logic") repositories { google { content {