Skip to content
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
084eb6a
➕ Build: CameraX dependency 추가
chanho0908 Jan 25, 2026
3597ab5
✨Feat: 카메라 활영 버튼, 렌즈 전후면 토글 버튼 컴포저블 추가
chanho0908 Jan 25, 2026
4e001bd
✨Feat: 카메라 플래시 on/off SVG 추가
chanho0908 Jan 25, 2026
6f50885
✨Feat: cameraX 촬영 기능 구현
chanho0908 Jan 25, 2026
846a1ef
♻️ Refactor: 버전 카탈로그 주석 추가 및 위치 수정
chanho0908 Jan 25, 2026
7df1e27
♻️ Refactor: CameraControlBar에 noRippleClickable 적용
chanho0908 Jan 26, 2026
8c2818e
✨ Feat: 화면 닫기 아이콘 추가
chanho0908 Jan 26, 2026
b33218e
✨ Feat: 인증샷 촬용 상태를 표현하기 위한 객체 추가
chanho0908 Jan 26, 2026
d3a4a95
✨ Feat: 임시 이미지 추가
chanho0908 Jan 26, 2026
0fd6cf3
✨ Feat: 카메라 프리뷰 화면 구현
chanho0908 Jan 26, 2026
203fd84
✨ Feat: 카메라 촬영 가능 구현
chanho0908 Jan 26, 2026
df06bb4
♻️ Refactor: 할일 인증 화면 KtlintFormat 적용
chanho0908 Jan 26, 2026
6949feb
♻️ Refactor: CameraControlBar 컬포저블 수정
chanho0908 Jan 26, 2026
4f7972e
♻️ Refactor: 이미지 캡쳐후 저장 로직 수정
chanho0908 Jan 26, 2026
215fae3
✨ Feat: 카메라 렌즈 토글 기능 추가
chanho0908 Jan 26, 2026
1d1a933
♻️ Refactor: 잘못 커밋된 파일 수정
chanho0908 Jan 26, 2026
9268343
♻️ Refactor: 잘못된 패키지명 수정
chanho0908 Jan 26, 2026
c678149
✨ Feat: TaskCertificationGraph 추가
chanho0908 Jan 26, 2026
4146605
♻️ Refactor: 미완성 코드 제거
chanho0908 Jan 26, 2026
5fb89fe
♻️ Refactor: CaptureStatus에 @Immutable 추가
chanho0908 Jan 27, 2026
5f881aa
♻️ Refactor: 플래시 아이콘 이름 변경
chanho0908 Jan 27, 2026
41d90d6
✨ Feat: 카메라 클래스에 플래시 On/Off 기능 추가
chanho0908 Jan 27, 2026
7a50827
➕ Build: 미사용 dependency 제거
chanho0908 Jan 27, 2026
2b7534e
➕ Build: guava dependency 추가
chanho0908 Jan 27, 2026
8c61d1a
✨ Feat: UI 카메라 플래시 토글 기능 추가
chanho0908 Jan 27, 2026
f2947c7
♻️ Refactor: 토치 아이콘 변수명 수정
chanho0908 Jan 27, 2026
19c23fe
♻️ Refactor: 로깅 제거
chanho0908 Jan 27, 2026
9733fde
♻️ Refactor: 불필요한 lifecycleowner 제거
chanho0908 Jan 27, 2026
900c7cc
♻️ Refactor: 카메라 바인딩 책임을 UI로 이동
chanho0908 Jan 30, 2026
ac190dd
♻️ Refactor: 카메라 촬영 책임을 UI로 이동
chanho0908 Jan 30, 2026
753f3b8
♻️ Refactor: 임시 코드 제거
chanho0908 Jan 30, 2026
94ea778
♻️ Refactor: 카메라 렌즈 토글 책임을 UI로 이동
chanho0908 Jan 30, 2026
8deb072
♻️ Refactor: 사진 촬영 함수를 콜백에서 suspend로 변경
chanho0908 Jan 30, 2026
7cf1a78
♻️ Refactor:: LifecycleOwner import 수정
chanho0908 Jan 30, 2026
326c781
♻️ Refactor: 카메라 바인딩 책임을 UI로 이동
chanho0908 Jan 30, 2026
34442dd
♻️ Refactor: 카메라 촬영 책임을 UI로 이동
chanho0908 Jan 30, 2026
5706c1a
♻️ Refactor: 임시 코드 제거
chanho0908 Jan 30, 2026
ccfe5e0
♻️ Refactor: 카메라 렌즈 토글 책임을 UI로 이동
chanho0908 Jan 30, 2026
d56df8b
♻️ Refactor: 사진 촬영 함수를 콜백에서 suspend로 변경
chanho0908 Jan 30, 2026
b2f436e
♻️ Refactor:: LifecycleOwner import 수정
chanho0908 Jan 30, 2026
c6d7b0d
♻️ Refactor: 불필요한 lifecycleowner 제거
chanho0908 Jan 27, 2026
acaeec3
♻️ Refactor: 카메라 촬영 책임을 UI로 이동
chanho0908 Jan 30, 2026
0f480fd
♻️ Refactor: 불필요한 lifecycleowner 제거
chanho0908 Jan 27, 2026
0e22c51
♻️ Refactor: 카메라 촬영 책임을 UI로 이동
chanho0908 Jan 30, 2026
0450fef
♻️ Refactor: 카메라 플래시 토글 책임을 UI로 이동
chanho0908 Jan 30, 2026
a0255ea
♻️ Refactor: 사진 촬영시 에러 콜백 처리 방식 수정
chanho0908 Jan 30, 2026
e862959
♻️ Refactor: 임시 코드 제거
chanho0908 Jan 30, 2026
987840d
✨Merge branch 'feat/#38-task-certification' into feat/#38-task-certif…
chanho0908 Jan 30, 2026
1b1895b
✨Merge branch 'feat/#38-task-certification-torch' into feat/#38-task-…
chanho0908 Jan 30, 2026
c8b73b6
✨ Feat: 카메라 권한 로직 추가
chanho0908 Jan 30, 2026
1d628d7
✨Merge branch 'develop' into feat/#38-task-certification
chanho0908 Jan 30, 2026
3f55676
♻️ Refactor: 토치 토글 로직 함수, 변수명 수정
chanho0908 Feb 2, 2026
4f5b5fc
♻️ Refactor: 사진 촬영시 토치 off 함수명 하나로 수정
chanho0908 Feb 2, 2026
f7654f4
♻️ Refactor: 이미지 캡쳐 실패 sideEffect 명 수정
chanho0908 Feb 2, 2026
0658bd3
✨ Feat: 후면 카메라로 변경시 토치 Off 기능 추가
chanho0908 Feb 2, 2026
6d72767
♻️ Refactor: lifecycle의 coroutineScope에서 rememberCoroutineScope로 수정
chanho0908 Feb 2, 2026
170a413
♻️ Refactor: 람다 제거
chanho0908 Feb 2, 2026
d908bbf
♻️ Refactor: 카메라를 생명주기에 맞게 unbind 하도록 수정
chanho0908 Feb 2, 2026
342d989
♻️ Refactor: viewModel에 reduce 함수들의 prefix에 reduce 추가
chanho0908 Feb 2, 2026
6f6c4b5
♻️ Refactor: 전면 카메라일 때 토치 버튼 숨김 처리
chanho0908 Feb 3, 2026
af74717
♻️ Refactor: camera unbinding 메서드를 동기 방식으로 수정
chanho0908 Feb 3, 2026
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
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies {
implementation(projects.domain)
implementation(projects.feature.login)
implementation(projects.feature.main)
implementation(projects.feature.taskCertification)

// Firebase
implementation(platform(libs.google.firebase.bom))
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/yapp/twix/di/FeatureModules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package com.yapp.twix.di
import com.twix.home.di.homeModule
import com.twix.login.di.loginModule
import com.twix.main.di.mainModule
import com.twix.task_certification.di.taskCertificationModule
import org.koin.core.module.Module

val featureModules: List<Module> =
listOf(
loginModule,
mainModule,
homeModule,
taskCertificationModule,
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@ sealed class NavRoutes(
object MainGraph : NavRoutes("main_graph")

object MainRoute : NavRoutes("main")

/**
* TaskCertificationGraph
* */
object TaskCertificationGraph : NavRoutes("task_certification_graph")

object TaskCertificationRoute : NavRoutes("task_certification")
}
1 change: 1 addition & 0 deletions feature/task-certification/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
11 changes: 11 additions & 0 deletions feature/task-certification/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
alias(libs.plugins.twix.feature)
}

android {
namespace = "com.twix.task_certification"
}
dependencies {
implementation(libs.bundles.cameraX)
implementation(libs.guava)
}
Empty file.
21 changes: 21 additions & 0 deletions feature/task-certification/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
4 changes: 4 additions & 0 deletions feature/task-certification/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.CAMERA"/>
</manifest>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

지금 Camera unbind 메서드가 호출이 안되고 있어서 DisposableEffect나 다른 방식을 써서 화면이 사라질 때 unbind를 호출해야 할 거 같아요!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

좋은 생각인 것 같아 ! 이 부분을 할지 말지 고민했었는데 현수 의견대로 안전하게 처리하는게 좋겠네

리뷰 반영 커밋 :

d908bbf

af74717

Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
package com.twix.task_certification

import android.Manifest
import android.content.pm.PackageManager
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.core.content.ContextCompat
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.coroutineScope
import com.twix.designsystem.components.text.AppText
import com.twix.designsystem.theme.GrayColor
import com.twix.designsystem.theme.TwixTheme
import com.twix.domain.model.enums.AppTextStyle
import com.twix.task_certification.camera.Camera
import com.twix.task_certification.component.CameraControlBar
import com.twix.task_certification.component.CameraPreviewBox
import com.twix.task_certification.component.TaskCertificationTopBar
import com.twix.task_certification.model.CameraPreview
import com.twix.task_certification.model.TaskCertificationIntent
import com.twix.task_certification.model.TaskCertificationUiState
import kotlinx.coroutines.launch
import org.koin.androidx.compose.koinViewModel
import org.koin.compose.koinInject

@Composable
fun TaskCertificationRoute(
camera: Camera = koinInject(),
viewModel: TaskCertificationViewModel = koinViewModel(),
navigateToBack: () -> Unit,
) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val cameraPreview by camera.surfaceRequests.collectAsStateWithLifecycle()

val lifecycleOwner = LocalLifecycleOwner.current
val coroutineScope = rememberCoroutineScope()
val context = androidx.compose.ui.platform.LocalContext.current

var hasPermission by remember {
mutableStateOf(
ContextCompat.checkSelfPermission(
context,
Manifest.permission.CAMERA,
) == PackageManager.PERMISSION_GRANTED,
)
}

val permissionLauncher =
rememberLauncherForActivityResult(
ActivityResultContracts.RequestPermission(),
) { granted ->
hasPermission = granted
}

LaunchedEffect(Unit) {
if (!hasPermission) {
permissionLauncher.launch(Manifest.permission.CAMERA)
}
}

DisposableEffect(lifecycleOwner, uiState.lens, hasPermission) {
if (hasPermission) {
coroutineScope.launch {
camera.bind(lifecycleOwner, uiState.lens)
}
}

onDispose {
coroutineScope.launch {
camera.unbind()
}
}
}

LaunchedEffect(uiState.torch, hasPermission) {
if (hasPermission) {
camera.toggleTorch(uiState.torch)
}
}

TaskCertificationScreen(
uiState = uiState,
cameraPreview = cameraPreview,
onClickClose = navigateToBack,
onCaptureClick = {
if (!hasPermission) return@TaskCertificationScreen

coroutineScope.launch {
camera
.takePicture()
.onSuccess {
viewModel.dispatch(TaskCertificationIntent.TakePicture(it))
}
}
Comment on lines +100 to +109
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

촬영 버튼을 빠르게 연타하면 사진이 계속 찍혀서 중간에 방어 로직 추가하면 좋을 거 같아요!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

요 문제는 다음 PR에 적용해놨어 ! 이 커밋 참고 부탁해

},
onToggleCameraClick = {
viewModel.dispatch(TaskCertificationIntent.ToggleLens)
},
onClickFlash = {
viewModel.dispatch(TaskCertificationIntent.ToggleTorch)
},
)
}

