@@ -1093,7 +1093,7 @@ public struct TypedUnaryViewGenerator<V>: UnaryViewGenerator where V: View {
1093
1093
}
1094
1094
}
1095
1095
1096
- // MARK: - UnaryElements
1096
+ // MARK: - UnaryElements [WIP]
1097
1097
1098
1098
private struct UnaryElements < Generator> : ViewList . Elements where Generator: UnaryViewGenerator {
1099
1099
var body : Generator
@@ -1135,6 +1135,17 @@ private struct UnaryElements<Generator>: ViewList.Elements where Generator: Unar
1135
1135
// MARK: - ViewListOutputs + Extension [TODO]
1136
1136
1137
1137
extension _ViewListOutputs {
1138
+ private struct ApplyModifiers : Rule , AsyncAttribute {
1139
+ @Attribute var base : any ViewList
1140
+ let modifier : ListModifier
1141
+
1142
+ var value : any ViewList {
1143
+ var value = base
1144
+ modifier. apply ( to: & value)
1145
+ return value
1146
+ }
1147
+ }
1148
+
1138
1149
private static func staticList( _ elements: any ViewList . Elements , inputs: _ViewListInputs , staticCount: Int ) -> _ViewListOutputs {
1139
1150
preconditionFailure ( " TODO " )
1140
1151
}
@@ -1184,6 +1195,108 @@ extension _ViewListOutputs {
1184
1195
}
1185
1196
}
1186
1197
1198
+ // MARK: - BaseViewList
1199
+
1200
+ private struct BaseViewList : ViewList {
1201
+ var elements : any Elements
1202
+ var implicitID : Int
1203
+ var traitKeys : ViewTraitKeys ?
1204
+ var traits : ViewTraitCollection
1205
+
1206
+ init (
1207
+ elements: any Elements ,
1208
+ implicitID: Int ,
1209
+ canTransition: Bool ,
1210
+ stableIDScope: WeakAttribute < DisplayList . StableIdentityScope > ? ,
1211
+ traitKeys: ViewTraitKeys ? ,
1212
+ traits: ViewTraitCollection
1213
+ ) {
1214
+ self . elements = elements
1215
+ self . implicitID = implicitID
1216
+ self . traitKeys = traitKeys
1217
+ self . traits = traits
1218
+ if canTransition {
1219
+ self . traits. canTransition = true
1220
+ }
1221
+ if let stableIDScope {
1222
+ self . traits [ DisplayList . StableIdentityScope. self] = stableIDScope
1223
+ }
1224
+ }
1225
+
1226
+ func count( style: IteratorStyle ) -> Int {
1227
+ style. applyGranularity ( to: elements. count)
1228
+ }
1229
+
1230
+ func estimatedCount( style: IteratorStyle ) -> Int {
1231
+ style. applyGranularity ( to: elements. count)
1232
+ }
1233
+
1234
+ var viewIDs : ID . Views ? {
1235
+ ID . _Views (
1236
+ ID . ElementCollection (
1237
+ id: ID ( implicitID: implicitID) ,
1238
+ count: elements. count) ,
1239
+ isDataDependent: false
1240
+ )
1241
+ }
1242
+
1243
+ func applyNodes(
1244
+ from start: inout Int ,
1245
+ style: IteratorStyle ,
1246
+ list: Attribute < any ViewList > ? ,
1247
+ transform: inout SublistTransform ,
1248
+ to body: ApplyBody
1249
+ ) -> Bool {
1250
+ let count = count ( style: style)
1251
+ guard start < count else {
1252
+ start -= count
1253
+ return true
1254
+ }
1255
+ let sublist = Sublist (
1256
+ start: start,
1257
+ count: count,
1258
+ id: ViewList . ID ( implicitID: implicitID) ,
1259
+ elements: elements,
1260
+ traits: traits,
1261
+ list: list
1262
+ )
1263
+ defer { start = 0 }
1264
+ return body ( & start, style, . sublist( sublist) , & transform)
1265
+ }
1266
+
1267
+ func edit( forID id: ID , since transaction: TransactionID ) -> Edit ? {
1268
+ nil
1269
+ }
1270
+
1271
+ func firstOffset< OtherID> ( forID id: OtherID , style: IteratorStyle ) -> Int ? where OtherID : Hashable {
1272
+ nil
1273
+ }
1274
+
1275
+ struct Init : Rule , AsyncAttribute , CustomStringConvertible {
1276
+ let elements : any Elements
1277
+ let implicitID : Int
1278
+ let canTransition : Bool
1279
+ let stableIDScope : WeakAttribute < DisplayList . StableIdentityScope > ?
1280
+ let traitKeys : ViewTraitKeys ?
1281
+ @OptionalAttribute var traits : ViewTraitCollection ?
1282
+
1283
+ var value : any ViewList {
1284
+ BaseViewList (
1285
+ elements: elements,
1286
+ implicitID: implicitID,
1287
+ canTransition: canTransition,
1288
+ stableIDScope: stableIDScope,
1289
+ traitKeys: traitKeys,
1290
+ traits: traits ?? . init( )
1291
+ )
1292
+ }
1293
+
1294
+ var description : String {
1295
+ " Elements [ \( elements. count) ] "
1296
+ }
1297
+ }
1298
+ }
1299
+
1187
1300
// MARK: - EmptyViewList
1188
1301
1189
1302
package struct EmptyViewList : ViewList {
0 commit comments