-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from TeamTripmate/feature/personalization
[feat] 개인화 화면 구성 및 로직 구현
- Loading branch information
Showing
82 changed files
with
2,498 additions
and
82 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="purple_200">#FFBB86FC</color> | ||
<color name="purple_500">#FF6200EE</color> | ||
<color name="purple_700">#FF3700B3</color> | ||
<color name="teal_200">#FF03DAC5</color> | ||
<color name="teal_700">#FF018786</color> | ||
<color name="black">#FF000000</color> | ||
<color name="white">#FFFFFFFF</color> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">Tripmate</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<style name="Theme.Tripmateandroid" parent="android:Theme.Material.Light.NoActionBar" /> | ||
</resources> |
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
core/common/src/main/kotlin/com/tripmate/android/core/common/ObserveAsEvents.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.tripmate.android.core.common | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.ui.platform.LocalLifecycleOwner | ||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.repeatOnLifecycle | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.withContext | ||
|
||
// https://www.youtube.com/watch?v=njchj9d_Lf8&t=1218s | ||
@Composable | ||
fun <T> ObserveAsEvents(flow: Flow<T>, onEvent: (T) -> Unit) { | ||
val lifecycleOwner = LocalLifecycleOwner.current | ||
LaunchedEffect(flow, lifecycleOwner.lifecycle) { | ||
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { | ||
withContext(Dispatchers.Main.immediate) { | ||
flow.collect(onEvent) | ||
} | ||
} | ||
} | ||
} |
Empty file.
20 changes: 20 additions & 0 deletions
20
core/common/src/main/kotlin/com/tripmate/android/core/common/extension/NavBackStackEntry.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.tripmate.android.core.common.extension | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import androidx.lifecycle.ViewModel | ||
import androidx.navigation.NavBackStackEntry | ||
import androidx.navigation.NavHostController | ||
|
||
// https://youtu.be/h61Wqy3qcKg?si=OqctoATR5MGbypOW | ||
@Composable | ||
inline fun <reified T : ViewModel> NavBackStackEntry.sharedViewModel( | ||
navController: NavHostController, | ||
): T { | ||
val navGraphRoute = destination.parent?.route ?: return hiltViewModel() | ||
val parentEntry = remember(this) { | ||
navController.getBackStackEntry(navGraphRoute) | ||
} | ||
return hiltViewModel(parentEntry) | ||
} |
2 changes: 1 addition & 1 deletion
2
core/data/src/main/kotlin/com/tripmate/android/core/data/di/RepositoryModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...rc/main/kotlin/com/tripmate/android/core/data/repository/PersonalizationRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,7 @@ dependencies { | |
libs.coil.compose, | ||
libs.timber, | ||
libs.compose.keyboard.state, | ||
|
||
libs.bundles.landscapist, | ||
) | ||
} |
57 changes: 57 additions & 0 deletions
57
core/designsystem/src/main/kotlin/com/tripmate/android/core/designsystem/component/Button.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.tripmate.android.core.designsystem.component | ||
|
||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.RowScope | ||
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.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.dp | ||
import com.tripmate.android.core.designsystem.ComponentPreview | ||
import com.tripmate.android.core.designsystem.theme.Gray004 | ||
import com.tripmate.android.core.designsystem.theme.Gray009 | ||
import com.tripmate.android.core.designsystem.theme.Primary01 | ||
import com.tripmate.android.core.designsystem.theme.TripmateTheme | ||
|
||
@Composable | ||
fun TripmateButton( | ||
onClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
enabled: Boolean = true, | ||
containerColor: Color = Primary01, | ||
contentColor: Color = Color.White, | ||
disabledContainerColor: Color = Gray009, | ||
disabledContentColor: Color = Gray004, | ||
contentPadding: PaddingValues = ButtonDefaults.ContentPadding, | ||
content: @Composable RowScope.() -> Unit, | ||
) { | ||
Button( | ||
onClick = onClick, | ||
modifier = modifier, | ||
enabled = enabled, | ||
shape = RoundedCornerShape(8.dp), | ||
colors = ButtonDefaults.buttonColors( | ||
containerColor = containerColor, | ||
contentColor = contentColor, | ||
disabledContainerColor = disabledContainerColor, | ||
disabledContentColor = disabledContentColor, | ||
), | ||
contentPadding = contentPadding, | ||
content = content, | ||
) | ||
} | ||
|
||
@ComponentPreview | ||
@Composable | ||
fun TripmateButtonPreview() { | ||
TripmateTheme { | ||
TripmateButton( | ||
onClick = {}, | ||
) { | ||
Text("Button") | ||
} | ||
} | ||
} |
148 changes: 148 additions & 0 deletions
148
core/designsystem/src/main/kotlin/com/tripmate/android/core/designsystem/component/Dialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
package com.tripmate.android.core.designsystem.component | ||
|
||
import androidx.annotation.StringRes | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.BasicAlertDialog | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.res.vectorResource | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.window.DialogProperties | ||
import com.tripmate.android.core.designsystem.ComponentPreview | ||
import com.tripmate.android.core.designsystem.R | ||
import com.tripmate.android.core.designsystem.theme.Background02 | ||
import com.tripmate.android.core.designsystem.theme.Gray001 | ||
import com.tripmate.android.core.designsystem.theme.Gray004 | ||
import com.tripmate.android.core.designsystem.theme.Medium16_SemiBold | ||
import com.tripmate.android.core.designsystem.theme.Primary01 | ||
import com.tripmate.android.core.designsystem.theme.Small14_Reg | ||
import com.tripmate.android.core.designsystem.theme.TripmateTheme | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun TripMateDialog( | ||
onDismissRequest: () -> Unit, | ||
@StringRes titleResId: Int, | ||
iconResId: Int?, | ||
iconDescription: String?, | ||
@StringRes descriptionResId: Int, | ||
cancelTextResId: Int?, | ||
confirmTextResId: Int, | ||
onCancelClick: () -> Unit, | ||
onConfirmClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
properties: DialogProperties = DialogProperties(), | ||
) { | ||
BasicAlertDialog( | ||
onDismissRequest = onDismissRequest, | ||
modifier = modifier, | ||
properties = properties, | ||
) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.clip(RoundedCornerShape(16.dp)) | ||
.background(color = Background02), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
Spacer(modifier = Modifier.height(60.dp)) | ||
if (iconResId != null && iconDescription != null) { | ||
Icon( | ||
imageVector = ImageVector.vectorResource(iconResId), | ||
contentDescription = iconDescription, | ||
tint = Color.Unspecified, | ||
) | ||
} | ||
Text( | ||
text = stringResource(id = titleResId), | ||
style = Medium16_SemiBold, | ||
color = Gray001, | ||
) | ||
Spacer(modifier = Modifier.height(8.dp)) | ||
Text( | ||
text = stringResource(id = descriptionResId), | ||
color = Gray004, | ||
style = Small14_Reg, | ||
) | ||
Spacer(modifier = Modifier.height(48.dp)) | ||
Row( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 24.dp), | ||
) { | ||
TripmateButton( | ||
onClick = onConfirmClick, | ||
modifier = Modifier | ||
.weight(1f) | ||
.height(48.dp) | ||
.then( | ||
if (cancelTextResId != null) { | ||
Modifier.padding(end = 4.dp) | ||
} else { | ||
Modifier | ||
}, | ||
), | ||
containerColor = Primary01, | ||
contentColor = Color.White, | ||
) { | ||
Text( | ||
text = stringResource(id = confirmTextResId), | ||
color = Color.White, | ||
style = Medium16_SemiBold, | ||
) | ||
} | ||
if (cancelTextResId != null) { | ||
TripmateButton( | ||
onClick = onCancelClick, | ||
modifier = Modifier | ||
.weight(1f) | ||
.height(48.dp) | ||
.padding(start = 4.dp), | ||
containerColor = Primary01, | ||
) { | ||
Text( | ||
text = stringResource(id = cancelTextResId), | ||
color = Color.White, | ||
style = Medium16_SemiBold, | ||
) | ||
} | ||
} | ||
} | ||
Spacer(modifier = Modifier.height(24.dp)) | ||
} | ||
} | ||
} | ||
|
||
@ComponentPreview | ||
@Composable | ||
fun TripMateDialogPreview() { | ||
TripmateTheme { | ||
TripMateDialog( | ||
onDismissRequest = {}, | ||
titleResId = R.string.under_age_title, | ||
iconResId = null, | ||
iconDescription = "", | ||
descriptionResId = R.string.under_age_description, | ||
cancelTextResId = null, | ||
confirmTextResId = R.string.under_age_confirm, | ||
onCancelClick = {}, | ||
onConfirmClick = {}, | ||
modifier = Modifier.padding(16.dp), | ||
) | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...gnsystem/src/main/kotlin/com/tripmate/android/core/designsystem/component/NetworkImage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.tripmate.android.core.designsystem.component | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.painter.Painter | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.platform.LocalInspectionMode | ||
import com.skydoves.landscapist.ImageOptions | ||
import com.skydoves.landscapist.coil.CoilImage | ||
import com.skydoves.landscapist.components.rememberImageComponent | ||
import com.skydoves.landscapist.placeholder.placeholder.PlaceholderPlugin | ||
import com.tripmate.android.core.designsystem.ComponentPreview | ||
import com.tripmate.android.core.designsystem.theme.TripmateTheme | ||
|
||
@Composable | ||
fun NetworkImage( | ||
imgUrl: String?, | ||
contentDescription: String?, | ||
modifier: Modifier = Modifier, | ||
placeholder: Painter? = null, | ||
contentScale: ContentScale = ContentScale.Crop, | ||
) { | ||
if (LocalInspectionMode.current) { | ||
// Image( | ||
// painter = painterResource(id = R.drawable.item_placeholder), | ||
// contentDescription = "Example Image Icon", | ||
// modifier = modifier, | ||
// ) | ||
} else { | ||
CoilImage( | ||
imageModel = { imgUrl }, | ||
modifier = modifier, | ||
component = rememberImageComponent { | ||
+PlaceholderPlugin.Loading(placeholder) | ||
+PlaceholderPlugin.Failure(placeholder) | ||
}, | ||
imageOptions = ImageOptions( | ||
contentScale = contentScale, | ||
alignment = Alignment.Center, | ||
contentDescription = contentDescription, | ||
), | ||
) | ||
} | ||
} | ||
|
||
@ComponentPreview | ||
@Composable | ||
fun NetworkImagePreview() { | ||
TripmateTheme { | ||
NetworkImage( | ||
imgUrl = "", | ||
contentDescription = "", | ||
) | ||
} | ||
} |
Oops, something went wrong.