Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
55aeb58
feat: 친구 프로필 Service 세팅
rhkrwngud445 Aug 24, 2025
783ba62
refactor: ContactFrequency -> ContactFrequencyLevel 수정
rhkrwngud445 Aug 24, 2025
83815a3
feat: repository API 호출 로직 구성
rhkrwngud445 Aug 24, 2025
061043f
refactor: friendSummary 모델 세부 패키지 구성
rhkrwngud445 Aug 24, 2025
7492ab0
feat: friendProfileScreen 상단 상태바 패딩 적용
rhkrwngud445 Aug 24, 2025
d2cc816
chore: string res 정리
rhkrwngud445 Aug 24, 2025
4979f35
feat: dropdown 구성
rhkrwngud445 Aug 24, 2025
6d55bbb
feat: 프로필 정보 조회 API 연동
rhkrwngud445 Aug 24, 2025
3dfd47d
feat: 전화 및 문자 화면 이동 로직 구성
rhkrwngud445 Aug 24, 2025
e69e043
docs: res 사용하는 model TODO 작성
rhkrwngud445 Aug 25, 2025
7502dae
refactor: remindInterval 서버와 네이밍을 똑같이 수정
rhkrwngud445 Aug 25, 2025
f76e95c
refactor: relation 타입을 enum으로 변경
rhkrwngud445 Aug 25, 2025
19df3f3
feat: 프로필 정보 데이터 연동
rhkrwngud445 Aug 26, 2025
3d793b5
feat: 챙김 기록 데이터 연동
rhkrwngud445 Aug 26, 2025
7933609
fix: 챙김 기록 Entity 직렬화 적용
rhkrwngud445 Aug 26, 2025
7e718b6
feat: 챙김 및 친구 삭제 데이터 연동
rhkrwngud445 Aug 26, 2025
5263fb3
feat: Friend Navigation 인자 전달을 위한 Serializable 적용
rhkrwngud445 Aug 27, 2025
431ccc2
feat: parcelize 의존성 추가
rhkrwngud445 Aug 30, 2025
04d6d36
feat: Route 인자 전달을 위한 serializable, pacelable 적용
rhkrwngud445 Aug 30, 2025
c25a8eb
feat: friend 파라미터 전달 적용
rhkrwngud445 Aug 30, 2025
e066210
feat: 정보 수정 이벤트 적용
rhkrwngud445 Aug 30, 2025
0074695
feat: 정보 수정 API 연동
rhkrwngud445 Aug 31, 2025
85a40ee
feat: 이전 화면 데이터 적용
rhkrwngud445 Aug 31, 2025
e5fd302
fix: navigation imageUrl 인코딩 적용
rhkrwngud445 Aug 31, 2025
83465cb
feat: 화면이 길어질 경우 스크롤 적용
rhkrwngud445 Aug 31, 2025
acdd13a
feat: 수정시 다이얼로그 추가
rhkrwngud445 Aug 31, 2025
9819c4c
fix: 친구 관계 버튼 클릭 포인트 수정
rhkrwngud445 Aug 31, 2025
79b504f
fix: 챔김순서 최신순으로 수정
rhkrwngud445 Aug 31, 2025
123091c
refactor: string res 분리
rhkrwngud445 Sep 1, 2025
146331b
feat: 스플래쉬 화면 구현
stopstone Sep 3, 2025
c3f5233
feat: 로그인 상태 확인 로직 구현
stopstone Sep 3, 2025
fa77703
feat: 앱 아이콘 변경
stopstone Sep 3, 2025
c25aa6b
refactor: img_bg.png 이미지 dpi별 drawable 분리
stopstone Sep 3, 2025
1ee5d34
refactor: 스플래시 화면 ViewModel 로직 수정
stopstone Sep 3, 2025
9b25c62
feat: 온보딩 버튼 컴포넌트 추가
stopstone Sep 4, 2025
172e602
feat: 온보딩 페이지 인디케이터 UI 구현
stopstone Sep 4, 2025
be8479c
feat: 온보딩 페이지 모델 구현
stopstone Sep 4, 2025
61d1fd4
feat: 온보딩 화면 구현
stopstone Sep 4, 2025
22c741b
feat: 온보딩 네비게이션 설정
stopstone Sep 4, 2025
717b0d4
feat: 온보딩 페이지 이미지 추가
stopstone Sep 5, 2025
ad971ef
feat: 온보딩 화면 이미지 추가
stopstone Sep 5, 2025
c4ff3c9
feat: 온보딩 UI 이미지 영역 수정
stopstone Sep 5, 2025
262ded3
feat: 온보딩 페이지 백그라운드 구성
stopstone Sep 5, 2025
45513a1
feat: 온보딩 배경 추가
stopstone Sep 5, 2025
7768d8f
refactor: 불필요한 패딩 제거
stopstone Sep 5, 2025
846bbce
feat: 온보딩 백그라운드 색상 변경
stopstone Sep 5, 2025
a053f43
refactor: OnboardingScreen UI 레이아웃 조정
stopstone Sep 5, 2025
18af35b
refactor: AnnotatedString.Builder 확장 함수 추가
stopstone Sep 5, 2025
037f6d3
feat: DataStore 분리 및 Qualifier 적용
stopstone Sep 5, 2025
ffc32db
feat: 온보딩 DataStore 추가
stopstone Sep 5, 2025
0e3ff5e
feat: 온보딩 완료 상태 저장 로직 추가
stopstone Sep 5, 2025
98a8d85
feat: 온보딩 버튼 로딩 상태 추가
stopstone Sep 5, 2025
fa5cadc
feat: 온보딩 화면 UI 상태 및 사이드 이펙트 처리
stopstone Sep 5, 2025
39d462b
fix: delete 엔드포인트 수정
rhkrwngud445 Sep 6, 2025
c9c6d8d
fix: ci 문법 수정
rhkrwngud445 Sep 6, 2025
25f2f20
feat: 온보딩 버튼 텍스트 stirng.xml 리소스 추가
stopstone Sep 6, 2025
22ec755
feat: 온보딩 레포지토리 추가 및 ViewModel 연동
stopstone Sep 6, 2025
a99de45
refactor: 온보딩 페이지 데이터 - remember로 성능 최적화
stopstone Sep 6, 2025
2ae7148
refactor: 온보딩 Preferences 키 상수화
stopstone Sep 6, 2025
1fa484d
refactor: 불필요한 코드 제거
stopstone Sep 6, 2025
508f2d5
refactor: 온보딩 페이지 데이터 모델 변경
stopstone Sep 6, 2025
5845e24
refactor: 디자인 가이드에 맞게 텍스트 수정
stopstone Sep 6, 2025
588a6a3
feat: Color.kt 온보딩 배경 장식 색상 추가
stopstone Sep 6, 2025
7360949
refactor: 불필요한 import문 제거
stopstone Sep 6, 2025
7e3f7b3
refactor: string res 적용
rhkrwngud445 Sep 7, 2025
a42d27a
refactor: 연락 빈도 매직넘버 처리
rhkrwngud445 Sep 7, 2025
90ed514
fix: context -> stringres 수정
rhkrwngud445 Sep 7, 2025
9bfdb65
refactor: dayOfWeek enum 적용
rhkrwngud445 Sep 7, 2025
ea1c634
fix: 네비게이션바 패딩 적용
rhkrwngud445 Sep 7, 2025
ea1bdae
fix: records isEmpty 상태를 통한 화면 상태 관리하도록 수정
rhkrwngud445 Sep 7, 2025
5b0a186
feat: 친구 프로필 Service 세팅
rhkrwngud445 Aug 24, 2025
369fd4d
refactor: ContactFrequency -> ContactFrequencyLevel 수정
rhkrwngud445 Aug 24, 2025
9a66d1a
feat: repository API 호출 로직 구성
rhkrwngud445 Aug 24, 2025
2891d1d
refactor: friendSummary 모델 세부 패키지 구성
rhkrwngud445 Aug 24, 2025
5119ed8
feat: friendProfileScreen 상단 상태바 패딩 적용
rhkrwngud445 Aug 24, 2025
77ced7c
chore: string res 정리
rhkrwngud445 Aug 24, 2025
7bfb1a8
feat: dropdown 구성
rhkrwngud445 Aug 24, 2025
4f5e7af
feat: 프로필 정보 조회 API 연동
rhkrwngud445 Aug 24, 2025
ccd2f94
refactor: conflict 수정
rhkrwngud445 Sep 7, 2025
bf10b44
docs: res 사용하는 model TODO 작성
rhkrwngud445 Aug 25, 2025
9e6673f
refactor: remindInterval 서버와 네이밍을 똑같이 수정
rhkrwngud445 Aug 25, 2025
22997cd
refactor: relation 타입을 enum으로 변경
rhkrwngud445 Aug 25, 2025
1c337d2
feat: 프로필 정보 데이터 연동
rhkrwngud445 Aug 26, 2025
46fd87f
feat: 챙김 기록 데이터 연동
rhkrwngud445 Aug 26, 2025
3367602
fix: 챙김 기록 Entity 직렬화 적용
rhkrwngud445 Aug 26, 2025
6056356
feat: 챙김 및 친구 삭제 데이터 연동
rhkrwngud445 Aug 26, 2025
d81ed8c
feat: Friend Navigation 인자 전달을 위한 Serializable 적용
rhkrwngud445 Aug 27, 2025
b802953
feat: parcelize 의존성 추가
rhkrwngud445 Aug 30, 2025
0127f09
feat: Route 인자 전달을 위한 serializable, pacelable 적용
rhkrwngud445 Aug 30, 2025
817ec40
feat: friend 파라미터 전달 적용
rhkrwngud445 Aug 30, 2025
010d395
feat: 정보 수정 이벤트 적용
rhkrwngud445 Aug 30, 2025
6eb87dd
feat: 정보 수정 API 연동
rhkrwngud445 Aug 31, 2025
77a1c65
feat: 이전 화면 데이터 적용
rhkrwngud445 Aug 31, 2025
b6dfdff
fix: navigation imageUrl 인코딩 적용
rhkrwngud445 Aug 31, 2025
5a0a84c
feat: 화면이 길어질 경우 스크롤 적용
rhkrwngud445 Aug 31, 2025
078384b
feat: 수정시 다이얼로그 추가
rhkrwngud445 Aug 31, 2025
7046065
fix: 친구 관계 버튼 클릭 포인트 수정
rhkrwngud445 Aug 31, 2025
f2807ab
fix: 챔김순서 최신순으로 수정
rhkrwngud445 Aug 31, 2025
80a0b87
refactor: string res 분리
rhkrwngud445 Sep 1, 2025
6e07d8e
fix: delete 엔드포인트 수정
rhkrwngud445 Sep 6, 2025
66c1ddd
refactor: string res 적용
rhkrwngud445 Sep 7, 2025
adfd5f4
refactor: 연락 빈도 매직넘버 처리
rhkrwngud445 Sep 7, 2025
258fa45
fix: context -> stringres 수정
rhkrwngud445 Sep 7, 2025
867511c
refactor: dayOfWeek enum 적용
rhkrwngud445 Sep 7, 2025
a77678d
fix: 네비게이션바 패딩 적용
rhkrwngud445 Sep 7, 2025
72acb6a
fix: records isEmpty 상태를 통한 화면 상태 관리하도록 수정
rhkrwngud445 Sep 7, 2025
c290de7
Merge remote-tracking branch 'origin/feat/#21-feat_친구_프로필_api_연동' int…
rhkrwngud445 Sep 7, 2025
eb93e25
feat: NearFrame 적용
rhkrwngud445 Sep 7, 2025
307da48
feat: NearDropdown 적용
rhkrwngud445 Sep 7, 2025
b53ebe6
Merge pull request #23 from near-Contact-Reminder/feat/#21-feat_친구_프로…
rhkrwngud445 Sep 7, 2025
cc908b4
Merge pull request #28 from near-Contact-Reminder/Fix]-CI-문법-수정
rhkrwngud445 Sep 7, 2025
32c70d8
Merge branch 'dev' into feat/splash-auto-login
stopstone Sep 16, 2025
83e9aba
feat: 스플래시 화면 관련 파일 삭제
stopstone Sep 16, 2025
90e1696
feat: 스플래시 화면 라이브러리 추가
stopstone Sep 16, 2025
d291865
feat: themes.xml에서 스플래시 화면 구현
stopstone Sep 16, 2025
8fb3bfc
feat: 스플래시 로고 이미지 추가
stopstone Sep 16, 2025
a669663
feat: 스플래시 화면 API 적용 및 로그인 상태에 따른 화면 분기 처리
stopstone Sep 16, 2025
6165bff
Merge pull request #26 from near-Contact-Reminder/feat/splash-auto-login
stopstone Sep 18, 2025
2fac627
feat: 온보딩 버튼 컴포넌트 추가
stopstone Sep 4, 2025
ea7a2e1
feat: 온보딩 페이지 인디케이터 UI 구현
stopstone Sep 4, 2025
0c22958
feat: 온보딩 페이지 모델 구현
stopstone Sep 4, 2025
c536bf4
feat: 온보딩 화면 구현
stopstone Sep 4, 2025
dcfd9ca
feat: 온보딩 네비게이션 설정
stopstone Sep 4, 2025
3396b74
feat: 온보딩 페이지 이미지 추가
stopstone Sep 5, 2025
48834cf
feat: 온보딩 화면 이미지 추가
stopstone Sep 5, 2025
d3c08c5
feat: 온보딩 UI 이미지 영역 수정
stopstone Sep 5, 2025
d58d85d
feat: 온보딩 페이지 백그라운드 구성
stopstone Sep 5, 2025
9d1453b
feat: 온보딩 배경 추가
stopstone Sep 5, 2025
7b59095
refactor: 불필요한 패딩 제거
stopstone Sep 5, 2025
fc190f0
feat: 온보딩 백그라운드 색상 변경
stopstone Sep 5, 2025
1577a75
refactor: OnboardingScreen UI 레이아웃 조정
stopstone Sep 5, 2025
1596dab
refactor: AnnotatedString.Builder 확장 함수 추가
stopstone Sep 5, 2025
2834cc6
feat: DataStore 분리 및 Qualifier 적용
stopstone Sep 5, 2025
b749fcb
feat: 온보딩 DataStore 추가
stopstone Sep 5, 2025
c19802b
feat: 온보딩 완료 상태 저장 로직 추가
stopstone Sep 5, 2025
e798851
feat: 온보딩 버튼 로딩 상태 추가
stopstone Sep 5, 2025
5cf9a2f
feat: 온보딩 화면 UI 상태 및 사이드 이펙트 처리
stopstone Sep 5, 2025
dc46da1
feat: 온보딩 버튼 텍스트 stirng.xml 리소스 추가
stopstone Sep 6, 2025
66ac5a1
feat: 온보딩 레포지토리 추가 및 ViewModel 연동
stopstone Sep 6, 2025
93ab1c3
refactor: 온보딩 페이지 데이터 - remember로 성능 최적화
stopstone Sep 6, 2025
b6577d0
refactor: 온보딩 Preferences 키 상수화
stopstone Sep 6, 2025
f30d851
refactor: 불필요한 코드 제거
stopstone Sep 6, 2025
4d59fef
refactor: 온보딩 페이지 데이터 모델 변경
stopstone Sep 6, 2025
d8a4c99
refactor: 디자인 가이드에 맞게 텍스트 수정
stopstone Sep 6, 2025
cd47e30
feat: Color.kt 온보딩 배경 장식 색상 추가
stopstone Sep 6, 2025
b29e18c
refactor: 불필요한 import문 제거
stopstone Sep 6, 2025
38045f7
feat: 앱 시작 시 온보딩 및 로그인 상태에 따른 화면 분기 처리
stopstone Sep 19, 2025
25b7bd9
Merge remote-tracking branch 'origin/feat/onboarding-pages' into feat…
stopstone Sep 19, 2025
a35fba3
refactor: 온보딩 관련 중복 문자열 제거
stopstone Sep 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/android-pull-request-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ jobs:
echo "TEMP_TOKEN=\"TEMP_TOKEN\"" >> local.properties

