snapshot of https://github.com/flutter/samples.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Main Branch CI / Test Flutter beta on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter stable on ubuntu-latest (push) Has been skipped
Main Branch CI / Test Flutter beta on macos-latest (push) Has been cancelled
Main Branch CI / Test Flutter stable on macos-latest (push) Has been cancelled
87
add_to_app/books/README.md
Normal file
@@ -0,0 +1,87 @@
|
||||
# books
|
||||
|
||||
Mimics a real world use-case of embedding Flutter into an existing Android app
|
||||
and demonstrates using [Pigeon](https://pub.dev/packages/pigeon) to communicate
|
||||
between Flutter and the host application.
|
||||
|
||||
## Description
|
||||
|
||||
These apps integrate the `flutter_books` module using the simpler build-together
|
||||
project setup. They simulate a mock scenario where an existing book catalog
|
||||
list app already exists. Flutter is used to implement an additional book details
|
||||
page.
|
||||
|
||||
* Similar to [`fullscreen`](../fullscreen).
|
||||
* An existing books catalog app is already implemented in Kotlin and Swift.
|
||||
* The platform-side app has existing middleware constraints that should also
|
||||
be the middleware foundation for the additional Flutter screen.
|
||||
* On Android, the Kotlin app already uses GSON and OkHttp for networking and
|
||||
references the Google Books API as a data source. These same libraries also
|
||||
underpin the data fetched and shown in the Flutter screen.
|
||||
* On iOS, the Swift app does a similar fetch and parse of the Google Books API
|
||||
using iOS's built-in libraries.
|
||||
* The platform application interfaces with the Flutter book details page using
|
||||
idiomatic platform API conventions rather than Flutter conventions.
|
||||
* On Android, the Flutter activity receives the book to show via activity
|
||||
intent and returns the edited book by setting the result intent on the
|
||||
activity. No Flutter concepts are leaked into the consumer activity.
|
||||
* On iOS, Storyboards are used to design the presentation of the books, just
|
||||
as one might do in a full UIKit app.
|
||||
* The [pigeon](https://pub.dev/packages/pigeon) plugin is used to generate
|
||||
interop APIs and data classes. The same `Book` model class is used within the
|
||||
Kotlin/Swift program, the Dart program and in the interop between Kotlin/Swift
|
||||
and Dart. No manual platform channel plumbing needed for interop.
|
||||
* The `api.dart/java/mm` files generated from the
|
||||
`flutter_module_books/pigeon/schema.dart` file are checked into source
|
||||
control. Therefore `pigeon` is only a dev dependency with no runtime
|
||||
requirements.
|
||||
* If the `schema.dart` is modified, the generated classes can be updated with
|
||||
|
||||
```bash
|
||||
dart run pigeon --input pigeon/schema.dart \
|
||||
--dart_out lib/api.dart \
|
||||
--objc_header_out ../ios_books/IosBooks/api.h \
|
||||
--objc_source_out ../ios_books/IosBooks/api.m \
|
||||
--objc_prefix BK \
|
||||
--java_out ../android_books/app/src/main/java/dev/flutter/example/books/Api.java \
|
||||
--java_package "dev.flutter.example.books"
|
||||
```
|
||||
|
||||
in the `flutter_module_books` directory.
|
||||
|
||||
Once you've understood the basics of add-to-app with `android_fullscreen` and
|
||||
`ios_fullscreen`, this is a good sample to demonstrate how to integrate Flutter
|
||||
in a slightly more realistic setting with existing business logic.
|
||||
|
||||
## tl;dr
|
||||
|
||||
If you're just looking to get up and running quickly, these bash commands will
|
||||
fetch packages and set up dependencies (note that the above commands assume
|
||||
you're building for both iOS and Android, with both toolchains installed):
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
cd flutter_module_books/
|
||||
flutter pub get
|
||||
|
||||
# For Android builds:
|
||||
open -a "Android Studio" ../android_books # macOS only
|
||||
# Or open the ../android_books folder in Android Studio for other platforms.
|
||||
|
||||
# For iOS builds:
|
||||
cd ../ios_books
|
||||
pod install
|
||||
open IosBooks.xcworkspace
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
* Flutter
|
||||
* Android Studio
|
||||
* Cocoapods (iOS)
|
||||
|
||||
## Questions/issues
|
||||
|
||||
See [add_to_app/README.md](../README.md) for further help.
|
||||
14
add_to_app/books/android_books/.gitignore
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
14
add_to_app/books/android_books/README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# android_books
|
||||
|
||||
An example Android application used in the Flutter add-to-app samples. For more
|
||||
information on how to use it, see the [README](../README.md) file located in the
|
||||
[/add_to_app](/add_to_app) directory of this repo.
|
||||
|
||||
## Getting Started
|
||||
|
||||
For more information about Flutter, check out
|
||||
[flutter.dev](https://flutter.dev).
|
||||
|
||||
For instructions on how to integrate Flutter modules into your existing
|
||||
applications, see Flutter's
|
||||
[add-to-app documentation](https://flutter.dev/docs/development/add-to-app).
|
||||
1
add_to_app/books/android_books/app/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
53
add_to_app/books/android_books/app/build.gradle
Normal file
@@ -0,0 +1,53 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 31
|
||||
buildToolsVersion "29.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "dev.flutter.example.books"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
profile {
|
||||
initWith debug
|
||||
}
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig debug.signingConfig
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation "com.squareup.okhttp3:okhttp:4.7.2"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation 'androidx.core:core-ktx:1.3.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation "androidx.activity:activity-ktx:1.1.0"
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'com.google.android.material:material:1.1.0'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
implementation project(path: ':flutter')
|
||||
testImplementation 'junit:junit:4.13'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
|
||||
}
|
||||
21
add_to_app/books/android_books/app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,27 @@
|
||||
package dev.flutter.example.books
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.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 MainActivityTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("dev.flutter.example.books", appContext.packageName)
|
||||
}
|
||||
|
||||
// The app should be hermetic (with offline books JSON) before adding
|
||||
// more tests.
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="dev.flutter.example.books">
|
||||
|
||||
<application
|
||||
android:name=".BookApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".FlutterBookActivity"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
</application>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,252 @@
|
||||
// Autogenerated from Pigeon (v1.0.1), do not edit directly.
|
||||
// See also: https://pub.dev/packages/pigeon
|
||||
|
||||
package dev.flutter.example.books;
|
||||
|
||||
import io.flutter.plugin.common.BasicMessageChannel;
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.common.MessageCodec;
|
||||
import io.flutter.plugin.common.StandardMessageCodec;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** Generated class from Pigeon. */
|
||||
@SuppressWarnings(
|
||||
{"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"})
|
||||
public class Api {
|
||||
|
||||
/** Generated class from Pigeon that represents data sent in messages. */
|
||||
public static class Book {
|
||||
private String title;
|
||||
public String getTitle() { return title; }
|
||||
public void setTitle(String setterArg) { this.title = setterArg; }
|
||||
|
||||
private String subtitle;
|
||||
public String getSubtitle() { return subtitle; }
|
||||
public void setSubtitle(String setterArg) { this.subtitle = setterArg; }
|
||||
|
||||
private String author;
|
||||
public String getAuthor() { return author; }
|
||||
public void setAuthor(String setterArg) { this.author = setterArg; }
|
||||
|
||||
private String summary;
|
||||
public String getSummary() { return summary; }
|
||||
public void setSummary(String setterArg) { this.summary = setterArg; }
|
||||
|
||||
private String publishDate;
|
||||
public String getPublishDate() { return publishDate; }
|
||||
public void setPublishDate(String setterArg) {
|
||||
this.publishDate = setterArg;
|
||||
}
|
||||
|
||||
private Long pageCount;
|
||||
public Long getPageCount() { return pageCount; }
|
||||
public void setPageCount(Long setterArg) { this.pageCount = setterArg; }
|
||||
|
||||
private Thumbnail thumbnail;
|
||||
public Thumbnail getThumbnail() { return thumbnail; }
|
||||
public void setThumbnail(Thumbnail setterArg) {
|
||||
this.thumbnail = setterArg;
|
||||
}
|
||||
|
||||
Map<String, Object> toMap() {
|
||||
Map<String, Object> toMapResult = new HashMap<>();
|
||||
toMapResult.put("title", title);
|
||||
toMapResult.put("subtitle", subtitle);
|
||||
toMapResult.put("author", author);
|
||||
toMapResult.put("summary", summary);
|
||||
toMapResult.put("publishDate", publishDate);
|
||||
toMapResult.put("pageCount", pageCount);
|
||||
toMapResult.put("thumbnail",
|
||||
(thumbnail == null) ? null : thumbnail.toMap());
|
||||
return toMapResult;
|
||||
}
|
||||
static Book fromMap(Map<String, Object> map) {
|
||||
Book fromMapResult = new Book();
|
||||
Object title = map.get("title");
|
||||
fromMapResult.title = (String)title;
|
||||
Object subtitle = map.get("subtitle");
|
||||
fromMapResult.subtitle = (String)subtitle;
|
||||
Object author = map.get("author");
|
||||
fromMapResult.author = (String)author;
|
||||
Object summary = map.get("summary");
|
||||
fromMapResult.summary = (String)summary;
|
||||
Object publishDate = map.get("publishDate");
|
||||
fromMapResult.publishDate = (String)publishDate;
|
||||
Object pageCount = map.get("pageCount");
|
||||
fromMapResult.pageCount =
|
||||
(pageCount == null)
|
||||
? null
|
||||
: ((pageCount instanceof Integer) ? (Integer)pageCount
|
||||
: (Long)pageCount);
|
||||
Object thumbnail = map.get("thumbnail");
|
||||
fromMapResult.thumbnail = Thumbnail.fromMap((Map)thumbnail);
|
||||
return fromMapResult;
|
||||
}
|
||||
}
|
||||
|
||||
/** Generated class from Pigeon that represents data sent in messages. */
|
||||
public static class Thumbnail {
|
||||
private String url;
|
||||
public String getUrl() { return url; }
|
||||
public void setUrl(String setterArg) { this.url = setterArg; }
|
||||
|
||||
Map<String, Object> toMap() {
|
||||
Map<String, Object> toMapResult = new HashMap<>();
|
||||
toMapResult.put("url", url);
|
||||
return toMapResult;
|
||||
}
|
||||
static Thumbnail fromMap(Map<String, Object> map) {
|
||||
Thumbnail fromMapResult = new Thumbnail();
|
||||
Object url = map.get("url");
|
||||
fromMapResult.url = (String)url;
|
||||
return fromMapResult;
|
||||
}
|
||||
}
|
||||
private static class FlutterBookApiCodec extends StandardMessageCodec {
|
||||
public static final FlutterBookApiCodec INSTANCE =
|
||||
new FlutterBookApiCodec();
|
||||
private FlutterBookApiCodec() {}
|
||||
@Override
|
||||
protected Object readValueOfType(byte type, ByteBuffer buffer) {
|
||||
switch (type) {
|
||||
case (byte)128:
|
||||
return Book.fromMap((Map<String, Object>)readValue(buffer));
|
||||
|
||||
default:
|
||||
return super.readValueOfType(type, buffer);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void writeValue(ByteArrayOutputStream stream, Object value) {
|
||||
if (value instanceof Book) {
|
||||
stream.write(128);
|
||||
writeValue(stream, ((Book)value).toMap());
|
||||
} else {
|
||||
super.writeValue(stream, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated class from Pigeon that represents Flutter messages that can be
|
||||
* called from Java.
|
||||
*/
|
||||
public static class FlutterBookApi {
|
||||
private final BinaryMessenger binaryMessenger;
|
||||
public FlutterBookApi(BinaryMessenger argBinaryMessenger) {
|
||||
this.binaryMessenger = argBinaryMessenger;
|
||||
}
|
||||
public interface Reply<T> {
|
||||
void reply(T reply);
|
||||
}
|
||||
static MessageCodec<Object> getCodec() {
|
||||
return FlutterBookApiCodec.INSTANCE;
|
||||
}
|
||||
|
||||
public void displayBookDetails(Book bookArg, Reply<Void> callback) {
|
||||
BasicMessageChannel<Object> channel = new BasicMessageChannel<>(
|
||||
binaryMessenger,
|
||||
"dev.flutter.pigeon.FlutterBookApi.displayBookDetails", getCodec());
|
||||
channel.send(new ArrayList<Object>(Arrays.asList(bookArg)),
|
||||
channelReply -> { callback.reply(null); });
|
||||
}
|
||||
}
|
||||
private static class HostBookApiCodec extends StandardMessageCodec {
|
||||
public static final HostBookApiCodec INSTANCE = new HostBookApiCodec();
|
||||
private HostBookApiCodec() {}
|
||||
@Override
|
||||
protected Object readValueOfType(byte type, ByteBuffer buffer) {
|
||||
switch (type) {
|
||||
case (byte)128:
|
||||
return Book.fromMap((Map<String, Object>)readValue(buffer));
|
||||
|
||||
default:
|
||||
return super.readValueOfType(type, buffer);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void writeValue(ByteArrayOutputStream stream, Object value) {
|
||||
if (value instanceof Book) {
|
||||
stream.write(128);
|
||||
writeValue(stream, ((Book)value).toMap());
|
||||
} else {
|
||||
super.writeValue(stream, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated interface from Pigeon that represents a handler of messages from
|
||||
* Flutter.
|
||||
*/
|
||||
public interface HostBookApi {
|
||||
void cancel();
|
||||
void finishEditingBook(Book book);
|
||||
|
||||
/** The codec used by HostBookApi. */
|
||||
static MessageCodec<Object> getCodec() { return HostBookApiCodec.INSTANCE; }
|
||||
|
||||
/**
|
||||
* Sets up an instance of `HostBookApi` to handle messages through the
|
||||
* `binaryMessenger`.
|
||||
*/
|
||||
static void setup(BinaryMessenger binaryMessenger, HostBookApi api) {
|
||||
{
|
||||
BasicMessageChannel<Object> channel = new BasicMessageChannel<>(
|
||||
binaryMessenger, "dev.flutter.pigeon.HostBookApi.cancel",
|
||||
getCodec());
|
||||
if (api != null) {
|
||||
channel.setMessageHandler((message, reply) -> {
|
||||
Map<String, Object> wrapped = new HashMap<>();
|
||||
try {
|
||||
api.cancel();
|
||||
wrapped.put("result", null);
|
||||
} catch (Error | RuntimeException exception) {
|
||||
wrapped.put("error", wrapError(exception));
|
||||
}
|
||||
reply.reply(wrapped);
|
||||
});
|
||||
} else {
|
||||
channel.setMessageHandler(null);
|
||||
}
|
||||
}
|
||||
{
|
||||
BasicMessageChannel<Object> channel = new BasicMessageChannel<>(
|
||||
binaryMessenger, "dev.flutter.pigeon.HostBookApi.finishEditingBook",
|
||||
getCodec());
|
||||
if (api != null) {
|
||||
channel.setMessageHandler((message, reply) -> {
|
||||
Map<String, Object> wrapped = new HashMap<>();
|
||||
try {
|
||||
ArrayList<Object> args = (ArrayList<Object>)message;
|
||||
Book bookArg = (Book)args.get(0);
|
||||
if (bookArg == null) {
|
||||
throw new NullPointerException("bookArg unexpectedly null.");
|
||||
}
|
||||
api.finishEditingBook(bookArg);
|
||||
wrapped.put("result", null);
|
||||
} catch (Error | RuntimeException exception) {
|
||||
wrapped.put("error", wrapError(exception));
|
||||
}
|
||||
reply.reply(wrapped);
|
||||
});
|
||||
} else {
|
||||
channel.setMessageHandler(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private static Map<String, Object> wrapError(Throwable exception) {
|
||||
Map<String, Object> errorMap = new HashMap<>();
|
||||
errorMap.put("message", exception.toString());
|
||||
errorMap.put("code", exception.getClass().getSimpleName());
|
||||
errorMap.put("details", null);
|
||||
return errorMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2020 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package dev.flutter.example.books
|
||||
|
||||
import android.app.Application
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.embedding.engine.FlutterEngineCache
|
||||
import io.flutter.embedding.engine.dart.DartExecutor
|
||||
|
||||
class BookApplication: Application() {
|
||||
companion object {
|
||||
const val ENGINE_ID = "book_engine"
|
||||
}
|
||||
|
||||
private lateinit var flutterEngine: FlutterEngine
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
// This application reuses a single FlutterEngine instance throughout.
|
||||
// Create the FlutterEngine on application start.
|
||||
flutterEngine = FlutterEngine(this).apply{
|
||||
dartExecutor.executeDartEntrypoint(DartExecutor.DartEntrypoint.createDefault())
|
||||
}
|
||||
FlutterEngineCache.getInstance().put(ENGINE_ID, flutterEngine)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
// Copyright 2020 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package dev.flutter.example.books
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import dev.flutter.example.books.BookApplication.Companion.ENGINE_ID
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import java.util.HashMap
|
||||
|
||||
/**
|
||||
* This {@link FlutterActivity} class repackages Kotlin-Dart interop using the Pigeon IPC mechanism.
|
||||
* It repackages Flutter/Dart-side functionalities in standard Android API style, passing
|
||||
* arguments in and out of the activity using 'startActivityForResult' intents and
|
||||
* 'onActivityResult' intents.
|
||||
*/
|
||||
class FlutterBookActivity: FlutterActivity() {
|
||||
companion object {
|
||||
const val EXTRA_BOOK = "book"
|
||||
|
||||
/**
|
||||
* Static intent factory to start {@link FlutterBookActivity} with the singleton
|
||||
* {@link FlutterEngine} the application started.
|
||||
*
|
||||
* The activity launched from this intent shows the details of the {@link Api.Book}
|
||||
* supplied.
|
||||
*/
|
||||
fun withBook(context: Context, book: Api.Book): Intent {
|
||||
// In a more realistic app, there should be some dependency injection mechanism to
|
||||
// determine which engine to use.
|
||||
return CachedEngineBookIntentBuilder(ENGINE_ID)
|
||||
.build(context)
|
||||
.putExtra(
|
||||
// The Pigeon data class is useful not only between Kotlin/Java and Dart
|
||||
// but also within Kotlin/Java where activities must communicate with
|
||||
// each other via serializable data. The Pigeon data class is a
|
||||
// serializable class by definition.
|
||||
EXTRA_BOOK,
|
||||
// TODO(gaaclarke): the Pigeon generated data class should just implement
|
||||
// Serializable so we won't need 'toMap()' here
|
||||
// https://github.com/flutter/flutter/issues/58909
|
||||
HashMap(book.toMap())
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* A static helper method to parse a result intent from this activity into a {@link Book}.
|
||||
*
|
||||
* @param resultIntent an {@link Intent} that must be the data intent returned by this
|
||||
* activity's {@code onActivityResult}.
|
||||
*/
|
||||
fun getBookFromResultIntent(resultIntent: Intent): Api.Book {
|
||||
return Api.Book.fromMap((resultIntent.getSerializableExtra(FlutterBookActivity.EXTRA_BOOK) as HashMap<String, Any>));
|
||||
}
|
||||
}
|
||||
|
||||
// Intent builder class to build a FlutterBookActivity instance instead of the default FlutterActivity.
|
||||
class CachedEngineBookIntentBuilder(engineId: String): CachedEngineIntentBuilder(FlutterBookActivity::class.java, engineId) { }
|
||||
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
// Called shortly after the activity is created, when the activity is bound to a
|
||||
// FlutterEngine responsible for rendering the Flutter activity's content.
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
|
||||
// The book to give to Flutter is passed in from the MainActivity via this activity's
|
||||
// source intent getter. The intent contains the book serialized as on extra.
|
||||
val bookToShow = Api.Book.fromMap(intent.getSerializableExtra(EXTRA_BOOK) as HashMap<String, Any>)
|
||||
|
||||
// Register the HostBookApiHandler callback class to get results from Flutter.
|
||||
Api.HostBookApi.setup(flutterEngine.dartExecutor, HostBookApiHandler())
|
||||
|
||||
// Send in the book instance to Flutter.
|
||||
Api.FlutterBookApi(flutterEngine.dartExecutor).displayBookDetails(bookToShow) {
|
||||
// We don't care about the callback
|
||||
}
|
||||
}
|
||||
|
||||
// This {@link Api.HostBookApi} subclass will be called by Pigeon when the corresponding
|
||||
// APIs are invoked on the Dart side.
|
||||
inner class HostBookApiHandler: Api.HostBookApi {
|
||||
override fun cancel() {
|
||||
// Flutter called cancel. Finish the activity with a cancel result.
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun finishEditingBook(book: Api.Book?) {
|
||||
if (book == null) {
|
||||
throw IllegalArgumentException("finishedEditingBook cannot be called with a null argument")
|
||||
}
|
||||
// Flutter returned an edited book instance. Return it to the MainActivity via the
|
||||
// standard Android Activity set result mechanism.
|
||||
setResult(Activity.RESULT_OK, Intent().putExtra(EXTRA_BOOK, HashMap(book.toMap())))
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
// Copyright 2020 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package dev.flutter.example.books
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.JsonParser
|
||||
import okhttp3.Call
|
||||
import okhttp3.Callback
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import java.io.IOException
|
||||
import java.lang.Exception
|
||||
import java.lang.RuntimeException
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
companion object {
|
||||
const val BOOKS_QUERY = "https://www.googleapis.com/books/v1/volumes?q=greenwood+tulsa&maxResults=15"
|
||||
}
|
||||
|
||||
private lateinit var books: MutableList<Api.Book>
|
||||
private lateinit var list: LinearLayout
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
list = findViewById<LinearLayout>(R.id.list)
|
||||
|
||||
// OkHttp is arbitrarily chosen here to represent an existing middleware constraint that's
|
||||
// already present in an existing application's infrastructure.
|
||||
val httpClient = OkHttpClient()
|
||||
val bookRequest = Request.Builder()
|
||||
// Retrieve data from Google Books API (arbitrarily chosen). This represents existing
|
||||
// data sources that an existing application is already interfacing with.
|
||||
.url(BOOKS_QUERY)
|
||||
.build()
|
||||
|
||||
httpClient.newCall(bookRequest).enqueue(object : Callback {
|
||||
override fun onFailure(call: Call, e: IOException) {
|
||||
throw e
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call, response: Response) {
|
||||
response.use {
|
||||
if (!response.isSuccessful) throw IOException("Unexpected code $response")
|
||||
books = parseGoogleBooksJsonToBooks(response.body!!.string())
|
||||
|
||||
val spinner = findViewById<ProgressBar>(R.id.spinner)
|
||||
|
||||
runOnUiThread {
|
||||
// Showed a spinner while network call is in progress. Remove it when
|
||||
// response is received.
|
||||
spinner.visibility = View.GONE
|
||||
populateBookCards()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Take a top level Google Books query's response JSON and create a list of Book Pigeon data
|
||||
// classes that will be used both as a model here on the Kotlin side and also in the IPCs
|
||||
// to Dart.
|
||||
private fun parseGoogleBooksJsonToBooks(jsonBody: String): MutableList<Api.Book> {
|
||||
// Here we're arbitrarily using GSON to represent another existing middleware constraint
|
||||
// that already exists in your existing application's infrastructure.
|
||||
val jsonBooks = JsonParser.parseString(jsonBody).asJsonObject.getAsJsonArray("items")
|
||||
val books = mutableListOf<Api.Book>()
|
||||
for (jsonBook in jsonBooks.map { it.asJsonObject }) {
|
||||
try {
|
||||
// Here we're using GSON to populate a Pigeon data class directly. The Pigeon data
|
||||
// class can be used not just as part of your IPC API's signature but also as a
|
||||
// normal data class in your existing application.
|
||||
//
|
||||
// We could either push the Pigeon data class usage higher into the existing GSON
|
||||
// "middleware" or lower, closer to the IPC.
|
||||
val book = Api.Book()
|
||||
val volumeInfoJson = jsonBook.getAsJsonObject("volumeInfo")
|
||||
book.title = volumeInfoJson.get("title").asString
|
||||
book.subtitle = volumeInfoJson.get("subtitle")?.asString
|
||||
// Sorry co-authors, we're trying to keep this simple.
|
||||
book.author = volumeInfoJson.getAsJsonArray("authors")[0].asString
|
||||
book.summary = volumeInfoJson.get("description").asString
|
||||
book.publishDate = volumeInfoJson.get("publishedDate").asString
|
||||
book.pageCount = volumeInfoJson.get("pageCount").asLong
|
||||
val thumbnail = Api.Thumbnail()
|
||||
thumbnail.url = volumeInfoJson.getAsJsonObject("imageLinks").get("thumbnail").asString
|
||||
book.thumbnail = thumbnail
|
||||
books.add(book)
|
||||
} catch (e: Exception) {
|
||||
println("Failed to parse book:")
|
||||
println(GsonBuilder().setPrettyPrinting().create().toJson(jsonBook))
|
||||
println("Parsing error:")
|
||||
println(e)
|
||||
}
|
||||
}
|
||||
return books
|
||||
}
|
||||
|
||||
// Given a populated books list, create a Material Design card in a scroll view for each book.
|
||||
private fun populateBookCards() {
|
||||
for ((index, book) in books.withIndex()) {
|
||||
val card = layoutInflater.inflate(R.layout.book_card, null)
|
||||
updateCardWithBook(card, book)
|
||||
card.findViewById<MaterialButton>(R.id.edit).setOnClickListener {
|
||||
// When the edit button is clicked in a book's card, launch a Flutter activity
|
||||
// showing the details of the book.
|
||||
startActivityForResult(
|
||||
// We're using our own 'FlutterActivity' subclass which wraps Pigeon API usages
|
||||
// into an idiomatic Android activity interface with intent extras as input and
|
||||
// with activity 'setResult' as output.
|
||||
//
|
||||
// This lets activity-level feature developers abstract their Flutter usage
|
||||
// and present a standard Android API to their upstream application developers.
|
||||
//
|
||||
// No Flutter-specific concepts are leaked outside the Flutter activity itself
|
||||
// into the consuming class.
|
||||
FlutterBookActivity
|
||||
// Re-read from the 'books' list rather than just capturing the iterated
|
||||
// 'book' instance since we change it when Dart updates it in onActivityResult.
|
||||
.withBook(this, books[index]),
|
||||
// The index lets us know which book we're returning the result for when we
|
||||
// return from the Flutter activity.
|
||||
index)
|
||||
}
|
||||
list.addView(card)
|
||||
}
|
||||
}
|
||||
|
||||
// Given a Material Design card and a book, update the card content to reflect the book model.
|
||||
private fun updateCardWithBook(card: View, book: Api.Book) {
|
||||
card.findViewById<TextView>(R.id.title).text = book.title
|
||||
card.findViewById<TextView>(R.id.subtitle).text = book.subtitle
|
||||
card.findViewById<TextView>(R.id.author).text = resources.getString(R.string.author_prefix, book.author)
|
||||
}
|
||||
|
||||
// Callback when the Flutter activity started with 'startActivityForResult' above returns.
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
|
||||
// The Flutter activity may cancel the edit. If so, don't update anything.
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (data == null) {
|
||||
throw RuntimeException("The FlutterBookActivity returning RESULT_OK should always have a return data intent")
|
||||
}
|
||||
|
||||
// If the book was edited in Flutter, the Flutter activity finishes and returns an
|
||||
// activity result in an intent (the 'data' argument). The intent has an extra which is
|
||||
// the edited book in serialized form.
|
||||
val returnedBook = FlutterBookActivity.getBookFromResultIntent(data)
|
||||
// Update our book model list.
|
||||
books[requestCode] = returnedBook
|
||||
|
||||
// Refresh the UI here on the Kotlin side.
|
||||
updateCardWithBook(list.getChildAt(requestCode), returnedBook)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
app:liftOnScroll="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nestedScrollView"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/list"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:context=".MainActivity" />
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/spinner"
|
||||
style="?android:attr/progressBarStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true"
|
||||
app:layout_anchor="@+id/nestedScrollView"
|
||||
app:layout_anchorGravity="center" />
|
||||
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="21dp"
|
||||
android:layout_marginStart="21dp"
|
||||
android:layout_marginEnd="21dp"
|
||||
android:layout_marginBottom="2dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?attr/textAppearanceHeadline5"
|
||||
tools:text="Title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:textAppearance="?attr/textAppearanceSubtitle1"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
tools:text="subtitle" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/author"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textAppearance="?attr/textAppearanceBody1"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
tools:text="Author" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="end">
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/edit"
|
||||
style="?attr/borderlessButtonStyle"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 7.7 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#6200EE</color>
|
||||
<color name="colorPrimaryDark">#3700B3</color>
|
||||
<color name="colorAccent">#03DAC5</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">Books</string>
|
||||
<string name="edit">Edit</string>
|
||||
<string name="author_prefix">By: %1$s</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,10 @@
|
||||
<resources>
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
26
add_to_app/books/android_books/build.gradle
Normal file
@@ -0,0 +1,26 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
ext.kotlin_version = "1.6.0"
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:7.4.2"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
21
add_to_app/books/android_books/gradle.properties
Normal file
@@ -0,0 +1,21 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app"s APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
5
add_to_app/books/android_books/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
234
add_to_app/books/android_books/gradlew
vendored
Executable file
@@ -0,0 +1,234 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
89
add_to_app/books/android_books/gradlew.bat
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
7
add_to_app/books/android_books/settings.gradle
Normal file
@@ -0,0 +1,7 @@
|
||||
include ':app'
|
||||
setBinding(new Binding([gradle: this]))
|
||||
evaluate(new File(
|
||||
settingsDir,
|
||||
'../flutter_module_books/.android/include_flutter.groovy'
|
||||
))
|
||||
rootProject.name = "android_books"
|
||||
48
add_to_app/books/flutter_module_books/.gitignore
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
.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
|
||||
.flutter-plugins-dependencies
|
||||
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
|
||||
# Obfuscation related
|
||||
app.*.map.json
|
||||
10
add_to_app/books/flutter_module_books/.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: c0091b289e9966b6da99647b2f18dcb93de1f207
|
||||
channel: master
|
||||
|
||||
project_type: module
|
||||
53
add_to_app/books/flutter_module_books/README.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Books add-to-app sample
|
||||
|
||||
This application simulates a mock scenario in which an existing app with
|
||||
business logic and middleware already exists. It demonstrates how to add Flutter
|
||||
to an app that has established patterns for these domains. For more information
|
||||
on how to use it, see the [README.md](../README.md) parent directory.
|
||||
|
||||
This application also utilizes the [Pigeon](https://pub.dev/packages/pigeon)
|
||||
plugin to avoid manual platform channel wiring. Pigeon autogenerates the
|
||||
platform channel code in Dart/Java/Objective-C to allow interop using higher
|
||||
order functions and data classes instead of string-encoded methods and
|
||||
serialized primitives.
|
||||
|
||||
The Pigeon autogenerated code is checked-in and ready to use. If the schema
|
||||
in `pigeon/schema.dart` is updated, the generated classes can also be re-
|
||||
generated using:
|
||||
|
||||
```shell
|
||||
dart run pigeon --input pigeon/schema.dart \
|
||||
--dart_out lib/api.dart \
|
||||
--objc_header_out ../ios_books/IosBooks/api.h \
|
||||
--objc_source_out ../ios_books/IosBooks/api.m \
|
||||
--objc_prefix BK \
|
||||
--java_out ../android_books/app/src/main/java/dev/flutter/example/books/Api.java \
|
||||
--java_package "dev.flutter.example.books"
|
||||
```
|
||||
|
||||
## Demonstrated concepts
|
||||
|
||||
* An existing books catalog app is already implemented in Kotlin and Swift.
|
||||
* The platform-side app has existing middleware constraints that should also
|
||||
be the middleware foundation for the additional Flutter screen.
|
||||
* On Android, the Kotlin app already uses GSON and OkHttp for networking and
|
||||
references the Google Books API as a data source. These same libraries
|
||||
also underpin the data fetched and shown in the Flutter screen.
|
||||
* The platform application interfaces with the Flutter book details page using
|
||||
idiomatic platform API conventions rather than Flutter conventions.
|
||||
* On Android, the Flutter activity receives the book to show via activity
|
||||
intent and returns the edited book by setting the result intent on the
|
||||
activity. No Flutter concepts are leaked into the consumer activity.
|
||||
* The [pigeon](https://pub.dev/packages/pigeon) plugin is used to generate
|
||||
interop APIs and data classes. The same `Book` model class is used within the
|
||||
Kotlin/Swift program, the Dart program and in the interop between Kotlin/Swift
|
||||
and Dart.
|
||||
|
||||
## More info
|
||||
|
||||
For more information about Flutter, check out
|
||||
[flutter.dev](https://flutter.dev).
|
||||
|
||||
For instructions on how to integrate Flutter modules into your existing
|
||||
applications, see Flutter's
|
||||
[add-to-app documentation](https://flutter.dev/docs/development/add-to-app).
|
||||
@@ -0,0 +1 @@
|
||||
include: ../../../analysis_options.yaml
|
||||
191
add_to_app/books/flutter_module_books/lib/api.dart
Normal file
@@ -0,0 +1,191 @@
|
||||
// Autogenerated from Pigeon (v1.0.1), do not edit directly.
|
||||
// See also: https://pub.dev/packages/pigeon
|
||||
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name
|
||||
// @dart = 2.12
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List;
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class Book {
|
||||
String? title;
|
||||
String? subtitle;
|
||||
String? author;
|
||||
String? summary;
|
||||
String? publishDate;
|
||||
int? pageCount;
|
||||
Thumbnail? thumbnail;
|
||||
|
||||
Object encode() {
|
||||
final pigeonMap = <Object?, Object?>{};
|
||||
pigeonMap['title'] = title;
|
||||
pigeonMap['subtitle'] = subtitle;
|
||||
pigeonMap['author'] = author;
|
||||
pigeonMap['summary'] = summary;
|
||||
pigeonMap['publishDate'] = publishDate;
|
||||
pigeonMap['pageCount'] = pageCount;
|
||||
pigeonMap['thumbnail'] = thumbnail == null ? null : thumbnail!.encode();
|
||||
return pigeonMap;
|
||||
}
|
||||
|
||||
static Book decode(Object message) {
|
||||
final pigeonMap = message as Map<Object?, Object?>;
|
||||
return Book()
|
||||
..title = pigeonMap['title'] as String?
|
||||
..subtitle = pigeonMap['subtitle'] as String?
|
||||
..author = pigeonMap['author'] as String?
|
||||
..summary = pigeonMap['summary'] as String?
|
||||
..publishDate = pigeonMap['publishDate'] as String?
|
||||
..pageCount = pigeonMap['pageCount'] as int?
|
||||
..thumbnail = pigeonMap['thumbnail'] != null
|
||||
? Thumbnail.decode(pigeonMap['thumbnail']!)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
class Thumbnail {
|
||||
String? url;
|
||||
|
||||
Object encode() {
|
||||
final pigeonMap = <Object?, Object?>{};
|
||||
pigeonMap['url'] = url;
|
||||
return pigeonMap;
|
||||
}
|
||||
|
||||
static Thumbnail decode(Object message) {
|
||||
final pigeonMap = message as Map<Object?, Object?>;
|
||||
return Thumbnail()..url = pigeonMap['url'] as String?;
|
||||
}
|
||||
}
|
||||
|
||||
class _FlutterBookApiCodec extends StandardMessageCodec {
|
||||
const _FlutterBookApiCodec();
|
||||
@override
|
||||
void writeValue(WriteBuffer buffer, Object? value) {
|
||||
if (value is Book) {
|
||||
buffer.putUint8(128);
|
||||
writeValue(buffer, value.encode());
|
||||
} else {
|
||||
super.writeValue(buffer, value);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Object? readValueOfType(int type, ReadBuffer buffer) {
|
||||
switch (type) {
|
||||
case 128:
|
||||
return Book.decode(readValue(buffer)!);
|
||||
|
||||
default:
|
||||
return super.readValueOfType(type, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class FlutterBookApi {
|
||||
static const MessageCodec<Object?> codec = _FlutterBookApiCodec();
|
||||
|
||||
void displayBookDetails(Book book);
|
||||
static void setup(FlutterBookApi? api) {
|
||||
{
|
||||
const channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.FlutterBookApi.displayBookDetails', codec);
|
||||
if (api == null) {
|
||||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
// ignore: avoid_types_on_closure_parameters
|
||||
channel.setMessageHandler((Object? message) async {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.FlutterBookApi.displayBookDetails was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final Book? arg_book = args[0] as Book?;
|
||||
assert(arg_book != null,
|
||||
'Argument for dev.flutter.pigeon.FlutterBookApi.displayBookDetails was null, expected non-null Book.');
|
||||
api.displayBookDetails(arg_book!);
|
||||
return;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _HostBookApiCodec extends StandardMessageCodec {
|
||||
const _HostBookApiCodec();
|
||||
@override
|
||||
void writeValue(WriteBuffer buffer, Object? value) {
|
||||
if (value is Book) {
|
||||
buffer.putUint8(128);
|
||||
writeValue(buffer, value.encode());
|
||||
} else {
|
||||
super.writeValue(buffer, value);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Object? readValueOfType(int type, ReadBuffer buffer) {
|
||||
switch (type) {
|
||||
case 128:
|
||||
return Book.decode(readValue(buffer)!);
|
||||
|
||||
default:
|
||||
return super.readValueOfType(type, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class HostBookApi {
|
||||
/// Constructor for [HostBookApi]. The [binaryMessenger] named argument is
|
||||
/// available for dependency injection. If it is left null, the default
|
||||
/// BinaryMessenger will be used which routes to the host platform.
|
||||
HostBookApi({BinaryMessenger? binaryMessenger})
|
||||
: _binaryMessenger = binaryMessenger;
|
||||
|
||||
final BinaryMessenger? _binaryMessenger;
|
||||
|
||||
static const MessageCodec<Object?> codec = _HostBookApiCodec();
|
||||
|
||||
Future<void> cancel() async {
|
||||
final channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.HostBookApi.cancel', codec,
|
||||
binaryMessenger: _binaryMessenger);
|
||||
final Map<Object?, Object?>? replyMap =
|
||||
await channel.send(null) as Map<Object?, Object?>?;
|
||||
if (replyMap == null) {
|
||||
throw PlatformException(
|
||||
code: 'channel-error',
|
||||
message: 'Unable to establish connection on channel.',
|
||||
details: null,
|
||||
);
|
||||
} else if (replyMap['error'] != null) {
|
||||
final error = (replyMap['error'] as Map<Object?, Object?>?)!;
|
||||
throw PlatformException(
|
||||
code: (error['code'] as String?)!,
|
||||
message: error['message'] as String?,
|
||||
details: error['details'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> finishEditingBook(Book arg_book) async {
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.HostBookApi.finishEditingBook', codec,
|
||||
binaryMessenger: _binaryMessenger);
|
||||
final Map<Object?, Object?>? replyMap =
|
||||
await channel.send(<Object>[arg_book]) as Map<Object?, Object?>?;
|
||||
if (replyMap == null) {
|
||||
throw PlatformException(
|
||||
code: 'channel-error',
|
||||
message: 'Unable to establish connection on channel.',
|
||||
details: null,
|
||||
);
|
||||
} else if (replyMap['error'] != null) {
|
||||
final Map<Object?, Object?> error =
|
||||
(replyMap['error'] as Map<Object?, Object?>?)!;
|
||||
throw PlatformException(
|
||||
code: (error['code'] as String?)!,
|
||||
message: error['message'] as String?,
|
||||
details: error['details'],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
239
add_to_app/books/flutter_module_books/lib/main.dart
Normal file
@@ -0,0 +1,239 @@
|
||||
// Copyright 2020 The Flutter team. 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';
|
||||
import 'package:flutter_module_books/api.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(primaryColor: const Color(0xff6200ee)),
|
||||
home: const BookDetail(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
typedef BookReceived = void Function(Book book);
|
||||
|
||||
class FlutterBookApiHandler extends FlutterBookApi {
|
||||
FlutterBookApiHandler(this.callback);
|
||||
|
||||
final BookReceived callback;
|
||||
|
||||
@override
|
||||
void displayBookDetails(Book book) {
|
||||
callback(book);
|
||||
}
|
||||
}
|
||||
|
||||
class BookDetail extends StatefulWidget {
|
||||
const BookDetail({super.key, this.hostApi, this.flutterApi, this.book});
|
||||
|
||||
// These are the outgoing and incoming APIs that are here for injection for
|
||||
// tests.
|
||||
final HostBookApi? hostApi;
|
||||
final FlutterBookApi? flutterApi;
|
||||
final Book? book;
|
||||
|
||||
@override
|
||||
State<BookDetail> createState() => _BookDetailState();
|
||||
}
|
||||
|
||||
class _BookDetailState extends State<BookDetail> {
|
||||
Book? book;
|
||||
|
||||
late HostBookApi hostApi;
|
||||
|
||||
FocusNode textFocusNode = FocusNode();
|
||||
TextEditingController titleTextController = TextEditingController();
|
||||
TextEditingController subtitleTextController = TextEditingController();
|
||||
TextEditingController authorTextController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
book = widget.book;
|
||||
|
||||
// This `HostBookApi` class instance lets us make outgoing calls to the
|
||||
// platform.
|
||||
hostApi = widget.hostApi ?? HostBookApi();
|
||||
|
||||
// Registering this `FlutterBookApiHandler` class lets us receive incoming
|
||||
// calls from the platform.
|
||||
FlutterBookApi.setup(
|
||||
FlutterBookApiHandler(
|
||||
// The `FlutterBookApi` just has one method. Just give a closure for that
|
||||
// method to the handler class.
|
||||
(book) {
|
||||
setState(() {
|
||||
// This book model is what we're going to return to Kotlin eventually.
|
||||
// Keep it bound to the UI.
|
||||
this.book = book;
|
||||
titleTextController.text = book.title ?? '';
|
||||
titleTextController.addListener(() {
|
||||
this.book!.title = titleTextController.text;
|
||||
});
|
||||
// Subtitle could be null.
|
||||
subtitleTextController.text = book.subtitle ?? '';
|
||||
subtitleTextController.addListener(() {
|
||||
this.book!.subtitle = subtitleTextController.text;
|
||||
});
|
||||
authorTextController.text = book.author ?? '';
|
||||
authorTextController.addListener(() {
|
||||
this.book!.author = authorTextController.text;
|
||||
});
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Not overriding didUpdateWidget because the Android program can't change
|
||||
// the book given to Flutter on the Android side.
|
||||
|
||||
void clear() {
|
||||
book = null;
|
||||
// Keep focus if going to the home screen but unfocus if leaving
|
||||
// the activity.
|
||||
textFocusNode.unfocus();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Book Details'),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
// Pressing clear cancels the edit and leaves the activity without
|
||||
// modification.
|
||||
onPressed: () {
|
||||
hostApi.cancel();
|
||||
clear();
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.check),
|
||||
// Pressing save sends the updated book to the platform.
|
||||
onPressed: book != null
|
||||
? () {
|
||||
hostApi.finishEditingBook(book!);
|
||||
clear();
|
||||
}
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
body: book == null
|
||||
// Draw a spinner until the platform gives us the book to show details
|
||||
// for.
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: BookForm(
|
||||
book: book!,
|
||||
focusNode: textFocusNode,
|
||||
authorTextController: authorTextController,
|
||||
subtitleTextController: subtitleTextController,
|
||||
titleTextController: titleTextController,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BookForm extends StatelessWidget {
|
||||
const BookForm({
|
||||
super.key,
|
||||
required this.book,
|
||||
required this.focusNode,
|
||||
required this.authorTextController,
|
||||
required this.subtitleTextController,
|
||||
required this.titleTextController,
|
||||
});
|
||||
|
||||
final Book book;
|
||||
final FocusNode focusNode;
|
||||
final TextEditingController titleTextController;
|
||||
final TextEditingController subtitleTextController;
|
||||
final TextEditingController authorTextController;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Focus(
|
||||
focusNode: focusNode,
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
children: [
|
||||
TextField(
|
||||
controller: titleTextController,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
filled: true,
|
||||
hintText: "Title",
|
||||
labelText: "Title",
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
TextField(
|
||||
controller: subtitleTextController,
|
||||
maxLines: 2,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
filled: true,
|
||||
hintText: "Subtitle",
|
||||
labelText: "Subtitle",
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
TextField(
|
||||
controller: authorTextController,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
filled: true,
|
||||
hintText: "Author",
|
||||
labelText: "Author",
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
const Divider(),
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'${book.pageCount} pages ~ published ${book.publishDate}',
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
const SizedBox(height: 32),
|
||||
if (book.thumbnail?.url != null) ...[
|
||||
Center(child: Image.network(book.thumbnail!.url!)),
|
||||
const SizedBox(height: 32),
|
||||
],
|
||||
if (book.summary != null) ...[
|
||||
const Center(
|
||||
child: Text(
|
||||
'BOOK DESCRIPTION',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
book.summary ?? '',
|
||||
style: TextStyle(color: Colors.grey.shade600, height: 1.24),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
30
add_to_app/books/flutter_module_books/pigeon/schema.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright 2020 The Flutter team. 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:pigeon/pigeon.dart';
|
||||
|
||||
class Book {
|
||||
String? title;
|
||||
String? subtitle;
|
||||
String? author;
|
||||
String? summary;
|
||||
String? publishDate;
|
||||
int? pageCount;
|
||||
Thumbnail? thumbnail;
|
||||
}
|
||||
|
||||
class Thumbnail {
|
||||
String? url;
|
||||
}
|
||||
|
||||
@FlutterApi()
|
||||
abstract class FlutterBookApi {
|
||||
void displayBookDetails(Book book);
|
||||
}
|
||||
|
||||
@HostApi()
|
||||
abstract class HostBookApi {
|
||||
void cancel();
|
||||
void finishEditingBook(Book book);
|
||||
}
|
||||
34
add_to_app/books/flutter_module_books/pubspec.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
name: flutter_module_books
|
||||
description: A Flutter module using the Pigeon package to demonstrate
|
||||
integrating Flutter in a realistic scenario where the existing platform app
|
||||
already has business logic and middleware constraints.
|
||||
version: 1.0.0+1
|
||||
resolution: workspace
|
||||
|
||||
environment:
|
||||
sdk: ^3.9.0-0
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
dev_dependencies:
|
||||
analysis_defaults:
|
||||
path: ../../../analysis_defaults
|
||||
pigeon: ">=11.0.0 <27.0.0"
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
# 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:
|
||||
androidX: true
|
||||
androidPackage: dev.flutter.example.flutter_module_books
|
||||
iosBundleIdentifier: dev.flutter.example.flutterModuleBooks
|
||||
8
add_to_app/books/flutter_module_books/run_pigeon.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
dart run pigeon --input pigeon/schema.dart \
|
||||
--dart_out lib/api.dart \
|
||||
--objc_header_out ../ios_books/IosBooks/api.h \
|
||||
--objc_source_out ../ios_books/IosBooks/api.m \
|
||||
--objc_prefix BK \
|
||||
--java_out ../android_books/app/src/main/java/dev/flutter/example/books/Api.java \
|
||||
--java_package "dev.flutter.example.books"
|
||||
54
add_to_app/books/flutter_module_books/test/widget_test.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright 2020 The Flutter team. 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';
|
||||
import 'package:flutter_module_books/api.dart';
|
||||
import 'package:flutter_module_books/main.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Pressing clear calls the cancel API', (tester) async {
|
||||
MockHostBookApi mockHostApi = MockHostBookApi();
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(home: BookDetail(hostApi: mockHostApi)),
|
||||
);
|
||||
|
||||
await tester.tap(find.byIcon(Icons.clear));
|
||||
|
||||
expect(mockHostApi.cancelCalls, 1);
|
||||
});
|
||||
|
||||
testWidgets('Pressing done calls the finish editing API', (
|
||||
tester,
|
||||
) async {
|
||||
MockHostBookApi mockHostApi = MockHostBookApi();
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: BookDetail(book: Book(), hostApi: mockHostApi),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byIcon(Icons.check));
|
||||
|
||||
expect(mockHostApi.booksFinished.length, 1);
|
||||
});
|
||||
}
|
||||
|
||||
// A super-simple mock for testing that calls are made to the API.
|
||||
class MockHostBookApi implements HostBookApi {
|
||||
int cancelCalls = 0;
|
||||
final booksFinished = <Book>[];
|
||||
|
||||
@override
|
||||
Future<void> cancel() async {
|
||||
cancelCalls++;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> finishEditingBook(Book arg) async {
|
||||
booksFinished.add(arg);
|
||||
}
|
||||
}
|
||||
2
add_to_app/books/ios_books/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
xcuserdata
|
||||
Pods
|
||||
438
add_to_app/books/ios_books/IosBooks.xcodeproj/project.pbxproj
Normal file
@@ -0,0 +1,438 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
00365BF7846F71A1052D8F66 /* Pods_IosBooks.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DEE09DC86DF77B0A62A53D22 /* Pods_IosBooks.framework */; };
|
||||
0DDE4C3B25E0390700389930 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DDE4C3A25E0390700389930 /* AppDelegate.swift */; };
|
||||
0DDE4C3D25E0390700389930 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DDE4C3C25E0390700389930 /* SceneDelegate.swift */; };
|
||||
0DDE4C3F25E0390700389930 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DDE4C3E25E0390700389930 /* ViewController.swift */; };
|
||||
0DDE4C4225E0390700389930 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0DDE4C4025E0390700389930 /* Main.storyboard */; };
|
||||
0DDE4C4425E0390700389930 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0DDE4C4325E0390700389930 /* Assets.xcassets */; };
|
||||
0DDE4C4725E0390700389930 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0DDE4C4525E0390700389930 /* LaunchScreen.storyboard */; };
|
||||
0DDE4C5725E041B700389930 /* BookCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DDE4C5625E041B700389930 /* BookCell.swift */; };
|
||||
0DDE4C5C25E0752A00389930 /* api.m in Sources */ = {isa = PBXBuildFile; fileRef = 0DDE4C5B25E0752A00389930 /* api.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0DDE4C3725E0390700389930 /* IosBooks.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = IosBooks.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
0DDE4C3A25E0390700389930 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
0DDE4C3C25E0390700389930 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||
0DDE4C3E25E0390700389930 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||
0DDE4C4125E0390700389930 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
0DDE4C4325E0390700389930 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
0DDE4C4625E0390700389930 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
0DDE4C4825E0390700389930 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
0DDE4C5625E041B700389930 /* BookCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookCell.swift; sourceTree = "<group>"; };
|
||||
0DDE4C5925E0752900389930 /* IosBooks-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "IosBooks-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
0DDE4C5A25E0752A00389930 /* api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = api.h; sourceTree = "<group>"; };
|
||||
0DDE4C5B25E0752A00389930 /* api.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = api.m; sourceTree = "<group>"; };
|
||||
18154B6C0196BC72EA210903 /* Pods-IosBooks.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IosBooks.release.xcconfig"; path = "Target Support Files/Pods-IosBooks/Pods-IosBooks.release.xcconfig"; sourceTree = "<group>"; };
|
||||
CC7F3EDAABB4C083AD5BFC47 /* Pods-IosBooks.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IosBooks.debug.xcconfig"; path = "Target Support Files/Pods-IosBooks/Pods-IosBooks.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
DEE09DC86DF77B0A62A53D22 /* Pods_IosBooks.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_IosBooks.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
0DDE4C3425E0390700389930 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
00365BF7846F71A1052D8F66 /* Pods_IosBooks.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
0DDE4C2E25E0390700389930 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0DDE4C3925E0390700389930 /* IosBooks */,
|
||||
0DDE4C3825E0390700389930 /* Products */,
|
||||
1CA615579663E7DAA193BE81 /* Pods */,
|
||||
4E1F60927412758AE8CBF737 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0DDE4C3825E0390700389930 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0DDE4C3725E0390700389930 /* IosBooks.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0DDE4C3925E0390700389930 /* IosBooks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0DDE4C5A25E0752A00389930 /* api.h */,
|
||||
0DDE4C5B25E0752A00389930 /* api.m */,
|
||||
0DDE4C3A25E0390700389930 /* AppDelegate.swift */,
|
||||
0DDE4C3C25E0390700389930 /* SceneDelegate.swift */,
|
||||
0DDE4C3E25E0390700389930 /* ViewController.swift */,
|
||||
0DDE4C4025E0390700389930 /* Main.storyboard */,
|
||||
0DDE4C4325E0390700389930 /* Assets.xcassets */,
|
||||
0DDE4C4525E0390700389930 /* LaunchScreen.storyboard */,
|
||||
0DDE4C4825E0390700389930 /* Info.plist */,
|
||||
0DDE4C5625E041B700389930 /* BookCell.swift */,
|
||||
0DDE4C5925E0752900389930 /* IosBooks-Bridging-Header.h */,
|
||||
);
|
||||
path = IosBooks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1CA615579663E7DAA193BE81 /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CC7F3EDAABB4C083AD5BFC47 /* Pods-IosBooks.debug.xcconfig */,
|
||||
18154B6C0196BC72EA210903 /* Pods-IosBooks.release.xcconfig */,
|
||||
);
|
||||
path = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
4E1F60927412758AE8CBF737 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DEE09DC86DF77B0A62A53D22 /* Pods_IosBooks.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
0DDE4C3625E0390700389930 /* IosBooks */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 0DDE4C4B25E0390700389930 /* Build configuration list for PBXNativeTarget "IosBooks" */;
|
||||
buildPhases = (
|
||||
10D6942EFE7900338BEA50F9 /* [CP] Check Pods Manifest.lock */,
|
||||
887B098B8DCF409FE0F1E164 /* [CP-User] Run Flutter Build flutter_module_books Script */,
|
||||
0DDE4C3325E0390700389930 /* Sources */,
|
||||
0DDE4C3425E0390700389930 /* Frameworks */,
|
||||
0DDE4C3525E0390700389930 /* Resources */,
|
||||
CA4628050A0CDB5CBFD737AD /* [CP-User] Embed Flutter Build flutter_module_books Script */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = IosBooks;
|
||||
productName = IosBooks;
|
||||
productReference = 0DDE4C3725E0390700389930 /* IosBooks.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
0DDE4C2F25E0390700389930 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 1220;
|
||||
LastUpgradeCheck = 1220;
|
||||
TargetAttributes = {
|
||||
0DDE4C3625E0390700389930 = {
|
||||
CreatedOnToolsVersion = 12.2;
|
||||
LastSwiftMigration = 1220;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 0DDE4C3225E0390700389930 /* Build configuration list for PBXProject "IosBooks" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 0DDE4C2E25E0390700389930;
|
||||
productRefGroup = 0DDE4C3825E0390700389930 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
0DDE4C3625E0390700389930 /* IosBooks */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
0DDE4C3525E0390700389930 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0DDE4C4725E0390700389930 /* LaunchScreen.storyboard in Resources */,
|
||||
0DDE4C4425E0390700389930 /* Assets.xcassets in Resources */,
|
||||
0DDE4C4225E0390700389930 /* Main.storyboard in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
10D6942EFE7900338BEA50F9 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||
"${PODS_ROOT}/Manifest.lock",
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
"$(DERIVED_FILE_DIR)/Pods-IosBooks-checkManifestLockResult.txt",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
887B098B8DCF409FE0F1E164 /* [CP-User] Run Flutter Build flutter_module_books Script */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
name = "[CP-User] Run Flutter Build flutter_module_books Script";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "set -e\nset -u\nsource \"${SRCROOT}/../flutter_module_books/.ios/Flutter/flutter_export_environment.sh\"\nexport VERBOSE_SCRIPT_LOGGING=1 && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh build";
|
||||
};
|
||||
CA4628050A0CDB5CBFD737AD /* [CP-User] Embed Flutter Build flutter_module_books Script */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
name = "[CP-User] Embed Flutter Build flutter_module_books Script";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "set -e\nset -u\nsource \"${SRCROOT}/../flutter_module_books/.ios/Flutter/flutter_export_environment.sh\"\nexport VERBOSE_SCRIPT_LOGGING=1 && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh embed_and_thin";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
0DDE4C3325E0390700389930 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0DDE4C5725E041B700389930 /* BookCell.swift in Sources */,
|
||||
0DDE4C3F25E0390700389930 /* ViewController.swift in Sources */,
|
||||
0DDE4C5C25E0752A00389930 /* api.m in Sources */,
|
||||
0DDE4C3B25E0390700389930 /* AppDelegate.swift in Sources */,
|
||||
0DDE4C3D25E0390700389930 /* SceneDelegate.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
0DDE4C4025E0390700389930 /* Main.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
0DDE4C4125E0390700389930 /* Base */,
|
||||
);
|
||||
name = Main.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0DDE4C4525E0390700389930 /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
0DDE4C4625E0390700389930 /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
0DDE4C4925E0390700389930 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
0DDE4C4A25E0390700389930 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
0DDE4C4C25E0390700389930 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = CC7F3EDAABB4C083AD5BFC47 /* Pods-IosBooks.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
INFOPLIST_FILE = IosBooks/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.samples.IosBooks;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "IosBooks/IosBooks-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
0DDE4C4D25E0390700389930 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 18154B6C0196BC72EA210903 /* Pods-IosBooks.release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
INFOPLIST_FILE = IosBooks/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.samples.IosBooks;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "IosBooks/IosBooks-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
0DDE4C3225E0390700389930 /* Build configuration list for PBXProject "IosBooks" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
0DDE4C4925E0390700389930 /* Debug */,
|
||||
0DDE4C4A25E0390700389930 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
0DDE4C4B25E0390700389930 /* Build configuration list for PBXNativeTarget "IosBooks" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
0DDE4C4C25E0390700389930 /* Debug */,
|
||||
0DDE4C4D25E0390700389930 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 0DDE4C2F25E0390700389930 /* Project object */;
|
||||
}
|
||||
7
add_to_app/books/ios_books/IosBooks.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1320"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0DDE4C3625E0390700389930"
|
||||
BuildableName = "IosBooks.app"
|
||||
BlueprintName = "IosBooks"
|
||||
ReferencedContainer = "container:IosBooks.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0DDE4C3625E0390700389930"
|
||||
BuildableName = "IosBooks.app"
|
||||
BlueprintName = "IosBooks"
|
||||
ReferencedContainer = "container:IosBooks.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0DDE4C3625E0390700389930"
|
||||
BuildableName = "IosBooks.app"
|
||||
BlueprintName = "IosBooks"
|
||||
ReferencedContainer = "container:IosBooks.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
10
add_to_app/books/ios_books/IosBooks.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:IosBooks.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Pods/Pods.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
37
add_to_app/books/ios_books/IosBooks/AppDelegate.swift
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright 2020 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import Flutter
|
||||
import UIKit
|
||||
|
||||
@main
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
lazy var engine: FlutterEngine = {
|
||||
let result = FlutterEngine.init(name: "Books")
|
||||
// This could be `run` earlier in the app to avoid the overhead of doing it the first time the
|
||||
// engine is needed.
|
||||
result.run()
|
||||
return result
|
||||
}()
|
||||
|
||||
func application(
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||
) -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func application(
|
||||
_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession,
|
||||
options: UIScene.ConnectionOptions
|
||||
) -> UISceneConfiguration {
|
||||
return UISceneConfiguration(
|
||||
name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||
}
|
||||
|
||||
func application(
|
||||
_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "83.5x83.5"
|
||||
},
|
||||
{
|
||||
"idiom" : "ios-marketing",
|
||||
"scale" : "1x",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
119
add_to_app/books/ios_books/IosBooks/Base.lproj/Main.storyboard
Normal file
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="b8i-Fj-lA1">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
|
||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="srE-pH-qZb">
|
||||
<objects>
|
||||
<navigationController id="b8i-Fj-lA1" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="wTo-xw-305">
|
||||
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<color key="barTintColor" red="0.38431372549019605" green="0.0" blue="0.93333333333333335" alpha="0.84705882352941175" colorSpace="calibratedRGB"/>
|
||||
<textAttributes key="titleTextAttributes">
|
||||
<color key="textColor" systemColor="systemGray6Color"/>
|
||||
</textAttributes>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
<segue destination="Xp0-05-6gn" kind="relationship" relationship="rootViewController" id="yik-Yg-HdC"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="NW2-DP-JZL" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-1328" y="-17"/>
|
||||
</scene>
|
||||
<!--Books-->
|
||||
<scene sceneID="Ywb-fB-wBN">
|
||||
<objects>
|
||||
<tableViewController title="Books" id="Xp0-05-6gn" customClass="ViewController" customModule="IosBooks" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" allowsSelection="NO" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="uCy-ec-yGR">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="BookCell" rowHeight="190" id="SBb-uI-gbV" customClass="BookCell" customModule="IosBooks" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="28" width="414" height="190"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="SBb-uI-gbV" id="C7V-w9-p66">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="190"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Book Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7KN-aJ-DT5">
|
||||
<rect key="frame" x="20" y="11" width="374" height="29"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="24"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Uh5-nw-lRt">
|
||||
<rect key="frame" x="20" y="48" width="374" height="41"/>
|
||||
<string key="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc velit orci, varius tincidunt nisi ac, porta porta ipsum. Pellentesque feugiat consequat massa, facilisis euismod turpis aliquam at. Suspendisse mollis volutpat lacinia. Aenean tristique porttitor purus, eu porta sem tempor sit amet. </string>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="By: Foobar F. Foobar" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="76v-Ju-4Wc">
|
||||
<rect key="frame" x="20" y="111" width="374" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="b0u-fM-VM6">
|
||||
<rect key="frame" x="350" y="140" width="44" height="44"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="44" id="Vf7-pJ-LZ3"/>
|
||||
<constraint firstAttribute="height" constant="44" id="cfM-g4-ptv"/>
|
||||
</constraints>
|
||||
<state key="normal" title="Edit"/>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="b0u-fM-VM6" secondAttribute="bottom" constant="6" id="BPN-jO-sVu"/>
|
||||
<constraint firstItem="7KN-aJ-DT5" firstAttribute="leading" secondItem="C7V-w9-p66" secondAttribute="leadingMargin" id="DsW-Gq-sjE"/>
|
||||
<constraint firstItem="7KN-aJ-DT5" firstAttribute="trailing" secondItem="C7V-w9-p66" secondAttribute="trailingMargin" id="IVX-uA-An6"/>
|
||||
<constraint firstItem="7KN-aJ-DT5" firstAttribute="top" secondItem="C7V-w9-p66" secondAttribute="topMargin" id="Iip-4a-2kS"/>
|
||||
<constraint firstItem="76v-Ju-4Wc" firstAttribute="leading" secondItem="C7V-w9-p66" secondAttribute="leadingMargin" id="ZbD-YJ-kaV"/>
|
||||
<constraint firstItem="76v-Ju-4Wc" firstAttribute="top" secondItem="Uh5-nw-lRt" secondAttribute="bottom" constant="22" id="cyp-xR-7If"/>
|
||||
<constraint firstItem="b0u-fM-VM6" firstAttribute="trailing" secondItem="C7V-w9-p66" secondAttribute="trailingMargin" id="gSP-0I-VmO"/>
|
||||
<constraint firstItem="b0u-fM-VM6" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="C7V-w9-p66" secondAttribute="leadingMargin" id="gzq-Ig-PZI"/>
|
||||
<constraint firstItem="b0u-fM-VM6" firstAttribute="top" secondItem="76v-Ju-4Wc" secondAttribute="bottom" constant="8" symbolic="YES" id="lCb-GM-BvA"/>
|
||||
<constraint firstItem="Uh5-nw-lRt" firstAttribute="trailing" secondItem="C7V-w9-p66" secondAttribute="trailingMargin" id="p6I-sS-CN3"/>
|
||||
<constraint firstItem="Uh5-nw-lRt" firstAttribute="leading" secondItem="C7V-w9-p66" secondAttribute="leadingMargin" id="qcT-uN-mqo"/>
|
||||
<constraint firstItem="Uh5-nw-lRt" firstAttribute="top" secondItem="7KN-aJ-DT5" secondAttribute="bottom" constant="8" symbolic="YES" id="r2u-eT-RhX"/>
|
||||
<constraint firstItem="76v-Ju-4Wc" firstAttribute="trailing" secondItem="C7V-w9-p66" secondAttribute="trailingMargin" id="zc4-dZ-JcM"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<outlet property="byLine" destination="76v-Ju-4Wc" id="9Ky-Yc-aXU"/>
|
||||
<outlet property="editButton" destination="b0u-fM-VM6" id="q99-MH-ThV"/>
|
||||
<outlet property="subtitle" destination="Uh5-nw-lRt" id="UGS-IB-WV1"/>
|
||||
<outlet property="title" destination="7KN-aJ-DT5" id="a5N-rW-azA"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<sections/>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="Xp0-05-6gn" id="nso-Wx-y17"/>
|
||||
<outlet property="delegate" destination="Xp0-05-6gn" id="Gk5-ND-hmv"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" id="Mr1-af-Ogz"/>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="17x-S3-agc" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-371.01449275362324" y="-17.410714285714285"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<systemColor name="systemBackgroundColor">
|
||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemGray6Color">
|
||||
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
8
add_to_app/books/ios_books/IosBooks/BookCell.swift
Normal file
@@ -0,0 +1,8 @@
|
||||
import UIKit
|
||||
|
||||
class BookCell: UITableViewCell {
|
||||
@IBOutlet weak var title: UILabel!
|
||||
@IBOutlet weak var subtitle: UILabel!
|
||||
@IBOutlet weak var byLine: UILabel!
|
||||
@IBOutlet weak var editButton: UIButton!
|
||||
}
|
||||
66
add_to_app/books/ios_books/IosBooks/Info.plist
Normal file
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIApplicationSceneManifest</key>
|
||||
<dict>
|
||||
<key>UIApplicationSupportsMultipleScenes</key>
|
||||
<false/>
|
||||
<key>UISceneConfigurations</key>
|
||||
<dict>
|
||||
<key>UIWindowSceneSessionRoleApplication</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UISceneConfigurationName</key>
|
||||
<string>Default Configuration</string>
|
||||
<key>UISceneDelegateClassName</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||
<key>UISceneStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
||||
//
|
||||
|
||||
#import "api.h"
|
||||
69
add_to_app/books/ios_books/IosBooks/SceneDelegate.swift
Normal file
@@ -0,0 +1,69 @@
|
||||
// Copyright 2020 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import Flutter
|
||||
import UIKit
|
||||
|
||||
class SceneDelegate: UIResponder, UIWindowSceneDelegate, FlutterSceneLifeCycleProvider
|
||||
{
|
||||
var sceneLifeCycleDelegate: FlutterPluginSceneLifeCycleDelegate =
|
||||
FlutterPluginSceneLifeCycleDelegate()
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
func scene(
|
||||
_ scene: UIScene,
|
||||
willConnectTo session: UISceneSession,
|
||||
options connectionOptions: UIScene.ConnectionOptions
|
||||
) {
|
||||
sceneLifeCycleDelegate.scene(
|
||||
scene,
|
||||
willConnectTo: session,
|
||||
options: connectionOptions
|
||||
)
|
||||
}
|
||||
|
||||
func sceneDidDisconnect(_ scene: UIScene) {
|
||||
sceneLifeCycleDelegate.sceneDidDisconnect(scene)
|
||||
}
|
||||
|
||||
func sceneWillEnterForeground(_ scene: UIScene) {
|
||||
sceneLifeCycleDelegate.sceneWillEnterForeground(scene)
|
||||
}
|
||||
|
||||
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||
sceneLifeCycleDelegate.sceneDidBecomeActive(scene)
|
||||
}
|
||||
|
||||
func sceneWillResignActive(_ scene: UIScene) {
|
||||
sceneLifeCycleDelegate.sceneWillResignActive(scene)
|
||||
}
|
||||
|
||||
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||
sceneLifeCycleDelegate.sceneDidEnterBackground(scene)
|
||||
}
|
||||
|
||||
func scene(
|
||||
_ scene: UIScene,
|
||||
openURLContexts URLContexts: Set<UIOpenURLContext>
|
||||
) {
|
||||
sceneLifeCycleDelegate.scene(scene, openURLContexts: URLContexts)
|
||||
}
|
||||
|
||||
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
|
||||
sceneLifeCycleDelegate.scene(scene, continue: userActivity)
|
||||
}
|
||||
|
||||
func windowScene(
|
||||
_ windowScene: UIWindowScene,
|
||||
performActionFor shortcutItem: UIApplicationShortcutItem,
|
||||
completionHandler: @escaping (Bool) -> Void
|
||||
) {
|
||||
sceneLifeCycleDelegate.windowScene(
|
||||
windowScene,
|
||||
performActionFor: shortcutItem,
|
||||
completionHandler: completionHandler
|
||||
)
|
||||
}
|
||||
}
|
||||
135
add_to_app/books/ios_books/IosBooks/ViewController.swift
Normal file
@@ -0,0 +1,135 @@
|
||||
// Copyright 2020 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import Flutter
|
||||
import UIKit
|
||||
|
||||
class ViewController: UITableViewController, BKHostBookApi {
|
||||
private var books: [BKBook] = []
|
||||
private var api: BKFlutterBookApi!
|
||||
private var editingIndex: Int = -1
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.navigationItem.title = "Books"
|
||||
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
||||
BKHostBookApiSetup(appDelegate.engine.binaryMessenger, self)
|
||||
api = BKFlutterBookApi.init(binaryMessenger: appDelegate.engine.binaryMessenger)
|
||||
if let url = URL(
|
||||
string: "https://www.googleapis.com/books/v1/volumes?q=greenwood+tulsa&maxResults=15")
|
||||
{
|
||||
self.loadBooks(url: url) { (newBooks) in
|
||||
if let newBooks = newBooks {
|
||||
self.books = newBooks
|
||||
self.tableView.reloadData()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Loads a JSON file from the supplied URL, parses it and calls the callback with the array of
|
||||
parsed books on the main thread.
|
||||
*/
|
||||
func loadBooks(url: URL, completion: @escaping ([BKBook]?) -> Void) {
|
||||
URLSession.shared.dataTask(with: url) { data, response, error in
|
||||
if let data = data {
|
||||
do {
|
||||
if let json = try JSONSerialization.jsonObject(with: data, options: [])
|
||||
as? [String: Any]
|
||||
{
|
||||
var newBooks: [BKBook] = []
|
||||
for item in json["items"] as! [[String: Any]] {
|
||||
let volumeInfo = item["volumeInfo"] as! [String: Any]
|
||||
let title = volumeInfo["title"] as! String
|
||||
let subtitle = volumeInfo["subtitle"] as! String?
|
||||
let authors = (volumeInfo["authors"] as! [String]).joined(separator: " & ")
|
||||
let pageCount = volumeInfo["pageCount"] as! Int32
|
||||
let publishedDate = volumeInfo["publishedDate"] as! String
|
||||
let summary = volumeInfo["description"] as! String?
|
||||
let imageLinks = volumeInfo["imageLinks"] as! [String: Any]
|
||||
let thumbnail: BKThumbnail = BKThumbnail.init()
|
||||
thumbnail.url = imageLinks["thumbnail"] as! String?
|
||||
let book: BKBook = BKBook.init()
|
||||
book.author = authors
|
||||
book.title = title
|
||||
book.subtitle = subtitle
|
||||
book.title = title
|
||||
book.pageCount = NSNumber.init(value: pageCount)
|
||||
book.publishDate = publishedDate
|
||||
book.summary = summary
|
||||
book.thumbnail = thumbnail
|
||||
newBooks.append(book)
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
completion(newBooks)
|
||||
}
|
||||
}
|
||||
} catch let error {
|
||||
print("json decode error: \(error)")
|
||||
completion(nil)
|
||||
}
|
||||
}
|
||||
}.resume()
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return self.books.count
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath)
|
||||
-> UITableViewCell
|
||||
{
|
||||
let cell: BookCell = self.tableView.dequeueReusableCell(withIdentifier: "BookCell") as! BookCell
|
||||
let bookInfo = books[indexPath.row]
|
||||
cell.title.text = bookInfo.title
|
||||
cell.subtitle.text = bookInfo.subtitle
|
||||
if let author = bookInfo.author {
|
||||
cell.byLine.text = "by: \(author)"
|
||||
}
|
||||
weak var weakSelf = self
|
||||
let editAction = UIAction(title: "Edit") { (action) in
|
||||
if let weakSelf = weakSelf {
|
||||
weakSelf.editItem(index: indexPath.row)
|
||||
}
|
||||
}
|
||||
cell.editButton.removeTarget(nil, action: nil, for: .allEvents)
|
||||
cell.editButton.addAction(editAction, for: UIControl.Event.touchUpInside)
|
||||
return cell
|
||||
}
|
||||
|
||||
/**
|
||||
Presents the FlutterViewController that edits the book at the supplied index.
|
||||
*/
|
||||
func editItem(index: Int) {
|
||||
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
||||
let flutterViewController = FlutterViewController.init(
|
||||
engine: appDelegate.engine, nibName: nil, bundle: nil)
|
||||
self.editingIndex = index
|
||||
api.displayBookDetailsBook(self.books[index]) { (error) in
|
||||
if let error = error {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
self.present(flutterViewController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
/**
|
||||
Called by Pigeon when the FlutterViewController is dismissed without accepting any edits.
|
||||
*/
|
||||
func cancelWithError(_ error: AutoreleasingUnsafeMutablePointer<FlutterError?>) {
|
||||
self.editingIndex = -1
|
||||
self.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
||||
/**
|
||||
Called by Pigeon when edits to the book are accepted in the FlutterViewController.
|
||||
*/
|
||||
func finishEditingBook(_ input: BKBook, error: AutoreleasingUnsafeMutablePointer<FlutterError?>) {
|
||||
self.books[editingIndex] = input
|
||||
self.tableView.reloadData()
|
||||
self.editingIndex = -1
|
||||
self.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
49
add_to_app/books/ios_books/IosBooks/api.h
Normal file
@@ -0,0 +1,49 @@
|
||||
// Autogenerated from Pigeon (v1.0.1), do not edit directly.
|
||||
// See also: https://pub.dev/packages/pigeon
|
||||
#import <Foundation/Foundation.h>
|
||||
@protocol FlutterBinaryMessenger;
|
||||
@protocol FlutterMessageCodec;
|
||||
@class FlutterError;
|
||||
@class FlutterStandardTypedData;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class BKBook;
|
||||
@class BKThumbnail;
|
||||
|
||||
@interface BKBook : NSObject
|
||||
@property(nonatomic, copy, nullable) NSString *title;
|
||||
@property(nonatomic, copy, nullable) NSString *subtitle;
|
||||
@property(nonatomic, copy, nullable) NSString *author;
|
||||
@property(nonatomic, copy, nullable) NSString *summary;
|
||||
@property(nonatomic, copy, nullable) NSString *publishDate;
|
||||
@property(nonatomic, strong, nullable) NSNumber *pageCount;
|
||||
@property(nonatomic, strong, nullable) BKThumbnail *thumbnail;
|
||||
@end
|
||||
|
||||
@interface BKThumbnail : NSObject
|
||||
@property(nonatomic, copy, nullable) NSString *url;
|
||||
@end
|
||||
|
||||
/// The codec used by BKFlutterBookApi.
|
||||
NSObject<FlutterMessageCodec> *BKFlutterBookApiGetCodec(void);
|
||||
|
||||
@interface BKFlutterBookApi : NSObject
|
||||
- (instancetype)initWithBinaryMessenger:
|
||||
(id<FlutterBinaryMessenger>)binaryMessenger;
|
||||
- (void)displayBookDetailsBook:(BKBook *)book
|
||||
completion:(void (^)(NSError *_Nullable))completion;
|
||||
@end
|
||||
/// The codec used by BKHostBookApi.
|
||||
NSObject<FlutterMessageCodec> *BKHostBookApiGetCodec(void);
|
||||
|
||||
@protocol BKHostBookApi
|
||||
- (void)cancelWithError:(FlutterError *_Nullable *_Nonnull)error;
|
||||
- (void)finishEditingBookBook:(BKBook *)book
|
||||
error:(FlutterError *_Nullable *_Nonnull)error;
|
||||
@end
|
||||
|
||||
extern void BKHostBookApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
|
||||
NSObject<BKHostBookApi> *_Nullable api);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
269
add_to_app/books/ios_books/IosBooks/api.m
Normal file
@@ -0,0 +1,269 @@
|
||||
// Autogenerated from Pigeon (v1.0.1), do not edit directly.
|
||||
// See also: https://pub.dev/packages/pigeon
|
||||
#import "api.h"
|
||||
#import <Flutter/Flutter.h>
|
||||
|
||||
#if !__has_feature(objc_arc)
|
||||
#error File requires ARC to be enabled.
|
||||
#endif
|
||||
|
||||
static NSDictionary<NSString *, id> *wrapResult(id result,
|
||||
FlutterError *error) {
|
||||
NSDictionary *errorDict = (NSDictionary *)[NSNull null];
|
||||
if (error) {
|
||||
errorDict = @{
|
||||
@"code" : (error.code ? error.code : [NSNull null]),
|
||||
@"message" : (error.message ? error.message : [NSNull null]),
|
||||
@"details" : (error.details ? error.details : [NSNull null]),
|
||||
};
|
||||
}
|
||||
return @{
|
||||
@"result" : (result ? result : [NSNull null]),
|
||||
@"error" : errorDict,
|
||||
};
|
||||
}
|
||||
|
||||
@interface BKBook ()
|
||||
+ (BKBook *)fromMap:(NSDictionary *)dict;
|
||||
- (NSDictionary *)toMap;
|
||||
@end
|
||||
@interface BKThumbnail ()
|
||||
+ (BKThumbnail *)fromMap:(NSDictionary *)dict;
|
||||
- (NSDictionary *)toMap;
|
||||
@end
|
||||
|
||||
@implementation BKBook
|
||||
+ (BKBook *)fromMap:(NSDictionary *)dict {
|
||||
BKBook *result = [[BKBook alloc] init];
|
||||
result.title = dict[@"title"];
|
||||
if ((NSNull *)result.title == [NSNull null]) {
|
||||
result.title = nil;
|
||||
}
|
||||
result.subtitle = dict[@"subtitle"];
|
||||
if ((NSNull *)result.subtitle == [NSNull null]) {
|
||||
result.subtitle = nil;
|
||||
}
|
||||
result.author = dict[@"author"];
|
||||
if ((NSNull *)result.author == [NSNull null]) {
|
||||
result.author = nil;
|
||||
}
|
||||
result.summary = dict[@"summary"];
|
||||
if ((NSNull *)result.summary == [NSNull null]) {
|
||||
result.summary = nil;
|
||||
}
|
||||
result.publishDate = dict[@"publishDate"];
|
||||
if ((NSNull *)result.publishDate == [NSNull null]) {
|
||||
result.publishDate = nil;
|
||||
}
|
||||
result.pageCount = dict[@"pageCount"];
|
||||
if ((NSNull *)result.pageCount == [NSNull null]) {
|
||||
result.pageCount = nil;
|
||||
}
|
||||
result.thumbnail = [BKThumbnail fromMap:dict[@"thumbnail"]];
|
||||
if ((NSNull *)result.thumbnail == [NSNull null]) {
|
||||
result.thumbnail = nil;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
- (NSDictionary *)toMap {
|
||||
return [NSDictionary
|
||||
dictionaryWithObjectsAndKeys:
|
||||
(self.title ? self.title : [NSNull null]), @"title",
|
||||
(self.subtitle ? self.subtitle : [NSNull null]), @"subtitle",
|
||||
(self.author ? self.author : [NSNull null]), @"author",
|
||||
(self.summary ? self.summary : [NSNull null]), @"summary",
|
||||
(self.publishDate ? self.publishDate : [NSNull null]), @"publishDate",
|
||||
(self.pageCount ? self.pageCount : [NSNull null]), @"pageCount",
|
||||
(self.thumbnail ? [self.thumbnail toMap] : [NSNull null]),
|
||||
@"thumbnail", nil];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation BKThumbnail
|
||||
+ (BKThumbnail *)fromMap:(NSDictionary *)dict {
|
||||
BKThumbnail *result = [[BKThumbnail alloc] init];
|
||||
result.url = dict[@"url"];
|
||||
if ((NSNull *)result.url == [NSNull null]) {
|
||||
result.url = nil;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
- (NSDictionary *)toMap {
|
||||
return [NSDictionary
|
||||
dictionaryWithObjectsAndKeys:(self.url ? self.url : [NSNull null]),
|
||||
@"url", nil];
|
||||
}
|
||||
@end
|
||||
|
||||
@interface BKFlutterBookApiCodecReader : FlutterStandardReader
|
||||
@end
|
||||
@implementation BKFlutterBookApiCodecReader
|
||||
- (nullable id)readValueOfType:(UInt8)type {
|
||||
switch (type) {
|
||||
case 128:
|
||||
return [BKBook fromMap:[self readValue]];
|
||||
|
||||
default:
|
||||
return [super readValueOfType:type];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@interface BKFlutterBookApiCodecWriter : FlutterStandardWriter
|
||||
@end
|
||||
@implementation BKFlutterBookApiCodecWriter
|
||||
- (void)writeValue:(id)value {
|
||||
if ([value isKindOfClass:[BKBook class]]) {
|
||||
[self writeByte:128];
|
||||
[self writeValue:[value toMap]];
|
||||
} else {
|
||||
[super writeValue:value];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@interface BKFlutterBookApiCodecReaderWriter : FlutterStandardReaderWriter
|
||||
@end
|
||||
@implementation BKFlutterBookApiCodecReaderWriter
|
||||
- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data {
|
||||
return [[BKFlutterBookApiCodecWriter alloc] initWithData:data];
|
||||
}
|
||||
- (FlutterStandardReader *)readerWithData:(NSData *)data {
|
||||
return [[BKFlutterBookApiCodecReader alloc] initWithData:data];
|
||||
}
|
||||
@end
|
||||
|
||||
NSObject<FlutterMessageCodec> *BKFlutterBookApiGetCodec() {
|
||||
static dispatch_once_t s_pred = 0;
|
||||
static FlutterStandardMessageCodec *s_sharedObject = nil;
|
||||
dispatch_once(&s_pred, ^{
|
||||
BKFlutterBookApiCodecReaderWriter *readerWriter =
|
||||
[[BKFlutterBookApiCodecReaderWriter alloc] init];
|
||||
s_sharedObject =
|
||||
[FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
|
||||
});
|
||||
return s_sharedObject;
|
||||
}
|
||||
|
||||
@interface BKFlutterBookApi ()
|
||||
@property(nonatomic, strong) NSObject<FlutterBinaryMessenger> *binaryMessenger;
|
||||
@end
|
||||
|
||||
@implementation BKFlutterBookApi
|
||||
- (instancetype)initWithBinaryMessenger:
|
||||
(NSObject<FlutterBinaryMessenger> *)binaryMessenger {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_binaryMessenger = binaryMessenger;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)displayBookDetailsBook:(BKBook *)arg_book
|
||||
completion:(void (^)(NSError *_Nullable))completion {
|
||||
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
|
||||
messageChannelWithName:
|
||||
@"dev.flutter.pigeon.FlutterBookApi.displayBookDetails"
|
||||
binaryMessenger:self.binaryMessenger
|
||||
codec:BKFlutterBookApiGetCodec()];
|
||||
[channel sendMessage:@[ arg_book ]
|
||||
reply:^(id reply) {
|
||||
completion(nil);
|
||||
}];
|
||||
}
|
||||
@end
|
||||
@interface BKHostBookApiCodecReader : FlutterStandardReader
|
||||
@end
|
||||
@implementation BKHostBookApiCodecReader
|
||||
- (nullable id)readValueOfType:(UInt8)type {
|
||||
switch (type) {
|
||||
case 128:
|
||||
return [BKBook fromMap:[self readValue]];
|
||||
|
||||
default:
|
||||
return [super readValueOfType:type];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@interface BKHostBookApiCodecWriter : FlutterStandardWriter
|
||||
@end
|
||||
@implementation BKHostBookApiCodecWriter
|
||||
- (void)writeValue:(id)value {
|
||||
if ([value isKindOfClass:[BKBook class]]) {
|
||||
[self writeByte:128];
|
||||
[self writeValue:[value toMap]];
|
||||
} else {
|
||||
[super writeValue:value];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@interface BKHostBookApiCodecReaderWriter : FlutterStandardReaderWriter
|
||||
@end
|
||||
@implementation BKHostBookApiCodecReaderWriter
|
||||
- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data {
|
||||
return [[BKHostBookApiCodecWriter alloc] initWithData:data];
|
||||
}
|
||||
- (FlutterStandardReader *)readerWithData:(NSData *)data {
|
||||
return [[BKHostBookApiCodecReader alloc] initWithData:data];
|
||||
}
|
||||
@end
|
||||
|
||||
NSObject<FlutterMessageCodec> *BKHostBookApiGetCodec() {
|
||||
static dispatch_once_t s_pred = 0;
|
||||
static FlutterStandardMessageCodec *s_sharedObject = nil;
|
||||
dispatch_once(&s_pred, ^{
|
||||
BKHostBookApiCodecReaderWriter *readerWriter =
|
||||
[[BKHostBookApiCodecReaderWriter alloc] init];
|
||||
s_sharedObject =
|
||||
[FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
|
||||
});
|
||||
return s_sharedObject;
|
||||
}
|
||||
|
||||
void BKHostBookApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
|
||||
NSObject<BKHostBookApi> *api) {
|
||||
{
|
||||
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
|
||||
messageChannelWithName:@"dev.flutter.pigeon.HostBookApi.cancel"
|
||||
binaryMessenger:binaryMessenger
|
||||
codec:BKHostBookApiGetCodec()];
|
||||
if (api) {
|
||||
NSCAssert(
|
||||
[api respondsToSelector:@selector(cancelWithError:)],
|
||||
@"BKHostBookApi api doesn't respond to @selector(cancelWithError:)");
|
||||
[channel
|
||||
setMessageHandler:^(id _Nullable message, FlutterReply callback) {
|
||||
FlutterError *error;
|
||||
[api cancelWithError:&error];
|
||||
callback(wrapResult(nil, error));
|
||||
}];
|
||||
} else {
|
||||
[channel setMessageHandler:nil];
|
||||
}
|
||||
}
|
||||
{
|
||||
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
|
||||
messageChannelWithName:
|
||||
@"dev.flutter.pigeon.HostBookApi.finishEditingBook"
|
||||
binaryMessenger:binaryMessenger
|
||||
codec:BKHostBookApiGetCodec()];
|
||||
if (api) {
|
||||
NSCAssert([api respondsToSelector:@selector(finishEditingBookBook:
|
||||
error:)],
|
||||
@"BKHostBookApi api doesn't respond to "
|
||||
@"@selector(finishEditingBookBook:error:)");
|
||||
[channel
|
||||
setMessageHandler:^(id _Nullable message, FlutterReply callback) {
|
||||
NSArray *args = message;
|
||||
BKBook *arg_book = args[0];
|
||||
FlutterError *error;
|
||||
[api finishEditingBookBook:arg_book error:&error];
|
||||
callback(wrapResult(nil, error));
|
||||
}];
|
||||
} else {
|
||||
[channel setMessageHandler:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
16
add_to_app/books/ios_books/Podfile
Normal file
@@ -0,0 +1,16 @@
|
||||
# Uncomment the next line to define a global platform for your project
|
||||
# platform :ios, '9.0'
|
||||
|
||||
flutter_application_path = '../flutter_module_books/'
|
||||
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
|
||||
|
||||
target 'IosBooks' do
|
||||
# Comment the next line if you don't want to use dynamic frameworks
|
||||
use_frameworks!
|
||||
# Pods for IosBooks
|
||||
install_all_flutter_pods(flutter_application_path)
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
flutter_post_install(installer) if defined?(flutter_post_install)
|
||||
end
|
||||