mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
add thumbnails to the books example to make memory leaks easier to test (#1353)
* add thumbnails to the books example to make memory leaks easier to test
* also add profile build
* migrate material 3 demo code to avoid warning
* Revert "migrate material 3 demo code to avoid warning"
This reverts commit 7df37d9f65.
* fix lints in various packages
* DoNothingAndStopPropagationIntent const conflicts between stable and beta, add lint ignore for now
This commit is contained in:
@@ -17,9 +17,13 @@ android {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
profile {
|
||||
initWith debug
|
||||
}
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig debug.signingConfig
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
|
||||
@@ -94,6 +94,9 @@ class MainActivity : AppCompatActivity() {
|
||||
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:")
|
||||
|
||||
@@ -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() {
|
||||
book = null;
|
||||
// Keep focus if going to the home screen but unfocus if leaving
|
||||
@@ -209,21 +212,29 @@ class BookForm extends StatelessWidget {
|
||||
),
|
||||
const Divider(),
|
||||
const SizedBox(height: 32),
|
||||
const Center(
|
||||
child: Text(
|
||||
'BOOK DESCRIPTION',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.underline,
|
||||
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),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
book.summary ?? '',
|
||||
style: TextStyle(color: Colors.grey.shade600, height: 1.24),
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 51;
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
@@ -113,7 +113,7 @@
|
||||
0DDE4C3325E0390700389930 /* Sources */,
|
||||
0DDE4C3425E0390700389930 /* Frameworks */,
|
||||
0DDE4C3525E0390700389930 /* Resources */,
|
||||
F82F2089B06A5489DA98C8B9 /* [CP] Embed Pods Frameworks */,
|
||||
CA4628050A0CDB5CBFD737AD /* [CP-User] Embed Flutter Build flutter_module_books Script */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -203,22 +203,15 @@
|
||||
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";
|
||||
};
|
||||
F82F2089B06A5489DA98C8B9 /* [CP] Embed Pods Frameworks */ = {
|
||||
CA4628050A0CDB5CBFD737AD /* [CP-User] Embed Flutter Build flutter_module_books Script */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
"${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",
|
||||
);
|
||||
name = "[CP-User] Embed Flutter Build flutter_module_books Script";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-IosBooks/Pods-IosBooks-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
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 */
|
||||
|
||||
@@ -381,6 +374,7 @@
|
||||
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)",
|
||||
@@ -403,6 +397,7 @@
|
||||
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)",
|
||||
|
||||
@@ -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 pageCount = volumeInfo["pageCount"] as! Int32
|
||||
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()
|
||||
book.author = authors
|
||||
book.title = title
|
||||
@@ -56,6 +59,7 @@ class ViewController: UITableViewController, BKHostBookApi {
|
||||
book.pageCount = NSNumber.init(value: pageCount)
|
||||
book.publishDate = publishedDate
|
||||
book.summary = summary
|
||||
book.thumbnail = thumbnail
|
||||
newBooks.append(book)
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
|
||||
Reference in New Issue
Block a user