Skip to content

Commit

Permalink
Merge pull request #30 from YAPP-Github/feature/sksowk156/PC-292
Browse files Browse the repository at this point in the history
[PC-292] 로그인 화면, 번호 인증 화면 ui 구현
  • Loading branch information
sksowk156 authored Jan 12, 2025
2 parents f842bfa + 15ddfae commit 71398d1
Show file tree
Hide file tree
Showing 51 changed files with 1,433 additions and 259 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ internal fun Project.configureAndroidCompose() {
add("implementation", libs.findLibrary("androidx.compose.material3").get())
add("implementation", libs.findLibrary("androidx.compose.ui").get())
add("implementation", libs.findLibrary("androidx.compose.ui.tooling.preview").get())
add("implementation", libs.findLibrary("androidx.compose.foundation").get())
add("debugImplementation", libs.findLibrary("androidx.compose.ui.tooling").get())
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.puzzle.common.ui

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
2 changes: 1 addition & 1 deletion core/common-ui/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.puzzle.common.ui

import org.junit.Assert.assertEquals
import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
Expand Down
2 changes: 1 addition & 1 deletion core/data/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>

</manifest>
16 changes: 16 additions & 0 deletions core/data/src/main/java/com/puzzle/data/di/DataModule.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.puzzle.data.di

import com.puzzle.data.repository.AuthCodeRepositoryImpl
import com.puzzle.data.repository.AuthRepositoryImpl
import com.puzzle.data.repository.TermsRepositoryImpl
import com.puzzle.data.util.TimerManagerImpl
import com.puzzle.domain.repository.AuthCodeRepository
import com.puzzle.domain.repository.AuthRepository
import com.puzzle.domain.repository.TermsRepository
import com.puzzle.domain.util.TimerManager
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -26,4 +30,16 @@ abstract class DataModule {
abstract fun bindsTermsRepository(
termsRepositoryImpl: TermsRepositoryImpl,
): TermsRepository

@Binds
@Singleton
abstract fun bindsAuthCodeRepository(
authCodeRepositoryImpl: AuthCodeRepositoryImpl,
): AuthCodeRepository

@Binds
@Singleton
abstract fun bindsTimerManager(
timerManagerImpl: TimerManagerImpl,
): TimerManager
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.puzzle.data.repository

import com.puzzle.domain.repository.AuthCodeRepository
import javax.inject.Inject

class AuthCodeRepositoryImpl @Inject constructor() : AuthCodeRepository {
override suspend fun requestAuthCode(phoneNumber: String): Boolean {
return true
}

override suspend fun verify(code: String): Boolean {
return true
}
}
55 changes: 55 additions & 0 deletions core/data/src/main/java/com/puzzle/data/util/TimerManagerImpl.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.puzzle.data.util

import com.puzzle.domain.util.TimerManager
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.util.concurrent.atomic.AtomicInteger
import javax.inject.Inject

class TimerManagerImpl @Inject constructor() : TimerManager {
private var timerJob: Job? = null
private val remainingTime = AtomicInteger(0)

override fun startTimer(
durationInSec: Int,
onTick: (remainingSec: Int) -> Unit,
onTimeExpired: () -> Unit
) {
stopTimer()

remainingTime.set(durationInSec)

timerJob = CoroutineScope(Dispatchers.Default).launch {
while (remainingTime.get() >= 0) {
withContext(Dispatchers.Main) {
onTick(remainingTime.get())
}

if (remainingTime.get() == 0) {
break
}

delay(1000L)
remainingTime.decrementAndGet()
}

withContext(Dispatchers.Main) {
onTimeExpired()
}
}
}

override fun stopTimer() {
timerJob?.cancel()
timerJob = null
remainingTime.set(0)
}

override fun isTimeRemaining(): Boolean {
return remainingTime.get() > 0
}
}
2 changes: 1 addition & 1 deletion core/database/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.puzzle.database

import org.junit.Assert.assertEquals
import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.puzzle.designsystem

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
2 changes: 1 addition & 1 deletion core/designsystem/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -40,7 +42,9 @@ fun PieceSolidButton(
disabledContainerColor = PieceTheme.colors.light1,
disabledContentColor = PieceTheme.colors.white,
),
modifier = modifier.height(52.dp),
modifier = modifier
.height(52.dp)
.widthIn(min = 100.dp),
) {
Text(
text = label,
Expand All @@ -67,7 +71,9 @@ fun PieceOutlinedButton(
disabledContainerColor = PieceTheme.colors.light1,
disabledContentColor = PieceTheme.colors.primaryDefault,
),
modifier = modifier.height(52.dp),
modifier = modifier
.height(52.dp)
.widthIn(min = 100.dp),
) {
Text(
text = label,
Expand All @@ -93,7 +99,9 @@ fun PieceSubButton(
disabledContainerColor = PieceTheme.colors.light3,
disabledContentColor = PieceTheme.colors.dark2,
),
modifier = modifier.height(52.dp),
modifier = modifier
.height(52.dp)
.widthIn(min = 100.dp),
) {
Text(
text = label,
Expand All @@ -105,29 +113,32 @@ fun PieceSubButton(
@Composable
fun PieceIconButton(
label: String,
@DrawableRes id: Int,
@DrawableRes imageId: Int,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
containerColor: Color = PieceTheme.colors.primaryDefault,
) {
Button(
onClick = onClick,
enabled = enabled,
shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors(
containerColor = PieceTheme.colors.primaryDefault,
containerColor = containerColor,
contentColor = PieceTheme.colors.white,
disabledContainerColor = PieceTheme.colors.light1,
disabledContentColor = PieceTheme.colors.white,
),
modifier = modifier.height(52.dp),
modifier = modifier
.height(52.dp)
.widthIn(min = 100.dp),
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Image(
painter = painterResource(id),
painter = painterResource(imageId),
contentDescription = null,
modifier = Modifier.size(32.dp),
)
Expand All @@ -140,6 +151,49 @@ fun PieceIconButton(
}
}

@Composable
fun PieceLoginButton(
label: String,
@DrawableRes imageId: Int,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
containerColor: Color = PieceTheme.colors.primaryDefault,
labelColor: Color = PieceTheme.colors.black
) {
Button(
onClick = onClick,
enabled = enabled,
shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors(
containerColor = containerColor,
contentColor = PieceTheme.colors.white,
disabledContainerColor = PieceTheme.colors.light1,
disabledContentColor = PieceTheme.colors.white,
),
modifier = modifier
.height(52.dp)
.widthIn(min = 100.dp),
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Image(
painter = painterResource(imageId),
contentDescription = null,
modifier = Modifier.size(20.dp),
)

Text(
text = label,
style = PieceTheme.typography.bodyMSB,
color = labelColor,
)
}
}
}

@Composable
fun PieceRoundingButton(
label: String,
Expand Down Expand Up @@ -233,7 +287,7 @@ fun PreviewPieceIconButton() {
PieceTheme {
PieceIconButton(
label = "Label",
id = R.drawable.ic_alarm,
imageId = R.drawable.ic_alarm,
onClick = {},
modifier = Modifier
.fillMaxWidth()
Expand All @@ -255,3 +309,18 @@ fun PreviewPieceRoundingButton() {
)
}
}

@Preview
@Composable
fun PreviewPieceLoginButton() {
PieceTheme {
PieceLoginButton(
label = "Label",
imageId = R.drawable.ic_alarm,
onClick = {},
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
)
}
}
Loading

0 comments on commit 71398d1

Please sign in to comment.