Skip to content
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
8 changes: 8 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ android {
compose = true
buildConfig = true
}
signingConfigs {
getByName("debug") {
keyAlias = "androiddebugkey"
keyPassword = "android"
storeFile = File("${project.rootDir.absolutePath}/keystore/debug.keystore")//project.rootProject.file("debug.keystore")
storePassword = "android"
}
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex
Expand Down Expand Up @@ -292,16 +293,20 @@ fun CourseDetail(
.fillMaxWidth(fillRatio)
.fillMaxHeight()
.background(backgroundColor, RoundedCornerShape(6.dp))
) {
Text(
text = tag.optionText,
color = PawKeyTheme.colors.black,
modifier = Modifier
.align(Alignment.CenterStart)
.padding(horizontal = 16.dp),
style = PawKeyTheme.typography.caption12Sb2
)
}
)

Text(
text = tag.optionText,
color = PawKeyTheme.colors.black,
modifier = Modifier
.align(Alignment.CenterStart)
.padding(horizontal = 16.dp)
.zIndex(1f),
style = PawKeyTheme.typography.caption12Sb2,
maxLines = 1,
softWrap = false,
overflow = TextOverflow.Visible
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
package com.paw.key.core.designsystem.component

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -19,6 +14,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.paw.key.R
import com.paw.key.core.designsystem.theme.PawKeyTheme
import com.paw.key.core.util.noRippleClickable

@Composable
fun TopBar(
Expand All @@ -38,7 +34,7 @@ fun TopBar(
contentDescription = "뒤로가기",
modifier = Modifier
.align(Alignment.CenterStart)
.clickable { onBackClick() }
.noRippleClickable { onBackClick() }
)
}

Expand Down
168 changes: 72 additions & 96 deletions app/src/main/java/com/paw/key/core/util/PreferenceDataStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,135 +38,115 @@ private fun String.toLatLngList(): List<LatLng> =
}

