m

    Manuel Lorenzo

    1 year ago
    hey everybody! how do you guys create a SearchView in Compose, you know, the one that is in the top bar? is there a native function for this?
    rsktash

    rsktash

    1 year ago
    You can animate Text And BasicTexField within TopAppBar
    m

    Manuel Lorenzo

    1 year ago
    oh, what do you mean? text for the hint and basic text field as an EditText?
    rsktash

    rsktash

    1 year ago
    Yes Text for title and basic text for querying
    m

    Manuel Lorenzo

    1 year ago
    cool thanks! I will also investigate about that animation, because I still haven’t worked with animations in compose
    Siyamed

    Siyamed

    1 year ago
    I think it deserves to be a component out of the box, but we don't have it.
    Adam Powell

    Adam Powell

    1 year ago
    I think we'd have to get the UX community to agree on one 😄 most of these search experiences are highly custom, but I agree we should have plenty of helpers and recipes for doing it
    Siyamed

    Siyamed

    1 year ago
    True
    😃
    Actually lately a lot of searchviews became an icon opening a new screen with a textfield
    Adam Powell

    Adam Powell

    1 year ago
    Yeah. It's also situational whether results are shown in a pop-up window anchored to the text field or in the primary content region below it
    m

    Manuel Lorenzo

    1 year ago
    erhm kind of stupid question but, how do you guys do the addition or the showing of the Basic text so the user can type their query? so clicking on the search icon and showing a basic text field in the top bar
    Adam Powell

    Adam Powell

    1 year ago
    generally something of the form:
    var isExpanded by remember { mutableStateOf(false) }
    
    if (isExpanded) {
      BasicTextField(...)
    } else {
      Button(onClick = { isExpanded = true }) {
        Text("Search...")
      }
    }
    user input updates state, and state updates drive recomposition
    m

    Manuel Lorenzo

    1 year ago
    Thanks a lot Adam! I have an app entirely made in compose but just not doing any programming in a couple of weeks made my brain entirely forget about declarative UI style 😄
    Piotr Prus

    Piotr Prus

    1 year ago
    @Manuel Lorenzo did you get it working? I am struggling with background colors, focus,etc. Also, did you make a drop-down list of suggestions?