mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/1843 - Scaffolds MVI component for Collection Creation
This commit is contained in:
parent
2ad55b3cd0
commit
b222c5b53d
@ -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
|
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 android.os.Bundle
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import kotlinx.android.synthetic.main.fragment_create_collection.view.*
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.mvi.ActionBusFactory
|
||||||
|
|
||||||
class CreateCollectionFragment : Fragment() {
|
class CreateCollectionFragment : Fragment() {
|
||||||
|
|
||||||
|
private lateinit var collectionCreationComponent: CollectionCreationComponent
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
// Inflate the layout for this fragment
|
val view = inflater.inflate(R.layout.fragment_create_collection, container, false)
|
||||||
return 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"?>
|
<?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">
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<gradient
|
<gradient
|
||||||
android:startColor="?shadow"
|
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"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/create_collection_wrapper"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/create_collection_background"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
tools:context="org.mozilla.fenix.collections.CreateCollectionFragment">
|
tools:context="org.mozilla.fenix.collections.CreateCollectionFragment">
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user