diff --git a/experimental/add_to_app/README.md b/experimental/add_to_app/README.md index 932750bc1..23ba03747 100644 --- a/experimental/add_to_app/README.md +++ b/experimental/add_to_app/README.md @@ -5,7 +5,7 @@ and the latest version of CocoaPods. See the [README](../README.md) in the `experimental` directory for details.*** This directory contains a bunch of Android and iOS projects that each import -a standalone Flutter module called `example_module`. +a standalone Flutter module called `flutter_module`. ## Goals for this sample @@ -13,42 +13,63 @@ a standalone Flutter module called `example_module`. ## The important bits -### `example_module` +### Flutter modules -This is the Flutter module that'll be added to all the individual projects -in the `add_to_app` folder. +There are two Flutter modules included in the codebase: -The first time you download this repo, you need to first resolve this -module's dependencies by running: +* `flutter_module` displays the dimensions of the screen, a button that + increments a simple counter, and an optional exit button. +* `flutter_module_using_plugin` does everything `flutter_module` does, and adds + another button that will save the counter's value to a file using the + [`path_provider`](https://pub.dev/packages/path_povider) Flutter plugin. + +Before running any of the Android or iOS apps included in this sample project, +you first need to resolve the Flutter modules' depencies. Do so by running this +command from within the `flutter_module` and `flutter_module_using_plugin` +directories: ```bash -cd example_module flutter packages get ``` -### `SimpleAndroidApp` +### Android and iOS applications -An Android application that imports `example_module` and uses it to display -a `FlutterActivity` containing widgets from the module. This project brings -in the Flutter module's Android host wrapper as a gradle sub-module. +In addition to the Flutter modules, this repo also includes a number of +Android and iOS applications that demonstrate different ways of importing +them. -To run, open the SimpleAndroidApp folder in Android Studio and press the run -button. +The Android apps are ready to run once you've completed the +`flutter packages get` commands listed above. The iOS apps use CocoaPods, +so you need to run this command to install the dependencies listed in their +Podfiles prior to running them the first time. -### `SimpleIOSExample` - -An iOS application that imports `example_module` and uses it to display -a `FlutterViewController` containing widgets from the module. This project -uses CocoaPods, so prior to running it for the first time, use this command -to set up the workspace file: +This should be done in the individual project directories themselves. For +example, prior to running `ios_fullscreen` for the first time, you need to run +these commands: ```bash -cd ../SimpleIOSExample +cd ios_fullscreen pod install ``` -Then open SimpleIOSExample/SimpleIOSExample.xcworkspace with Xcode. This -workspace will have the Flutter module linked in as a dependent CocoaPod. +Once that command is complete, you'll find an `xcworkspace` file in the project +directories with the correct Flutter module (and any other dependencies) +included. Open that workspace file, and the app is ready to build and run. + +### `android_fullscreen` and `ios_fullscreen` + +These apps showcase a relatively straightforward integration of +`flutter_module`: + +* The Flutter module is built along with the app when the app is built. +* The Flutter engine is warmed up at app launch. +* The Flutter view is presented with a full-screen Activity or + UIViewController. +* The Flutter view is a navigational leaf node; it does not launch any new, + native Activities or UIViewControllers in response to user actions. + +If you are new to Flutter's add-to-app APIs, these projects are a great place +to begin learning how to use them. ## Questions/issues diff --git a/experimental/add_to_app/SimpleAndroidApp/app/src/androidTest/java/com/example/simpleandroidapp/ExampleInstrumentedTest.kt b/experimental/add_to_app/SimpleAndroidApp/app/src/androidTest/java/com/example/simpleandroidapp/ExampleInstrumentedTest.kt deleted file mode 100644 index bd91b7615..000000000 --- a/experimental/add_to_app/SimpleAndroidApp/app/src/androidTest/java/com/example/simpleandroidapp/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.example.simpleandroidapp - -import android.support.test.InstrumentationRegistry -import android.support.test.runner.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getTargetContext() - assertEquals("com.example.simpleandroidapp", appContext.packageName) - } -} diff --git a/experimental/add_to_app/SimpleAndroidApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/experimental/add_to_app/SimpleAndroidApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index 6348baae3..000000000 --- a/experimental/add_to_app/SimpleAndroidApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - diff --git a/experimental/add_to_app/SimpleAndroidApp/app/src/main/res/drawable/ic_launcher_background.xml b/experimental/add_to_app/SimpleAndroidApp/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index a0ad202f9..000000000 --- a/experimental/add_to_app/SimpleAndroidApp/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/experimental/add_to_app/SimpleAndroidApp/app/src/main/res/layout/activity_main.xml b/experimental/add_to_app/SimpleAndroidApp/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index a051374aa..000000000 --- a/experimental/add_to_app/SimpleAndroidApp/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - + + diff --git a/experimental/add_to_app/SimpleIOSExample/SimpleIOSExample/Info.plist b/experimental/add_to_app/ios_fullscreen/IOSFullScreen/Info.plist similarity index 100% rename from experimental/add_to_app/SimpleIOSExample/SimpleIOSExample/Info.plist rename to experimental/add_to_app/ios_fullscreen/IOSFullScreen/Info.plist diff --git a/experimental/add_to_app/SimpleIOSExample/SimpleIOSExample/ViewController.swift b/experimental/add_to_app/ios_fullscreen/IOSFullScreen/ViewController.swift similarity index 87% rename from experimental/add_to_app/SimpleIOSExample/SimpleIOSExample/ViewController.swift rename to experimental/add_to_app/ios_fullscreen/IOSFullScreen/ViewController.swift index 363e79e29..76976b3aa 100644 --- a/experimental/add_to_app/SimpleIOSExample/SimpleIOSExample/ViewController.swift +++ b/experimental/add_to_app/ios_fullscreen/IOSFullScreen/ViewController.swift @@ -6,10 +6,10 @@ import UIKit import Flutter class ViewController: UIViewController { - @IBAction func buttonWasTapped(_ sender: Any) { - let flutterEngine = (UIApplication.shared.delegate as? AppDelegate)?.flutterEngine; - let flutterViewController = FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)!; + let flutterEngine = (UIApplication.shared.delegate as? AppDelegate)?.flutterEngine + let flutterViewController = FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)! self.present(flutterViewController, animated: false, completion: nil) } } + diff --git a/experimental/add_to_app/SimpleIOSExample/SimpleIOSExampleTests/SimpleIOSExampleTests.swift b/experimental/add_to_app/ios_fullscreen/IOSFullScreenTests/IOSFullScreenTests.swift similarity index 91% rename from experimental/add_to_app/SimpleIOSExample/SimpleIOSExampleTests/SimpleIOSExampleTests.swift rename to experimental/add_to_app/ios_fullscreen/IOSFullScreenTests/IOSFullScreenTests.swift index f7f3840fc..0eafb491b 100644 --- a/experimental/add_to_app/SimpleIOSExample/SimpleIOSExampleTests/SimpleIOSExampleTests.swift +++ b/experimental/add_to_app/ios_fullscreen/IOSFullScreenTests/IOSFullScreenTests.swift @@ -3,9 +3,9 @@ // found in the LICENSE file. import XCTest -@testable import SimpleIOSExample +@testable import IOSFullScreen -class SimpleIOSExampleTests: XCTestCase { +class IOSFullScreenTests: XCTestCase { override func setUp() { // Put setup code here. This method is called before the invocation of each test method in the class. diff --git a/experimental/add_to_app/SimpleIOSExample/SimpleIOSExampleTests/Info.plist b/experimental/add_to_app/ios_fullscreen/IOSFullScreenTests/Info.plist similarity index 100% rename from experimental/add_to_app/SimpleIOSExample/SimpleIOSExampleTests/Info.plist rename to experimental/add_to_app/ios_fullscreen/IOSFullScreenTests/Info.plist diff --git a/experimental/add_to_app/SimpleIOSExample/SimpleIOSExampleUITests/SimpleIOSExampleUITests.swift b/experimental/add_to_app/ios_fullscreen/IOSFullScreenUITests/IOSFullScreenUITests.swift similarity index 96% rename from experimental/add_to_app/SimpleIOSExample/SimpleIOSExampleUITests/SimpleIOSExampleUITests.swift rename to experimental/add_to_app/ios_fullscreen/IOSFullScreenUITests/IOSFullScreenUITests.swift index 70ba51143..1def48909 100644 --- a/experimental/add_to_app/SimpleIOSExample/SimpleIOSExampleUITests/SimpleIOSExampleUITests.swift +++ b/experimental/add_to_app/ios_fullscreen/IOSFullScreenUITests/IOSFullScreenUITests.swift @@ -4,7 +4,7 @@ import XCTest -class SimpleIOSExampleUITests: XCTestCase { +class IOSFullScreenUITests: XCTestCase { override func setUp() { // Put setup code here. This method is called before the invocation of each test method in the class. diff --git a/experimental/add_to_app/SimpleIOSExample/SimpleIOSExampleUITests/Info.plist b/experimental/add_to_app/ios_fullscreen/IOSFullScreenUITests/Info.plist similarity index 100% rename from experimental/add_to_app/SimpleIOSExample/SimpleIOSExampleUITests/Info.plist rename to experimental/add_to_app/ios_fullscreen/IOSFullScreenUITests/Info.plist diff --git a/experimental/add_to_app/SimpleIOSExample/Podfile b/experimental/add_to_app/ios_fullscreen/Podfile similarity index 55% rename from experimental/add_to_app/SimpleIOSExample/Podfile rename to experimental/add_to_app/ios_fullscreen/Podfile index 0c2d93e2e..8b44b8c40 100644 --- a/experimental/add_to_app/SimpleIOSExample/Podfile +++ b/experimental/add_to_app/ios_fullscreen/Podfile @@ -1,25 +1,22 @@ # Uncomment the next line to define a global platform for your project # platform :ios, '9.0' -# These three lines add the dependencies for example_module to the workspace -# for the project: -flutter_application_path = '../example_module' -`pushd "#{flutter_application_path}" && flutter create . && popd` +flutter_application_path = '../flutter_module' load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb') -target 'SimpleIOSExample' do +target 'IOSFullScreen' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! - # Pods for SimpleIOSExample + # Pods for IOSFullScreen install_all_flutter_pods(flutter_application_path) - target 'SimpleIOSExampleTests' do + target 'IOSFullScreenTests' do inherit! :search_paths # Pods for testing end - target 'SimpleIOSExampleUITests' do + target 'IOSFullScreenUITests' do inherit! :search_paths # Pods for testing end diff --git a/experimental/add_to_app/ios_fullscreen/Podfile.lock b/experimental/add_to_app/ios_fullscreen/Podfile.lock new file mode 100644 index 000000000..3546304a9 --- /dev/null +++ b/experimental/add_to_app/ios_fullscreen/Podfile.lock @@ -0,0 +1,28 @@ +PODS: + - Flutter (1.0.0) + - flutter_module (0.0.1): + - Flutter + - FlutterPluginRegistrant (0.0.1): + - Flutter + +DEPENDENCIES: + - Flutter (from `../flutter_module/.ios/Flutter/engine`) + - flutter_module (from `../flutter_module/.ios/Flutter`) + - FlutterPluginRegistrant (from `../flutter_module/.ios/Flutter/FlutterPluginRegistrant`) + +EXTERNAL SOURCES: + Flutter: + :path: "../flutter_module/.ios/Flutter/engine" + flutter_module: + :path: "../flutter_module/.ios/Flutter" + FlutterPluginRegistrant: + :path: "../flutter_module/.ios/Flutter/FlutterPluginRegistrant" + +SPEC CHECKSUMS: + Flutter: 0e3d915762c693b495b44d77113d4970485de6ec + flutter_module: 37f078337caf8acad3074374a49bf81442fd3e07 + FlutterPluginRegistrant: d59dd07dd90e9c6430996073575a5bd1ea19677e + +PODFILE CHECKSUM: 3a2cacb59163f4a25654a84fcd92b179f682c008 + +COCOAPODS: 1.7.5