@Composable
private fun TaskCertificationScreen(
uiState: TaskCertificationUiState,
cameraPreview: CameraPreview?,
onClickClose: () -> Unit,
onCaptureClick: () -> Unit,
onToggleCameraClick: () -> Unit,
onClickFlash: () -> Unit,
) {
Column(
Modifier
.fillMaxSize()
.background(GrayColor.C500),
horizontalAlignment = Alignment.CenterHorizontally,
) {
TaskCertificationTopBar(
onClickClose = onClickClose,
)

Spacer(modifier = Modifier.height(24.26.dp))

AppText(
text = stringResource(R.string.task_certification_title),
style = AppTextStyle.H2,
color = GrayColor.C100,
)

Spacer(modifier = Modifier.height(40.dp))

CameraPreviewBox(
capture = uiState.capture,
previewRequest = cameraPreview,
torch = uiState.torch,
onClickFlash = { onClickFlash() },
)

Spacer(modifier = Modifier.height(52.dp))

CameraControlBar(
onCaptureClick = onCaptureClick,
onToggleCameraClick = onToggleCameraClick,
)
}
}

@Preview
@Composable
fun TaskCertificationScreenPreview() {
TwixTheme {
TaskCertificationScreen(
uiState = TaskCertificationUiState(),
cameraPreview = null,
onClickClose = {},
onCaptureClick = {},
onToggleCameraClick = {},
onClickFlash = {},
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.twix.task_certification

import android.net.Uri
import androidx.lifecycle.viewModelScope
import com.twix.task_certification.model.TaskCertificationIntent
import com.twix.task_certification.model.TaskCertificationSideEffect
import com.twix.task_certification.model.TaskCertificationUiState
import com.twix.ui.base.BaseViewModel
import kotlinx.coroutines.launch

class TaskCertificationViewModel :
BaseViewModel<TaskCertificationUiState, TaskCertificationIntent, TaskCertificationSideEffect>(
TaskCertificationUiState(),
) {
override suspend fun handleIntent(intent: TaskCertificationIntent) {
when (intent) {
is TaskCertificationIntent.TakePicture -> {
reducePicture(intent.uri)
}

is TaskCertificationIntent.ToggleLens -> {
reduceLens()
}

is TaskCertificationIntent.ToggleTorch -> {
reduceTorch()
}
}
}

private fun reducePicture(uri: Uri?) {
uri?.let {
reduce { updatePicture(uri) }
} ?: run { onFailureCapture() }
}

private fun onFailureCapture() {
viewModelScope.launch {
emitSideEffect(TaskCertificationSideEffect.ShowImageCaptureFailToast)
}
}
Comment on lines +37 to +41
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

여기에서 지금 SideEffect를 발생시키기만 하고 처리하는 로직이 없어요! 그리고 네이밍도 토스트를 띄우거나 핸들링하는 로직에 따라서 좀 더 직관적으로 바꾸면 좋을 것 같아요

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

토스트를 띄우는건 다음 PR에 작성해놨어
네이밍은 수정했으니 커밋 참고해줘 ~

리뷰 반영 커밋 : f7654f4


private fun reduceLens() {
reduce { toggleLens() }
}

private fun reduceTorch() {
reduce { toggleTorch() }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.twix.task_certification.camera

import android.net.Uri
import androidx.camera.core.CameraSelector
import androidx.lifecycle.LifecycleOwner
import com.twix.task_certification.model.CameraPreview
import com.twix.task_certification.model.TorchStatus
import kotlinx.coroutines.flow.StateFlow

interface Camera {
val surfaceRequests: StateFlow<CameraPreview?>

suspend fun bind(
lifecycleOwner: LifecycleOwner,
lens: CameraSelector,
)

suspend fun unbind()

suspend fun takePicture(): Result<Uri>

fun toggleTorch(torch: TorchStatus)
}
Loading