object PreferenceDataStore {

private lateinit var appContext: Context

fun init(context: Context) {
appContext = context.applicationContext
}

private val summaryStore
get() = appContext.summaryStore


suspend fun saveWalkSummary(
context: Context,
points: List<LatLng>,
totalDistance: Float,
totalTime: Long,
totalSteps: Int,
) {
context.summaryStore.edit { preferences ->
summaryStore.edit { preferences ->
preferences[POINTS_KEY] = points.toPreferenceString()
preferences[TOTAL_DISTANCE_KEY] = totalDistance
preferences[TOTAL_TIME_KEY] = totalTime
preferences[TOTAL_STEPS_KEY] = totalSteps
}
}

fun getPoints(context: Context): Flow<List<LatLng>> {
return context.summaryStore.data.map { preferences ->
preferences[POINTS_KEY]?.toLatLngList() ?: emptyList()
}
fun getPoints(): Flow<List<LatLng>> = summaryStore.data.map {
it[POINTS_KEY]?.toLatLngList() ?: emptyList()
}

fun getTotalDistance(context: Context): Flow<Float> {
return context.summaryStore.data.map { preferences ->
preferences[TOTAL_DISTANCE_KEY] ?: 0f
}
fun getTotalDistance(): Flow<Float> = summaryStore.data.map {
it[TOTAL_DISTANCE_KEY] ?: 0f
}

fun getTotalTime(context: Context): Flow<Long> {
return context.summaryStore.data.map { preferences ->
preferences[TOTAL_TIME_KEY] ?: 0L
}
fun getTotalTime(): Flow<Long> = summaryStore.data.map {
it[TOTAL_TIME_KEY] ?: 0L
}

fun getTotalSteps(context: Context): Flow<Int> {
return context.summaryStore.data.map { preferences ->
preferences[TOTAL_STEPS_KEY] ?: 0
}
fun getTotalSteps(): Flow<Int> = summaryStore.data.map {
it[TOTAL_STEPS_KEY] ?: 0
}

suspend fun clearWalkSummary(context: Context) {
context.summaryStore.edit { preferences ->
preferences.remove(POINTS_KEY)
preferences.remove(TOTAL_DISTANCE_KEY)
preferences.remove(TOTAL_TIME_KEY)
preferences.remove(TOTAL_STEPS_KEY)
suspend fun clearWalkSummary() {
summaryStore.edit {
it.remove(POINTS_KEY)
it.remove(TOTAL_DISTANCE_KEY)
it.remove(TOTAL_TIME_KEY)
it.remove(TOTAL_STEPS_KEY)
}
}

suspend fun saveLoginInfo(
context: Context,
email: String,
password: String
) {
context.summaryStore.edit { preferences ->
preferences[LOGIN_EMAIL_KEY] = email
preferences[LOGIN_PASSWORD_KEY] = password
suspend fun saveLoginInfo(email: String, password: String) {
summaryStore.edit {
it[LOGIN_EMAIL_KEY] = email
it[LOGIN_PASSWORD_KEY] = password
}
}

fun getLoginEmail(context: Context): Flow<String> {
return context.summaryStore.data.map { preferences ->
preferences[LOGIN_EMAIL_KEY] ?: ""
}
fun getLoginEmail(): Flow<String> = summaryStore.data.map {
it[LOGIN_EMAIL_KEY] ?: ""
}

fun getLoginPassword(context: Context): Flow<String> {
return context.summaryStore.data.map { preferences ->
preferences[LOGIN_PASSWORD_KEY] ?: ""
}
fun getLoginPassword(): Flow<String> = summaryStore.data.map {
it[LOGIN_PASSWORD_KEY] ?: ""
}

data class LoginInfo(
val email: String,
val password: String
)
data class LoginInfo(val email: String, val password: String)

fun getLoginInfo(context: Context): Flow<LoginInfo> {
return context.summaryStore.data.map { preferences ->
LoginInfo(
email = preferences[LOGIN_EMAIL_KEY] ?: "",
password = preferences[LOGIN_PASSWORD_KEY] ?: ""
)
}
fun getLoginInfo(): Flow<LoginInfo> = summaryStore.data.map {
LoginInfo(
email = it[LOGIN_EMAIL_KEY] ?: "",
password = it[LOGIN_PASSWORD_KEY] ?: ""
)
}

suspend fun clearLoginInfo(context: Context) {
context.summaryStore.edit { preferences ->
preferences.remove(LOGIN_EMAIL_KEY)
preferences.remove(LOGIN_PASSWORD_KEY)
suspend fun clearLoginInfo() {
summaryStore.edit {
it.remove(LOGIN_EMAIL_KEY)
it.remove(LOGIN_PASSWORD_KEY)
}
}

suspend fun saveUserInfo(
context: Context,
userId: Int,
userName: String,
petId: Int,
petName: String
) {
context.summaryStore.edit { preferences ->
preferences[USER_ID_KEY] = userId
preferences[USER_NAME_KEY] = userName
preferences[PET_ID_KEY] = petId
preferences[PET_NAME_KEY] = petName
summaryStore.edit {
it[USER_ID_KEY] = userId
it[USER_NAME_KEY] = userName
it[PET_ID_KEY] = petId
it[PET_NAME_KEY] = petName
}
}

fun getUserId(context: Context): Flow<Int> {
return context.summaryStore.data.map { preferences ->
preferences[USER_ID_KEY] ?: 0
}
fun getUserId(): Flow<Int> = summaryStore.data.map {
it[USER_ID_KEY] ?: 0
}

fun getUserName(context: Context): Flow<String> {
return context.summaryStore.data.map { preferences ->
preferences[USER_NAME_KEY] ?: ""
}
fun getUserName(): Flow<String> = summaryStore.data.map {
it[USER_NAME_KEY] ?: ""
}

fun getPetId(context: Context): Flow<Int> {
return context.summaryStore.data.map { preferences ->
preferences[PET_ID_KEY] ?: 0
}
fun getPetId(): Flow<Int> = summaryStore.data.map {
it[PET_ID_KEY] ?: 0
}

fun getPetName(context: Context): Flow<String> {
return context.summaryStore.data.map { preferences ->
preferences[PET_NAME_KEY] ?: ""
}
fun getPetName(): Flow<String> = summaryStore.data.map {
it[PET_NAME_KEY] ?: ""
}

data class UserInfo(
Expand All @@ -176,29 +156,25 @@ object PreferenceDataStore {
val petName: String
)

fun getUserInfo(context: Context): Flow<UserInfo> {
return context.summaryStore.data.map { preferences ->
UserInfo(
userId = preferences[USER_ID_KEY] ?: 0,
userName = preferences[USER_NAME_KEY] ?: "",
petId = preferences[PET_ID_KEY] ?: 0,
petName = preferences[PET_NAME_KEY] ?: ""
)
}
fun getUserInfo(): Flow<UserInfo> = summaryStore.data.map {
UserInfo(
userId = it[USER_ID_KEY] ?: 0,
userName = it[USER_NAME_KEY] ?: "",
petId = it[PET_ID_KEY] ?: 0,
petName = it[PET_NAME_KEY] ?: ""
)
}

suspend fun clearUserInfo(context: Context) {
context.summaryStore.edit { preferences ->
preferences.remove(USER_ID_KEY)
preferences.remove(USER_NAME_KEY)
preferences.remove(PET_ID_KEY)
preferences.remove(PET_NAME_KEY)
suspend fun clearUserInfo() {
summaryStore.edit {
it.remove(USER_ID_KEY)
it.remove(USER_NAME_KEY)
it.remove(PET_ID_KEY)
it.remove(PET_NAME_KEY)
}
}

suspend fun clearAllData(context: Context) {
context.summaryStore.edit { preferences ->
preferences.clear()
}
suspend fun clearAllData() {
summaryStore.edit { it.clear() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ fun EntireCourseScreen(
onTabSelected : (Int) -> Unit,
modifier: Modifier = Modifier,
) {
val scope = rememberCoroutineScope()

Column (
modifier = modifier
.padding(paddingValues)
Expand All @@ -176,15 +178,24 @@ fun EntireCourseScreen(

when (currentPage) {
0 -> {
TapMapRoute(
paddingValues = paddingValues,
navigateUp = {},
navigateNext = {
navigateNext()
},
isGranted = isGranted,
snackBarHostState = snackBarHostState,
)
if (!isGranted) {
TapMapRoute(
paddingValues = paddingValues,
navigateUp = {},
navigateNext = {
navigateNext()
},
isGranted = isGranted,
snackBarHostState = snackBarHostState,
)
} else {
// 스낵바 알림만 띄우고 아무 것도 렌더링하지 않음
LaunchedEffect(Unit) {
scope.launch {
snackBarHostState.showSnackbar("위치 권한이 필요합니다.")
}
}
}
}

1 -> {
Expand Down
Loading