diff --git a/add_to_app/ios_content_resizing/flutter_module/lib/main.dart b/add_to_app/ios_content_resizing/flutter_module/lib/main.dart index 875600586..ba7f7b7ba 100644 --- a/add_to_app/ios_content_resizing/flutter_module/lib/main.dart +++ b/add_to_app/ios_content_resizing/flutter_module/lib/main.dart @@ -1,55 +1,46 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + import 'package:flutter/material.dart'; void main() { - runApp(const MyApp()); + runApp(const ResizeApp()); } -/// The main application widget for the Fruit Catalog. -class MyApp extends StatefulWidget { - /// Creates the [MyApp]. - const MyApp({super.key}); +class ResizeApp extends StatefulWidget { + /// Creates the [ResizeApp]. + const ResizeApp({super.key}); @override - State createState() => _MyAppState(); + State createState() => _ResizeAppState(); } -class _MyAppState extends State { - int _counter = 1; - void _incrementCounter() { +class _ResizeAppState extends State { + int _listSize = 1; + void _addToList() { setState(() { - if (_counter > 40) { - _counter = 1; - } - _counter++; + _listSize++; }); } @override Widget build(BuildContext context) { - - return Center( - heightFactor: 1, - child: Directionality( - textDirection: TextDirection.ltr, - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - for (int i = 0; i < _counter; i++) - Text( - "Hello from Flutter $i", - style: TextStyle(color: Colors.pink), - ), - Padding( - padding: const EdgeInsets.fromLTRB(8.0, 50, 8.0, 8.0), - child: ElevatedButton( - onPressed: _incrementCounter, - child: Text("Add to list"), - ), - ), - - ], + return GestureDetector( + onTap: _addToList, // The tap anywhere logic + child: Center( + heightFactor: 1, + child: Directionality( + textDirection: TextDirection.ltr, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + for (int i = 0; i < _listSize; i++) + Container(color: HSVColor.fromAHSV(1, (10.0 * i), 1, 1).toColor(), height: 50, width: 100), + ], + ), ), ), ); } -} +} \ No newline at end of file diff --git a/add_to_app/ios_content_resizing/flutter_module/test/widget_test.dart b/add_to_app/ios_content_resizing/flutter_module/test/widget_test.dart deleted file mode 100644 index 396d69651..000000000 --- a/add_to_app/ios_content_resizing/flutter_module/test/widget_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:flutter_module/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} diff --git a/add_to_app/ios_content_resizing/ios_content_resizing/ios_content_resizing.xcworkspace/xcuserdata/louisehsu.xcuserdatad/UserInterfaceState.xcuserstate b/add_to_app/ios_content_resizing/ios_content_resizing/ios_content_resizing.xcworkspace/xcuserdata/louisehsu.xcuserdatad/UserInterfaceState.xcuserstate index ee27681bf..00060cb67 100644 Binary files a/add_to_app/ios_content_resizing/ios_content_resizing/ios_content_resizing.xcworkspace/xcuserdata/louisehsu.xcuserdatad/UserInterfaceState.xcuserstate and b/add_to_app/ios_content_resizing/ios_content_resizing/ios_content_resizing.xcworkspace/xcuserdata/louisehsu.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/add_to_app/ios_content_resizing/ios_content_resizing/ios_content_resizing/ViewController.swift b/add_to_app/ios_content_resizing/ios_content_resizing/ios_content_resizing/ViewController.swift index 01ca771b0..7dc8e4182 100644 --- a/add_to_app/ios_content_resizing/ios_content_resizing/ios_content_resizing/ViewController.swift +++ b/add_to_app/ios_content_resizing/ios_content_resizing/ios_content_resizing/ViewController.swift @@ -15,6 +15,7 @@ class ViewController: UIViewController { let stackView = UIStackView() stackView.axis = .vertical stackView.distribution = .fill + stackView.backgroundColor = .yellow stackView.translatesAutoresizingMaskIntoConstraints = false let engine1 = FlutterEngine(name: "one") @@ -27,6 +28,7 @@ class ViewController: UIViewController { addChild(flutterViewController) stackView.addArrangedSubview(flutterViewController.view) flutterViewController.didMove(toParent: self) + } else { let label = UILabel() label.text = "Hello from iOS \(index)"