Skip to content

Commit

Permalink
[WEAV-106] 내 프로필 입력 - 활동 지역 (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
moondev03 authored Nov 3, 2024
1 parent 0a41744 commit 9f7a5fb
Show file tree
Hide file tree
Showing 22 changed files with 839 additions and 5 deletions.
5 changes: 5 additions & 0 deletions 3days/core/design-system/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,9 @@
<string name="my_profile_occupation_sub_title">좋아요, 조금만 더 알려주세요!</string>
<string name="my_profile_occupation_title">재직 중인 회사에서\n당신의 직군은 무엇인가요?</string>
<string name="my_profile_occupation_not_selected_error_message">내 직군을 선택해 주세요</string>

<string name="my_profile_location_sub_title">설레는 만남이 다가오고 있어요.</string>
<string name="my_profile_location_title">당신의 활동 지역은 어디인가요?</string>
<string name="my_profile_location_not_selected_error_message">내 활동 지역을 선택해 주세요</string>
<string name="my_profile_location_fetch_data_failure_message">지역 정보 조회에 실패했습니다</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.weave.model.domain.myprofile

data class Location(
val id: java.util.UUID,
val region: String,
val subRegion: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.weave.data.datasource

import com.weave.model.network.NetworkResult
import com.weave.network.model.Location

interface LocationRemoteDataSource {

suspend fun getLocationRegions(): NetworkResult<List<String>>

suspend fun getLocationsByRegion(regionName: String): NetworkResult<List<Location>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.weave.data.datasource

import com.weave.data.extension.handleApiResponse
import com.weave.model.network.NetworkResult
import com.weave.network.api.LocationsApi
import com.weave.network.model.Location
import javax.inject.Inject

class LocationRemoteDataSourceImpl @Inject constructor(
private val service: LocationsApi
) : LocationRemoteDataSource {

override suspend fun getLocationRegions(): NetworkResult<List<String>> {
return handleApiResponse {
service.getLocationRegions()
}
}

override suspend fun getLocationsByRegion(regionName: String): NetworkResult<List<Location>> {
return handleApiResponse {
service.getLocationsByRegion(regionName)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import com.weave.data.datasource.AuthRemoteDataSource
import com.weave.data.datasource.AuthRemoteDataSourceImpl
import com.weave.data.datasource.CompanyRemoteDataSource
import com.weave.data.datasource.CompanyRemoteDataSourceImpl
import com.weave.data.datasource.LocationRemoteDataSource
import com.weave.data.datasource.LocationRemoteDataSourceImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -21,4 +23,8 @@ abstract class DataSourceModule {
@Binds
@Singleton
abstract fun bindsCompanyDataSource(impl: CompanyRemoteDataSourceImpl): CompanyRemoteDataSource

@Binds
@Singleton
abstract fun bindsLocationDataSource(impl: LocationRemoteDataSourceImpl): LocationRemoteDataSource
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.weave.data.di

import com.weave.data.repository.AuthRepositoryImpl
import com.weave.data.repository.CompanyRepositoryImpl
import com.weave.data.repository.LocationRepositoryImpl
import com.weave.domain.repository.AuthRepository
import com.weave.domain.repository.CompanyRepository
import com.weave.domain.repository.LocationRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -21,4 +23,8 @@ abstract class RepositoryModule {
@Binds
@Singleton
abstract fun bindsCompanyRepository(impl: CompanyRepositoryImpl): CompanyRepository

@Binds
@Singleton
abstract fun bindsLocationRepository(impl: LocationRepositoryImpl): LocationRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.weave.data.mapper

import com.weave.network.model.Location
import com.weave.model.domain.myprofile.Location as LocationEntity

val Location.toDomain
get() = LocationEntity(
id = id, region = region, subRegion = subRegion
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.weave.data.repository

import com.weave.data.datasource.LocationRemoteDataSource
import com.weave.data.extension.handleNetworkCall
import com.weave.data.mapper.toDomain
import com.weave.domain.repository.LocationRepository
import com.weave.model.domain.myprofile.Location
import com.weave.model.network.NetworkResult
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class LocationRepositoryImpl @Inject constructor(
private val dataSource: LocationRemoteDataSource
) : LocationRepository {

override suspend fun getLocationRegions(): Flow<NetworkResult<List<String>>> =
handleNetworkCall(
networkCall = {
dataSource.getLocationRegions()
},
mapToDomain = { it.map { regionName -> regionName } }
)

override suspend fun getLocationsByRegion(regionName: String): Flow<NetworkResult<List<Location>>> =
handleNetworkCall(
networkCall = {
dataSource.getLocationsByRegion(regionName = regionName)
},
mapToDomain = { it.map { data -> data.toDomain } }
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.moon.company
package com.weave.company

import com.weave.domain.repository.CompanyRepository
import com.weave.model.domain.myprofile.Company
Expand Down
1 change: 1 addition & 0 deletions 3days/domain/location/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
16 changes: 16 additions & 0 deletions 3days/domain/location/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id("java-library")
alias(libs.plugins.jetbrains.kotlin.jvm)
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

dependencies {
implementation(project(":domain"))
implementation(project(":core:model"))
implementation(libs.kotlinx.coroutines.core)
implementation(libs.javax.inject)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.weave.location

import com.weave.domain.repository.LocationRepository
import com.weave.model.network.NetworkResult
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class GetLocationRegionsUseCase @Inject constructor(
private val repository: LocationRepository
) {
suspend operator fun invoke(): Flow<NetworkResult<List<String>>> =
repository.getLocationRegions()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.weave.location

import com.weave.domain.repository.LocationRepository
import com.weave.model.domain.myprofile.Location
import com.weave.model.network.NetworkResult
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class GetLocationsByRegionUseCase @Inject constructor(
private val repository: LocationRepository
) {
suspend operator fun invoke(regionName: String): Flow<NetworkResult<List<Location>>> =
repository.getLocationsByRegion(regionName)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.weave.domain.repository

import com.weave.model.domain.myprofile.Location
import com.weave.model.network.NetworkResult
import kotlinx.coroutines.flow.Flow

interface LocationRepository {

suspend fun getLocationRegions(): Flow<NetworkResult<List<String>>>

suspend fun getLocationsByRegion(regionName: String): Flow<NetworkResult<List<Location>>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ enum class Route(val routeName: String) {
fun NavGraphBuilder.navGraphIntro(navController: NavController) {
navigation(startDestination = Route.Welcome.routeName, route = Route.Intro.routeName) {
composable(Route.Welcome.routeName) {
IntroScreen(onClicked = { navController.navigate(Route.MobileSendAuth.routeName) })
// 개발 편의를 위한 주석 처리
// IntroScreen(onClicked = { navController.navigate(Route.MobileSendAuth.routeName) })
IntroScreen(onClicked = { navController.navigate(Route.MyProfile.withArgs("Test Register Token")) })
}

composable(Route.MobileSendAuth.routeName) {
Expand Down
1 change: 1 addition & 0 deletions 3days/feat/my-profile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies {
implementation(project(":core:utils"))
implementation(project(":core:design-system"))
implementation(project(":domain:company"))
implementation(project(":domain:location"))

implementation(libs.bundles.compose)
debugImplementation(libs.bundles.compose.debug)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.weave.my_profile.birth.MyProfileBirthYearScreen
import com.weave.my_profile.company.MyProfileCompanyScreen
import com.weave.my_profile.gender.MyProfileGenderScreen
import com.weave.my_profile.init.MyProfileInitScreen
import com.weave.my_profile.location.MyProfileLocationScreen
import com.weave.my_profile.occupation.MyProfileOccupationScreen
import com.weave.utils.navigation.navigateWithClearBackStack

Expand All @@ -25,6 +26,7 @@ enum class Route(val routeName: String) {
MyProfileBirth("my_profile_birth"),
MyProfileCompany("my_profile_company"),
MyProfileOccupation("my_profile_occupation"),
MyProfileLocation("my_profile_location"),
NextScreen("next_screen");

fun withArgs(vararg args: String): String {
Expand Down Expand Up @@ -82,8 +84,13 @@ fun NavGraphBuilder.navGraphMyProfile(navController: NavController) {
)
},
onNextBtnClicked = {
// 개발 편의를 위한 주석 처리
// navController.navigateWithClearBackStack(
// Route.MyProfileBirth.routeName,
// Route.MyProfileInit.withArgs(registerToken)
// )
navController.navigateWithClearBackStack(
Route.MyProfileBirth.routeName,
Route.MyProfileLocation.routeName,
Route.MyProfileInit.withArgs(registerToken)
)
}
Expand Down Expand Up @@ -149,12 +156,34 @@ fun NavGraphBuilder.navGraphMyProfile(navController: NavController) {
},
onNextBtnClicked = {
navController.navigateWithClearBackStack(
Route.NextScreen.routeName,
Route.MyProfileLocation.routeName,
Route.MyProfileCompany.routeName
)
}
)
}

composable(Route.MyProfileLocation.routeName) {
val sharedViewModel =
it.sharedViewModel<MyProfileSharedViewModel>(navController = navController)

MyProfileLocationScreen(
sharedViewModel = sharedViewModel,
onBackBtnClicked = {
navController.navigateWithClearBackStack(
Route.MyProfileOccupation.routeName,
Route.MyProfileLocation.routeName,
launchSingleTop = true
)
},
onNextBtnClicked = {
navController.navigateWithClearBackStack(
Route.NextScreen.routeName,
Route.MyProfileOccupation.routeName
)
}
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.lifecycle.ViewModel
import com.weave.design_system.component.Gender
import com.weave.model.domain.myprofile.Company
import com.weave.model.domain.myprofile.JobOccupation
import com.weave.model.domain.myprofile.Location
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

Expand All @@ -21,4 +22,5 @@ class MyProfileSharedViewModel @Inject constructor(
var company: Company? = null
var isMatchSameCompany: Boolean? = null
var occupation: JobOccupation? = null
var locations: List<Location> = listOf()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.weave.my_profile.company

import android.content.Context
import androidx.lifecycle.viewModelScope
import com.moon.company.SearchCompaniesUseCase
import com.weave.company.SearchCompaniesUseCase
import com.weave.design_system.R
import com.weave.design_system.component.SnackBarType
import com.weave.model.domain.myprofile.Company
Expand Down
Loading

0 comments on commit 9f7a5fb

Please sign in to comment.