- name: Access Kakao KAKAO_NATIVE_APP_KEY
env:
KAKAO_NATIVE_APP_KEY: ${{ secrets.KAKAO_NATIVE_APP_KEY }}
run: |
echo "KAKAO_NATIVE_APP_KEY=\"$KAKAO_NATIVE_APP_KEY\"" >> local.properties
env:
KAKAO_NATIVE_APP_KEY: ${{ secrets.KAKAO_NATIVE_APP_KEY }}
run: |
echo "KAKAO_NATIVE_APP_KEY=\"$KAKAO_NATIVE_APP_KEY\"" >> local.properties

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand Down
4 changes: 4 additions & 0 deletions Near/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
alias(libs.plugins.hilt.application)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kotlin.parcelize)
}

android {
Expand Down Expand Up @@ -98,6 +99,9 @@ dependencies {

// Kakao Module
implementation(libs.v2.all)

// Splash Screen API
implementation(libs.androidx.core.splashscreen)
}

fun getProperty(propertyKey: String): String = gradleLocalProperties(rootDir, providers).getProperty(propertyKey)
15 changes: 9 additions & 6 deletions Near/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
Expand All @@ -20,25 +20,28 @@
<meta-data
android:name="com.kakao.sdk.AppKey"
android:value="${kakaoAppKey}" />

<!-- 카카오톡 로그인 콜백을 위한 Activity -->
<activity
android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="oauth"
android:scheme="kakao${kakaoAppKey}" />

<data
android:host="oauth"
android:scheme="kakao${kakaoAppKey}" />
</intent-filter>
</activity>

<activity
android:name=".presentation.feature.main.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Near">
android:theme="@style/Theme.Near.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
24 changes: 21 additions & 3 deletions Near/app/src/main/java/com/alarmy/near/data/di/DataStoreModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,35 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Qualifier
import javax.inject.Singleton

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class AuthDataStore

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class OnboardingDataStore

// DataStore 확장 프로퍼티
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "auth_preferences")
private val Context.authDataStore: DataStore<Preferences> by preferencesDataStore(name = "auth_preferences")
private val Context.onboardingDataStore: DataStore<Preferences> by preferencesDataStore(name = "onboarding_preferences")

