TTBaseSUIText

Core

Enhanced Text view that integrates with TTBaseUIKit's FontConfig and ViewConfig. Uses the same TYPE enum as TTBaseUILabel for consistent font sizing across UIKit and SwiftUI sections of your app.


📋 Declaration

public struct TTBaseSUIText: View {
    public var textDefColor: Color    // From ViewConfig.textDefColor
    public var textDefHeight: CGFloat // From FontConfig.TITLE_H
    public var fontDef: UIFont        // From FontConfig.FONT
    public var type: TTBaseUILabel.TYPE = .TITLE
    public var align: TextAlignment = .leading
    public var text: String = ""
    public var isBold: Bool = false
    public var isItalic: Bool = false
}

🔤 Font Type Mapping

TYPEFontConfig SourceSmall (≤5.8")Large (>5.8")
.HEADER_SUPERFontConfig.HEADER_SUPER_H24pt24pt
.HEADERFontConfig.HEADER_H18pt18pt
.TITLEFontConfig.TITLE_H14pt16pt
.SUB_TITLEFontConfig.SUB_TITLE_H12pt14pt
.SUB_SUB_TILEFontConfig.SUB_SUB_TITLE_H10pt12pt

🔧 Initializers

InitializerDescription
init(withType:text:align:color:)Standard text — type, alignment, optional custom color
init(withBold:text:align:color:)Bold text — uses TYPE enum, sets isBold: true
init(withItalic:text:align:color:)Italic text — uses TYPE enum, sets isItalic: true

🚀 Usage

Basic Text

// Standard title text
TTBaseSUIText(withType: .TITLE, text: "Hello, World!")

// Header with centered alignment
TTBaseSUIText(withType: .HEADER, text: "Welcome", align: .center)

// Custom color
TTBaseSUIText(withType: .SUB_TITLE, text: "Secondary info", color: .gray)

Bold Text

// Convenience bold initializer
TTBaseSUIText(withBold: .HEADER, text: "Important Title")

// Or call setBold() modifier
TTBaseSUIText(withType: .TITLE, text: "Bold content").setBold()

Italic Text

TTBaseSUIText(withItalic: .TITLE, text: "Italic quotation", color: .secondary)

Typography Scale in a View

VStack(alignment: .leading, spacing: 8) {
    TTBaseSUIText(withBold: .HEADER_SUPER, text: "Page Title", align: .center)
    TTBaseSUIText(withType: .HEADER, text: "Section Header")
    TTBaseSUIText(withType: .TITLE, text: "Body text content here...")
    TTBaseSUIText(withType: .SUB_TITLE, text: "Subtitle text")
    TTBaseSUIText(withType: .SUB_SUB_TILE, text: "Fine print / legal text")
}

In a Flight Booking Card

// Real-world example from 12Bay app pattern
VStack(alignment: .leading, spacing: 4) {
    TTBaseSUIText(withBold: .TITLE, text: "HAN → SGN")
    HStack {
        TTBaseSUIText(withType: .SUB_TITLE, text: "07:00 — 09:10")
        Spacer()
        TTBaseSUIText(withBold: .TITLE, text: "VND 1,200,000", color: .blue)
    }
    TTBaseSUIText(withType: .SUB_SUB_TILE, text: "Vietnam Airlines • VN-234")
        .foregroundColor(.secondary)
}

Colored & Aligned Text

// Error state
TTBaseSUIText(withType: .SUB_TITLE, text: "Email is required", color: .red)
    .padding(.top, 4)

// Success state  
TTBaseSUIText(withType: .TITLE, text: "Payment successful!", color: .green)
    .multilineTextAlignment(.center)

// Price label right-aligned
TTBaseSUIText(withBold: .HEADER, text: "$29.99", align: .trailing)
Consistency: TTBaseSUIText uses the same TTBaseUILabel.TYPE enum as the UIKit counterpart, so font sizes stay consistent across UIKit and SwiftUI screens of your app. Change FontConfig once in AppDelegate — both UIKit and SwiftUI components update.
Performance: TTBaseSUIText is a lightweight value type (struct). Prefer it over a bare Text() when you want config-aware fonts without manually specifying sizes.