-
Notifications
You must be signed in to change notification settings - Fork 2
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 #462 from BCSDLab/feature/bus-search
[Feature] 버스 조회 뷰
- Loading branch information
Showing
15 changed files
with
648 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...system/src/main/java/in/koreatech/koin/core/designsystem/component/dialog/ChoiceDialog.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
6 changes: 6 additions & 0 deletions
6
domain/src/main/java/in/koreatech/koin/domain/error/busv2/ErrorType.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,6 @@ | ||
package `in`.koreatech.koin.domain.error.busv2 | ||
|
||
sealed class SearchBusError: Throwable() { | ||
class EmptyDeparture: SearchBusError() | ||
class EmptyArrival: SearchBusError() | ||
} |
21 changes: 21 additions & 0 deletions
21
domain/src/main/java/in/koreatech/koin/domain/usecase/busv2/SearchBusV2UseCase.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,21 @@ | ||
package `in`.koreatech.koin.domain.usecase.busv2 | ||
|
||
import `in`.koreatech.koin.domain.error.busv2.SearchBusError | ||
import javax.inject.Inject | ||
|
||
class SearchBusV2UseCase @Inject constructor( | ||
// private val busRepository | ||
) { | ||
|
||
suspend operator fun invoke(departure: String, arrival: String): Result<Unit> { | ||
return when { | ||
departure.isEmpty() -> Result.failure(SearchBusError.EmptyDeparture()) | ||
arrival.isEmpty() -> Result.failure(SearchBusError.EmptyArrival()) | ||
else -> { | ||
// TODO repository Search bus | ||
// busRepository.searchBus(departure, arrival) | ||
Result.success(Unit) | ||
} | ||
} | ||
} | ||
} |
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
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
199 changes: 199 additions & 0 deletions
199
feature/bus/src/main/java/in/koreatech/bus/screen/search/composable/BusSearchContentView.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,199 @@ | ||
package `in`.koreatech.bus.screen.search.composable | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.IntrinsicSize | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
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.shape.RoundedCornerShape | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
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.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import androidx.constraintlayout.compose.ConstraintLayout | ||
import androidx.constraintlayout.compose.Dimension | ||
import `in`.koreatech.koin.core.designsystem.component.button.FilledButton | ||
import `in`.koreatech.koin.core.designsystem.component.tab.KoinSurface | ||
import `in`.koreatech.koin.core.designsystem.noRippleClickable | ||
import `in`.koreatech.koin.core.designsystem.theme.KoinTheme | ||
import `in`.koreatech.koin.feature.bus.R | ||
|
||
@Composable | ||
internal fun BusSearchContentView( | ||
departure: String, | ||
arrival: String, | ||
modifier: Modifier = Modifier, | ||
searchButtonEnabled: Boolean = false, | ||
onSwapIconClicked: () -> Unit = {}, | ||
onSearchClicked: () -> Unit = {}, | ||
onDepartureFieldClicked: () -> Unit = {}, | ||
onArrivalFieldClicked: () -> Unit = {} | ||
) { | ||
|
||
KoinSurface { | ||
Column(modifier = modifier) { | ||
Text( | ||
modifier = Modifier, | ||
text = stringResource(R.string.introduce_bus_search), | ||
style = KoinTheme.typography.medium16, | ||
color = KoinTheme.colors.neutral800 | ||
) | ||
|
||
Text( | ||
modifier = Modifier.padding(top = 2.dp), | ||
text = stringResource(R.string.caution_possibly_inaccurate), | ||
style = KoinTheme.typography.regular12, | ||
color = KoinTheme.colors.neutral600 | ||
) | ||
|
||
ConstraintLayout( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(top = 46.dp) | ||
.height(IntrinsicSize.Min) | ||
) { | ||
val (departureText, arrivalText, departureField, arrivalField, iconSwap) = createRefs() | ||
|
||
Text( | ||
modifier = Modifier.constrainAs(departureText) { | ||
start.linkTo(departureField.start) | ||
top.linkTo(parent.top) | ||
end.linkTo(departureField.end) | ||
}, | ||
text = stringResource(R.string.departure), | ||
style = KoinTheme.typography.medium16, | ||
color = KoinTheme.colors.primary500 | ||
) | ||
Text( | ||
modifier = Modifier.constrainAs(arrivalText) { | ||
top.linkTo(parent.top) | ||
start.linkTo(arrivalField.start) | ||
end.linkTo(arrivalField.end) | ||
}, | ||
text = stringResource(R.string.arrival), | ||
style = KoinTheme.typography.medium16, | ||
color = KoinTheme.colors.primary500 | ||
) | ||
|
||
BusSearchInput( | ||
place = departure, | ||
placeholder = stringResource(R.string.select_departure), | ||
modifier = Modifier | ||
.padding(top = 10.dp) | ||
.noRippleClickable { | ||
onDepartureFieldClicked() | ||
} | ||
.constrainAs(departureField) { | ||
top.linkTo(iconSwap.top) | ||
bottom.linkTo(iconSwap.bottom) | ||
start.linkTo(parent.start) | ||
end.linkTo(iconSwap.start) | ||
|
||
width = Dimension.fillToConstraints | ||
height = Dimension.preferredWrapContent | ||
} | ||
) | ||
|
||
IconButton( | ||
onClick = onSwapIconClicked, | ||
modifier = Modifier | ||
.padding(top = 10.dp) | ||
.padding(horizontal = 16.dp, vertical = 12.dp) | ||
.size(32.dp) | ||
.constrainAs(iconSwap) { | ||
top.linkTo(departureText.bottom) | ||
start.linkTo(departureField.end) | ||
end.linkTo(arrivalField.start) | ||
} | ||
) { | ||
Icon( | ||
painter = painterResource(id = R.drawable.ic_swap), // TODO : 아이콘 깨짐 | ||
contentDescription = stringResource(R.string.swap_content_description), | ||
) | ||
} | ||
|
||
BusSearchInput( | ||
place = arrival, | ||
placeholder = stringResource(R.string.select_arrival), | ||
modifier = Modifier | ||
.padding(top = 10.dp) | ||
.noRippleClickable { | ||
onArrivalFieldClicked() | ||
} | ||
.constrainAs(arrivalField) { | ||
top.linkTo(iconSwap.top) | ||
bottom.linkTo(iconSwap.bottom) | ||
start.linkTo(iconSwap.end) | ||
end.linkTo(parent.end) | ||
|
||
width = Dimension.fillToConstraints | ||
height = Dimension.preferredWrapContent | ||
} | ||
) | ||
} | ||
|
||
Spacer(modifier = Modifier.weight(1f)) | ||
FilledButton( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(bottom = 30.dp), | ||
enabled = searchButtonEnabled, | ||
text = stringResource(R.string.search), | ||
contentPadding = PaddingValues(vertical = 12.dp), | ||
onClick = onSearchClicked | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun BusSearchInput( | ||
place: String, | ||
placeholder: String, | ||
modifier: Modifier = Modifier, | ||
) { | ||
|
||
val isPlaceDetermined = place.isNotEmpty() | ||
|
||
Column( | ||
modifier = modifier, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Box( | ||
modifier = Modifier | ||
.clip(RoundedCornerShape(4.dp)) | ||
.background(if (isPlaceDetermined.not()) KoinTheme.colors.neutral100 else Color.Transparent) | ||
.fillMaxSize(), | ||
contentAlignment = Alignment.Center | ||
) { | ||
if (isPlaceDetermined.not()) | ||
Text( | ||
text = placeholder, | ||
maxLines = 1, | ||
style = KoinTheme.typography.regular14, | ||
color = KoinTheme.colors.neutral400 // TODO neutral450 ? | ||
) | ||
else { | ||
Text( | ||
text = place, | ||
maxLines = 1, | ||
style = KoinTheme.typography.bold18, | ||
color = KoinTheme.colors.neutral800 | ||
) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.