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] 버스 리뉴얼 - 셔틀버스 시간표 개요 #459

Merged
merged 13 commits into from
Nov 6, 2024
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package `in`.koreatech.koin.core.designsystem.component.chip

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
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.Shape
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import `in`.koreatech.koin.core.designsystem.theme.KoinTheme

/**
* 선택 불가한 텍스트 칩
* @param title 텍스트
* @param modifier Modifier
* @param containerColor 칩 배경색
* @param textStyle 텍스트 스타일
* @param shape 칩 모양
* @param contentPadding 칩 내부 padding
*/
@Composable
Comment on lines +20 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컴포넌트 추가할 때 마다 주석 달아주시는거 너무 좋아요!!
매번 감사하게 가져다가 쓰고 있습니다 🙇‍♂️

fun ReadOnlyTextChip(
title: String,
modifier: Modifier = Modifier,
containerColor: Color = KoinTheme.colors.primary500,
textStyle: TextStyle = KoinTheme.typography.regular12,
shape: Shape = RoundedCornerShape(4.dp),
contentPadding: PaddingValues = PaddingValues(horizontal = 4.dp)
) {
Box(
modifier = modifier
.clip(shape)
.background(containerColor)
.padding(contentPadding),
contentAlignment = Alignment.Center
) {
Text(
text = title,
style = textStyle,
)
}
}

