Skip to content

Commit

Permalink
[Fix] hackerton ysh (#45)
Browse files Browse the repository at this point in the history
* [FIX] #41 링크 추가/삭제 UseCase, Repository의 Result 타입을 int에서 Link로 수정 (링크 업데이트 내용 반영 구현 관련)

* [BASE] #41 core:feature 모듈 추가

* [FIX] #41 RemindResult에 id값 추가

* [FEATURE] #41 링크 추가/수정, 포킷 추가/수정시 다른 화면에 반영되도록 구현

* [FIX] #41 포킷 수정화면에서 기존 포킷의 정보를 UI에 반영하지 못하는 문제 수정, 포킷 수정 호출시 memo가 emptyString일시 body request에서 제외되어 전송되는 문제 수정

* [FIX] #41 리마인드 화면 내 화면 이동 로직 누락 수정

* [FIX] #41 링크 리스트 조회의 isRead, favorites 변수값을 Nullable하게 수정

* [FEATURE] #41 포킷, 링크 삭제 발생시 관련 화면에서 이벤트 수신 가능하도록 구현

* [CHORE] #41 ktlint 적용

* [FIX] #41 포킷 상세 조회시 기본 필터값 중 북마크여부와 안읽음 여부를 false로 변경
  • Loading branch information
l5x5l authored Aug 24, 2024
1 parent 06cfdda commit 4e05841
Show file tree
Hide file tree
Showing 45 changed files with 677 additions and 92 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
alias(libs.plugins.org.jetbrains.kotlin.android)
alias(libs.plugins.hilt)
alias(libs.plugins.googleServices)
alias(libs.plugins.kotlin.parcelize)
id("kotlin-kapt")
}

