local _, namespace = ...

local BUTTON_MARGIN = 10

-- Creates a popup window with a single button
-- The popup window and frame cover are always hidden after the button is clicked, no need to include it in the OnClick function
function namespace:CreatePopupWindowWithButton()
    local popupWindow = namespace:CreatePopupWindow()

    popupWindow.button = namespace:CreateButton(
        popupWindow,
        "",
        function()
            popupWindow.button.OnClick()

            popupWindow:Hide()
            popupWindow.frameCover:Hide()
        end
    )

    popupWindow.button:SetPoint("BOTTOM", popupWindow, "BOTTOM", 0, BUTTON_MARGIN)

    popupWindow:SetAdditionalHeight(popupWindow.button:GetHeight() + BUTTON_MARGIN)

    function popupWindow:SetButtonText(text)
        popupWindow.button:SetText(text)
    end

    function popupWindow:SetButtonOnClick(OnClick)
        popupWindow.button.OnClick = OnClick
    end

    return popupWindow
end
