2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00
iceraven-browser/docs/architectureexample/ContactsFragment.kt
Severin Rudie a0ca8b84bb For #5799: document architecture choices (#5800)
* For #5799: add architecture document outline for review

* For 5799: update architecture doc outline

- Remove references to old architecture (Soon it will all have been replaced. No need for the additional cognitive load)
- Add some subheadings
- 'Simplified Example' seems like a good idea. Update the language to clarify that it will be done

* For 5799: add additional known limitations

* For 5799: wrote first draft for architecture 'overview' and 'important objects'

* For 5799: wrote first draft for arch doc 'important notes'

* For 5799: wrote arch doc 'known limitations' section

* For 5799: wrote example code for architecture doc

* For 5799: added example app wireframe for arch docs

* For 5799: update arch docs 'Simplified Example section'

* For 5799: improve formatting for architecture docs

* For 5799: minor tweaks to architecture docs

* For 5799: link 'simplified example' section to example code

* For 5799: update arch doc per review
2019-10-21 13:58:09 -07:00

48 lines
1.5 KiB
Kotlin

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This is example code for the 'Simplified Example' section of
// /docs/architecture-overview.md
class ContactsFragment : Fragment() {
lateinit var contactsStore: ContactsStore
lateinit var contactsView: ContactsView
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_contacts, container, false)
// Create the various components and hook them up to each other
val initialState = ContactsState(
contacts = emptyList(),
theme = Theme.ORANGE
)
contactsStore = ContactsStore(initialState = initialState)
val contactsController = ContactsController(
store = store,
navController = findNavController()
)
val themeController = ThemeController(
store = store
)
val interactor = ContactsInteractor(
contactsController = contactsController,
themeController = themeController
)
contactsView = ContactsView(view.contains_container, interactor)
}
override onViewCreated(view: View, savedInstanceState: Bundle?) {
// Whenever State is updated, pass it to the View
consumeFrom(contactsStore) { state ->
contactsView.update(state)
}
}
}