package de.softwareapp_hb.privateqrscanner.ui

import de.softwareapp_hb.privateqrscanner.R

enum class UseCaseView(
    val storageKey: String,
    val titleRes: Int
) {
    EverydayPersonal(
        storageKey = "everyday_personal",
        titleRes = R.string.use_case_everyday_personal
    ),
    EventTicketing(
        storageKey = "event_ticketing",
        titleRes = R.string.use_case_event_ticketing
    );

    companion object {
        val default = EverydayPersonal

        fun fromStorageKey(value: String?): UseCaseView {
            return entries.firstOrNull { it.storageKey == value } ?: default
        }
    }
}

data class UseCaseCapabilities(
    val allowScanFromImage: Boolean = true,
    val allowBatchMode: Boolean = false,
    val allowCopy: Boolean = true,
    val allowShare: Boolean = true,
    val allowOpenUrl: Boolean = true,
    val allowAddContact: Boolean = false,
    val allowDialPhone: Boolean = false,
    val allowSendSms: Boolean = false,
    val allowSendEmail: Boolean = false,
    val allowOpenWifiSettings: Boolean = false,
    val allowAddCalendarEvent: Boolean = false,
    val allowHistoryExport: Boolean = false,
    val allowBatchShare: Boolean = true
)

fun UseCaseView.capabilities(): UseCaseCapabilities {
    return when (this) {
        UseCaseView.EverydayPersonal -> UseCaseCapabilities(
            allowScanFromImage = true,
            allowBatchMode = false,
            allowCopy = true,
            allowShare = true,
            allowOpenUrl = true,
            allowAddContact = true,
            allowDialPhone = true,
            allowSendSms = true,
            allowSendEmail = true,
            allowOpenWifiSettings = true,
            allowAddCalendarEvent = true,
            allowHistoryExport = true
        )

        UseCaseView.EventTicketing -> UseCaseCapabilities(
            allowScanFromImage = false,
            allowBatchMode = true,
            allowCopy = true,
            allowShare = true,
            allowOpenUrl = false,
            allowBatchShare = true
        )
    }
}
