Option Strict On
Option Explicit On

Imports Nexamas.UI.Components
Imports Nexamas.UI.Icons
Imports Nexamas.UI.Values
Imports SkiaSharp

Namespace Nexamas.UI.Rendering

    Friend NotInheritable Class MessageBoxShellAdapter

        Private Sub New()
        End Sub

        Friend Shared Function CreateSpec(panelRectPx As SKRect,
                                          request As MessageBoxRequest,
                                          state As MessageBoxInteractionState) As MASPanelShellSpec

            If request Is Nothing Then
                request = New MessageBoxRequest()
            End If

            If state Is Nothing Then
                state = New MessageBoxInteractionState()
            End If

            Dim showHeaderIcon As Boolean =
                (request.Kind <> MessageBoxKind.None)

            Dim options As MASPanelShellDialogOptions =
                MASPanelShellDialogOptions.MessageBox(If(request.Title, String.Empty))

            options.IconKind = ResolveHeaderIconKind(request.Kind)
            options.ShowIcon = showHeaderIcon
            options.ShowCloseButton = request.AllowCloseButton
            options.PaddingLeftDip = MessageBoxTokens.BodyPaddingLeftDip
            options.PaddingTopDip = MessageBoxTokens.BodyPaddingTopDip
            options.PaddingRightDip = MessageBoxTokens.BodyPaddingRightDip
            options.PaddingBottomDip = MessageBoxTokens.BodyPaddingBottomDip

            Return MASPanelShellDialogHost.CreateSpec(
                boundsPx:=panelRectPx,
                options:=options,
                closeHover:=state.CloseHover,
                closePressed:=state.ClosePressed)

        End Function

        Friend Shared Function ResolveHeaderIconKind(kind As MessageBoxKind) As MASIconKind

            Select Case kind
                Case MessageBoxKind.Success
                    Return MASIconKind.Success

                Case MessageBoxKind.Warning
                    Return MASIconKind.Warning

                Case MessageBoxKind.Error
                    Return MASIconKind.Failure

                Case MessageBoxKind.Question
                    Return MASIconKind.Question

                Case MessageBoxKind.Security
                    Return MASIconKind.Security

                Case MessageBoxKind.Delete
                    Return MASIconKind.Delete

                Case MessageBoxKind.None
                    Return MASIconKind.Info

                Case Else
                    Return MASIconKind.Info
            End Select

        End Function

    End Class

End Namespace