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

[#1012] 간단한 화면에서 MVVM Like 구조 없이 상태관리할 수 있게 구조 변경 #1013

Merged
merged 26 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e5c7790
[#1012] AuthRepository 가져올 수 있는 EntryPoint 정의, SignOutActivity 간소화
l2hyunwoo Dec 31, 2024
37b038c
[#1012] 패키지네임에 camelCase 제거, SignOutViewModel 제거
l2hyunwoo Dec 31, 2024
07f63f0
[#1012] Rin 추가
l2hyunwoo Dec 31, 2024
4436f86
[#1012] Spotless Apply
l2hyunwoo Dec 31, 2024
e180d03
[#1012] AdjustSentence쪽 패키지 이동
l2hyunwoo Dec 31, 2024
91f2095
[#1012] UserRepository EntryPoint 설치
l2hyunwoo Dec 31, 2024
d10b4dc
[#1012] 솝탬프 한마디 수정 영역 UiState 정의 및 UI 로직 remember로 따로 빼기
l2hyunwoo Dec 31, 2024
dff6d25
[#1012] Context#findActivity util 함수 추가
l2hyunwoo Dec 31, 2024
ed0a080
[#1012] Activity에 ModifyProfileState 적용
l2hyunwoo Dec 31, 2024
d739db8
[#1012] SideEffect, ViewModel 삭제
l2hyunwoo Dec 31, 2024
b39fa8d
[#1012] Spotless Apply
l2hyunwoo Dec 31, 2024
8dcae83
[#1012] Context 직접 참조하는 부분 변경
l2hyunwoo Jan 1, 2025
11b6973
[#1012] mockk 의존성 추가, mypage에 테스트 의존성 추가
l2hyunwoo Jan 1, 2025
e3092cc
[#1012] Testable하게 구조 변경 (UserRepository)
l2hyunwoo Jan 1, 2025
073b7f4
[#1012] Add unit test for modify profile state
l2hyunwoo Jan 1, 2025
21e9850
[#1012] Spotless Apply
l2hyunwoo Jan 1, 2025
fc18e3c
[#1012] StartArgs -> Argument로 네이밍 변경
l2hyunwoo Jan 1, 2025
bd76bee
[#1012] Lint
l2hyunwoo Jan 1, 2025
c160ff3
[#1012] MyPage UiState, Action 정의
l2hyunwoo Jan 1, 2025
44762a4
[#1012] MyPage의 UiState Holder 정의
l2hyunwoo Jan 1, 2025
58fda61
[#1012] MyPageActivity에 적용
l2hyunwoo Jan 1, 2025
91f99cf
[#1012] Spotless Apply
l2hyunwoo Jan 1, 2025
b984b97
[#1012] generateBaselineProfile
l2hyunwoo Jan 1, 2025
e4686ea
[#1012] Spotless Apply
l2hyunwoo Jan 2, 2025
5b16e97
[#1012] generateBaselineProfile
l2hyunwoo Jan 2, 2025
8d2b1f1
[#1012] remove warning
l2hyunwoo Jan 2, 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
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@
android:exported="false"
android:launchMode="singleTop" />
<activity
android:name=".feature.mypage.signOut.SignOutActivity"
android:name=".feature.mypage.signout.SignOutActivity"
android:exported="false" />
<activity
android:name=".feature.mypage.soptamp.sentence.AdjustSentenceActivity"
android:name=".feature.mypage.soptamp.ui.AdjustSentenceActivity"
android:exported="false" />
<activity
android:name=".feature.poke.onboarding.OnboardingActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
* Copyright 2023-2024 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
* Copyright 2023-2024 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2023-2024 SOPT - Shout Our Passion Together
* Copyright 2023-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -153,7 +153,7 @@ class HomeActivity : AppCompatActivity() {
tracker.track(type = EventType.CLICK, name = "mypage", properties = mapOf("view_type" to args?.userStatus?.value))
lifecycleScope.launch {
startActivity(
MyPageActivity.getIntent(this@HomeActivity, MyPageActivity.StartArgs(viewModel.userActiveState.value))
MyPageActivity.getIntent(this@HomeActivity, MyPageActivity.Argument(viewModel.userActiveState.value))
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2023-2024 SOPT - Shout Our Passion Together
* Copyright 2023-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -55,7 +55,7 @@ class NavigatorProviderIntent @Inject constructor(

override fun getMyPageActivityIntent(name: String) = MyPageActivity.getIntent(
context,
MyPageActivity.StartArgs(UserActiveState.valueOf(name))
MyPageActivity.Argument(UserActiveState.valueOf(name))
)

override fun getAttendanceActivityIntent() = AttendanceActivity.newInstance(context)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_auth_alert_circle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
MIT License

Copyright (c) 2024 SOPT Makers
Copyright (c) 2023-2024 SOPT Makers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_auth_arrow_right.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
MIT License

Copyright (c) 2024 SOPT Makers
Copyright (c) 2023-2024 SOPT Makers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
MIT License

Copyright (c) 2024 SOPT Makers
Copyright (c) 2023-2024 SOPT Makers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_auth_memeber_error.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
MIT License

Copyright (c) 2024 SOPT Makers
Copyright (c) 2022-2024 SOPT Makers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
842 changes: 441 additions & 401 deletions app/src/release/generated/baselineProfiles/baseline-prof.txt

Large diffs are not rendered by default.

842 changes: 441 additions & 401 deletions app/src/release/generated/baselineProfiles/startup-prof.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/analytics/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2023-2024 SOPT - Shout Our Passion Together
* Copyright 2023-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
* Copyright 2024-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
* Copyright 2023-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
* Copyright 2024-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
* Copyright 2024-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2023-2024 SOPT - Shout Our Passion Together
* Copyright 2023-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
* Copyright 2024-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions core/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

plugins {
sopt("feature")
sopt("compose")
}

android {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2023-2024 SOPT - Shout Our Passion Together
* Copyright 2024 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -22,33 +22,18 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.sopt.official.feature.mypage.signOut
package org.sopt.official.common.context

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
import org.sopt.official.auth.repository.AuthRepository
import timber.log.Timber
import android.content.Context
import android.content.ContextWrapper

@HiltViewModel
class SignOutViewModel @Inject constructor(
private val authRepository: AuthRepository,
) : ViewModel() {
private val _event = Channel<Unit>()
val event = _event.receiveAsFlow()

fun signOut() {
viewModelScope.launch {
authRepository.withdraw()
.onSuccess {
_event.send(Unit)
}.onFailure {
Timber.e(it)
}
inline fun <reified T> Context.findActivity(): T? {
var context = this
while (context is ContextWrapper) {
if (context is T) {
return context
}
context = context.baseContext
}
return null
Comment on lines +30 to +38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개인적으로 해당 함수에서 null이 반환될 경우 그 이유를 JavaDoc으로 적어주시면 좋을 것 같아요! 해당 함수는 이후 기수분들도 많이 사용할 것 같아서요.

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
* Copyright 2024-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
* Copyright 2024-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
* Copyright 2024-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
* Copyright 2024-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
* Copyright 2024-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
* Copyright 2024-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
16 changes: 14 additions & 2 deletions feature/mypage/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2023-2024 SOPT - Shout Our Passion Together
* Copyright 2023-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,6 +26,7 @@
plugins {
sopt("feature")
sopt("compose")
sopt("test")
}

android {
Expand All @@ -43,4 +44,15 @@ dependencies {
implementation(libs.bundles.firebase)
implementation(libs.process.phoenix)
implementation(libs.kotlin.collections.immutable)
}
implementation(libs.rin)

testImplementation(libs.mockk)
testImplementation(libs.truth)
testImplementation(libs.robolectric)
testImplementation(libs.bundles.compose.test)

androidTestImplementation(libs.mockk.android)
androidTestImplementation(libs.hilt.testing)
kspAndroidTest(libs.hilt.testing.compiler)
androidTestImplementation(libs.bundles.compose.android.test)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* MIT License
* Copyright 2024-2025 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.sopt.official.feature.mypage.di

import dagger.hilt.EntryPoint
import dagger.hilt.InstallIn
import dagger.hilt.android.EntryPointAccessors
import dagger.hilt.components.SingletonComponent
import org.sopt.official.auth.repository.AuthRepository
import org.sopt.official.common.context.appContext
import org.sopt.official.domain.mypage.repository.UserRepository
import org.sopt.official.domain.soptamp.repository.StampRepository

@EntryPoint
@InstallIn(SingletonComponent::class)
internal interface AuthEntryPoint {
fun authRepository(): AuthRepository
fun userRepository(): UserRepository
fun stampRepository(): StampRepository
}

internal val authRepository by lazy {
EntryPointAccessors
.fromApplication(appContext, AuthEntryPoint::class.java)
.authRepository()
}

internal val userRepository by lazy {
EntryPointAccessors
.fromApplication(appContext, AuthEntryPoint::class.java)
.userRepository()
}

internal val stampRepository by lazy {
EntryPointAccessors
.fromApplication(appContext, AuthEntryPoint::class.java)
.stampRepository()
}
Loading
Loading