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

[컴포즈] NavController 활용한 컴포즈 화면 구성 #52

Merged
merged 30 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
90bda46
feat: compose-navigation 모듈 추가
sieunju Apr 6, 2024
8eca830
feat: compose-navigation 모듈 추가
sieunju Apr 6, 2024
77890e7
feat: compose-navigation 모듈 추가
sieunju Apr 7, 2024
1102579
feat: compose-navigation 모듈 추가
sieunju Apr 7, 2024
065bf5d
feat: compose-navigation 모듈 추가
sieunju Apr 7, 2024
e167d6c
refactor: StateFlow Transformations.map 과 같은 함수 추가
sieunju Apr 8, 2024
74f5556
refactor: Til Compose 컴포넌트 추가
sieunju Apr 10, 2024
732bdac
refactor: Til Compose 컴포넌트 추가
sieunju Apr 10, 2024
a2494e4
refactor: Hilt 버전 업데이트
sieunju Apr 12, 2024
b4f8ec9
refactor: TilComponent 추가
sieunju Apr 21, 2024
f9e5852
feat: 로그인 화면 UI 수정
sieunju Apr 21, 2024
b3b5427
feat: 로그인 화면 UI 수정
sieunju Apr 21, 2024
f35c0a7
feat: compose 공통 이미지 로더 함수 추가
sieunju Apr 30, 2024
b240ca9
feat: compose 공통 이미지 로더 함수 추가
sieunju May 1, 2024
8dc5f66
feat: compose 공통 이미지 로더 함수 추가
sieunju May 1, 2024
ffac87d
feat: glide 라이브러리 버전 관련 업데이트
sieunju May 1, 2024
e6b03ea
feat: 이미지 로더 함수 재정의
sieunju May 1, 2024
68bbcc9
feat: 회원 가입 화면 추가
sieunju May 1, 2024
4e6828f
feat: 회원 가입 화면에 아이디 및 비밀번호 이벤트 연결 처리
sieunju May 1, 2024
9359f54
feat: compose navigation 뒤로가기 버튼 이벤트 관련 공통 함수 추가
sieunju May 1, 2024
119fab9
refactor: 애니메이션 처리 추가 및 회원 가입 -> 로그인 자동 완성 기능 추가
sieunju May 6, 2024
ae2b9e2
refactor: 메모 화면 추가
sieunju May 6, 2024
05c7c54
chore: 이미지 리소스 URL 변경
sieunju May 12, 2024
78e4066
feat: 메모 화면 UI 구성
sieunju May 12, 2024
807b953
feat: 화면 전환 애니메이션 효과 수정
sieunju May 22, 2024
32d15d7
refactor: Navigation 로직 개선
sieunju May 22, 2024
8cfe8d3
chore: 애니메이션 길이 조절
sieunju May 22, 2024
969a6a8
chore: 탑 앱바 애니메이션 처리 금일 반영
sieunju May 25, 2024
b4683eb
chore: 탑 앱바 애니메이션 처리 금일 반영
sieunju May 26, 2024
4d201c2
refactor: 메모 화면 AppBar Expand, CollapseToolbar 과 동일한 UI 구현
sieunju May 29, 2024
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
9 changes: 1 addition & 8 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ dependencies {
implementation(project(":features:base_mvvm_lifecycle"))
implementation(project(":features:base_mvvm_bottom_sheet"))
implementation(project(":features:compose_permissions_result"))
implementation(project(":features:compose_navigation"))

/**
* Network
Expand Down Expand Up @@ -108,14 +109,6 @@ dependencies {
implementation(Rx.java)
implementation(Rx.kotlin)

/**
* Glide
*/
implementation(Glide.base)
implementation(Glide.compiler)
implementation(Glide.okhttp)
kapt(Glide.compiler)

/**
* Timber
*/
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<item name="colorSecondaryVariant">@color/purple_500</item>
<item name="colorOnSecondary">@color/purple_500</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">@color/white</item>
<item name="android:statusBarColor" >@color/white</item>
<!-- Customize your theme here. -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
classpath("com.android.tools.build:gradle:8.2.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22")
classpath("org.jetbrains.kotlin:kotlin-serialization:1.8.22")
classpath("com.google.dagger:hilt-android-gradle-plugin:2.45")
classpath("com.google.dagger:hilt-android-gradle-plugin:2.48")
}
}