Expand Down Expand Up @@ -70,6 +71,7 @@ dependencies {
debugImplementation(libs.androidx.ui.test.manifest)

implementation(project(":core:ui"))
implementation(project(":core:feature"))
implementation(project(":data"))
implementation(project(":domain"))
implementation(project(":feature:addlink"))
Expand Down
17 changes: 3 additions & 14 deletions app/src/main/java/pokitmons/pokit/navigation/RootNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package pokitmons.pokit.navigation
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
Expand Down Expand Up @@ -65,13 +64,7 @@ fun RootNavHost(
val viewModel: AddPokitViewModel = hiltViewModel()
AddPokitScreenContainer(
viewModel = viewModel,
onBackPressed = navHostController::popBackStack,
onBackWithModifySuccess = { modifiedPokitId ->
navHostController.popBackStack()
navHostController.currentBackStackEntry
?.savedStateHandle
?.set("modified_pokit_id", modifiedPokitId)
}
onBackPressed = navHostController::popBackStack
)
}

Expand All @@ -80,11 +73,6 @@ fun RootNavHost(
arguments = PokitDetail.arguments
) {
val viewModel: PokitDetailViewModel = hiltViewModel()
LaunchedEffect(it) {
val pokitId = navHostController.currentBackStackEntry?.savedStateHandle?.get<Int>("modified_pokit_id") ?: return@LaunchedEffect
viewModel.getPokit(pokitId)
}

PokitDetailScreenContainer(
viewModel = viewModel,
onBackPressed = navHostController::popBackStack,
Expand Down Expand Up @@ -134,7 +122,8 @@ fun RootNavHost(
onNavigateToSetting = { navHostController.navigate(Setting.route) },
onNavigateToPokitDetail = { navHostController.navigate("${PokitDetail.route}/$it") },
onNavigateAddLink = { navHostController.navigate(AddLink.route) },
onNavigateAddPokit = { navHostController.navigate(AddPokit.route) }
onNavigateAddPokit = { navHostController.navigate(AddPokit.route) },
onNavigateToLinkModify = { navHostController.navigate("${AddLink.route}?${AddLink.linkIdArg}=$it") }
)
}

Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
alias(libs.plugins.hilt) apply false
alias(libs.plugins.com.android.library) apply false
alias(libs.plugins.googleServices) apply false
alias(libs.plugins.kotlin.parcelize) apply false
}

subprojects {
Expand Down
1 change: 1 addition & 0 deletions core/feature/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
59 changes: 59 additions & 0 deletions core/feature/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
plugins {
alias(libs.plugins.com.android.library)
alias(libs.plugins.org.jetbrains.kotlin.android)
alias(libs.plugins.kotlin.parcelize)
}

android {
namespace = "pokitmons.pokit.core.feature"
compileSdk = 34

defaultConfig {
minSdk = 24

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
buildFeatures {
compose = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}
Empty file added core/feature/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions core/feature/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package pokitmons.pokit.core.feature

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("pokitmons.pokit.core.feature.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions core/feature/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package pokitmons.pokit.core.feature.navigation.args

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class LinkArg(
val id: Int,
val title: String,
val thumbnail: String,
val createdAt: String,
val domain: String,
) : Parcelable
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package pokitmons.pokit.core.feature.navigation.args

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.launch

object LinkUpdateEvent {
private val _updatedLink = MutableSharedFlow<LinkArg>()
val updatedLink = _updatedLink.asSharedFlow()

private val _removedLink = MutableSharedFlow<Int>()
val removedLink = _removedLink.asSharedFlow()

fun modifySuccess(link: LinkArg) {
CoroutineScope(Dispatchers.Default).launch {
_updatedLink.emit(link)
}
}

fun removeSuccess(linkId: Int) {
CoroutineScope(Dispatchers.Default).launch {
_removedLink.emit(linkId)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package pokitmons.pokit.core.feature.navigation.args

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class PokitArg(
val id: Int,
val imageId: Int,
val imageUrl: String,
val title: String,
) : Parcelable
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package pokitmons.pokit.core.feature.navigation.args

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.launch

object PokitUpdateEvent {
private val _updatedPokit = MutableSharedFlow<PokitArg>()
val updatedPokit = _updatedPokit.asSharedFlow()

private val _removedPokitId = MutableSharedFlow<Int>()
val removedPokitId = _removedPokitId.asSharedFlow()

fun updatePokit(pokitArg: PokitArg) {
CoroutineScope(Dispatchers.Default).launch {
_updatedPokit.emit(pokitArg)
}
}

fun removePokit(pokitId: Int) {
CoroutineScope(Dispatchers.Default).launch {
_removedPokitId.emit(pokitId)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package pokitmons.pokit.core.feature

import org.junit.Assert.assertEquals
import org.junit.Test

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
4 changes: 2 additions & 2 deletions data/src/main/java/pokitmons/pokit/data/api/LinkApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ interface LinkApi {
@Query("page") page: Int = 0,
@Query("size") size: Int = 10,
@Query("sort") sort: List<String> = listOf(LinksSort.RECENT.value),
@Query("isRead") isRead: Boolean = false,
@Query("favorites") favorites: Boolean = false,
@Query("isRead") isRead: Boolean? = null,
@Query("favorites") favorites: Boolean? = null,
@Query("startDate") startDate: String? = null,
@Query("endDate") endDate: String? = null,
@Query("categoryIds") categoryIds: List<Int>? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ interface LinkDataSource {
page: Int = 0,
size: Int = 10,
sort: List<String> = listOf(LinksSort.RECENT.value),
isRead: Boolean = false,
favorites: Boolean = false,
isRead: Boolean? = null,
favorites: Boolean? = null,
startDate: String? = null,
endDate: String? = null,
categoryIds: List<Int>? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class RemoteLinkDataSource @Inject constructor(
page: Int,
size: Int,
sort: List<String>,
isRead: Boolean,
favorites: Boolean,
isRead: Boolean?,
favorites: Boolean?,
startDate: String?,
endDate: String?,
categoryIds: List<Int>?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ object RemindMapper {
fun mapperToRemind(remindResponse: RemindResponse): List<RemindResult> {
return remindResponse.data.map { remind ->
RemindResult(
id = remind.contentId,
title = remind.title,
domain = remind.domain,
createdAt = remind.createdAt,
Expand All @@ -21,6 +22,7 @@ object RemindMapper {
fun mapperToTodayContents(remindResponse: List<Remind>): List<RemindResult> {
return remindResponse.map { remind ->
RemindResult(
id = remind.contentId,
title = remind.title,
domain = remind.domain,
createdAt = remind.createdAt,
Expand Down
20 changes: 18 additions & 2 deletions data/src/main/java/pokitmons/pokit/data/mapper/link/LinkMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pokitmons.pokit.data.mapper.link

import pokitmons.pokit.data.model.link.response.GetLinkResponse
import pokitmons.pokit.data.model.link.response.GetLinksResponse
import pokitmons.pokit.data.model.link.response.ModifyLinkResponse
import pokitmons.pokit.domain.model.link.Link

object LinkMapper {
Expand All @@ -26,8 +27,8 @@ object LinkMapper {
fun mapperToLink(linkResponse: GetLinkResponse): Link {
return Link(
id = linkResponse.contentId,
categoryId = linkResponse.categoryId,
categoryName = "",
categoryId = linkResponse.category.categoryId,
categoryName = linkResponse.category.categoryName,
data = linkResponse.data,
domain = "",
title = linkResponse.title,
Expand All @@ -37,4 +38,19 @@ object LinkMapper {
favorites = linkResponse.favorites
)
}

fun mapperToLink(modifyLinkResponse: ModifyLinkResponse): Link {
return Link(
id = modifyLinkResponse.contentId,
categoryId = modifyLinkResponse.categoryId,
categoryName = "",
data = modifyLinkResponse.data,
domain = "",
title = modifyLinkResponse.title,
memo = modifyLinkResponse.memo,
alertYn = modifyLinkResponse.alertYn,
createdAt = modifyLinkResponse.createdAt,
favorites = modifyLinkResponse.favorites
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package pokitmons.pokit.data.model.link.request
import kotlinx.serialization.Serializable

@Serializable
class ModifyLinkRequest(
val data: String = "",
val title: String = "",
val categoryId: Int = 0,
val memo: String = "",
val alertYn: String = "",
val thumbNail: String = "",
data class ModifyLinkRequest(
val data: String,
val title: String,
val categoryId: Int,
val memo: String,
val alertYn: String,
val thumbNail: String,
)
Loading

0 comments on commit 4e05841

Please sign in to comment.