@Module
@InstallIn(SingletonComponent::class)
object DataStoreModule {
@Provides
@Singleton
fun provideDataStore(
@AuthDataStore
fun provideAuthDataStore(
@ApplicationContext context: Context,
): DataStore<Preferences> = context.authDataStore

@Provides
@Singleton
@OnboardingDataStore
fun provideOnboardingDataStore(
@ApplicationContext context: Context,
): DataStore<Preferences> = context.dataStore
): DataStore<Preferences> = context.onboardingDataStore
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import com.alarmy.near.data.repository.DefaultFriendRepository
import com.alarmy.near.data.repository.ExampleRepository
import com.alarmy.near.data.repository.ExampleRepositoryImpl
import com.alarmy.near.data.repository.FriendRepository
import com.alarmy.near.data.repository.OnBoardingRepository
import com.alarmy.near.data.repository.OnBoardingRepositoryImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -26,4 +28,8 @@ interface RepositoryModule {
@Binds
@Singleton
abstract fun bindAuthRepository(authRepositoryImpl: AuthRepositoryImpl): AuthRepository

@Binds
@Singleton
abstract fun bindOnBoardingRepository(onBoardingRepositoryImpl: OnBoardingRepositoryImpl): OnBoardingRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.alarmy.near.data.local.datastore

import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import com.alarmy.near.data.di.OnboardingDataStore
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import javax.inject.Inject
import javax.inject.Singleton

/**
* 온보딩 완료 상태를 관리하는 DataStore
* 최초 접속 여부를 확인하여 온보딩 화면 표시 여부를 결정
*/
@Singleton
class OnboardingPreferences @Inject constructor(
@OnboardingDataStore private val dataStore: DataStore<Preferences>,
) {
companion object {
private val ONBOARDING_COMPLETED_KEY = booleanPreferencesKey("onboarding_completed")
}

/**
* 온보딩 완료 여부를 확인하는 Flow
* true: 온보딩 완료됨, false: 온보딩 미완료
*/
val isOnboardingCompleted: Flow<Boolean> = dataStore.data.map { preferences ->
preferences[ONBOARDING_COMPLETED_KEY] ?: false
}

/**
* 온보딩 완료 상태를 저장
*/
suspend fun setOnboardingCompleted(completed: Boolean) {
dataStore.edit { preferences ->
preferences[ONBOARDING_COMPLETED_KEY] = completed
}
}

/**
* 온보딩 완료 상태를 true로 설정
*/
suspend fun markOnboardingAsCompleted() {
setOnboardingCompleted(true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.longPreferencesKey
import androidx.datastore.preferences.core.stringPreferencesKey
import com.alarmy.near.data.di.AuthDataStore
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map

import javax.inject.Inject
import javax.inject.Singleton

Expand All @@ -16,11 +16,9 @@ import javax.inject.Singleton
* 액세스 토큰과 리프레시 토큰의 저장, 조회, 삭제를 담당
*/
@Singleton
class TokenPreferences
@Inject
constructor(
private val dataStore: DataStore<Preferences>,
) {
class TokenPreferences @Inject constructor(
@AuthDataStore private val dataStore: DataStore<Preferences>,
) {
private val accessTokenKey = stringPreferencesKey("access_token")
private val refreshTokenKey = stringPreferencesKey("refresh_token")
private val expiresAtKey = longPreferencesKey("expires_at")
Expand Down
74 changes: 59 additions & 15 deletions Near/app/src/main/java/com/alarmy/near/data/mapper/FriendMapper.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,65 @@
package com.alarmy.near.data.mapper

import com.alarmy.near.model.Anniversary
import com.alarmy.near.model.ContactFrequency
import com.alarmy.near.model.FriendSummary
import com.alarmy.near.model.DayOfWeek
import com.alarmy.near.model.Friend
import com.alarmy.near.model.Relation
import com.alarmy.near.model.ReminderInterval
import com.alarmy.near.network.request.AnniversaryRequest
import com.alarmy.near.network.request.ContactFrequencyRequest
import com.alarmy.near.network.request.FriendRequest
import com.alarmy.near.network.response.AnniversaryEntity
import com.alarmy.near.network.response.ContactFrequencyEntity
import com.alarmy.near.network.response.FriendEntity

fun FriendEntity.toModel(): FriendSummary =
FriendSummary(
id = friendId,
fun FriendEntity.toModel(): Friend =
Friend(
friendId = friendId,
imageUrl = imageUrl,
relation = Relation.valueOf(relation),
name = name,
profileImageUrl = imageUrl,
lastContactedAt = lastContactAt,
isContacted = true,
contactFrequency =
when (checkRate) {
in 0..29 -> ContactFrequency.LOW
in 30..69 -> ContactFrequency.MIDDLE
in 70..100 -> ContactFrequency.HIGH
else -> ContactFrequency.LOW
},
)
contactFrequency = contactFrequency.toModel(),
birthday = birthday,
anniversaryList = anniversaryList.map { it.toModel() },
memo = memo,
phone = phone,
lastContactAt = lastContactAt,
)

fun ContactFrequencyEntity.toModel(): ContactFrequency =
ContactFrequency(
reminderInterval = ReminderInterval.valueOf(contactWeek),
dayOfWeek = DayOfWeek.valueOf(dayOfWeek),
)

fun AnniversaryEntity.toModel(): Anniversary =
Anniversary(
id = id,
title = title,
date = date,
)

fun Friend.toRequest(): FriendRequest =
FriendRequest(
name = name,
relation = relation.toString(),
contactFrequency = contactFrequency.toRequest(),
birthday = birthday,
anniversaryList = anniversaryList.map { it.toRequest() },
memo = memo,
phone = phone,
)

fun ContactFrequency.toRequest(): ContactFrequencyRequest =
ContactFrequencyRequest(
contactWeek = reminderInterval.toString(),
dayOfWeek = dayOfWeek.toString(),
)

fun Anniversary.toRequest(): AnniversaryRequest =
AnniversaryRequest(
id = id,
title = title,
date = date,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.alarmy.near.data.mapper

import com.alarmy.near.model.FriendRecord
import com.alarmy.near.network.response.FriendRecordEntity
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

fun FriendRecordEntity.toModel(): FriendRecord =
FriendRecord(
isChecked = isChecked,
createdAt = createdAt.toShortDate(),
)

private fun String.toShortDate(): String {
val inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
val outputFormatter = DateTimeFormatter.ofPattern("yy.MM.dd")

val dateTime = LocalDateTime.parse(this, inputFormatter)
return dateTime.format(outputFormatter)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.alarmy.near.data.mapper

import com.alarmy.near.model.friendsummary.ContactFrequencyLevel
import com.alarmy.near.model.friendsummary.FriendSummary
import com.alarmy.near.network.response.FriendSummaryEntity

private val CONTACT_FREQUENCY_LOW_RANGE = 0..29
private val CONTACT_FREQUENCY_MIDDLE_RANGE = 30..69
private val CONTACT_FREQUENCY_HIGH_RANGE = 70..100

fun FriendSummaryEntity.toModel(): FriendSummary =
FriendSummary(
id = friendId,
name = name,
profileImageUrl = imageUrl,
lastContactedAt = lastContactAt,
isContacted = true,
contactFrequencyLevel =
when (checkRate) {
in CONTACT_FREQUENCY_LOW_RANGE -> ContactFrequencyLevel.LOW
in CONTACT_FREQUENCY_MIDDLE_RANGE -> ContactFrequencyLevel.MIDDLE
in CONTACT_FREQUENCY_HIGH_RANGE -> ContactFrequencyLevel.HIGH
else -> ContactFrequencyLevel.LOW
},
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.alarmy.near.data.repository

import com.alarmy.near.data.mapper.toModel
import com.alarmy.near.model.FriendSummary
import com.alarmy.near.data.mapper.toRequest
import com.alarmy.near.model.Friend
import com.alarmy.near.model.FriendRecord
import com.alarmy.near.model.friendsummary.FriendSummary
import com.alarmy.near.model.monthly.MonthlyFriend
import com.alarmy.near.network.service.FriendService
import kotlinx.coroutines.flow.Flow
Expand Down Expand Up @@ -30,4 +33,34 @@ class DefaultFriendRepository
},
)
}

override fun fetchFriendById(friendId: String): Flow<Friend> =
flow {
emit(friendService.fetchFriendById(friendId).toModel())
}

override fun updateFriend(
friendId: String,
friend: Friend,
): Flow<Friend> =
flow {
emit(friendService.updateFriend(friendId, friend.toRequest()).toModel())
}

override fun deleteFriend(friendId: String): Flow<Unit> =
flow {
friendService.deleteFriend(friendId)
emit(Unit)
}

override fun fetchFriendRecord(friendId: String): Flow<List<FriendRecord>> =
flow {
emit(friendService.fetchFriendRecord(friendId).map { it.toModel() })
}

override fun recordContact(friendId: String): Flow<String> =
flow {
val response = friendService.recordContact(friendId)
emit(response.message) // CommonMessageEntity.message 라고 가정
}
}
Loading