Option Strict On
Option Explicit On

Imports Nexamas.UI.Controls

Namespace Nexamas.UI.Composition

    ''' <summary>
    ''' Internal control-factory layer used by MASPage template recipes.
    ''' </summary>
    ''' <remarks>
    ''' MASPage is a public composition facade. When a convenience recipe accepts text
    ''' instead of caller-provided controls, this factory creates the small MASLabel
    ''' controls required by that recipe. Keeping label construction here makes the
    ''' responsibility explicit: MASPage describes page templates; this factory owns
    ''' the control instances generated for text-based recipes.
    ''' </remarks>
    Friend NotInheritable Class MASPageLabelRecipeFactory

        Private Sub New()
        End Sub

        Friend Shared Function CreateSectionTitle(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Heading, MASLabelTextRole.Primary, MASHorizontalAlignment.Left, MASVerticalAlignment.Center)
        End Function

        Friend Shared Function CreateSectionDescription(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Body, MASLabelTextRole.Secondary, MASHorizontalAlignment.Left, MASVerticalAlignment.Center)
        End Function

        Friend Shared Function CreateFormFieldLabel(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Body, MASLabelTextRole.Primary, MASHorizontalAlignment.Left, MASVerticalAlignment.Center)
        End Function

        Friend Shared Function CreateSettingsTitle(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Heading, MASLabelTextRole.Primary, MASHorizontalAlignment.Left, MASVerticalAlignment.Center)
        End Function

        Friend Shared Function CreateSettingsDescription(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Body, MASLabelTextRole.Secondary, MASHorizontalAlignment.Left, MASVerticalAlignment.Center)
        End Function

        Friend Shared Function CreateSettingsRowLabel(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Body, MASLabelTextRole.Primary, MASHorizontalAlignment.Left, MASVerticalAlignment.Center)
        End Function

        Friend Shared Function CreateSettingsRowDescription(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Body, MASLabelTextRole.Secondary, MASHorizontalAlignment.Left, MASVerticalAlignment.Center)
        End Function

        Friend Shared Function CreateDetailsTitle(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Heading, MASLabelTextRole.Primary, MASHorizontalAlignment.Left, MASVerticalAlignment.Center)
        End Function

        Friend Shared Function CreateDetailsDescription(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Body, MASLabelTextRole.Secondary, MASHorizontalAlignment.Left, MASVerticalAlignment.Center)
        End Function

        Friend Shared Function CreateDetailsRowLabel(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Body, MASLabelTextRole.Secondary, MASHorizontalAlignment.Left, MASVerticalAlignment.Center)
        End Function

        Friend Shared Function CreateDetailsValue(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Body, MASLabelTextRole.Primary, MASHorizontalAlignment.Left, MASVerticalAlignment.Center, multiLine:=True, wordWrap:=True)
        End Function

        Friend Shared Function CreateDetailsRowDescription(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Caption, MASLabelTextRole.Muted, MASHorizontalAlignment.Left, MASVerticalAlignment.Center, multiLine:=True, wordWrap:=True)
        End Function

        Friend Shared Function CreateEmptyStateTitle(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Heading, MASLabelTextRole.Primary, MASHorizontalAlignment.Center, MASVerticalAlignment.Center, multiLine:=True, wordWrap:=True)
        End Function

        Friend Shared Function CreateEmptyStateMessage(text As String) As MASLabel
            Return CreateLabel(text, MASLabelVariant.Body, MASLabelTextRole.Secondary, MASHorizontalAlignment.Center, MASVerticalAlignment.Center, multiLine:=True, wordWrap:=True)
        End Function

        Private Shared Function CreateLabel(text As String,
                                    labelVariant As MASLabelVariant,
                                    role As MASLabelTextRole,
                                    horizontalAlignment As MASHorizontalAlignment,
                                    verticalAlignment As MASVerticalAlignment,
                                    Optional multiLine As Boolean = False,
                                    Optional wordWrap As Boolean = False) As MASLabel

            Return New MASLabel(If(text, String.Empty)) With {
        .LabelVariant = labelVariant,
        .TextRole = role,
        .HorizontalAlignment = horizontalAlignment,
        .VerticalAlignment = verticalAlignment,
        .MultiLine = multiLine,
        .WordWrap = wordWrap,
        .CompositionLifetimeOwnedInternal = True
    }
        End Function

    End Class

End Namespace