@Preview
@Composable
private fun ReadOnlyTextChipPreview() {
ReadOnlyTextChip(
title = "순환",
containerColor = Color(0xFF4ED92C),
textStyle = KoinTheme.typography.regular12.copy(color = Color.White)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import `in`.koreatech.koin.core.designsystem.component.chip.ChipOverflowStrategy
*/
@Composable
fun TextChipGroup(
modifier: Modifier = Modifier,
chipOverflowStrategy: ChipOverflowStrategy = Flow(),
titles: List<String>,
shape: Shape = RoundedCornerShape(50),
vararg selectedChipIndexes: Int,
onChipSelected: (title: String) -> Unit,
modifier: Modifier = Modifier,
chipOverflowStrategy: ChipOverflowStrategy = Flow(),
shape: Shape = RoundedCornerShape(50),
showClickRipple: Boolean = true,
contentPadding: PaddingValues = PaddingValues(vertical = 6.dp, horizontal = 12.dp),
horizontalArrangement: Arrangement.Horizontal = Arrangement.spacedBy(6.dp),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package `in`.koreatech.koin.core.designsystem.component.tab

import androidx.compose.foundation.BorderStroke
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

@Composable
fun KoinSurface(
modifier: Modifier = Modifier,
shape: Shape = RectangleShape,
color: Color = Color.White,
contentColor: Color = Color.Black,
tonalElevation: Dp = 0.dp,
shadowElevation: Dp = 0.dp,
border: BorderStroke? = null,
content: @Composable () -> Unit
) {

Surface(
modifier = modifier,
shape = shape,
color = color,
contentColor = contentColor,
tonalElevation = tonalElevation,
shadowElevation = shadowElevation,
border = border,
content = content
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import `in`.koreatech.koin.core.designsystem.R
import `in`.koreatech.koin.core.designsystem.noRippleClickable
import `in`.koreatech.koin.core.designsystem.theme.KoinTheme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun KoinTopAppBar(
title: String,
modifier: Modifier = Modifier,
textStyle: TextStyle = KoinTheme.typography.medium18,
onNavigationIconClick: () -> Unit = {},
actions: @Composable() (RowScope.() -> Unit) = {},
colors: TopAppBarColors = TopAppBarDefaults.centerAlignedTopAppBarColors(
Expand All @@ -35,7 +38,10 @@ fun KoinTopAppBar(
) {
CenterAlignedTopAppBar(
title = {
Text(title)
Text(
text = title,
style = textStyle,
)
},
modifier = modifier,
navigationIcon = {
Expand Down
13 changes: 13 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_caution.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="17dp"
android:viewportWidth="16"
android:viewportHeight="17">
<group>
<clip-path
android:pathData="M0,0.5h16v16h-16z"/>
<path
android:pathData="M8,11.667C8.141,11.667 8.26,11.619 8.356,11.523C8.451,11.427 8.499,11.308 8.499,11.167V8.333C8.499,8.191 8.451,8.073 8.356,7.977C8.26,7.881 8.141,7.833 7.999,7.833C7.857,7.833 7.739,7.881 7.643,7.977C7.547,8.073 7.499,8.191 7.499,8.333V11.167C7.499,11.308 7.547,11.427 7.643,11.523C7.739,11.619 7.858,11.667 8,11.667ZM7.999,6.692C8.152,6.692 8.28,6.641 8.383,6.537C8.486,6.434 8.538,6.306 8.538,6.154C8.538,6.001 8.486,5.873 8.383,5.77C8.28,5.667 8.152,5.615 7.999,5.615C7.847,5.615 7.719,5.667 7.616,5.77C7.512,5.873 7.461,6.001 7.461,6.154C7.461,6.306 7.512,6.434 7.616,6.537C7.719,6.641 7.847,6.692 7.999,6.692ZM8.001,14.833C7.125,14.833 6.301,14.667 5.53,14.335C4.76,14.002 4.089,13.551 3.519,12.981C2.949,12.411 2.498,11.741 2.165,10.97C1.832,10.2 1.666,9.377 1.666,8.501C1.666,7.625 1.832,6.802 2.165,6.031C2.497,5.26 2.948,4.59 3.518,4.019C4.088,3.449 4.758,2.998 5.529,2.665C6.299,2.333 7.122,2.167 7.998,2.167C8.874,2.167 9.698,2.333 10.468,2.665C11.239,2.998 11.91,3.449 12.48,4.019C13.05,4.589 13.501,5.259 13.834,6.029C14.166,6.8 14.333,7.623 14.333,8.499C14.333,9.375 14.167,10.198 13.834,10.969C13.502,11.74 13.05,12.41 12.481,12.98C11.911,13.55 11.241,14.002 10.47,14.334C9.7,14.667 8.876,14.833 8.001,14.833ZM7.999,13.833C9.488,13.833 10.749,13.316 11.783,12.283C12.816,11.25 13.333,9.989 13.333,8.5C13.333,7.011 12.816,5.75 11.783,4.716C10.749,3.683 9.488,3.167 7.999,3.167C6.51,3.167 5.249,3.683 4.216,4.716C3.183,5.75 2.666,7.011 2.666,8.5C2.666,9.989 3.183,11.25 4.216,12.283C5.249,13.316 6.51,13.833 7.999,13.833Z"
android:fillColor="#727272"/>
</group>
</vector>
5 changes: 5 additions & 0 deletions feature/bus/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
alias(libs.plugins.koin.library)
alias(libs.plugins.koin.hilt)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlinx.serialization)
}

android {
Expand All @@ -24,10 +25,14 @@ dependencies {
implementation(libs.core.ktx)
implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.kotlinxCollectionsImmutable)

implementation(platform(libs.compose.bom))
implementation(libs.bundles.compose.m3)

debugImplementation(libs.bundles.compose.debug.test)
androidTestImplementation(libs.compose.ui.test.manifest)

implementation("androidx.navigation:navigation-compose:2.8.3")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 이렇게 쓴 이유가 없으면, toml 파일 사용해주시면 감사하겠습니다 🙇🏻

Copy link
Contributor Author

@ThirFir ThirFir Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지금 toml에서 2.7.7 쓰고 있는데 navigation 2.8.0 부터 Kotlin Serializable을 사용한 방식이 도입됐습니다 !
근데 막 올리면 2.7.7 사용하던 비즈니스 모듈에 무슨 문제가 생길지 예상이 안돼서 분리했습니다 ㅠㅠ

implementation(libs.kotlinx.serialization.json)
}
10 changes: 9 additions & 1 deletion feature/bus/src/main/java/in/koreatech/bus/Bus2Activity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ package `in`.koreatech.bus
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.MaterialTheme
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.navigation.compose.rememberNavController
import `in`.koreatech.bus.navigation.BusNavigation
import `in`.koreatech.koin.feature.bus.R

class Bus2Activity : AppCompatActivity() {
Expand All @@ -16,7 +21,10 @@ class Bus2Activity : AppCompatActivity() {
setContentView(R.layout.activity_bus2)
findViewById<ComposeView>(R.id.compose_view_bus).setContent {
MaterialTheme {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theme 설정을 KoinTheme 로 하지 않은 이유가 있나요? 👀

Copy link
Contributor Author

@ThirFir ThirFir Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아직 뷰 만드는 작업만 해서 그렇습니다 !!
나중에 바꿀게욥


BusNavigation(
modifier = Modifier.fillMaxSize(),
navController = rememberNavController(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BusNavigation 함수에서도 default value로 rememberNavController 넣어줬던데, default value 설정하고 밖에서 넣어주면 무슨 이점이 있나요?

Copy link
Contributor Author

@ThirFir ThirFir Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default로 두면 Preview할 때 navController를 주지 않아도 되는 점이 장점인 거 같아용
굳이 Activity에서 만들어서 넘길 필요는 없는 것 같긴해요 (아직까지는 그렇게만 느꼈어요)

)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package `in`.koreatech.bus.navigation

import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import `in`.koreatech.bus.screen.timetable.viewmodel.BusViewModel

@Composable
fun BusNavigation(
modifier: Modifier = Modifier,
navController: NavHostController = rememberNavController(),
viewModel: BusViewModel = hiltViewModel()
) {

NavHost(
modifier = modifier,
navController = navController,
startDestination = Routes.BusTimetable,
enterTransition = {
EnterTransition.None
}, exitTransition = {
ExitTransition.None
}
) {

composable<Routes.BusTimetable> {

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package `in`.koreatech.bus.navigation

import kotlinx.serialization.Serializable

internal object Routes {

@Serializable data object BusTimetable
}
Loading
Loading