Skip to content
Closed
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
Expand Up @@ -3,6 +3,7 @@ package com.foke.together.domain.interactor.entity
import androidx.annotation.DrawableRes
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import com.foke.together.domain.R

abstract class CutFrame(
Expand Down Expand Up @@ -47,9 +48,9 @@ sealed class DefaultCutFrameSet (
PhotoPosition(159, 106, 16, 369),
),
emptyList(),
datePosition = TextStickerPosition(139,541,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6),
copyrightPosition = TextStickerPosition(122,547,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6),
qrCodePosition = QrStickerPosition(25,16,530)
datePosition = TextStickerPosition(80, 10, 91,541,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
copyrightPosition = TextStickerPosition(80, 10, 91,547,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
qrCodePosition = QrStickerPosition(30,16,530)
)

data object FourCurDark: DefaultCutFrameSet(
Expand All @@ -64,9 +65,9 @@ data object FourCurDark: DefaultCutFrameSet(
PhotoPosition(159, 106, 16, 369),
),
emptyList(),
datePosition = TextStickerPosition(139,541,R.font.cascadia_mono, color = Color(170, 170, 170), fontWeight = FontWeight.ExtraBold, fontSize = 6),
copyrightPosition = TextStickerPosition(122,547,R.font.cascadia_mono, color = Color(170, 170, 170), fontWeight = FontWeight.ExtraBold, fontSize = 6),
qrCodePosition = QrStickerPosition(25,16,530)
datePosition = TextStickerPosition(80, 10, 91,541,R.font.cascadia_mono, color = Color(170, 170, 170), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
copyrightPosition = TextStickerPosition(80, 10, 91,547,R.font.cascadia_mono, color = Color(170, 170, 170), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
qrCodePosition = QrStickerPosition(30,16,530)
)

data object MakerFaire: DefaultCutFrameSet(
Expand All @@ -81,9 +82,9 @@ data object FourCurDark: DefaultCutFrameSet(
PhotoPosition(159, 106, 16, 369),
),
emptyList(),
datePosition = TextStickerPosition(139,541,R.font.cascadia_mono, color = Color(238, 238, 238), fontWeight = FontWeight.ExtraBold, fontSize = 6),
copyrightPosition = TextStickerPosition(122,547,R.font.cascadia_mono, color = Color(238, 238, 238), fontWeight = FontWeight.ExtraBold, fontSize = 6),
qrCodePosition = QrStickerPosition(25,16,530)
datePosition = TextStickerPosition(80, 10, 91,541,R.font.cascadia_mono, color = Color(238, 238, 238), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
copyrightPosition = TextStickerPosition(80, 10, 91,547,R.font.cascadia_mono, color = Color(238, 238, 238), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
qrCodePosition = QrStickerPosition(30,16,530)
)

data object MakerFaire25_1: DefaultCutFrameSet(
Expand All @@ -100,9 +101,9 @@ data object FourCurDark: DefaultCutFrameSet(
listOf(
R.drawable.maker_faire_frame_25_1
),
datePosition = TextStickerPosition(139,541,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6),
copyrightPosition = TextStickerPosition(122,547,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6),
qrCodePosition = QrStickerPosition(25,149,517)
datePosition = TextStickerPosition(80, 10, 92,546,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
copyrightPosition = TextStickerPosition(80, 10, 92,551,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
qrCodePosition = QrStickerPosition(30,145,515)
)

data object MakerFaire25_2: DefaultCutFrameSet(
Expand All @@ -119,9 +120,9 @@ data object FourCurDark: DefaultCutFrameSet(
listOf(
R.drawable.maker_faire_frame_25_2
),
datePosition = TextStickerPosition(139,541,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6),
copyrightPosition = TextStickerPosition(122,547,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6),
qrCodePosition = QrStickerPosition(25,149,517)
datePosition = TextStickerPosition(80, 10, 92,546,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
copyrightPosition = TextStickerPosition(80, 10, 92,551,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
qrCodePosition = QrStickerPosition(30,145,515)
)

data object MakerFaire25_3: DefaultCutFrameSet(
Expand All @@ -138,9 +139,9 @@ data object FourCurDark: DefaultCutFrameSet(
listOf(
R.drawable.maker_faire_frame_25_3
),
datePosition = TextStickerPosition(139,541,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6),
copyrightPosition = TextStickerPosition(122,547,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6),
qrCodePosition = QrStickerPosition(25,149,517)
datePosition = TextStickerPosition(80, 10, 92,546,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
copyrightPosition = TextStickerPosition(80, 10, 92,551,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
qrCodePosition = QrStickerPosition(30,145,515)
)

data object MakerFaire25_4: DefaultCutFrameSet(
Expand All @@ -157,9 +158,9 @@ data object FourCurDark: DefaultCutFrameSet(
listOf(
R.drawable.maker_faire_frame_25_4
),
datePosition = TextStickerPosition(139,541,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6),
copyrightPosition = TextStickerPosition(122,547,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6),
qrCodePosition = QrStickerPosition(25,149,517)
datePosition = TextStickerPosition(80, 10, 92,546,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
copyrightPosition = TextStickerPosition(80, 10, 92,551,R.font.cascadia_mono, color = Color(34, 34, 34), fontWeight = FontWeight.ExtraBold, fontSize = 6, textAlign = TextAlign.End),
qrCodePosition = QrStickerPosition(30,145,515)
)

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.foke.together.domain.interactor.entity

import android.graphics.Bitmap

data class SessionData (
val sessionId: SessionId,
val cutFrame: CutFrame? = null,
val qrCodeBitmap: Bitmap? = null,
val status: Status
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ package com.foke.together.domain.interactor.entity
import androidx.annotation.FontRes
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign

data class TextStickerPosition (
val width: Int,
val height: Int,
val x: Int,
val y: Int,
@FontRes val font: Int,
val color: Color,
val backgroundColor: Color = Color(0,0,0,0),
val fontWeight: FontWeight,
val fontSize: Int,
val rotation: Float = 0f
val rotation: Float = 0f,
val textAlign: TextAlign = TextAlign.Left,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.foke.together.domain.interactor.session

import android.graphics.Bitmap
import com.foke.together.domain.interactor.entity.CutFrame
import com.foke.together.domain.interactor.entity.Status
import com.foke.together.domain.output.SessionRepositoryInterface
Expand All @@ -15,4 +16,8 @@ class UpdateSessionStatusUseCase @Inject constructor(
operator fun invoke(cutFrame: CutFrame) {
sessionRepository.updateSession(cutFrame)
}

operator fun invoke(qrCodeBitmap: Bitmap) {
sessionRepository.updateSession(qrCodeBitmap)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.foke.together.domain.interactor.web

import com.foke.together.domain.interactor.entity.AccountData
import com.foke.together.domain.output.RemoteRepositoryInterface
import com.foke.together.util.AppLog
import javax.inject.Inject

class RegisterUseCase @Inject constructor(
private val remoteRepository: RemoteRepositoryInterface,
) {
suspend operator fun invoke(id: String, password: String, name: String): Result<Unit> {
return remoteRepository.registerAccount(AccountData(id, password, name))
.onSuccess {
AppLog.i("RegisterUseCase", "init", "register success: ${it}")
}.onFailure { ee ->
AppLog.e("RegisterUseCase", "init", "error: ${ee}")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class UploadFileUseCase @Inject constructor(
.onSuccess { preSignedUrl ->
AppLog.e(TAG, "invoke", "preSignedUrl: $preSignedUrl")
remoteRepository.uploadFile(preSignedUrl, file)
.onSuccess {
return Result.success(Unit)
}
.onFailure {
AppLog.e(TAG, "invoke", "upload failed")
return Result.failure(Exception("cannot upload file: $it"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.foke.together.domain.output

import android.graphics.Bitmap
import com.foke.together.domain.interactor.entity.CutFrame
import com.foke.together.domain.interactor.entity.SessionData
import com.foke.together.domain.interactor.entity.Status
Expand All @@ -12,6 +13,7 @@ interface SessionRepositoryInterface {
fun updateSession(cutFrame: CutFrame)
fun updateSession(status: Status)
fun updateSession(cutFrame: CutFrame, status: Status)
fun updateSession(qrCodeBitmap: Bitmap)

fun clearSession()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.foke.together.util.AppPolicy
import com.foke.together.util.FileUtil
import com.foke.together.util.ImageFileUtil
import qrcode.QRCode
import qrcode.color.Colors
import javax.inject.Inject

class QRCodeGenerator @Inject constructor(
Expand All @@ -18,9 +19,12 @@ class QRCodeGenerator @Inject constructor(
// val roundedSquares = QRCode.ofRoundedSquares()

val qrcode = squares
.withMargin(20)
.withInnerSpacing(0)
// TODO: 아래 속성이 없어서 QR코드가 안보였던건데 그 전에는 왜 제대로 동작했는지?
.withColor(Colors.BLACK)
.withBackgroundColor(Colors.WHITE)
// TODO: check customize qrcode
// .withColor(Colors.BLACK)
// .withRadius(20)
// .withSize(25)
// .withLogo(logo.readBytes(), 20, 20)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.foke.together.external.repository

import android.graphics.Bitmap
import com.foke.together.domain.interactor.entity.CutFrame
import com.foke.together.domain.interactor.entity.SessionData
import com.foke.together.domain.interactor.entity.SessionId
Expand Down Expand Up @@ -33,7 +34,7 @@ class SessionRepository @Inject constructor(): SessionRepositoryInterface {

override fun updateSession(cutFrame: CutFrame) {
sessionData = sessionData?.let {
SessionData(it.sessionId, cutFrame, it.status)
SessionData(it.sessionId, cutFrame, it.qrCodeBitmap, it.status)
}
AppLog.i(TAG, "updateSession", "sessionData: $sessionData")

Expand All @@ -42,7 +43,7 @@ class SessionRepository @Inject constructor(): SessionRepositoryInterface {

override fun updateSession(status: Status) {
sessionData = sessionData?.let {
SessionData(it.sessionId, it.cutFrame, status)
SessionData(it.sessionId, it.cutFrame, it.qrCodeBitmap, status)
}
AppLog.i(TAG, "updateSession", "sessionData: $sessionData")

Expand All @@ -51,7 +52,16 @@ class SessionRepository @Inject constructor(): SessionRepositoryInterface {

override fun updateSession(cutFrame: CutFrame, status: Status) {
sessionData = sessionData?.let {
SessionData(it.sessionId, cutFrame, status)
SessionData(it.sessionId, cutFrame, it.qrCodeBitmap, status)
}
AppLog.i(TAG, "updateSession", "sessionData: $sessionData")

// TODO: save session data to Pref.
}

override fun updateSession(qrCodeBitmap: Bitmap) {
sessionData = sessionData?.let {
SessionData(it.sessionId, it.cutFrame, qrCodeBitmap, it.status)
}
AppLog.i(TAG, "updateSession", "sessionData: $sessionData")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,15 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.imageResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.foke.together.domain.R
import com.foke.together.domain.interactor.entity.DefaultCutFrameSet
import com.foke.together.util.TimeUtil

Expand Down Expand Up @@ -86,48 +81,50 @@ fun DefaultCutFrame(
// Copyright Text Sticker
Text(
modifier = Modifier
.fillMaxSize()
.width(cutFrame.copyrightPosition.width.dp)
.height(cutFrame.copyrightPosition.height.dp)
.background(cutFrame.copyrightPosition.backgroundColor)
.rotate(cutFrame.copyrightPosition.rotation)
.offset(x = cutFrame.copyrightPosition.x.dp, y = cutFrame.copyrightPosition.y.dp),
text = stringResource(com.foke.together.presenter.R.string.copyright),
color = cutFrame.copyrightPosition.color,
fontSize = cutFrame.copyrightPosition.fontSize.sp,
fontWeight = cutFrame.copyrightPosition.fontWeight
fontWeight = cutFrame.copyrightPosition.fontWeight,
textAlign = cutFrame.copyrightPosition.textAlign
)

// Date Text Sticker
if (cutFrame.isDateString) {
Text(
modifier = Modifier
.fillMaxSize()
.width(cutFrame.datePosition.width.dp)
.height(cutFrame.datePosition.height.dp)
.rotate(cutFrame.datePosition.rotation)
.offset(x = cutFrame.datePosition.x.dp, y = cutFrame.datePosition.y.dp),
text = TimeUtil.getCurrentDisplayTime(),
color = Color.White,
fontSize = 9.sp,
textAlign = TextAlign.Center,
fontWeight = FontWeight.Bold
color = cutFrame.datePosition.color,
fontSize = cutFrame.datePosition.fontSize.sp,
fontWeight = cutFrame.datePosition.fontWeight,
textAlign = cutFrame.datePosition.textAlign
)
}

// QR Code Sticker
if (cutFrame.isQrCode) {
val qrBitmap = qrImageBitmap ?: ImageBitmap.imageResource(id = R.drawable.qr_sample)
Box(
modifier = Modifier
.width(cutFrame.qrCodePosition.size.dp)
.height(cutFrame.qrCodePosition.size.dp)
.offset(x = cutFrame.qrCodePosition.x.dp, y = cutFrame.qrCodePosition.y.dp),
) {
AsyncImage(
model = ImageRequest.Builder(LocalContext.current)
.data(qrBitmap)
.build(),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize()
)
qrImageBitmap?.let {
Box(
modifier = Modifier
.width(cutFrame.qrCodePosition.size.dp)
.height(cutFrame.qrCodePosition.size.dp)
.offset(x = cutFrame.qrCodePosition.x.dp, y = cutFrame.qrCodePosition.y.dp),
) {
Image(
bitmap = qrImageBitmap.asImageBitmap(),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize()
)
}
}
}
}
Expand Down
Loading