@@ -21,12 +21,15 @@ import androidx.compose.foundation.layout.Box
2121import androidx.compose.foundation.layout.Column
2222import androidx.compose.foundation.layout.Row
2323import androidx.compose.foundation.layout.Spacer
24+ import androidx.compose.foundation.layout.WindowInsets
2425import androidx.compose.foundation.layout.aspectRatio
2526import androidx.compose.foundation.layout.fillMaxSize
2627import androidx.compose.foundation.layout.fillMaxWidth
2728import androidx.compose.foundation.layout.height
2829import androidx.compose.foundation.layout.padding
2930import androidx.compose.foundation.layout.size
31+ import androidx.compose.foundation.layout.systemBars
32+ import androidx.compose.foundation.layout.windowInsetsPadding
3033import androidx.compose.foundation.shape.RoundedCornerShape
3134import androidx.compose.material3.MaterialTheme
3235import androidx.compose.runtime.Composable
@@ -50,11 +53,16 @@ import androidx.compose.ui.viewinterop.AndroidView
5053import com.google.accompanist.permissions.ExperimentalPermissionsApi
5154import com.google.accompanist.permissions.isGranted
5255import com.google.accompanist.permissions.rememberPermissionState
56+ import com.google.android.gms.ads.AdRequest
57+ import com.google.android.gms.ads.AdSize
58+ import com.google.android.gms.ads.AdView
5359import com.no5ing.bbibbi.R
5460import com.no5ing.bbibbi.presentation.component.BBiBBiSurface
61+ import com.no5ing.bbibbi.presentation.component.BannerAd
5562import com.no5ing.bbibbi.presentation.component.ClosableTopBar
5663import com.no5ing.bbibbi.presentation.component.button.CameraCaptureButton
5764import com.no5ing.bbibbi.presentation.theme.bbibbiScheme
65+ import com.no5ing.bbibbi.util.getAdView
5866import com.no5ing.bbibbi.util.getCameraProvider
5967import com.no5ing.bbibbi.util.takePhotoWithImage
6068import kotlinx.coroutines.launch
@@ -122,6 +130,7 @@ fun CameraView(
122130 preview.setSurfaceProvider(previewView.surfaceProvider)
123131 }
124132
133+ val adView = getAdView()
125134 val zoomValue: Float by animateFloatAsState(
126135 targetValue = if (isZoomed) 0.5f else 0.0f ,
127136 animationSpec = tween(
@@ -156,91 +165,98 @@ fun CameraView(
156165 Column (
157166 modifier = Modifier
158167 .padding(vertical = 10 .dp)
159- .fillMaxWidth()
168+ .fillMaxWidth(),
169+ verticalArrangement = Arrangement .SpaceBetween ,
160170 ) {
161- ClosableTopBar (
162- onDispose = onDispose,
163- title = stringResource(id = R .string.camera_title),
164- )
165- Spacer (modifier = Modifier .height(48 .dp))
166- Box {
167- AndroidView (
168- { previewView },
169- modifier = Modifier
170- .aspectRatio(1.0f )
171- .fillMaxWidth()
172- .clip(RoundedCornerShape (48 .dp))
173- .background(MaterialTheme .bbibbiScheme.backgroundHover),
171+ Column {
172+ ClosableTopBar (
173+ onDispose = onDispose,
174+ title = stringResource(id = R .string.camera_title),
174175 )
175- Box (
176- modifier = Modifier
177- .aspectRatio(1.0f )
178- .fillMaxWidth()
179- .padding(bottom = 20 .dp),
180- contentAlignment = Alignment .BottomCenter
176+ Spacer (modifier = Modifier .height(48 .dp))
177+ Box {
178+ AndroidView (
179+ { previewView },
180+ modifier = Modifier
181+ .aspectRatio(1.0f )
182+ .fillMaxWidth()
183+ .clip(RoundedCornerShape (48 .dp))
184+ .background(MaterialTheme .bbibbiScheme.backgroundHover),
185+ )
186+ Box (
187+ modifier = Modifier
188+ .aspectRatio(1.0f )
189+ .fillMaxWidth()
190+ .padding(bottom = 20 .dp),
191+ contentAlignment = Alignment .BottomCenter
192+ ) {
193+ Image (
194+ painter = painterResource(id = R .drawable.zoom_button),
195+ contentDescription = null ,
196+ modifier = Modifier
197+ .size(43 .dp)
198+ .clickable {
199+ isZoomed = ! isZoomed
200+ }
201+ )
202+
203+ }
204+ }
205+
206+ Spacer (modifier = Modifier .height(36 .dp))
207+ Row (
208+ modifier = Modifier .fillMaxWidth(),
209+ horizontalArrangement = Arrangement .SpaceAround ,
210+ verticalAlignment = Alignment .CenterVertically ,
181211 ) {
182212 Image (
183- painter = painterResource(id = R .drawable.zoom_button ),
184- contentDescription = null ,
213+ painter = painterResource(R .drawable.toggle_flash_button ),
214+ contentDescription = null , // 필수 param
185215 modifier = Modifier
186- .size(43 .dp)
216+ .size(48 .dp)
187217 .clickable {
188- isZoomed = ! isZoomed
218+ torchState.value = ! torchState.value
219+ cameraState.value?.cameraControl?.enableTorch(torchState.value)
220+ }
221+ )
222+ CameraCaptureButton (
223+ onClick = {
224+ if (isCapturing) return @CameraCaptureButton
225+ haptic.performHapticFeedback(HapticFeedbackType .LongPress )
226+ coroutineScope.launch {
227+ isCapturing = true
228+ val uri = captureState.value.takePhotoWithImage(
229+ context,
230+ requiredFlip = cameraDirection.value == CameraSelector .DEFAULT_FRONT_CAMERA
231+ )
232+ isCapturing = false
233+ onImageCaptured(uri)
189234 }
235+ },
236+ isCapturing = isCapturing,
190237 )
238+ Image (
239+ painter = painterResource(R .drawable.rorate_button),
240+ contentDescription = null , // 필수 param
241+ modifier = Modifier
242+ .size(48 .dp)
243+ .clickable {
244+ cameraDirection.value = run {
245+ if (cameraDirection.value == CameraSelector .DEFAULT_BACK_CAMERA ) {
246+ CameraSelector .DEFAULT_FRONT_CAMERA
247+ } else {
248+ CameraSelector .DEFAULT_BACK_CAMERA
249+ }
250+ }
191251
252+ }
253+ )
192254 }
193255 }
194-
195- Spacer (modifier = Modifier .height(36 .dp))
196- Row (
197- modifier = Modifier .fillMaxWidth(),
198- horizontalArrangement = Arrangement .SpaceAround ,
199- verticalAlignment = Alignment .CenterVertically ,
200- ) {
201- Image (
202- painter = painterResource(R .drawable.toggle_flash_button),
203- contentDescription = null , // 필수 param
204- modifier = Modifier
205- .size(48 .dp)
206- .clickable {
207- torchState.value = ! torchState.value
208- cameraState.value?.cameraControl?.enableTorch(torchState.value)
209- }
210- )
211- CameraCaptureButton (
212- onClick = {
213- if (isCapturing) return @CameraCaptureButton
214- haptic.performHapticFeedback(HapticFeedbackType .LongPress )
215- coroutineScope.launch {
216- isCapturing = true
217- val uri = captureState.value.takePhotoWithImage(
218- context,
219- requiredFlip = cameraDirection.value == CameraSelector .DEFAULT_FRONT_CAMERA
220- )
221- isCapturing = false
222- onImageCaptured(uri)
223- }
224- },
225- isCapturing = isCapturing,
226- )
227- Image (
228- painter = painterResource(R .drawable.rorate_button),
229- contentDescription = null , // 필수 param
230- modifier = Modifier
231- .size(48 .dp)
232- .clickable {
233- cameraDirection.value = run {
234- if (cameraDirection.value == CameraSelector .DEFAULT_BACK_CAMERA ) {
235- CameraSelector .DEFAULT_FRONT_CAMERA
236- } else {
237- CameraSelector .DEFAULT_BACK_CAMERA
238- }
239- }
240-
241- }
242- )
256+ Box (modifier = Modifier .fillMaxWidth().windowInsetsPadding(WindowInsets .systemBars)) {
257+ BannerAd (adView = adView, modifier = Modifier .fillMaxWidth())
243258 }
259+
244260 }
245261
246262 }
0 commit comments