TTBaseSUIList

Layout

A List wrapper that strips system background/separator defaults and applies TTBaseUIKit color tokens. Three style types: PLAIN, GROUPED, INSET. Supports pull-to-refresh on iOS 15+.

TYPESwiftUI StyleVisual
.PLAINPlainListStyle()Traditional flat list (UITableView plain)
.GROUPEDInsetGroupedListStyle()Rounded grouped cards (iOS Settings style)
.INSETInsetListStyle()Compact inset list

🚀 Usage

// Simple plain list
TTBaseSUIList(type: .PLAIN) {
    ForEach(items) { item in
        ItemRowView(item: item)
            .listRowStyle()  // Extension: remove default insets and bg
    }
}

// Grouped list (Settings style)
TTBaseSUIList(type: .GROUPED) {
    Section(header: Text("Account")) {
        SettingsRow(title: "Name", value: user.name)
        SettingsRow(title: "Email", value: user.email)
    }
    Section(header: Text("Preferences")) {
        SettingsRow(title: "Notifications", value: "On")
    }
}

// With pull-to-refresh
@StateObject var viewModel = ListViewModel()

TTBaseSUIList(
    type: .PLAIN,
    isEnablePullToRefresh: true,
    content: {
        ForEach(viewModel.items) { item in
            ItemRowView(item: item).listRowStyle()
        }
    },
    pullToRefresh: {
        await viewModel.reload()
    }
)

// Full customization
TTBaseSUIList(
    type: .PLAIN,
    bg: Color(TTView.viewBgColor),
    rowBgColor: Color(TTView.viewBgCellColor),
    showSeparator: false,
    isEnablePullToRefresh: false
) {
    ForEach(items) { item in
        ItemRowView(item: item)
    }
}

📖 listRowStyle() Extension

// Applied to each row to remove default insets:
ItemRowView()
    .listRowStyle()
// or with custom bg and horizontal inset:
    .listRowStyle(bg: Color.white, horizontalInset: 16)

📖 API Reference

Parameter (full init)DefaultDescription
type.PLAINList style variant
bgviewStackDefBgColorBackground behind all rows
rowBgColorviewBgCellColorIndividual row background
showSeparatortrueShow/hide row separator lines
isEnablePullToRefreshfalseEnable .refreshable (iOS 15+)
pullToRefreshnilAsync refresh callback
Pro Tip: Always apply .listRowStyle() to each row to remove SwiftUI's default 16pt leading inset and cell background that interferes with custom designs. Without it, rows show a gray background that doesn't match the TTBaseUIKit token.