-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/#135 search UI #142
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
Changes from all commits
f6fa3de
c5bbbab
8d17482
6070ce2
9441b4a
3489f78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| package com.teamsolply.solply.designsystem.component.searchbar | ||
|
|
||
| import androidx.compose.foundation.Image | ||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.border | ||
| import androidx.compose.foundation.clickable | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||
| import androidx.compose.foundation.text.BasicTextField | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.focus.FocusRequester | ||
| import androidx.compose.ui.focus.focusRequester | ||
| import androidx.compose.ui.platform.LocalSoftwareKeyboardController | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import com.teamsolply.solply.designsystem.R | ||
| import com.teamsolply.solply.designsystem.theme.SolplyTheme | ||
|
|
||
| @Composable | ||
| fun SolplySearchbar( | ||
| modifier: Modifier, | ||
| query: String, | ||
| onQueryChange: (String) -> Unit, | ||
| onImageClick: () -> Unit | ||
| ) { | ||
| val keyboardController = LocalSoftwareKeyboardController.current | ||
| val focusRequester = remember { FocusRequester() } | ||
|
|
||
| Row( | ||
| modifier = modifier | ||
| .fillMaxWidth() | ||
| .border( | ||
| width = 1.dp, | ||
| color = SolplyTheme.colors.gray300, | ||
| shape = RoundedCornerShape(20.dp) | ||
| ) | ||
| .background(color = SolplyTheme.colors.white) | ||
| .padding(vertical = 14.dp, horizontal = 20.dp) | ||
| .clickable { | ||
| focusRequester.requestFocus() | ||
| keyboardController?.show() | ||
| }, | ||
| horizontalArrangement = Arrangement.Start, | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| BasicTextField( | ||
| value = query, | ||
| onValueChange = onQueryChange, | ||
| modifier = modifier | ||
| .weight(1f) | ||
| .fillMaxWidth() | ||
| .focusRequester(focusRequester), | ||
| textStyle = SolplyTheme.typography.body16R.copy(color = SolplyTheme.colors.black), | ||
| decorationBox = { innerTextField -> | ||
| if (query.isEmpty()) { | ||
| Text( | ||
| text = "์ฐพ๋ ๊ณต๊ฐ์ ์ ๋ ฅํ์ธ์", | ||
| style = SolplyTheme.typography.body16R, | ||
| color = SolplyTheme.colors.gray500 | ||
| ) | ||
| } | ||
| innerTextField() | ||
| }, | ||
| maxLines = 1, | ||
| singleLine = true | ||
| ) | ||
| Image( | ||
| painter = painterResource(id = R.drawable.ic_setting), // ic_search 134 ๋ธ๋์น ๋ค์ด์ค๊ณ ๋ฐ๊ฟ์ผํจ | ||
| contentDescription = "Search Icon", | ||
| modifier = Modifier | ||
| .clickable { | ||
| onImageClick() | ||
| keyboardController?.hide() | ||
| } | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| fun SearchBoxPreview() { | ||
| SolplyTheme { | ||
| SolplySearchbar( | ||
| modifier = Modifier.fillMaxWidth(), | ||
| query = "", | ||
| onQueryChange = {}, | ||
| onImageClick = {} | ||
| ) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /build |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| plugins { | ||
| alias(libs.plugins.solply.java.library) | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(projects.core.model) | ||
| implementation(libs.bundles.coroutine) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| package com.teamsolply.solply.search | ||
|
|
||
| class MyClass |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,13 +15,16 @@ import androidx.compose.material3.SnackbarDuration | |
| import androidx.compose.material3.SnackbarHost | ||
| import androidx.compose.material3.SnackbarHostState | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.LaunchedEffect | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.rememberCoroutineScope | ||
| import androidx.compose.runtime.snapshotFlow | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.platform.LocalLayoutDirection | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.navigation.NavDestination.Companion.hasRoute | ||
| import androidx.navigation.compose.NavHost | ||
| import androidx.navigation.navOptions | ||
| import com.teamsolply.solply.collection.collection.course.courseCollectionNavGraph | ||
|
|
@@ -38,24 +41,51 @@ import com.teamsolply.solply.main.component.MainBottomBar | |
| import com.teamsolply.solply.main.model.SolplySnackBarData | ||
| import com.teamsolply.solply.main.splash.splashNavGraph | ||
| import com.teamsolply.solply.maps.navigation.mapsNavGraph | ||
| import com.teamsolply.solply.model.MapsType | ||
| import com.teamsolply.solply.model.SnackBarType | ||
| import com.teamsolply.solply.oauth.navigation.oauthNavGraph | ||
| import com.teamsolply.solply.onboarding.navigation.onBoardingNavGraph | ||
| import com.teamsolply.solply.place.navigation.placeNavGraph | ||
| import com.teamsolply.solply.search.navigation.Search | ||
| import com.teamsolply.solply.search.navigation.searchNavGraph | ||
| import kotlinx.collections.immutable.toPersistentList | ||
| import kotlinx.coroutines.Job | ||
| import kotlinx.coroutines.flow.filterNotNull | ||
| import kotlinx.coroutines.flow.first | ||
| import kotlinx.coroutines.launch | ||
|
|
||
| @Composable | ||
| internal fun MainScreen( | ||
| modifier: Modifier = Modifier, | ||
| navigator: MainNavigator = rememberMainNavigator() | ||
| navigator: MainNavigator = rememberMainNavigator(), | ||
| isFreshLaunch: Boolean = false | ||
| ) { | ||
| val coroutineScope = rememberCoroutineScope() | ||
| val snackbarHostState = remember { SnackbarHostState() } | ||
| val currentSnackbarJob = remember { mutableStateOf<Job?>(null) } | ||
| val currentSnackbarState = remember { mutableStateOf(SolplySnackBarData()) } | ||
|
|
||
| val navController = navigator.navController | ||
|
|
||
| if (isFreshLaunch) { | ||
| LaunchedEffect(navController) { | ||
| val initialDestination = snapshotFlow { navController.currentBackStackEntry } | ||
| .filterNotNull() | ||
| .first() | ||
| .destination | ||
|
|
||
| if (!initialDestination.hasRoute(Search::class)) { | ||
| val initialNavOptions = navOptions { | ||
| popUpTo(0) { | ||
| inclusive = true | ||
| } | ||
| launchSingleTop = true | ||
| } | ||
| navigator.navigateToSearch(initialNavOptions) | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+71
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ด๊ธฐ ๋ฐฑ์คํ ์กฐํ๊ฐ ์์ํ ์๋ฃ๋์ง ์๋ ๋ฒ๊ทธ๊ฐ ์์ต๋๋ค
LaunchedEffect(navController) {
- val initialDestination = snapshotFlow { navController.currentBackStackEntry }
- .filterNotNull()
- .first()
- .destination
+ val initialDestination = navController.currentBackStackEntryFlow
+ .filterNotNull()
+ .first()
+ .destination
๐ค Prompt for AI Agents |
||
|
|
||
| suspend fun showTextSnackBar(message: String) { | ||
| currentSnackbarJob.value?.join() | ||
| currentSnackbarJob.value = coroutineScope.launch { | ||
|
|
@@ -128,6 +158,29 @@ internal fun MainScreen( | |
| .background(color = SolplyTheme.colors.gray100) | ||
| .fillMaxSize() | ||
| ) { | ||
| searchNavGraph( | ||
| paddingValues = innerPadding, | ||
| onBack = navigator::navigateToBack, | ||
| navigateToPlaceDetail = { townId, placeId -> | ||
| val navOptions = navOptions {} | ||
| navigator.navigateToMaps( | ||
| mapsType = MapsType.PLACE_DETAIL.name, | ||
| townId = townId, | ||
| placeId = placeId, | ||
| courseId = null, | ||
| navOptions = navOptions | ||
| ) | ||
| }, | ||
| onNoPlaceClick = { | ||
| val navOptions = navOptions { | ||
| popUpTo(0) { | ||
| inclusive = true | ||
| } | ||
| launchSingleTop = true | ||
| } | ||
| navigator.navigateToPlace(navOptions = navOptions) | ||
| } | ||
| ) | ||
| splashNavGraph( | ||
| navigateToOauth = { | ||
| val navOptions = navOptions { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /build |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| plugins { | ||
| alias(libs.plugins.solply.feature) | ||
| } | ||
|
|
||
| android { | ||
| namespace = "com.teamsolply.solply.search" | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(projects.core.designsystem) | ||
| implementation(projects.core.model) | ||
| implementation(projects.core.ui) | ||
| implementation(projects.domain.place) | ||
| implementation(projects.domain.search) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Add project specific ProGuard rules here. | ||
| # You can control the set of applied configuration files using the | ||
| # proguardFiles setting in build.gradle. | ||
| # | ||
| # For more details, see | ||
| # http://developer.android.com/guide/developing/tools/proguard.html | ||
|
|
||
| # If your project uses WebView with JS, uncomment the following | ||
| # and specify the fully qualified class name to the JavaScript interface | ||
| # class: | ||
| #-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
| # public *; | ||
| #} | ||
|
|
||
| # Uncomment this to preserve the line number information for | ||
| # debugging stack traces. | ||
| #-keepattributes SourceFile,LineNumberTable | ||
|
|
||
| # If you keep the line number information, uncomment this to | ||
| # hide the original source file name. | ||
| #-renamesourcefileattribute SourceFile |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
|
||
| </manifest> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package com.teamsolply.solply.search | ||
|
|
||
| import com.teamsolply.solply.model.PlaceType | ||
| import com.teamsolply.solply.ui.base.SideEffect | ||
| import com.teamsolply.solply.ui.base.UiIntent | ||
| import com.teamsolply.solply.ui.base.UiState | ||
| import kotlinx.collections.immutable.PersistentList | ||
| import kotlinx.collections.immutable.persistentListOf | ||
|
|
||
| data class SearchState( | ||
| val query: String = "", | ||
| val isLoading: Boolean = false, | ||
| val results: PersistentList<SearchItemUi> = persistentListOf(), | ||
| val selectedTownId: Long? = null | ||
| ) : UiState { | ||
| val resultCount: Int get() = results.size | ||
| val hasQuery: Boolean get() = query.isNotBlank() | ||
| } | ||
|
|
||
| data class SearchItemUi( | ||
| val id: Long, | ||
| val name: String, | ||
| val tag: PlaceType, | ||
| val address: String, | ||
| val imageUrl: String | ||
| ) | ||
|
|
||
| sealed interface SearchIntent : UiIntent { | ||
| data class QueryChanged(val value: String) : SearchIntent | ||
| data object ClearQuery : SearchIntent | ||
| data object Submit : SearchIntent | ||
| data class ClickItem(val id: Long) : SearchIntent | ||
| data object ClickNoResult : SearchIntent | ||
| data object Retry : SearchIntent | ||
| } | ||
|
|
||
| sealed interface SearchSideEffect : SideEffect { | ||
| data class NavigateToPlaceDetail(val townId: Long, val placeId: Long) : SearchSideEffect | ||
| data object NavigateToNoResult : SearchSideEffect | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weightimport ๋๋ฝ์ผ๋ก ์ปดํ์ผ์ด ์คํจํฉ๋๋ค.Line 58์์
.weight(1f)๋ฅผ ํธ์ถํ์ง๋งandroidx.compose.foundation.layout.weightimport๊ฐ ์์ด์ ๋น๋๊ฐ ๋ฉ์ถฅ๋๋ค. ์๋์ฒ๋ผ import๋ฅผ ์ถ๊ฐํด ์ฃผ์ธ์.+import androidx.compose.foundation.layout.weight๐ Committable suggestion
๐ค Prompt for AI Agents