41
dev/integration_tests/ios_add2app/flutterapp/.gitignore
vendored
Normal file
41
dev/integration_tests/ios_add2app/flutterapp/.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
.DS_Store
|
||||
.dart_tool/
|
||||
|
||||
.packages
|
||||
.pub/
|
||||
|
||||
.idea/
|
||||
.vagrant/
|
||||
.sconsign.dblite
|
||||
.svn/
|
||||
|
||||
*.swp
|
||||
profile
|
||||
|
||||
DerivedData/
|
||||
|
||||
.generated/
|
||||
|
||||
*.pbxuser
|
||||
*.mode1v3
|
||||
*.mode2v3
|
||||
*.perspectivev3
|
||||
|
||||
!default.pbxuser
|
||||
!default.mode1v3
|
||||
!default.mode2v3
|
||||
!default.perspectivev3
|
||||
|
||||
xcuserdata
|
||||
|
||||
*.moved-aside
|
||||
|
||||
*.pyc
|
||||
*sync/
|
||||
Icon?
|
||||
.tags*
|
||||
|
||||
build/
|
||||
.android/
|
||||
.ios/
|
||||
.flutter-plugins
|
||||
10
dev/integration_tests/ios_add2app/flutterapp/.metadata
Normal file
10
dev/integration_tests/ios_add2app/flutterapp/.metadata
Normal file
@@ -0,0 +1,10 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: 06179457d553b96b4d7421a08ac90535ca2c9632
|
||||
channel: unknown
|
||||
|
||||
project_type: module
|
||||
8
dev/integration_tests/ios_add2app/flutterapp/README.md
Normal file
8
dev/integration_tests/ios_add2app/flutterapp/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# ios_add2app_flutter
|
||||
|
||||
A new flutter module project.
|
||||
|
||||
## Getting Started
|
||||
|
||||
For help getting started with Flutter, view our online
|
||||
[documentation](https://flutter.io/).
|
||||
190
dev/integration_tests/ios_add2app/flutterapp/lib/main.dart
Normal file
190
dev/integration_tests/ios_add2app/flutterapp/lib/main.dart
Normal file
@@ -0,0 +1,190 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'marquee.dart';
|
||||
|
||||
/// Route names. (See [main] for more details.)
|
||||
///
|
||||
/// The route names must match those sent by the platform-specific component.
|
||||
const String greenMarqueeRouteName = 'marquee_green';
|
||||
const String purpleMarqueeRouteName = 'marquee_purple';
|
||||
const String fullscreenRouteName = 'full';
|
||||
const String hybridRouteName = 'hybrid';
|
||||
|
||||
/// Channel used to let the Flutter app know to reset the app to a specific
|
||||
/// route. See the [run] method.
|
||||
///
|
||||
/// Note that we shouldn't use the `setInitialRoute` method on the system
|
||||
/// navigation channel, as that never gets propagated back to Flutter after the
|
||||
/// initial call.
|
||||
const String _kReloadChannelName = 'reload';
|
||||
const BasicMessageChannel<String> _kReloadChannel =
|
||||
BasicMessageChannel<String>(_kReloadChannelName, StringCodec());
|
||||
|
||||
void main() {
|
||||
// Start listening immediately for messages from the iOS side. ObjC calls
|
||||
// will be made to let us know when we should be changing the app state.
|
||||
_kReloadChannel.setMessageHandler(run);
|
||||
// Start off with whatever the initial route is supposed to be.
|
||||
run(ui.window.defaultRouteName);
|
||||
}
|
||||
|
||||
Future<String> run(String name) async {
|
||||
// The platform-specific component will call [setInitialRoute] on the Flutter
|
||||
// view (or view controller for iOS) to set [ui.window.defaultRouteName].
|
||||
// We then dispatch based on the route names to show different Flutter
|
||||
// widgets.
|
||||
// Since we don't really care about Flutter-side navigation in this app, we're
|
||||
// not using a regular routes map.
|
||||
switch (name) {
|
||||
case greenMarqueeRouteName:
|
||||
runApp(Marquee(color: Colors.green[400]));
|
||||
break;
|
||||
case purpleMarqueeRouteName:
|
||||
runApp(Marquee(color: Colors.purple[400]));
|
||||
break;
|
||||
case fullscreenRouteName:
|
||||
case hybridRouteName:
|
||||
default:
|
||||
runApp(FlutterView(initialRoute: name));
|
||||
break;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
class FlutterView extends StatelessWidget {
|
||||
const FlutterView({@required this.initialRoute});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter View',
|
||||
home: MyHomePage(initialRoute: initialRoute),
|
||||
);
|
||||
}
|
||||
|
||||
final String initialRoute;
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
const MyHomePage({this.initialRoute});
|
||||
|
||||
@override
|
||||
_MyHomePageState createState() => _MyHomePageState();
|
||||
|
||||
final String initialRoute;
|
||||
|
||||
/// Whether we should display the home page in fullscreen mode.
|
||||
///
|
||||
/// If in full screen mode, we will use an [AppBar] widget to show our own
|
||||
/// title.
|
||||
bool get isFullscreen => initialRoute == fullscreenRouteName;
|
||||
|
||||
/// Whether tapping the Flutter button should notify an external source.
|
||||
///
|
||||
/// If false, the button will increments our own internal counter.
|
||||
bool get hasExternalTarget => initialRoute == hybridRouteName;
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
// The name of the message channel used to communicate with the
|
||||
// platform-specific component.
|
||||
//
|
||||
// This string must match the one used on the platform side.
|
||||
static const String _channel = 'increment';
|
||||
|
||||
// The message to send to the platform-specific component when our button
|
||||
// is tapped.
|
||||
static const String _pong = 'pong';
|
||||
|
||||
// Used to pass messages between the platform-specific component and the
|
||||
// Flutter component.
|
||||
static const BasicMessageChannel<String> _platform =
|
||||
BasicMessageChannel<String>(_channel, StringCodec());
|
||||
|
||||
// An internal count. Normally this represents the number of times that the
|
||||
// button on the Flutter page has been tapped.
|
||||
int _counter = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_platform.setMessageHandler(_handlePlatformIncrement);
|
||||
}
|
||||
|
||||
/// Directly increments our internal counter and rebuilds the UI.
|
||||
void _incrementCounter() {
|
||||
setState(() {
|
||||
_counter++;
|
||||
});
|
||||
}
|
||||
|
||||
/// Callback for messages sent by the platform-specific component.
|
||||
///
|
||||
/// Increments our internal counter.
|
||||
Future<String> _handlePlatformIncrement(String message) async {
|
||||
// Normally we'd dispatch based on the value of [message], but in this
|
||||
// sample, there is only one message that is sent to us.
|
||||
_incrementCounter();
|
||||
return '';
|
||||
}
|
||||
|
||||
/// Sends a message to the platform-specific component to increment its
|
||||
/// counter.
|
||||
void _sendFlutterIncrement() {
|
||||
_platform.send(_pong);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final String buttonName =
|
||||
widget.hasExternalTarget ? 'Platform button' : 'Button';
|
||||
return Scaffold(
|
||||
appBar: widget.isFullscreen
|
||||
? AppBar(title: const Text('Fullscreen Flutter'))
|
||||
: null,
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Center(
|
||||
child: Text(
|
||||
'$buttonName tapped $_counter time${_counter == 1 ? '' : 's'}.',
|
||||
style: const TextStyle(fontSize: 17.0),
|
||||
),
|
||||
),
|
||||
const FlatButton(
|
||||
child: Text('POP'),
|
||||
onPressed: SystemNavigator.pop,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.only(bottom: 15.0, left: 5.0),
|
||||
child: Row(
|
||||
children: const <Widget>[
|
||||
Text('Flutter', style: TextStyle(fontSize: 30.0)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: Semantics(
|
||||
label: 'Increment via Flutter',
|
||||
child: FloatingActionButton(
|
||||
onPressed: widget.hasExternalTarget
|
||||
? _sendFlutterIncrement
|
||||
: _incrementCounter,
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/animation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class _MarqueeText extends AnimatedWidget {
|
||||
const _MarqueeText({Key key, Animation<double> animation})
|
||||
: super(key: key, listenable: animation);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Animation<double> animation = listenable;
|
||||
return Container(
|
||||
margin: EdgeInsets.only(left: animation.value),
|
||||
child: const Text(
|
||||
'This is Marquee',
|
||||
softWrap: false,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Marquee extends StatefulWidget {
|
||||
const Marquee({this.color});
|
||||
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => MarqueeState();
|
||||
}
|
||||
|
||||
class MarqueeState extends State<Marquee> with SingleTickerProviderStateMixin {
|
||||
AnimationController controller;
|
||||
Animation<double> animation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 2000),
|
||||
vsync: this,
|
||||
);
|
||||
animation = Tween<double>(begin: 0.0, end: 400.0).animate(controller);
|
||||
controller.repeat();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: widget.color,
|
||||
child: Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Align(
|
||||
child: _MarqueeText(animation: animation),
|
||||
alignment: Alignment.centerLeft,
|
||||
),
|
||||
const FlatButton(child: Text('POP'), onPressed: SystemNavigator.pop),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
101
dev/integration_tests/ios_add2app/flutterapp/pubspec.yaml
Normal file
101
dev/integration_tests/ios_add2app/flutterapp/pubspec.yaml
Normal file
@@ -0,0 +1,101 @@
|
||||
name: ios_add2app_flutter
|
||||
description: A new flutter module project.
|
||||
|
||||
# The following defines the version and build number for your application.
|
||||
# A version number is three numbers separated by dots, like 1.2.43
|
||||
# followed by an optional build number separated by a +.
|
||||
# Both the version and the builder number may be overridden in flutter
|
||||
# build by specifying --build-name and --build-number, respectively.
|
||||
# Read more about versioning at semver.org.
|
||||
#
|
||||
# This version is used _only_ for the Runner app, which is used if you just do
|
||||
# a `flutter run` or a `flutter make-host-app-editable`. It has no impact
|
||||
# on any other native host app that you embed your Flutter project into.
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.0.0-dev.68.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: 0.1.2
|
||||
|
||||
collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://www.dartlang.org/tools/pub/pubspec
|
||||
|
||||
async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
pedantic: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
source_span: 1.5.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
|
||||
flutter:
|
||||
# The following line ensures that the Material Icons font is
|
||||
# included with your application, so that you can use the icons in
|
||||
# the material Icons class.
|
||||
uses-material-design: true
|
||||
|
||||
# To add Flutter specific assets to your application, add an assets section,
|
||||
# like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.io/assets-and-images/#resolution-aware.
|
||||
|
||||
# For details regarding adding assets from package dependencies, see
|
||||
# https://flutter.io/assets-and-images/#from-packages
|
||||
|
||||
# To add Flutter specific custom fonts to your application, add a fonts
|
||||
# section here, in this "flutter" section. Each entry in this list should
|
||||
# have a "family" key with the font family name, and a "fonts" key with a
|
||||
# list giving the asset and other descriptors for the font. For
|
||||
# example:
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
# - asset: fonts/Schyler-Regular.ttf
|
||||
# - asset: fonts/Schyler-Italic.ttf
|
||||
# style: italic
|
||||
# - family: Trajan Pro
|
||||
# fonts:
|
||||
# - asset: fonts/TrajanPro.ttf
|
||||
# - asset: fonts/TrajanPro_Bold.ttf
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts from package dependencies,
|
||||
# see https://flutter.io/custom-fonts/#from-packages
|
||||
|
||||
# This section identifies your Flutter project as a module meant for
|
||||
# embedding in a native host app. These identifiers should _not_ ordinarily
|
||||
# be changed after generation - they are used to ensure that the tooling can
|
||||
# maintain consistency when adding or modifying assets and plugins.
|
||||
# They also do not have any bearing on your native host application's
|
||||
# identifiers, which may be completely independent or the same as these.
|
||||
module:
|
||||
androidPackage: com.example.iosadd2appflutter
|
||||
iosBundleIdentifier: com.example.iosAdd2appFlutter
|
||||
|
||||
# PUBSPEC CHECKSUM: f764
|
||||
@@ -0,0 +1,3 @@
|
||||
void main() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user