Skip to content

Commit

Permalink
Merge pull request #181 from WithPeace/feat/#180_밸런스_게임_ui_구현
Browse files Browse the repository at this point in the history
Feat/#180 밸런스 게임 UI 구현
  • Loading branch information
rhkrwngud445 authored Jan 5, 2025
2 parents ea756ae + ab70175 commit 011507f
Show file tree
Hide file tree
Showing 49 changed files with 1,067 additions and 38 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ dependencies {
implementation(project(":feature:disablepolicy"))
implementation(project(":feature:policylist"))
implementation(project(":feature:policyfilter"))
implementation(project(":feature:search"))
implementation(project(":feature:balancegame"))
implementation(project(":core:ui"))
implementation(project(":core:interceptor"))
implementation(project(":core:data"))
Expand All @@ -69,6 +71,5 @@ dependencies {
implementation(project(":core:domain"))
implementation(project(":core:analytics"))
implementation(project(":core:designsystem"))
implementation(project(":feature:search"))
testImplementation(project(":core:testing"))
}
12 changes: 12 additions & 0 deletions app/src/main/java/com/withpeace/withpeace/navigation/NavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import com.app.profileeditor.navigation.navigateProfileEditor
import com.app.profileeditor.navigation.profileEditorNavGraph
import com.withpeace.withpeace.core.designsystem.ui.snackbar.SnackbarState
import com.withpeace.withpeace.core.designsystem.ui.snackbar.SnackbarType
import com.withpeace.withpeace.feature.balancegame.navigation.balanceGameGraph
import com.withpeace.withpeace.feature.balancegame.navigation.navigateToBalanceGame
import com.withpeace.withpeace.feature.disablepolicy.navigation.disabledPolicyNavGraph
import com.withpeace.withpeace.feature.disablepolicy.navigation.navigateDisabledPolicy
import com.withpeace.withpeace.feature.gallery.navigation.galleryNavGraph
Expand Down Expand Up @@ -215,6 +217,9 @@ fun WithpeaceNavHost(
onSearchClick = {
navController.navigateToSearch()
},
onClickBalanceGame = {
navController.navigateToBalanceGame()
}
)
searchGraph(
onAuthExpired = {},
Expand Down Expand Up @@ -421,6 +426,13 @@ fun WithpeaceNavHost(
navController.navigateToPolicyDetail(policyId = it)
},
)
balanceGameGraph(
onShowSnackBar = {
onShowSnackBar(SnackbarState(it))
},
onAuthExpired = {},
onClickBackButton = navController::popBackStack,
)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.withpeace.withpeace.core.data.di

import com.withpeace.withpeace.core.data.repository.DefaultAppUpdateRepository
import com.withpeace.withpeace.core.data.repository.DefaultBalanceGameRepository
import com.withpeace.withpeace.core.data.repository.DefaultImageRepository
import com.withpeace.withpeace.core.data.repository.DefaultPostRepository
import com.withpeace.withpeace.core.data.repository.DefaultRecentSearchKeywordRepository
import com.withpeace.withpeace.core.data.repository.DefaultTokenRepository
import com.withpeace.withpeace.core.data.repository.DefaultUserRepository
import com.withpeace.withpeace.core.data.repository.DefaultYouthPolicyRepository
import com.withpeace.withpeace.core.domain.repository.AppUpdateRepository
import com.withpeace.withpeace.core.domain.repository.BalanceGameRepository
import com.withpeace.withpeace.core.domain.repository.ImageRepository
import com.withpeace.withpeace.core.domain.repository.PostRepository
import com.withpeace.withpeace.core.domain.repository.RecentSearchKeywordRepository
Expand Down Expand Up @@ -60,4 +62,11 @@ interface RepositoryModule {
fun bindsAppUpdateRepository(
appUpdateRepository: DefaultAppUpdateRepository,
): AppUpdateRepository

@Binds
@ViewModelScoped
fun bindsBalanceGameRepository(
defaultBalanceGameRepository: DefaultBalanceGameRepository
): BalanceGameRepository

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.withpeace.withpeace.core.data.repository

import com.withpeace.withpeace.core.datastore.dataStore.balancegame.BalanceGameDataStore
import com.withpeace.withpeace.core.domain.repository.BalanceGameRepository
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class DefaultBalanceGameRepository @Inject constructor(
private val balanceGameDataStore: BalanceGameDataStore,
): BalanceGameRepository {
override fun isVisited(): Flow<Boolean> {
return balanceGameDataStore.isVisited
}

override suspend fun updateVisitedStatus(visited: Boolean) {
balanceGameDataStore.updateVisitedStatus(visited)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.withpeace.withpeace.core.datastore.dataStore.balancegame

import kotlinx.coroutines.flow.Flow

interface BalanceGameDataStore {

val isVisited: Flow<Boolean>

suspend fun updateVisitedStatus(visited: Boolean)
}

//TODO 구현체 설정
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.withpeace.withpeace.core.datastore.dataStore.balancegame

import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import javax.inject.Inject
import javax.inject.Named

class DefaultBalanceGameDataStore @Inject constructor(
@Named("balance_game") private val dataStore: DataStore<Preferences>,
) : BalanceGameDataStore {
override val isVisited: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[BALANCE_GAME_VISITED] ?: false
}

override suspend fun updateVisitedStatus(visited: Boolean) {
dataStore.edit { preferences ->
preferences[BALANCE_GAME_VISITED] = visited
}
}

companion object {
private val BALANCE_GAME_VISITED = booleanPreferencesKey("BALANCE_GAME_VISITED")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ object DataStoreModule {

private const val AUTH_DATASTORE_NAME = "AUTH_PREFERENCES"
private const val USER_DATASTORE_NAME = "USER_PREFERENCES"
private const val BALANCE_GAME_DATASTORE_NAME = "BALANCE_GAME_DATASTORE_NAME"

private val Context.authDataStore: DataStore<Preferences> by preferencesDataStore(name = AUTH_DATASTORE_NAME)
private val Context.userDataStore: DataStore<Preferences> by preferencesDataStore(name = USER_DATASTORE_NAME)
private val Context.balanceGameDataStore: DataStore<Preferences> by preferencesDataStore(name = BALANCE_GAME_DATASTORE_NAME)

@Provides
@Singleton
Expand All @@ -35,4 +37,11 @@ object DataStoreModule {
fun providesUserDataStore(
@ApplicationContext context: Context,
): DataStore<Preferences> = context.userDataStore

@Provides
@Singleton
@Named("balance_game")
fun providesBalanceGameDataStore(
@ApplicationContext context: Context,
): DataStore<Preferences> = context.balanceGameDataStore
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.withpeace.withpeace.core.datastore.di

import com.withpeace.withpeace.core.datastore.dataStore.balancegame.BalanceGameDataStore
import com.withpeace.withpeace.core.datastore.dataStore.balancegame.DefaultBalanceGameDataStore
import com.withpeace.withpeace.core.datastore.dataStore.token.DefaultTokenPreferenceDataSource
import com.withpeace.withpeace.core.datastore.dataStore.token.TokenPreferenceDataSource
import com.withpeace.withpeace.core.datastore.dataStore.user.DefaultUserPreferenceDataSource
Expand All @@ -25,4 +27,10 @@ interface PreferenceDataSourceModule {
fun bindsUserPreferenceDataSource(
defaultUserPreferenceDataSource: DefaultUserPreferenceDataSource,
): UserPreferenceDataSource

@Binds
@Singleton
fun bindsBalanceGamePreferenceDataSource(
defaultBalanceGameDataStore: DefaultBalanceGameDataStore
): BalanceGameDataStore
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,10 @@ data class WithPeaceTypography(
lineHeight = 21.sp,
letterSpacing = 0.16.sp,
),
val medium16LineHeight20: TextStyle = TextStyle(
fontFamily = PretendardFont,
fontWeight = FontWeight.Medium,
fontSize = 16.sp,
lineHeight = 20.sp,
),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.withpeace.withpeace.core.domain.repository

import kotlinx.coroutines.flow.Flow

interface BalanceGameRepository {
fun isVisited(): Flow<Boolean>

suspend fun updateVisitedStatus(visited: Boolean)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.withpeace.withpeace.core.domain.usecase

import com.withpeace.withpeace.core.domain.repository.BalanceGameRepository
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class BalanceGameVisitedUseCase @Inject constructor(
private val balanceGameRepository: BalanceGameRepository,
) {
operator fun invoke(): Flow<Boolean> = balanceGameRepository.isVisited()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.withpeace.withpeace.core.domain.usecase

import com.withpeace.withpeace.core.domain.repository.BalanceGameRepository
import javax.inject.Inject

class UpdateBalanceGameVisitedStatus @Inject constructor(
private val balanceGameRepository: BalanceGameRepository,
){
suspend operator fun invoke(isVisited: Boolean) {
balanceGameRepository.updateVisitedStatus(isVisited)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.withpeace.withpeace.feature.postdetail
package com.withpeace.withpeace.core.ui.comment

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
Expand Down Expand Up @@ -41,10 +41,12 @@ import com.skydoves.landscapist.glide.GlideImage
import com.withpeace.withpeace.core.designsystem.theme.PretendardFont
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.core.ui.DateUiModel
import com.withpeace.withpeace.core.ui.R
import com.withpeace.withpeace.core.ui.R.drawable
import com.withpeace.withpeace.core.ui.post.CommentUiModel
import com.withpeace.withpeace.core.ui.post.CommentUserUiModel
import com.withpeace.withpeace.core.ui.post.ReportTypeUiModel
import com.withpeace.withpeace.core.ui.report.PostDetailReportBottomSheet
import com.withpeace.withpeace.core.ui.toRelativeString
import java.time.LocalDateTime

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.withpeace.withpeace.core.ui.comment

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.core.ui.R

@Composable
fun CommentSize(
modifier: Modifier = Modifier,
commentSize: Int,
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start
) {
Row(
modifier = modifier.padding(horizontal = WithpeaceTheme.padding.BasicHorizontalPadding),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = horizontalArrangement
) {
Icon(
painter = painterResource(id = R.drawable.ic_chat),
contentDescription = "댓글 개수",
modifier = Modifier.padding(end = 4.dp),
)
Text(
text = "$commentSize",
style = WithpeaceTheme.typography.caption,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.withpeace.withpeace.feature.postdetail
package com.withpeace.withpeace.core.ui.comment

import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
Expand Down Expand Up @@ -27,6 +27,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.dp
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.core.ui.R

@Composable
fun RegisterCommentSection(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.withpeace.withpeace.core.ui.report

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.RectangleShape
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.core.designsystem.ui.WithPeaceBackButtonTopAppBar
import com.withpeace.withpeace.core.ui.post.ReportTypeUiModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun PostDetailReportBottomSheet(
isPostReport: Boolean,
id: Long,
onDismissRequest: () -> Unit,
onClickReportType: (id: Long, ReportTypeUiModel) -> Unit,
) {
val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
ModalBottomSheet(
contentWindowInsets = { WindowInsets(0, 0, 0, 0) },
containerColor = WithpeaceTheme.colors.SystemWhite,
onDismissRequest = onDismissRequest,
sheetState = bottomSheetState,
shape = RectangleShape,
) {
Column(
modifier = Modifier.fillMaxSize(),
) {
WithPeaceBackButtonTopAppBar(
onClickBackButton = onDismissRequest,
title = {
Text(text = "신고하는 이유를 선택해주세요", style = WithpeaceTheme.typography.title1)
},
)
HorizontalDivider(Modifier.padding(horizontal = WithpeaceTheme.padding.BasicHorizontalPadding))
Column(
modifier = Modifier
.fillMaxWidth(),
) {
ReportTypeUiModel.entries.forEach { reportTypeUiModel ->
ReportTypeItem(
isPostReport = isPostReport,
id = id,
reportTypeUiModel = reportTypeUiModel,
onClickReportType = onClickReportType,
onDismissRequest = onDismissRequest,
)
}
}
}
}
}
Loading

0 comments on commit 011507f

Please sign in to comment.