Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat/#11] 7주차 과제 구현 #12

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

This file was deleted.

19 changes: 9 additions & 10 deletions app/src/main/java/org/sopt/and/core/utils/PreferenceUtil.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package org.sopt.and.core.utils

import android.content.SharedPreferences
import androidx.compose.runtime.staticCompositionLocalOf
import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject


class PreferenceUtil @Inject constructor(
private val sharedPreferences: SharedPreferences
@ApplicationContext private val context: Context
) {

companion object {
private const val USER_TOKEN = "user_token"
val LocalPreferenceUtils = staticCompositionLocalOf<PreferenceUtil> {
error("PreferenceUtils is not initialized")
}
}
private val sharedPreferences =
context.getSharedPreferences("wavve_prefs", Context.MODE_PRIVATE)

fun saveUserToken(token: String) {
sharedPreferences.edit().putString(USER_TOKEN, token).apply()
Expand All @@ -31,4 +26,8 @@ class PreferenceUtil @Inject constructor(
fun clearAll() {
sharedPreferences.edit().clear().apply()
}

companion object {
private const val USER_TOKEN = "user_token"
}
}
7 changes: 2 additions & 5 deletions app/src/main/java/org/sopt/and/data/di/PreferenceModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import javax.inject.Singleton
object PreferenceModule {
@Provides
@Singleton
fun providePreferenceUtils(
@ApplicationContext context: Context
): PreferenceUtil {
val sharedPreferences = context.getSharedPreferences("wavve_prefs", Context.MODE_PRIVATE)
return PreferenceUtil(sharedPreferences)
fun providePreferenceUtil(@ApplicationContext context: Context): PreferenceUtil {
return PreferenceUtil(context)
}
}
8 changes: 8 additions & 0 deletions app/src/main/java/org/sopt/and/data/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import org.sopt.and.data.api.UserService
import org.sopt.and.data.repository.DummyHomeContentRepositoryImpl
import org.sopt.and.data.repository.GetMyHobbyRepositoryImpl
import org.sopt.and.data.repository.UserLoginRepositoryImpl
import org.sopt.and.data.repository.UserRegisterRepositoryImpl
import org.sopt.and.domain.repository.DummyHomeContentRepository
import org.sopt.and.domain.repository.GetMyHobbyRepository
import org.sopt.and.domain.repository.UserLoginRepository
import org.sopt.and.domain.repository.UserRegisterRepository
Expand All @@ -34,4 +36,10 @@ object RepositoryModule {
fun provideGetMyHobbyRepository(userService: UserService): GetMyHobbyRepository {
return GetMyHobbyRepositoryImpl(userService)
}

@Provides
@Singleton
fun provideDummyHomeContentRepository(): DummyHomeContentRepository {
return DummyHomeContentRepositoryImpl()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
package org.sopt.and.data.repository

import org.sopt.and.R
import org.sopt.and.domain.model.entity.HomeCommonContent
import org.sopt.and.domain.model.entity.HomeContent
import org.sopt.and.domain.repository.DummyHomeContentRepository
import javax.inject.Inject

class DummyHomeContentRepositoryImpl @Inject constructor() : DummyHomeContentRepository {
override fun getDummyMainContents(): List<HomeContent> = listOf(
HomeContent(
id = 1,
title = "이토록 친밀한 배신자",
image = R.drawable.img_banner_poaster_1,
description = "이토록 친밀한 배신자"
), HomeContent(
id = 1,
title = "어이미남!!2",
image = R.drawable.img_banner_poaster_2,
description = "어이미남!!2"
), HomeContent(
id = 1,
title = "나의 히어로 아카데미아",
image = R.drawable.img_banner_poaster_3,
description = "나의 히어로 아카데미아"
)
)

override fun getDummyCommonContents(): List<HomeCommonContent> = listOf(
HomeCommonContent(
mainTitle = "믿고 보는 웨이브 에디터 추천작",
contentStates = listOf(
HomeContent(
id = 1,
title = "로 앤 오더 : 토론토 - 크리미널 인텐드 시즌1",
image = R.drawable.thumbnail1,
description = "로 앤 오더 : 토론토 - 크리미널 인텐드 시즌1"
), HomeContent(
id = 1,
title = "원피스",
image = R.drawable.thumbnail2,
description = "원피스"
), HomeContent(
id = 1,
title = "이토록 친절한 배신자",
image = R.drawable.thumbnail3,
description = "이토록 친절한 배신자"
), HomeContent(
id = 1,
title = "강철부대",
image = R.drawable.thumbnail4,
description = "강철부대"
), HomeContent(
id = 1,
title = "지옥에서 온 판사",
image = R.drawable.thumbnail5,
description = "지옥에서 온 판사"
)
)
), HomeCommonContent(
mainTitle = "실시간 인기 콘텐츠",
contentStates = listOf(
HomeContent(
id = 1,
title = "로 앤 오더 : 토론토 - 크리미널 인텐드 시즌1",
image = R.drawable.thumbnail1,
description = "로 앤 오더 : 토론토 - 크리미널 인텐드 시즌1"
), HomeContent(
id = 1,
title = "원피스",
image = R.drawable.thumbnail2,
description = "원피스"
), HomeContent(
id = 1,
title = "이토록 친절한 배신자",
image = R.drawable.thumbnail3,
description = "이토록 친절한 배신자"
), HomeContent(
id = 1,
title = "강철부대",
image = R.drawable.thumbnail4,
description = "강철부대"
), HomeContent(
id = 1,
title = "지옥에서 온 판사",
image = R.drawable.thumbnail5,
description = "지옥에서 온 판사"
)
).reversed()
), HomeCommonContent(
mainTitle = "오직 웨이브에서",
contentStates = listOf(
HomeContent(
id = 1,
title = "런닝맨",
image = R.drawable.thumbnail6,
description = "런닝맨"
), HomeContent(
id = 1,
title = "미운 우리 새끼",
image = R.drawable.thumbnail7,
description = "미운 우리 새끼"
), HomeContent(
id = 1,
title = "심야괴담회",
image = R.drawable.thumbnail8,
description = "심야괴담회"
), HomeContent(
id = 1,
title = "나 혼자 산다",
image = R.drawable.thumbnail9,
description = "나 혼자 산다"
), HomeContent(
id = 1,
title = "전지적 참견 시점",
image = R.drawable.thumbnail10,
description = "전지적 참견 시점"
)
)
)
)

override fun getDummyRankingContents(): HomeCommonContent =
HomeCommonContent(
mainTitle = "오늘의 TOP 20",
contentStates = listOf(
HomeContent(
id = 1,
title = "로 앤 오더 : 토론토 - 크리미널 인텐드 시즌1",
image = R.drawable.thumbnail1,
description = "로 앤 오더 : 토론토 - 크리미널 인텐드 시즌1"
), HomeContent(
id = 1,
title = "원피스",
image = R.drawable.thumbnail2,
description = "원피스"
), HomeContent(
id = 1,
title = "이토록 친절한 배신자",
image = R.drawable.thumbnail3,
description = "이토록 친절한 배신자"
), HomeContent(
id = 1,
title = "강철부대",
image = R.drawable.thumbnail4,
description = "강철부대"
), HomeContent(
id = 1,
title = "지옥에서 온 판사",
image = R.drawable.thumbnail5,
description = "지옥에서 온 판사"
),
HomeContent(
id = 1,
title = "런닝맨",
image = R.drawable.thumbnail6,
description = "런닝맨"
), HomeContent(
id = 1,
title = "미운 우리 새끼",
image = R.drawable.thumbnail7,
description = "미운 우리 새끼"
), HomeContent(
id = 1,
title = "심야괴담회",
image = R.drawable.thumbnail8,
description = "심야괴담회"
), HomeContent(
id = 1,
title = "나 혼자 산다",
image = R.drawable.thumbnail9,
description = "나 혼자 산다"
), HomeContent(
id = 1,
title = "전지적 참견 시점",
image = R.drawable.thumbnail10,
description = "전지적 참견 시점"
)
)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.sopt.and.domain.model.entity

data class HomeCommonContent(
val mainTitle: String,
val contentStates: List<HomeContent>,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.sopt.and.domain.model.entity

data class HomeContent(
val id: Int,
val title: String,
val image: Int,
val description: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sopt.and.domain.repository

import org.sopt.and.domain.model.entity.HomeCommonContent
import org.sopt.and.domain.model.entity.HomeContent

interface DummyHomeContentRepository {
fun getDummyMainContents(): List<HomeContent>
fun getDummyCommonContents(): List<HomeCommonContent>
fun getDummyRankingContents(): HomeCommonContent
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.sopt.and.presentation.auth.signin

import org.sopt.and.presentation.util.UiEffect
import org.sopt.and.presentation.util.UiEvent
import org.sopt.and.presentation.util.UiState

class SignInContract {
data class SignInUiState(
val username: String = "",
val password: String = "",
val isLoading: Boolean = false,
val errorMessage: String? = null
) : UiState

sealed class SignInUiEvent : UiEvent {
data class UpdateUserName(val username: String) : SignInUiEvent()
data class UpdatePassword(val password: String) : SignInUiEvent()
data object SignInFormSubmit : SignInUiEvent()
data object NavigateUp : SignInUiEvent()
}

sealed class SignInUiEffect : UiEffect {
data object ShowSuccessSnackBar : SignInUiEffect()
data class ShowErrorSnackBar(val message: String) : SignInUiEffect()
data object NavigateToSignUp : SignInUiEffect()
data object NavigateToMy : SignInUiEffect()
data object NavigateUp : SignInUiEffect()
}
}
Loading