pull/2756/head
louisehsu 6 days ago
parent 3118ee7607
commit 106a06300d

@ -9,7 +9,6 @@ void main() {
}
class ResizeApp extends StatefulWidget {
/// Creates the [ResizeApp].
const ResizeApp({super.key});
@override
@ -26,19 +25,26 @@ class _ResizeAppState extends State<ResizeApp> {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: _addToList, // The tap anywhere logic
child: Center(
heightFactor: 1,
child: Directionality(
textDirection: TextDirection.ltr,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
for (int i = 0; i < _listSize; i++)
Container(color: HSVColor.fromAHSV(1, (10.0 * i), 1, 1).toColor(), height: 50, width: 100),
],
),
return Center(
heightFactor: 1,
child: Directionality(
textDirection: TextDirection.ltr,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
for (int i = 0; i < _listSize; i++)
Container(color: HSVColor.fromAHSV(1, (10.0 * i), 1, 1).toColor(), height: 50, width: 200,
child: Center(
child: Text(
'Flutter Widget $i',
style: const TextStyle(fontSize: 16, color: Colors.black),
),
)),
TextButton(
onPressed: _addToList,
child: Text('Listception!'),
)
],
),
),
);

@ -65,11 +65,15 @@
};
F23EDFE92EE0E81C00A217AA /* ios_content_resizingTests */ = {
isa = PBXFileSystemSynchronizedRootGroup;
exceptions = (
);
path = ios_content_resizingTests;
sourceTree = "<group>";
};
F23EDFF32EE0E81C00A217AA /* ios_content_resizingUITests */ = {
isa = PBXFileSystemSynchronizedRootGroup;
exceptions = (
);
path = ios_content_resizingUITests;
sourceTree = "<group>";
};
@ -292,11 +296,7 @@
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP-User] Run Flutter Build flutter_module Script";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -e\nset -u\nsource \"${SRCROOT}/../flutter_module/.ios/Flutter/flutter_export_environment.sh\"\nexport VERBOSE_SCRIPT_LOGGING=1 && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh build";
@ -328,11 +328,7 @@
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP-User] Embed Flutter Build flutter_module Script";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -e\nset -u\nsource \"${SRCROOT}/../flutter_module/.ios/Flutter/flutter_export_environment.sh\"\nexport VERBOSE_SCRIPT_LOGGING=1 && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh embed_and_thin";

@ -12,22 +12,19 @@ class ViewController: UIViewController {
let scrollView = UIScrollView()
let stackView = UIStackView()
stackView.axis = .vertical
stackView.spacing = 12 // Spacing between the "cards"
stackView.spacing = 12
let engine1 = FlutterEngine(name: "one")
engine1.run()
let engine = FlutterEngine()
engine.run()
for index in 1...50 {
if index == 10 {
// This is our Flutter view
let flutterViewController = FlutterViewController(engine: engine1, nibName: nil, bundle: nil)
if index == 1 {
let flutterViewController = FlutterViewController(engine: engine, nibName: nil, bundle: nil)
flutterViewController.isAutoResizable = true
addChild(flutterViewController)
// The Flutter view's background should be clear to see the card behind it
flutterViewController.view.backgroundColor = .clear
// Wrap the Flutter view in a styled container "card"
let cardView = UIView()
cardView.backgroundColor = .systemBackground
cardView.layer.cornerRadius = 12
@ -48,7 +45,7 @@ class ViewController: UIViewController {
} else {
let label = UILabel()
label.text = "It's me, iOS \(index)"
label.text = "iOS Label \(index)"
label.translatesAutoresizingMaskIntoConstraints = false
let cardView = UIView()
@ -67,14 +64,12 @@ class ViewController: UIViewController {
}
}
// --- Auto Layout Setup ---
scrollView.translatesAutoresizingMaskIntoConstraints = false
stackView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(scrollView)
scrollView.addSubview(stackView)
// Set constraints for the scroll view to fill the main view
NSLayoutConstraint.activate([
scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
scrollView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
@ -82,11 +77,9 @@ class ViewController: UIViewController {
scrollView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor)
])
// Set constraints for the stack view within the scroll view
NSLayoutConstraint.activate([
stackView.topAnchor.constraint(equalTo: scrollView.contentLayoutGuide.topAnchor, constant: 20),
stackView.bottomAnchor.constraint(equalTo: scrollView.contentLayoutGuide.bottomAnchor, constant: -20),
// Inset the stack view horizontally for the grouped look
stackView.leadingAnchor.constraint(equalTo: scrollView.frameLayoutGuide.leadingAnchor, constant: 20),
stackView.trailingAnchor.constraint(equalTo: scrollView.frameLayoutGuide.trailingAnchor, constant: -20)
])

Loading…
Cancel
Save