Skip to content

Commit

Permalink
[#1012] 간단한 화면에서 MVVM Like 구조 없이 상태관리할 수 있게 구조 변경 (#1013)
Browse files Browse the repository at this point in the history
* [#1012] AuthRepository 가져올 수 있는 EntryPoint 정의, SignOutActivity 간소화

* [#1012] 패키지네임에 camelCase 제거, SignOutViewModel 제거

* [#1012] Rin 추가

* [#1012] Spotless Apply

* [#1012] AdjustSentence쪽 패키지 이동

* [#1012] UserRepository EntryPoint 설치

* [#1012] 솝탬프 한마디 수정 영역 UiState 정의 및 UI 로직 remember로 따로 빼기

* [#1012] Context#findActivity util 함수 추가

- AndroidX의 LocalActivity 코드 참고

https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:activity/activity-compose/src/main/java/androidx/activity/compose/LocalActivity.kt;l=34?q=LocalActivity

* [#1012] Activity에 ModifyProfileState 적용

* [#1012] SideEffect, ViewModel 삭제

* [#1012] Spotless Apply

* [#1012] Context 직접 참조하는 부분 변경

* [#1012] mockk 의존성 추가, mypage에 테스트 의존성 추가

* [#1012] Testable하게 구조 변경 (UserRepository)

* [#1012] Add unit test for modify profile state

* [#1012] Spotless Apply

* [#1012] StartArgs -> Argument로 네이밍 변경

* [#1012] Lint

* [#1012] MyPage UiState, Action 정의

* [#1012] MyPage의 UiState Holder 정의

* [#1012] MyPageActivity에 적용

* [#1012] Spotless Apply

* [#1012] generateBaselineProfile

* [#1012] Spotless Apply

* [#1012] generateBaselineProfile

* [#1012] remove warning
  • Loading branch information
l2hyunwoo authored Jan 9, 2025
1 parent 64b563d commit 980c48c
Show file tree
Hide file tree
Showing 49 changed files with 1,442 additions and 1,166 deletions.
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
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_auth_certification_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) 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
}
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

0 comments on commit 980c48c

Please sign in to comment.