Expand Down
21 changes: 17 additions & 4 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Apps {
object Versions {
const val retrofit = "2.9.0"
const val lifecycle = "2.6.1"
const val hilt = "2.45"
const val hilt = "2.48"

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:property-naming reported by reviewdog 🐶
Property name should use the screaming snake case notation when the value can not be changed

}

object AndroidX {
Expand Down Expand Up @@ -59,10 +59,21 @@ object Retrofit {
}

object Glide {
const val base = "com.github.bumptech.glide:glide:4.16.0"
const val okhttp = "com.github.bumptech.glide:okhttp3-integration:4.16.0"
const val compiler = "com.github.bumptech.glide:ksp:4.16.0"
const val base = "com.github.bumptech.glide:glide:4.13.2"

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:property-naming reported by reviewdog 🐶
Property name should use the screaming snake case notation when the value can not be changed

const val okhttp = "com.github.bumptech.glide:okhttp3-integration:4.13.2"

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:property-naming reported by reviewdog 🐶
Property name should use the screaming snake case notation when the value can not be changed

const val compiler = "com.github.bumptech.glide:compiler:4.13.2"

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:property-naming reported by reviewdog 🐶
Property name should use the screaming snake case notation when the value can not be changed

const val annotations = "com.github.bumptech.glide:annotations:4.13.2"

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:property-naming reported by reviewdog 🐶
Property name should use the screaming snake case notation when the value can not be changed

const val compose = "com.github.bumptech.glide:compose:1.0.0-beta01"
// const val base = "com.github.bumptech.glide:glide:4.16.0"
// const val okhttp = "com.github.bumptech.glide:okhttp3-integration:4.16.0"
// const val compiler = "com.github.bumptech.glide:ksp:4.16.0"
// const val annotations = "com.github.bumptech.glide:annotations:4.16.0"
// const val compose = "com.github.bumptech.glide:compose:1.0.0-beta01"
// const val base = "com.github.bumptech.glide:glide:5.0.0-rc01"
// const val okhttp = "com.github.bumptech.glide:okhttp3-integration:5.0.0-rc01"
// const val compiler = "com.github.bumptech.glide:ksp:5.0.0-rc01"
// const val annotations = "com.github.bumptech.glide:annotations:5.0.0-rc01"
// const val compose = "com.github.bumptech.glide:compose:1.0.0-beta01"
}

object KotlinX {
Expand Down Expand Up @@ -90,6 +101,8 @@ object Compose {
const val viewModel = "androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1"
const val constraint = "androidx.constraintlayout:constraintlayout-compose:1.0.1"
const val runtime = "androidx.compose.runtime:runtime"
const val navigation = "androidx.navigation:navigation-compose:2.7.7"

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:property-naming reported by reviewdog 🐶
Property name should use the screaming snake case notation when the value can not be changed

const val navigationViewModel = "androidx.hilt:hilt-navigation-compose:1.0.0"

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:property-naming reported by reviewdog 🐶
Property name should use the screaming snake case notation when the value can not be changed

}

object UnitTest {
Expand Down
3 changes: 3 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ dependencies {
implementation(Glide.base)
implementation(Glide.compiler)
implementation(Glide.okhttp)
implementation(Glide.annotations)
implementation(Glide.compose)
kapt(Glide.compiler)

/**
Expand Down Expand Up @@ -106,6 +108,7 @@ dependencies {
implementation(Compose.preview)
implementation(Compose.ui)
implementation(Compose.runtime)
implementation(Compose.navigation)

/**
* Unit Test
Expand Down
50 changes: 50 additions & 0 deletions core/src/main/java/com/hmju/core/compose/Extensions.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package com.hmju.core.compose

import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusManager
import androidx.compose.ui.input.pointer.pointerInput
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.SavedStateHandle
import androidx.navigation.NavController
import androidx.navigation.NavHostController
import com.hmju.core.compose.ComposeLifecycleState.Companion.from


Expand Down Expand Up @@ -35,3 +43,45 @@ fun rememberLifecycleUpdatedState(
}
return currentState
}

/**
* 다른데 터치할때 키보드 내리기 위한 유틸 함수
* @param focusManager LocalFocusManager
*/
fun Modifier.addFocusCleaner(
focusManager: FocusManager,
doOnClear: () -> Unit = {}

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶
Missing trailing comma before ")"

): Modifier {
return this.pointerInput(Unit) {
detectTapGestures(onTap = {
doOnClear()
focusManager.clearFocus()
})
}
}

fun NavHostController.backPressed() {
if (!popBackStack()) {
val activity = this.context as? FragmentActivity
activity?.finish()
}
}

inline fun <reified T> NavController.getBundleData(key: String): T? {
val savedStateHandle = currentBackStackEntry?.savedStateHandle ?: return null
return savedStateHandle.get<T>(key)
}

inline fun NavController.putBundle(
predicate: SavedStateHandle.() -> Unit

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:function-signature reported by reviewdog 🐶
No whitespace expected between opening parenthesis and first parameter name

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:function-signature reported by reviewdog 🐶
No whitespace expected between last parameter and closing parenthesis

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶
Missing trailing comma before ")"

) {
val savedStateHandle = currentBackStackEntry?.savedStateHandle ?: return
predicate.invoke(savedStateHandle)
}

inline fun NavController.prevPutBundle(
predicate: SavedStateHandle.() -> Unit

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:function-signature reported by reviewdog 🐶
No whitespace expected between opening parenthesis and first parameter name

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:function-signature reported by reviewdog 🐶
No whitespace expected between last parameter and closing parenthesis

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶
Missing trailing comma before ")"

) {
val savedStateHandle = previousBackStackEntry?.savedStateHandle ?: return
predicate.invoke(savedStateHandle)
}
37 changes: 37 additions & 0 deletions core/src/main/java/com/hmju/core/compose/MutableStateAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.hmju.core.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.State
import androidx.compose.runtime.collectAsState
import kotlinx.coroutines.flow.MutableStateFlow
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext

/**
* Description :
*
* Created by juhongmin on 4/7/24
*/
class MutableStateAdapter<T>(
private val state: State<T>,
private val mutate: (T) -> Unit

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶
Missing trailing comma before ")"

) : MutableState<T> {

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:no-empty-first-line-in-class-body reported by reviewdog 🐶
Class body should not start with blank line

override var value: T
get() = state.value
set(value) {
mutate(value)
}

override fun component1(): T = value
override fun component2(): (T) -> Unit = { value = it }

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:blank-line-before-declaration reported by reviewdog 🐶
Expected a blank line for this declaration

}

@Composable
fun <T> MutableStateFlow<T>.collectAsMutableState(
context: CoroutineContext = EmptyCoroutineContext

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:function-signature reported by reviewdog 🐶
No whitespace expected between opening parenthesis and first parameter name

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:function-signature reported by reviewdog 🐶
No whitespace expected between last parameter and closing parenthesis

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶
Missing trailing comma before ")"

): MutableState<T> = MutableStateAdapter(

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:multiline-expression-wrapping reported by reviewdog 🐶
A multiline expression should start on a new line

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:function-signature reported by reviewdog 🐶
Newline expected before expression body

state = collectAsState(context),
mutate = { value = it }

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:trailing-comma-on-call-site reported by reviewdog 🐶
Missing trailing comma before ")"

)
37 changes: 37 additions & 0 deletions core/src/main/java/com/hmju/core/compose/MutableStateFlowList.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.hmju.core.compose

import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow

/**
* Description : Compose + Flow 전용 List 형태의 Flow
*
* Created by juhongmin on 5/6/24
*/
class MutableStateFlowList<T> {

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:no-empty-first-line-in-class-body reported by reviewdog 🐶
Class body should not start with blank line

private val _list = mutableListOf<T>()

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:backing-property-naming reported by reviewdog 🐶
Backing property is only allowed when a matching property or function exists

private val _stateFlow = MutableStateFlow<List<T>>(emptyList())

val stateFlow = _stateFlow.asStateFlow()

fun add(item: T) {
_list.add(item)
notifyObserver()
}

fun addAll(items: List<T>?) {
if (items == null) return
_list.addAll(items)
notifyObserver()
}

fun remove(item: T) {
_list.remove(item)
notifyObserver()
}

private fun notifyObserver() {
_stateFlow.value = _list.toList()
}
}
6 changes: 4 additions & 2 deletions core/src/main/java/com/hmju/core/compose/TilColor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class TilColor internal constructor(
val gray3: Color,
val gray3Light: Color,
val gray4: Color,
val gray5: Color
val gray5: Color,
val defBgColor: Color

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶
Missing trailing comma before ")"

) {
constructor() : this(
white = Color(255, 255, 255),
Expand All @@ -36,6 +37,7 @@ class TilColor internal constructor(
gray3 = Color(204, 204, 204),
gray3Light = Color(229, 229, 229),
gray4 = Color(240, 240, 240),
gray5 = Color(247, 247, 247)
gray5 = Color(247, 247, 247),
defBgColor = Color(245,243,244)

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:comma-spacing reported by reviewdog 🐶
Missing spacing after ","

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:comma-spacing reported by reviewdog 🐶
Missing spacing after ","

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:trailing-comma-on-call-site reported by reviewdog 🐶
Missing trailing comma before ")"

)
}
Loading
Loading