package net.pokeranalytics.android.ui.view

import android.content.Context
import net.pokeranalytics.android.model.LiveData
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetType
import net.pokeranalytics.android.util.NULL_TEXT

/**
 * An interface extending Displayable to add a way to represent an object as a String
 */
interface RowRepresentable : Displayable, EditDataSource, ImageDecorator {

	fun getDisplayName(context: Context): String {
		return NULL_TEXT
	}
}

interface EditDataSource {
	fun editingDescriptors(map: Map<String, Any?>): ArrayList<RowRepresentableEditDescriptor>? {
		return null
	}
}

interface DefaultEditDataSource : EditDataSource, Localizable {
	override fun editingDescriptors(map: Map<String, Any?>): ArrayList<RowRepresentableEditDescriptor>? {
		val defaultValue: String? by map
		return arrayListOf(RowRepresentableEditDescriptor(defaultValue, this.resId))
	}
}

/**
 * An interface to add an image to a row
 */
interface ImageDecorator {

	val imageRes: Int?
		get() = null

	val imageTint: Int?
		get() = null

	val imageClickable: Boolean?
		get() = false
}

/**
 * An interface used so that enums numericValues can be represented visually
 *  as rows in RecyclerViews
 */
interface Displayable : Localizable {

	/**
	 * The type of view associated with the row
	 */
	val viewType: Int
		get() {
			return -1
		}

	val relatedResultsRepresentable: LiveData?
		get() {
			return null
		}

	val bottomSheetType: BottomSheetType
		get() {
			return BottomSheetType.NONE
		}

	val selectedChoice: Int
		get() {
			return -1
		}

	val choices: List<*>?
		get() {
			return null
		}
}

/**
 * An interface to easily localize any object
 */
interface Localizable {

	/**
	 * The resource uniqueIdentifier of the localized titleResId
	 */
	val resId: Int?
		get() {
			return null
		}

	/**
	 * The localized titleResId of the row
	 */
	fun localizedTitle(context: Context): String {
		this.resId?.let {
			return context.getString(it)
		}
		return "LOCALISATION NOT FOUND"
	}
}
