mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-02 03:40:16 +00:00
For #1843 - Scaffolds MVI component for Collection Creation
This commit is contained in:
parent
63574cc359
commit
ab4cf786d7
@ -0,0 +1,44 @@
|
||||
package org.mozilla.fenix.collections
|
||||
|
||||
import android.view.ViewGroup
|
||||
import org.mozilla.fenix.mvi.Action
|
||||
import org.mozilla.fenix.mvi.ActionBusFactory
|
||||
import org.mozilla.fenix.mvi.Change
|
||||
import org.mozilla.fenix.mvi.Reducer
|
||||
import org.mozilla.fenix.mvi.UIComponent
|
||||
import org.mozilla.fenix.mvi.ViewState
|
||||
|
||||
/* 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/. */
|
||||
|
||||
sealed class CollectionCreationState : ViewState {
|
||||
object Empty : CollectionCreationState()
|
||||
}
|
||||
|
||||
sealed class CollectionCreationChange : Change {
|
||||
|
||||
}
|
||||
|
||||
sealed class CollectionCreationAction : Action {
|
||||
|
||||
}
|
||||
|
||||
class CollectionCreationComponent(
|
||||
private val container: ViewGroup,
|
||||
bus: ActionBusFactory,
|
||||
override var initialState: CollectionCreationState = CollectionCreationState.Empty
|
||||
) : UIComponent<CollectionCreationState, CollectionCreationAction, CollectionCreationChange>(
|
||||
bus.getManagedEmitter(CollectionCreationAction::class.java),
|
||||
bus.getSafeManagedObservable(CollectionCreationChange::class.java)
|
||||
) {
|
||||
override val reducer: Reducer<CollectionCreationState, CollectionCreationChange> = { state, change ->
|
||||
CollectionCreationState.Empty
|
||||
}
|
||||
|
||||
override fun initView() = CollectionCreationUIView(container, actionEmitter, changesObservable)
|
||||
|
||||
init {
|
||||
render(reducer)
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package org.mozilla.fenix.collections
|
||||
|
||||
/* 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/. */
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import org.mozilla.fenix.R
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.functions.Consumer
|
||||
import org.mozilla.fenix.mvi.UIView
|
||||
|
||||
class CollectionCreationUIView(
|
||||
container: ViewGroup,
|
||||
actionEmitter: Observer<CollectionCreationAction>,
|
||||
changesObservable: Observable<CollectionCreationChange>
|
||||
) : UIView<CollectionCreationState, CollectionCreationAction, CollectionCreationChange>(
|
||||
container,
|
||||
actionEmitter,
|
||||
changesObservable
|
||||
) {
|
||||
override val view = LayoutInflater.from(container.context)
|
||||
.inflate(R.layout.component_collection_creation, container, true)
|
||||
|
||||
override fun updateView() = Consumer<CollectionCreationState> {
|
||||
|
||||
}
|
||||
}
|
@ -1,23 +1,33 @@
|
||||
package org.mozilla.fenix.collections
|
||||
|
||||
/* 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/. */
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
import kotlinx.android.synthetic.main.fragment_create_collection.view.*
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.mvi.ActionBusFactory
|
||||
|
||||
class CreateCollectionFragment : Fragment() {
|
||||
|
||||
private lateinit var collectionCreationComponent: CollectionCreationComponent
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_create_collection, container, false)
|
||||
}
|
||||
val view = inflater.inflate(R.layout.fragment_create_collection, container, false)
|
||||
|
||||
collectionCreationComponent = CollectionCreationComponent(
|
||||
view.create_collection_wrapper,
|
||||
ActionBusFactory.get(this)
|
||||
)
|
||||
|
||||
return view
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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/. -->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:startColor="?accentBright"
|
||||
android:endColor="?accent" />
|
||||
</shape>
|
@ -1,4 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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/. -->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:startColor="?shadow"
|
||||
|
11
app/src/main/res/layout/component_collection_creation.xml
Normal file
11
app/src/main/res/layout/component_collection_creation.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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/. -->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</LinearLayout>
|
@ -1,11 +1,10 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/create_collection_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/create_collection_background"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context="org.mozilla.fenix.collections.CreateCollectionFragment">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</FrameLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user