@@ -12,22 +12,19 @@ class ViewController: UIViewController {
1212 let scrollView = UIScrollView ( )
1313 let stackView = UIStackView ( )
1414 stackView. axis = . vertical
15- stackView. spacing = 12 // Spacing between the "cards"
15+ stackView. spacing = 12
1616
17- let engine1 = FlutterEngine ( name : " one " )
18- engine1 . run ( )
17+ let engine = FlutterEngine ( )
18+ engine . run ( )
1919
2020 for index in 1 ... 50 {
21- if index == 10 {
22- // This is our Flutter view
23- let flutterViewController = FlutterViewController ( engine: engine1, nibName: nil , bundle: nil )
21+ if index == 1 {
22+ let flutterViewController = FlutterViewController ( engine: engine, nibName: nil , bundle: nil )
2423 flutterViewController. isAutoResizable = true
2524 addChild ( flutterViewController)
26-
27- // The Flutter view's background should be clear to see the card behind it
25+
2826 flutterViewController. view. backgroundColor = . clear
2927
30- // Wrap the Flutter view in a styled container "card"
3128 let cardView = UIView ( )
3229 cardView. backgroundColor = . systemBackground
3330 cardView. layer. cornerRadius = 12
@@ -48,7 +45,7 @@ class ViewController: UIViewController {
4845
4946 } else {
5047 let label = UILabel ( )
51- label. text = " It's me, iOS \( index) "
48+ label. text = " iOS Label \( index) "
5249 label. translatesAutoresizingMaskIntoConstraints = false
5350
5451 let cardView = UIView ( )
@@ -67,26 +64,22 @@ class ViewController: UIViewController {
6764 }
6865 }
6966
70- // --- Auto Layout Setup ---
7167 scrollView. translatesAutoresizingMaskIntoConstraints = false
7268 stackView. translatesAutoresizingMaskIntoConstraints = false
7369
7470 view. addSubview ( scrollView)
7571 scrollView. addSubview ( stackView)
7672
77- // Set constraints for the scroll view to fill the main view
7873 NSLayoutConstraint . activate ( [
7974 scrollView. topAnchor. constraint ( equalTo: view. safeAreaLayoutGuide. topAnchor) ,
8075 scrollView. bottomAnchor. constraint ( equalTo: view. safeAreaLayoutGuide. bottomAnchor) ,
8176 scrollView. leadingAnchor. constraint ( equalTo: view. safeAreaLayoutGuide. leadingAnchor) ,
8277 scrollView. trailingAnchor. constraint ( equalTo: view. safeAreaLayoutGuide. trailingAnchor)
8378 ] )
8479
85- // Set constraints for the stack view within the scroll view
8680 NSLayoutConstraint . activate ( [
8781 stackView. topAnchor. constraint ( equalTo: scrollView. contentLayoutGuide. topAnchor, constant: 20 ) ,
8882 stackView. bottomAnchor. constraint ( equalTo: scrollView. contentLayoutGuide. bottomAnchor, constant: - 20 ) ,
89- // Inset the stack view horizontally for the grouped look
9083 stackView. leadingAnchor. constraint ( equalTo: scrollView. frameLayoutGuide. leadingAnchor, constant: 20 ) ,
9184 stackView. trailingAnchor. constraint ( equalTo: scrollView. frameLayoutGuide. trailingAnchor, constant: - 20 )
9285 ] )
0 commit comments