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

Feature/360 입장 확인 고도화 #363

Merged
merged 15 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading