package net.pokeranalytics.android.ui.view.rowrepresentable

import android.text.InputType
import net.pokeranalytics.android.R
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetType
import net.pokeranalytics.android.ui.view.DefaultEditDataSource
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor
import net.pokeranalytics.android.ui.view.RowViewType


enum class BankrollRow : RowRepresentable, DefaultEditDataSource {
    LIVE,
	INITIAL_VALUE,
    CURRENCY,
    RATE,
    REFRESH_RATE;

    override val resId: Int?
        get() {
            return when (this) {
                LIVE -> R.string.online
	            INITIAL_VALUE -> R.string.initial_value
	            CURRENCY -> R.string.currency
	            RATE -> R.string.rate
	            REFRESH_RATE -> R.string.refresh_rate
            }
        }

    override val viewType: Int
        get() {
            return when (this) {
                LIVE -> RowViewType.TITLE_SWITCH.ordinal
	            INITIAL_VALUE -> RowViewType.TITLE_VALUE.ordinal
	            CURRENCY -> RowViewType.TITLE_VALUE_ARROW.ordinal
	            RATE -> RowViewType.TITLE_VALUE.ordinal
	            REFRESH_RATE -> RowViewType.ROW_BUTTON.ordinal
            }
        }

    override val bottomSheetType: BottomSheetType
        get() {
            return when (this) {
                LIVE -> BottomSheetType.NONE
	            INITIAL_VALUE -> BottomSheetType.NUMERIC_TEXT
	            CURRENCY -> BottomSheetType.NONE
	            RATE -> BottomSheetType.NUMERIC_TEXT
	            REFRESH_RATE -> BottomSheetType.NONE
            }
        }

	override fun editingDescriptors(map: Map<String, Any?>): ArrayList<RowRepresentableEditDescriptor>? {
		return when (this) {
			INITIAL_VALUE -> {
				val defaultValue : Any? by map
				arrayListOf(
					RowRepresentableEditDescriptor(defaultValue, R.string.initial_value, InputType.TYPE_CLASS_NUMBER
							or InputType.TYPE_NUMBER_FLAG_DECIMAL)
				)
			}
			RATE -> {
				val defaultValue : Any? by map
				arrayListOf(
					RowRepresentableEditDescriptor(defaultValue, R.string.rate, InputType.TYPE_CLASS_NUMBER
						or InputType.TYPE_NUMBER_FLAG_DECIMAL)
				)
			}
			else -> super<RowRepresentable>.editingDescriptors(map)
		}
	}
}