TTBaseSUIList
LayoutA 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+.
| TYPE | SwiftUI Style | Visual |
|---|---|---|
.PLAIN | PlainListStyle() | Traditional flat list (UITableView plain) |
.GROUPED | InsetGroupedListStyle() | Rounded grouped cards (iOS Settings style) |
.INSET | InsetListStyle() | 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) | Default | Description |
|---|---|---|
type | .PLAIN | List style variant |
bg | viewStackDefBgColor | Background behind all rows |
rowBgColor | viewBgCellColor | Individual row background |
showSeparator | true | Show/hide row separator lines |
isEnablePullToRefresh | false | Enable .refreshable (iOS 15+) |
pullToRefresh | nil | Async 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.