2019-04-23 04:49:44 +02:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2019-07-12 20:38:15 +02:00
|
|
|
* 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/. */
|
|
|
|
|
|
|
|
package org.mozilla.fenix.collections
|
2019-04-23 04:49:44 +02:00
|
|
|
|
2019-05-30 20:43:11 +02:00
|
|
|
import android.view.View
|
2019-04-23 04:49:44 +02:00
|
|
|
import androidx.lifecycle.ViewModel
|
2019-05-06 20:20:19 +02:00
|
|
|
import org.mozilla.fenix.home.sessioncontrol.Tab
|
2019-05-16 23:35:15 +02:00
|
|
|
import org.mozilla.fenix.home.sessioncontrol.TabCollection
|
2019-04-23 04:49:44 +02:00
|
|
|
|
2019-04-24 01:40:26 +02:00
|
|
|
class CreateCollectionViewModel : ViewModel() {
|
2019-05-20 17:44:29 +02:00
|
|
|
var selectedTabs = mutableSetOf<Tab>()
|
2019-04-23 04:49:44 +02:00
|
|
|
var tabs = listOf<Tab>()
|
2019-05-02 17:53:40 +02:00
|
|
|
var saveCollectionStep: SaveCollectionStep = SaveCollectionStep.SelectTabs
|
2019-05-16 23:35:15 +02:00
|
|
|
var tabCollections = listOf<TabCollection>()
|
2019-05-20 22:34:58 +02:00
|
|
|
var selectedTabCollection: TabCollection? = null
|
2019-05-30 20:43:11 +02:00
|
|
|
var snackbarAnchorView: View? = null
|
2019-07-01 18:39:48 +02:00
|
|
|
var previousFragmentId: Int? = null
|
2019-06-04 02:00:08 +02:00
|
|
|
|
|
|
|
fun getStepForTabsAndCollectionSize(): SaveCollectionStep =
|
|
|
|
if (tabs.size > 1) SaveCollectionStep.SelectTabs else tabCollections.getStepForCollectionsSize()
|
2019-04-23 04:49:44 +02:00
|
|
|
}
|
2019-05-31 19:59:51 +02:00
|
|
|
|
|
|
|
fun List<TabCollection>.getStepForCollectionsSize(): SaveCollectionStep =
|
|
|
|
if (isEmpty()) SaveCollectionStep.NameCollection else SaveCollectionStep.SelectCollection
|
2019-06-04 02:00:08 +02:00
|
|
|
|
|
|
|
fun List<TabCollection>.getBackStepForCollectionsSize(): SaveCollectionStep =
|
|
|
|
if (isEmpty()) SaveCollectionStep.SelectTabs else SaveCollectionStep.SelectCollection
|