Skip to content

Commit

Permalink
Merge pull request #363 from Nexters/feature/360
Browse files Browse the repository at this point in the history
Feature/360 입장 확인 고도화
  • Loading branch information
HamBP authored Jan 14, 2025
2 parents 5e41055 + 7af0d0f commit a248006
Show file tree
Hide file tree
Showing 11 changed files with 309 additions and 101 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.nexters.boolti.data.network.response

import com.nexters.boolti.data.util.toLocalDate
import com.nexters.boolti.data.util.toLocalDateTime
import com.nexters.boolti.domain.model.Show
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -10,13 +12,16 @@ import java.time.LocalDateTime
internal data class HostedShowDto(
@SerialName("showId") val showId: String,
@SerialName("showName") val showName: String,
@SerialName("date") val date: String,
@SerialName("salesStartTime") val salesStartDate: String,
@SerialName("salesEndTime") val salesEndDate: String,
) {
fun toDomain(): Show = Show(
id = showId,
name = showName,
date = LocalDateTime.now(),
salesStartDate = LocalDate.now(),
salesEndDate = LocalDate.now(),
date = date.toLocalDateTime(),
salesStartDate = salesStartDate.toLocalDate(),
salesEndDate = salesEndDate.toLocalDate(),
thumbnailImage = "",
)
}
1 change: 1 addition & 0 deletions presentation/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.VIBRATE" />

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package com.nexters.boolti.presentation

import android.Manifest
import android.graphics.Color
import android.hardware.Camera
import android.os.Bundle
import android.os.VibrationEffect
import android.view.KeyEvent
import androidx.activity.ComponentActivity
import androidx.activity.SystemBarStyle
Expand All @@ -19,6 +21,7 @@ import com.journeyapps.barcodescanner.BarcodeResult
import com.journeyapps.barcodescanner.DecoratedBarcodeView
import com.journeyapps.barcodescanner.DefaultDecoderFactory
import com.nexters.boolti.presentation.extension.requestPermission
import com.nexters.boolti.presentation.extension.vibrator
import com.nexters.boolti.presentation.screen.qr.QrScanScreen
import com.nexters.boolti.presentation.theme.BooltiTheme
import dagger.hilt.android.AndroidEntryPoint
Expand All @@ -27,6 +30,7 @@ import kotlinx.coroutines.launch

@AndroidEntryPoint
class QrScanActivity : ComponentActivity() {
private var isBackCamera = true

private val barcodeView: DecoratedBarcodeView by lazy {
DecoratedBarcodeView(this).apply {
Expand All @@ -43,6 +47,14 @@ class QrScanActivity : ComponentActivity() {
private val callback = BarcodeCallback { result: BarcodeResult ->
result.text ?: return@BarcodeCallback
viewModel.scan(result.text)

vibrator.vibrate(
VibrationEffect.createOneShot(
100,
VibrationEffect.DEFAULT_AMPLITUDE
)
)

lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
barcodeView.pause()
Expand All @@ -63,7 +75,8 @@ class QrScanActivity : ComponentActivity() {
BooltiTheme {
QrScanScreen(
barcodeView = barcodeView,
onClickClose = { finish() }
onClickClose = { finish() },
onClickSwitchCamera = ::switchCamera
)
}
}
Expand All @@ -82,4 +95,15 @@ class QrScanActivity : ComponentActivity() {
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
return barcodeView.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event)
}

private fun switchCamera() {
barcodeView.pause()
isBackCamera = !isBackCamera
barcodeView.cameraSettings.requestedCameraId = if (isBackCamera) {
Camera.CameraInfo.CAMERA_FACING_BACK
} else {
Camera.CameraInfo.CAMERA_FACING_FRONT
}
barcodeView.resume()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.ImageVector

@Composable
fun CircleBgIcon(
modifier: Modifier = Modifier,
painter: Painter,
imageVector: ImageVector,
bgColor: Color,
) {
Box(
modifier = modifier
.clip(CircleShape)
.background(bgColor)
) {
Icon(painter = painter, contentDescription = null)
Icon(imageVector = imageVector, contentDescription = null)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fun ToastSnackbarHost(
) {
if (leadingIcon != null) {
leadingIcon()
Spacer(modifier = Modifier.padding(end = 12.dp))
Spacer(modifier = Modifier.padding(end = 8.dp))
}
Text(
modifier = Modifier.padding(vertical = 12.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import android.content.pm.PackageManager
import android.os.Build
import android.os.VibrationEffect
import android.os.Vibrator
import android.os.VibratorManager
import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.getSystemService

fun Context.requireActivity(): Activity {
var ctx = this
Expand All @@ -24,3 +29,10 @@ fun Context.requireActivity(): Activity {
fun Context.checkGrantedPermission(permission: String): Boolean {
return ContextCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED
}

val Context.vibrator: Vibrator
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
(getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager).defaultVibrator
} else {
getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
Expand Down Expand Up @@ -36,7 +37,7 @@ import com.nexters.boolti.presentation.R
import com.nexters.boolti.presentation.component.BtBackAppBar
import com.nexters.boolti.presentation.theme.BooltiTheme
import com.nexters.boolti.presentation.theme.Grey30
import com.nexters.boolti.presentation.theme.Grey60
import com.nexters.boolti.presentation.theme.Grey50
import com.nexters.boolti.presentation.theme.point1
import java.time.LocalDate
import java.time.LocalDateTime
Expand All @@ -60,7 +61,9 @@ fun HostedShowScreen(
}
) { innerPadding ->
if (uiState.shows.isEmpty()) {
EmptyHostedShow(modifier = modifier.padding(innerPadding))
EmptyHostedShow(modifier = modifier
.padding(innerPadding)
.fillMaxSize())
} else {
HostedShows(
modifier = modifier
Expand Down Expand Up @@ -96,7 +99,7 @@ private fun HostedShowItem(
onClick: (showId: String, showName: String) -> Unit,
) {
val enable = LocalDate.now().toEpochDay() <= show.date.toLocalDate().toEpochDay()
val tint = if (enable) White else Grey60
val tint = if (enable) White else Grey50

Row(
modifier = Modifier
Expand All @@ -119,18 +122,6 @@ private fun HostedShowItem(
}
}

@Preview
@Composable
fun HostedShowItemPreview() {
BooltiTheme {
Surface {
HostedShowItem(
Show("", "hello world", LocalDateTime.now(), LocalDate.now(), LocalDate.now(), "")
) { _, _ -> }
}
}
}

@Composable
fun EmptyHostedShow(
modifier: Modifier,
Expand Down Expand Up @@ -163,3 +154,46 @@ fun EmptyHostedShow(
}
}
}

@Preview
@Composable
fun HostedShowItemPreview() {
BooltiTheme {
Surface {
HostedShowItem(
Show("", "hello world", LocalDateTime.now(), LocalDate.now(), LocalDate.now(), "")
) { _, _ -> }
}
}
}

@Preview
@Composable
fun OutDatedHostedShowItemPreview() {
BooltiTheme {
Surface {
HostedShowItem(
Show(
"",
"hello world",
LocalDateTime.now().minusDays(1),
LocalDate.now(),
LocalDate.now(),
""
)
) { _, _ -> }
}
}
}

@Preview(widthDp = 360, heightDp = 760)
@Composable
fun EmptyShowItemPreview() {
BooltiTheme {
Surface {
EmptyHostedShow(
Modifier
)
}
}
}
Loading

0 comments on commit a248006

Please sign in to comment.