#include "script/common.lua"
#include "ui/ui_extensions.lua"

ProsView = {}
ProsView.statusText = ""
ProsView.statusIcon = ""
ProsView.qrImage = ""
ProsView.qrPromt = ""
ProsView.isQrExpried = true
ProsView.qrImageKey = "PROS QR CODE"

function ProsView.prosTabOnDraw()
    if ProsHasActiveQRCode() then
        ProsView.isQrExpried = false
        ProsView.qrImage = ProsView.qrImageKey
        ProsView.qrPromt = "loc@PROS_GET_QR_LOGIN"
    else
        ProsView.isQrExpried = true
        ProsView.qrImage = "common/img_0_31.png"
		ProsView.qrPromt = "loc@PROS_GET_QR_EXPIRED"
    end

	if ProsIsAccountLinked() then
		ProsView.statusText = "loc@PROS_STATUS_REGISTRED"
		ProsView.statusIcon = "common/img_7_8.png"
	else
		ProsView.statusText = "loc@PROS_STATUS_NOT_REGISTRED"
		ProsView.statusIcon = "common/img_0_38.png"
	end
end

function ProsView.onQrCodeZoneClicked()
	if ProsView.isQrExpried then
		ProsRequestQRCode(ProsView.qrImageKey)
	else
		ProsBrowseToQRLink()
	end
end

gStepperKsivaCurrentIdx = 1
gStepperKsivaValues = {'Disable', 'Enable'}

function getStepperKsivaCurrentValue()
    return gStepperKsivaValues[gStepperKsivaCurrentIdx]
end

function onStepperKsivaPrev()
    gStepperKsivaCurrentIdx = clamp(gStepperKsivaCurrentIdx - 1, 1, #gStepperKsivaValues)
end

function onStepperKsivaNext()
    gStepperKsivaCurrentIdx = clamp(gStepperKsivaCurrentIdx + 1, 1, #gStepperKsivaValues)
end


gStepperMessageOfDCurrentIdx = 1
gStepperMessageOfDValues = {'Disable', 'Enable'}

function getStepperMessageOfDCurrentValue()
    return gStepperMessageOfDValues[gStepperMessageOfDCurrentIdx]
end

function onStepperMessageOfDPrev()
    gStepperMessageOfDCurrentIdx = clamp(gStepperMessageOfDCurrentIdx - 1, 1, #gStepperMessageOfDValues)
end

function onStepperMessageOfDNext()
    gStepperMessageOfDCurrentIdx = clamp(gStepperMessageOfDCurrentIdx + 1, 1, #gStepperMessageOfDValues)
end


function ProsView.getQrImg()
    return ProsView.qrImage
end


function ProsView.getHintText()
    return ProsView.qrPromt
end


function ProsView.getStatusImg()
    return ProsView.statusIcon
end


function ProsView.getStatusText()
    return ProsView.statusText
end

ProsDescText = "loc@PROS_DESC"

ksivaText = "loc@KSIVA"
stepperKsivaParams = 
{
    currentIdx = 1,
    allValues = {"loc@UI_BUTTON_DISABLED", "loc@UI_BUTTON_ENABLED"},

    getCurrentValue = function(self)
        return self.allValues[self.currentIdx]
    end,

    onNext = function(self)
        self.currentIdx = clamp(self.currentIdx + 1, 1, #self.allValues)
    end,

    onPrev = function(self)
        self.currentIdx = clamp(self.currentIdx - 1, 1, #self.allValues)
    end,
}


modText = "loc@MoD"
stepperMoDParams = 
{
    currentIdx = 1,
    allValues = {"loc@UI_BUTTON_DISABLED", "loc@UI_BUTTON_ENABLED"},

    getCurrentValue = function(self)
        return self.allValues[self.currentIdx]
    end,

    onNext = function(self)
        self.currentIdx = clamp(self.currentIdx + 1, 1, #self.allValues)
    end,

    onPrev = function(self)
        self.currentIdx = clamp(self.currentIdx - 1, 1, #self.allValues)
    end,
}

