diff --git a/app/src/main/java/com/everymeal/everymeal_android/di/NetworkModule.kt b/app/src/main/java/com/everymeal/everymeal_android/di/NetworkModule.kt index 196aba02..ea5b1669 100644 --- a/app/src/main/java/com/everymeal/everymeal_android/di/NetworkModule.kt +++ b/app/src/main/java/com/everymeal/everymeal_android/di/NetworkModule.kt @@ -1,6 +1,5 @@ package com.everymeal.everymeal_android.di -import com.everymeal.data.service.ExampleApi import com.everymeal.data.service.onboarding.OnboardingApi import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory import dagger.Module @@ -41,12 +40,6 @@ object NetworkModule { .build() } - @Provides - @Singleton - fun provideApi(retrofit: Retrofit): ExampleApi { - return retrofit.create(ExampleApi::class.java) - } - @Provides @Singleton fun provideOnboardingApi(retrofit: Retrofit): OnboardingApi { diff --git a/app/src/main/java/com/everymeal/everymeal_android/di/RepositoryModule.kt b/app/src/main/java/com/everymeal/everymeal_android/di/RepositoryModule.kt index 903accbe..da5bacce 100644 --- a/app/src/main/java/com/everymeal/everymeal_android/di/RepositoryModule.kt +++ b/app/src/main/java/com/everymeal/everymeal_android/di/RepositoryModule.kt @@ -1,12 +1,8 @@ package com.everymeal.everymeal_android.di -import com.everymeal.data.datasource.FoodDataSource -import com.everymeal.data.datasource.FoodDataSourceImpl import com.everymeal.data.datasource.onboarding.OnboardingDataSource import com.everymeal.data.datasource.onboarding.OnboardingDataSourceImpl -import com.everymeal.data.repository.FoodRepositoryImpl import com.everymeal.data.repository.onboarding.OnboardingRepositoryImpl -import com.everymeal.domain.repository.FoodRepository import com.everymeal.domain.repository.onboarding.OnboardingRepository import dagger.Binds import dagger.Module @@ -18,18 +14,6 @@ import javax.inject.Singleton @InstallIn(SingletonComponent::class) abstract class RepositoryModule { - @Singleton - @Binds - abstract fun bindFoodRepository( - foodRepositoryImpl: FoodRepositoryImpl, - ) : FoodRepository - - @Singleton - @Binds - abstract fun bindFoodV2DataSource( - foodDataSourceImpl: FoodDataSourceImpl - ): FoodDataSource - @Singleton @Binds abstract fun bindOnboardingRepository( diff --git a/data/src/main/java/com/everymeal/data/datasource/FoodDataSource.kt b/data/src/main/java/com/everymeal/data/datasource/FoodDataSource.kt deleted file mode 100644 index 9e66b20e..00000000 --- a/data/src/main/java/com/everymeal/data/datasource/FoodDataSource.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.everymeal.data.datasource - -import com.everymeal.domain.model.ResponseWeekFoodEntity -import com.everymeal.domain.model.Result - -interface FoodDataSource { - - suspend fun weekGetFoodArea(s: String): Result -} \ No newline at end of file diff --git a/data/src/main/java/com/everymeal/data/datasource/FoodDataSourceImpl.kt b/data/src/main/java/com/everymeal/data/datasource/FoodDataSourceImpl.kt deleted file mode 100644 index 0909e510..00000000 --- a/data/src/main/java/com/everymeal/data/datasource/FoodDataSourceImpl.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.everymeal.data.datasource - -import com.everymeal.data.model.toWeekFoodEntity -import com.everymeal.data.service.ExampleApi -import com.everymeal.domain.model.ResponseWeekFoodEntity -import javax.inject.Inject -import com.everymeal.domain.model.Result - -class FoodDataSourceImpl @Inject constructor( - private val exampleApi: ExampleApi -) : FoodDataSource { - override suspend fun weekGetFoodArea(s: String): Result { - val response = exampleApi.weekGetFoodArea(s) - return try { - if (response.isSuccessful) { - response.body()?.let { data -> - return Result.Success(data.toWeekFoodEntity()) - } ?: Result.Error(404) - } else { - Result.Error(response.code()) - } - } catch (e: Exception) { - Result.Error(response.code()) - } - } -} \ No newline at end of file diff --git a/data/src/main/java/com/everymeal/data/model/GetWeekFood.kt b/data/src/main/java/com/everymeal/data/model/GetWeekFood.kt deleted file mode 100644 index d1d8c395..00000000 --- a/data/src/main/java/com/everymeal/data/model/GetWeekFood.kt +++ /dev/null @@ -1,44 +0,0 @@ -package com.everymeal.data.model - -import com.everymeal.domain.model.ResponseWeekFoodEntity -import kotlinx.serialization.Serializable - -@Serializable -data class WeekFoodResponse( - val success : Boolean, - val message : String, - val localDateTime : String, - val httpStatus : String, - val httpCode : Int, - val data : List, -) { - @Serializable - data class WeekFoodResult( - val mealId: Int, - val toDay: String, - val mealType : String, - val statusType : String, - val meals : List - ) -} - -fun WeekFoodResponse.toWeekFoodEntity(): ResponseWeekFoodEntity { - val weekFoodResultEntityList = this.data.map { result -> - ResponseWeekFoodEntity.WeekFoodResultEntity( - mealId = result.mealId, - toDay = result.toDay, - mealType = result.mealType, - statusType = result.statusType, - meals = result.meals - ) - } - - return ResponseWeekFoodEntity( - success = this.success, - message = this.message, - localDateTime = this.localDateTime, - httpStatus = this.httpStatus, - httpCode = this.httpCode, - data = weekFoodResultEntityList - ) -} \ No newline at end of file diff --git a/data/src/main/java/com/everymeal/data/repository/FoodRepositoryImpl.kt b/data/src/main/java/com/everymeal/data/repository/FoodRepositoryImpl.kt deleted file mode 100644 index 3def471f..00000000 --- a/data/src/main/java/com/everymeal/data/repository/FoodRepositoryImpl.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.everymeal.data.repository - -import com.everymeal.data.datasource.FoodDataSource -import com.everymeal.domain.model.ResponseWeekFoodEntity -import com.everymeal.domain.model.Result -import com.everymeal.domain.repository.FoodRepository -import javax.inject.Inject - -class FoodRepositoryImpl @Inject constructor( - private val foodDataSource: FoodDataSource -) : FoodRepository { - - override suspend fun weekFood(area: String): Result { - return foodDataSource.weekGetFoodArea(area) - } -} \ No newline at end of file diff --git a/data/src/main/java/com/everymeal/data/service/ExampleApi.kt b/data/src/main/java/com/everymeal/data/service/ExampleApi.kt deleted file mode 100644 index 8157944a..00000000 --- a/data/src/main/java/com/everymeal/data/service/ExampleApi.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.everymeal.data.service - -import com.everymeal.data.model.WeekFoodResponse -import retrofit2.Response -import retrofit2.http.GET -import retrofit2.http.Path - -interface ExampleApi { - - @GET("/api/v2/meals/week/{area}") - suspend fun weekGetFoodArea( - @Path("area") area: String - ): Response -} \ No newline at end of file diff --git a/domain/src/main/java/com/everymeal/domain/model/ResponseWeekFoodEntity.kt b/domain/src/main/java/com/everymeal/domain/model/ResponseWeekFoodEntity.kt deleted file mode 100644 index 2e280d77..00000000 --- a/domain/src/main/java/com/everymeal/domain/model/ResponseWeekFoodEntity.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.everymeal.domain.model - -data class ResponseWeekFoodEntity( - val success : Boolean, - val message : String, - val localDateTime : String, - val httpStatus : String, - val httpCode : Int, - val data : List, -){ - data class WeekFoodResultEntity( - val mealId: Int, - val toDay: String, - val mealType : String, - val statusType : String, - val meals : List - ) -} diff --git a/domain/src/main/java/com/everymeal/domain/model/Result.kt b/domain/src/main/java/com/everymeal/domain/model/Result.kt deleted file mode 100644 index 1d15d382..00000000 --- a/domain/src/main/java/com/everymeal/domain/model/Result.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.everymeal.domain.model - -sealed class Result { - data class Success(val data: T) : Result() - - data class Error(val exception: Int) : Result() -} \ No newline at end of file diff --git a/domain/src/main/java/com/everymeal/domain/repository/FoodRepository.kt b/domain/src/main/java/com/everymeal/domain/repository/FoodRepository.kt deleted file mode 100644 index 4c57b7f2..00000000 --- a/domain/src/main/java/com/everymeal/domain/repository/FoodRepository.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.everymeal.domain.repository - -import com.everymeal.domain.model.ResponseWeekFoodEntity -import com.everymeal.domain.model.Result - -interface FoodRepository { - suspend fun weekFood(area: String): Result -} \ No newline at end of file diff --git a/domain/src/main/java/com/everymeal/domain/usecase/GetWeekFoodUseCase.kt b/domain/src/main/java/com/everymeal/domain/usecase/GetWeekFoodUseCase.kt deleted file mode 100644 index 107d0d58..00000000 --- a/domain/src/main/java/com/everymeal/domain/usecase/GetWeekFoodUseCase.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.everymeal.domain.usecase - -import com.everymeal.domain.repository.FoodRepository -import javax.inject.Inject - -class GetWeekFoodUseCase @Inject constructor( - private val foodRepository: FoodRepository -) { - suspend operator fun invoke(s : String) = foodRepository.weekFood(s) -} \ No newline at end of file diff --git a/presentation/src/main/java/com/everymeal/presentation/ExampleFoodState.kt b/presentation/src/main/java/com/everymeal/presentation/ExampleFoodState.kt deleted file mode 100644 index ffcad981..00000000 --- a/presentation/src/main/java/com/everymeal/presentation/ExampleFoodState.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.everymeal.presentation - -import com.everymeal.domain.model.ResponseWeekFoodEntity - -sealed class ExampleFoodState { - object UnInitialized : ExampleFoodState() - - object Loading : ExampleFoodState() - - data class SuccessWeekFoodGetData(val getWeekFoodData: ResponseWeekFoodEntity) : ExampleFoodState() - - data class Error(val errorCode: Int) : ExampleFoodState() -} \ No newline at end of file diff --git a/presentation/src/main/java/com/everymeal/presentation/ExampleViewModel.kt b/presentation/src/main/java/com/everymeal/presentation/ExampleViewModel.kt deleted file mode 100644 index fe12186c..00000000 --- a/presentation/src/main/java/com/everymeal/presentation/ExampleViewModel.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.everymeal.presentation - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import com.everymeal.domain.model.Result -import com.everymeal.domain.usecase.GetWeekFoodUseCase -import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.asStateFlow -import kotlinx.coroutines.launch -import javax.inject.Inject - -@HiltViewModel -class ExampleViewModel @Inject constructor( - private val getWeekFoodUseCase: GetWeekFoodUseCase -) : ViewModel() { - - private val _weekGetFoodArea = MutableStateFlow(ExampleFoodState.UnInitialized) - val weekGetFoodArea: StateFlow = _weekGetFoodArea.asStateFlow() - - fun getWeekFood(area: String) { - viewModelScope.launch { - when(val result = getWeekFoodUseCase(area)) { - is Result.Success -> { - _weekGetFoodArea.value = ExampleFoodState.SuccessWeekFoodGetData(result.data) - } - is Result.Error -> { - _weekGetFoodArea.value = ExampleFoodState.Error(result.exception) - } - } - } - } -} \ No newline at end of file diff --git a/presentation/src/main/java/com/everymeal/presentation/ui/splash/SplashScreen.kt b/presentation/src/main/java/com/everymeal/presentation/ui/splash/SplashScreen.kt index 63fd72ab..8d001f41 100644 --- a/presentation/src/main/java/com/everymeal/presentation/ui/splash/SplashScreen.kt +++ b/presentation/src/main/java/com/everymeal/presentation/ui/splash/SplashScreen.kt @@ -1,59 +1,27 @@ package com.everymeal.presentation.ui.splash import android.annotation.SuppressLint -import android.util.Log import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import androidx.hilt.navigation.compose.hiltViewModel import com.airbnb.lottie.compose.LottieAnimation import com.airbnb.lottie.compose.LottieCompositionSpec import com.airbnb.lottie.compose.animateLottieCompositionAsState import com.airbnb.lottie.compose.rememberLottieComposition -import com.everymeal.presentation.ExampleFoodState -import com.everymeal.presentation.ExampleViewModel import com.everymeal.presentation.ui.theme.EveryMeal_AndroidTheme @SuppressLint("CoroutineCreationDuringComposition") @Composable fun SplashScreen( onFinishSplash: () -> Unit, - viewModel: ExampleViewModel = hiltViewModel(), ) { - LaunchedEffect(Unit) { - viewModel.getWeekFood("MCC식당") - } - val weekFoodState by viewModel.weekGetFoodArea.collectAsState() - - when (weekFoodState) { - is ExampleFoodState.UnInitialized -> { - - } - - is ExampleFoodState.Loading -> { - - } - - is ExampleFoodState.SuccessWeekFoodGetData -> { - val data = - (weekFoodState as ExampleFoodState.SuccessWeekFoodGetData).getWeekFoodData - Log.d("clean architecture test url success", "$data") - } - - is ExampleFoodState.Error -> { - - } - } - val composition by rememberLottieComposition(LottieCompositionSpec.Asset("everymeal_splash.json")) val progress by animateLottieCompositionAsState(composition)