For #364 - Moves edit mode to be a part of the toolbar component state
Co-authored-by: Sawyer Blatz <sdblatz@gmail.com> Co-authored-by: Emily Kager <emilykager@gmail.com>master
parent
abd08453ce
commit
dbea570747
|
@ -19,6 +19,7 @@ import org.mozilla.fenix.search.awesomebar.AwesomeBarAction
|
|||
import org.mozilla.fenix.search.awesomebar.AwesomeBarChange
|
||||
import org.mozilla.fenix.search.awesomebar.AwesomeBarComponent
|
||||
import org.mozilla.fenix.search.toolbar.SearchAction
|
||||
import org.mozilla.fenix.search.toolbar.SearchState
|
||||
import org.mozilla.fenix.search.toolbar.ToolbarComponent
|
||||
import org.mozilla.fenix.search.toolbar.ToolbarUIView
|
||||
|
||||
|
@ -32,17 +33,12 @@ class SearchFragment : Fragment() {
|
|||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
val view = inflater.inflate(R.layout.fragment_search, container, false)
|
||||
toolbarComponent = ToolbarComponent(view.toolbar_wrapper, ActionBusFactory.get(this))
|
||||
toolbarComponent = ToolbarComponent(view.toolbar_wrapper, ActionBusFactory.get(this), SearchState("", isEditing = true))
|
||||
awesomeBarComponent = AwesomeBarComponent(view.search_layout, ActionBusFactory.get(this))
|
||||
ActionBusFactory.get(this).logMergedObservables()
|
||||
return view
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
toolbarComponent.editMode()
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.mozilla.fenix.mvi.ViewState
|
|||
class ToolbarComponent(
|
||||
private val container: ViewGroup,
|
||||
bus: ActionBusFactory,
|
||||
override var initialState: SearchState = SearchState("")
|
||||
override var initialState: SearchState = SearchState("", false)
|
||||
) :
|
||||
UIComponent<SearchState, SearchAction, SearchChange>(
|
||||
bus.getManagedEmitter(SearchAction::class.java),
|
||||
|
@ -34,12 +34,9 @@ class ToolbarComponent(
|
|||
init {
|
||||
render(reducer)
|
||||
}
|
||||
|
||||
fun getView(): BrowserToolbar = uiView.toolbar
|
||||
fun editMode() = getView().editMode()
|
||||
}
|
||||
|
||||
data class SearchState(val query: String) : ViewState
|
||||
data class SearchState(val query: String, val isEditing: Boolean) : ViewState
|
||||
|
||||
sealed class SearchAction : Action {
|
||||
data class UrlCommitted(val url: String) : SearchAction()
|
||||
|
|
|
@ -70,6 +70,11 @@ class ToolbarUIView(
|
|||
}
|
||||
|
||||
override fun updateView() = Consumer<SearchState> {
|
||||
if (it.isEditing) {
|
||||
view.editMode()
|
||||
} else {
|
||||
view.displayMode()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
Loading…
Reference in New Issue