Skip to content

Commit

Permalink
Merge pull request #127 from tarkalabs/nilesh/tuiSearchBar/changes
Browse files Browse the repository at this point in the history
 Fixed searchbar default search query text issue
  • Loading branch information
askNilesh authored Oct 3, 2023
2 parents 40cd002 + bf25c2f commit 73d76ca
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 33 deletions.
88 changes: 57 additions & 31 deletions example/src/main/java/com/tarkalabs/ui/UIComponentListActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,81 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.tarkalabs.tarkaicons.ChevronRight20
import com.tarkalabs.tarkaicons.TarkaIcons.Regular
import com.tarkalabs.uicomponents.components.TUITextRow
import com.tarkalabs.uicomponents.components.TUITopBar
import com.tarkalabs.uicomponents.components.TextRowStyle.Title
import com.tarkalabs.uicomponents.theme.TUITheme

class UIComponentListActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
@OptIn(ExperimentalMaterial3Api::class) override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContent {
TUITheme {
val query by remember {
mutableStateOf("")
}

Column(
modifier = Modifier
.fillMaxSize()
.background(color = TUITheme.colors.surface)
// .padding(30.dp)
) {
Scaffold(topBar = {
TUITopBar(
title = "Lorem Ipsum",
navigationIcon = Regular.ChevronRight20,
searchIcon = Regular.ChevronRight20,
searchQuery = query
)
}) { paddingValues ->
Column(
modifier = Modifier
.fillMaxSize()
.background(color = TUITheme.colors.surface)
.padding(paddingValues)

) {

TUITextRow(title = "Title",
style = Title,
infoIcon = Regular.ChevronRight20,
onTextRowClick = {
Log.d("TAG", "TUITextRowPreview: ")
}, onInfoIconClick = null,
paddingValues = PaddingValues(horizontal = 20.dp, vertical = 0.dp)
)
TUITextRow(
title = "Title",
style = Title,
infoIcon = Regular.ChevronRight20,
onTextRowClick = {
Log.d("TAG", "TUITextRowPreview: ")
},
onInfoIconClick = null,
paddingValues = PaddingValues(horizontal = 20.dp, vertical = 0.dp)
)

TUITextRow(
title = "Title",
style = Title,
infoIcon = Regular.ChevronRight20,
onTextRowClick = {
Log.d("TAG", "TUITextRowPreview: ")
},
onInfoIconClick = null,
paddingValues = PaddingValues(horizontal = 20.dp, vertical = 0.dp)
)
TUITextRow(
title = "Title",
style = Title,
infoIcon = Regular.ChevronRight20,
onTextRowClick = {
Log.d("TAG", "TUITextRowPreview: ")
},
onInfoIconClick = null,
paddingValues = PaddingValues(horizontal = 20.dp, vertical = 0.dp)
)
}

TUITextRow(title = "Title",
style = Title,
infoIcon = Regular.ChevronRight20,
onTextRowClick = {
Log.d("TAG", "TUITextRowPreview: ")
}, onInfoIconClick = null,
paddingValues = PaddingValues(horizontal = 20.dp, vertical = 0.dp)
)
TUITextRow(title = "Title",
style = Title,
infoIcon = Regular.ChevronRight20,
onTextRowClick = {
Log.d("TAG", "TUITextRowPreview: ")
}, onInfoIconClick = null,
paddingValues = PaddingValues(horizontal = 20.dp, vertical = 0.dp)
)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tarkaui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ publishing {
run {
groupId = "com.tarkalabs"
artifactId = getLibraryArtifactId()
version = "0.46-alpha"
version = "0.47-alpha"
artifact("$buildDir/outputs/aar/${getLibraryArtifactId()}-release.aar")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import com.tarkalabs.uicomponents.theme.TUITheme
* @param onThirdMenuItemClicked The callback function to be called when the third menu item icon is clicked.
* @param onSearchQuery The callback function to be called when a search query is entered.
* @param colors The colors to be applied to the top app bar.
* @param searchQuery the default search text that we need to show in searchbar
* @param scrollBehavior The scroll behavior to be applied to the top app bar.
* How to use TopBar()
TopBar(
Expand Down Expand Up @@ -79,6 +80,7 @@ scrollBehavior = TopAppBarScrollBehavior.ScrollOnAppBarScroll, // Optional: Spec
onSecondMenuItemClicked: () -> Unit = {},
onThirdMenuItemClicked: () -> Unit = {},
onSearchQuery: (String) -> Unit = {},
searchQuery : String = "",
disableSearchIcon: Boolean = false,
clearQueryAndHideSearchBar: Boolean = false,
colors: TopAppBarColors = TopAppBarDefaults.topAppBarColors(
Expand All @@ -93,7 +95,7 @@ scrollBehavior = TopAppBarScrollBehavior.ScrollOnAppBarScroll, // Optional: Spec
}

var query by remember {
mutableStateOf("")
mutableStateOf(searchQuery)
}

if (clearQueryAndHideSearchBar && showSearchBar) {
Expand Down

0 comments on commit 73d76ca

Please sign in to comment.