mirror of
https://github.com/flutter/samples.git
synced 2025-11-12 07:48:55 +00:00
add thumbnails to the books example to make memory leaks easier to test
This commit is contained in:
@@ -20,6 +20,7 @@ android {
|
|||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
signingConfig debug.signingConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
|||||||
@@ -94,6 +94,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
book.summary = volumeInfoJson.get("description").asString
|
book.summary = volumeInfoJson.get("description").asString
|
||||||
book.publishDate = volumeInfoJson.get("publishedDate").asString
|
book.publishDate = volumeInfoJson.get("publishedDate").asString
|
||||||
book.pageCount = volumeInfoJson.get("pageCount").asLong
|
book.pageCount = volumeInfoJson.get("pageCount").asLong
|
||||||
|
val thumbnail = Api.Thumbnail()
|
||||||
|
thumbnail.url = volumeInfoJson.getAsJsonObject("imageLinks").get("thumbnail").asString
|
||||||
|
book.thumbnail = thumbnail
|
||||||
books.add(book)
|
books.add(book)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
println("Failed to parse book:")
|
println("Failed to parse book:")
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ class _BookDetailState extends State<BookDetail> {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not overriding didUpdateWidget because the Android program can't change
|
||||||
|
// the book given to Flutter on the Android side.
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
book = null;
|
book = null;
|
||||||
// Keep focus if going to the home screen but unfocus if leaving
|
// Keep focus if going to the home screen but unfocus if leaving
|
||||||
@@ -209,21 +212,29 @@ class BookForm extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
const SizedBox(height: 32),
|
const SizedBox(height: 32),
|
||||||
const Center(
|
if (book.thumbnail?.url != null) ... [
|
||||||
child: Text(
|
Center(
|
||||||
'BOOK DESCRIPTION',
|
child: Image.network(book.thumbnail!.url!),
|
||||||
style: TextStyle(
|
),
|
||||||
fontSize: 15,
|
const SizedBox(height: 32),
|
||||||
fontWeight: FontWeight.bold,
|
],
|
||||||
decoration: TextDecoration.underline,
|
if (book.summary != null) ... [
|
||||||
|
const Center(
|
||||||
|
child: Text(
|
||||||
|
'BOOK DESCRIPTION',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 12),
|
||||||
const SizedBox(height: 12),
|
Text(
|
||||||
Text(
|
book.summary ?? '',
|
||||||
book.summary ?? '',
|
style: TextStyle(color: Colors.grey.shade600, height: 1.24),
|
||||||
style: TextStyle(color: Colors.grey.shade600, height: 1.24),
|
),
|
||||||
),
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
archiveVersion = 1;
|
archiveVersion = 1;
|
||||||
classes = {
|
classes = {
|
||||||
};
|
};
|
||||||
objectVersion = 51;
|
objectVersion = 50;
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
@@ -113,7 +113,7 @@
|
|||||||
0DDE4C3325E0390700389930 /* Sources */,
|
0DDE4C3325E0390700389930 /* Sources */,
|
||||||
0DDE4C3425E0390700389930 /* Frameworks */,
|
0DDE4C3425E0390700389930 /* Frameworks */,
|
||||||
0DDE4C3525E0390700389930 /* Resources */,
|
0DDE4C3525E0390700389930 /* Resources */,
|
||||||
F82F2089B06A5489DA98C8B9 /* [CP] Embed Pods Frameworks */,
|
CA4628050A0CDB5CBFD737AD /* [CP-User] Embed Flutter Build flutter_module_books Script */,
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
@@ -203,22 +203,15 @@
|
|||||||
shellPath = /bin/sh;
|
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";
|
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";
|
||||||
};
|
};
|
||||||
F82F2089B06A5489DA98C8B9 /* [CP] Embed Pods Frameworks */ = {
|
CA4628050A0CDB5CBFD737AD /* [CP-User] Embed Flutter Build flutter_module_books Script */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
);
|
);
|
||||||
inputFileListPaths = (
|
name = "[CP-User] Embed Flutter Build flutter_module_books Script";
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-IosBooks/Pods-IosBooks-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
|
||||||
);
|
|
||||||
name = "[CP] Embed Pods Frameworks";
|
|
||||||
outputFileListPaths = (
|
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-IosBooks/Pods-IosBooks-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-IosBooks/Pods-IosBooks-frameworks.sh\"\n";
|
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";
|
||||||
showEnvVarsInLog = 0;
|
|
||||||
};
|
};
|
||||||
/* End PBXShellScriptBuildPhase section */
|
/* End PBXShellScriptBuildPhase section */
|
||||||
|
|
||||||
@@ -381,6 +374,7 @@
|
|||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
DEVELOPMENT_TEAM = "";
|
||||||
INFOPLIST_FILE = IosBooks/Info.plist;
|
INFOPLIST_FILE = IosBooks/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
@@ -403,6 +397,7 @@
|
|||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
DEVELOPMENT_TEAM = "";
|
||||||
INFOPLIST_FILE = IosBooks/Info.plist;
|
INFOPLIST_FILE = IosBooks/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -47,7 +47,10 @@ class ViewController: UITableViewController, BKHostBookApi {
|
|||||||
let authors = (volumeInfo["authors"] as! [String]).joined(separator: " & ")
|
let authors = (volumeInfo["authors"] as! [String]).joined(separator: " & ")
|
||||||
let pageCount = volumeInfo["pageCount"] as! Int32
|
let pageCount = volumeInfo["pageCount"] as! Int32
|
||||||
let publishedDate = volumeInfo["publishedDate"] as! String
|
let publishedDate = volumeInfo["publishedDate"] as! String
|
||||||
let summary = volumeInfo["description"] 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()
|
let book: BKBook = BKBook.init()
|
||||||
book.author = authors
|
book.author = authors
|
||||||
book.title = title
|
book.title = title
|
||||||
@@ -56,6 +59,7 @@ class ViewController: UITableViewController, BKHostBookApi {
|
|||||||
book.pageCount = NSNumber.init(value: pageCount)
|
book.pageCount = NSNumber.init(value: pageCount)
|
||||||
book.publishDate = publishedDate
|
book.publishDate = publishedDate
|
||||||
book.summary = summary
|
book.summary = summary
|
||||||
|
book.thumbnail = thumbnail
|
||||||
newBooks.append(book)
|
newBooks.append(book)
|
||||||
}
|
}
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
|||||||
Reference in New Issue
Block a user