diff --git a/packages/epub_view/example/ios/Flutter/Debug.xcconfig b/packages/epub_view/example/ios/Flutter/Debug.xcconfig index 592ceee8..ec97fc6f 100644 --- a/packages/epub_view/example/ios/Flutter/Debug.xcconfig +++ b/packages/epub_view/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/packages/epub_view/example/ios/Podfile b/packages/epub_view/example/ios/Podfile new file mode 100644 index 00000000..d97f17e2 --- /dev/null +++ b/packages/epub_view/example/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/packages/epub_view/lib/src/ui/epub_view.dart b/packages/epub_view/lib/src/ui/epub_view.dart index 28ece456..f03e9ffe 100644 --- a/packages/epub_view/lib/src/ui/epub_view.dart +++ b/packages/epub_view/lib/src/ui/epub_view.dart @@ -10,6 +10,8 @@ import 'package:epub_view/src/data/models/paragraph.dart'; import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; +//import 'package:flutter_html_all/flutter_html_all.dart'; +//import 'package:flutter_html/flutter_html.dart' as flutter_html; export 'package:epubx/epubx.dart' hide Image; @@ -316,60 +318,120 @@ class _EpubViewState extends State { ), ); - static Widget _chapterBuilder( - BuildContext context, - EpubViewBuilders builders, - EpubBook document, - List chapters, - List paragraphs, - int index, - int chapterIndex, - int paragraphIndex, - ExternalLinkPressed onExternalLinkPressed, - ) { - if (paragraphs.isEmpty) { - return Container(); - } - - final defaultBuilder = builders as EpubViewBuilders; - final options = defaultBuilder.options; + // static Widget _chapterBuilder( + // BuildContext context, + // EpubViewBuilders builders, + // EpubBook document, + // List chapters, + // List paragraphs, + // int index, + // int chapterIndex, + // int paragraphIndex, + // ExternalLinkPressed onExternalLinkPressed, + // ) { + // if (paragraphs.isEmpty) { + // return Container(); + // } + + // final defaultBuilder = builders as EpubViewBuilders; + // final options = defaultBuilder.options; + + // return Column( + // children: [ + // if (chapterIndex >= 0 && paragraphIndex == 0) + // builders.chapterDividerBuilder(chapters[chapterIndex]), + // Html( + // data: paragraphs[index].element.outerHtml, + // onLinkTap: (href, _, __) => onExternalLinkPressed(href!), + // style: { + // 'html': Style( + // padding: HtmlPaddings.only( + // top: (options.paragraphPadding as EdgeInsets?)?.top, + // right: (options.paragraphPadding as EdgeInsets?)?.right, + // bottom: (options.paragraphPadding as EdgeInsets?)?.bottom, + // left: (options.paragraphPadding as EdgeInsets?)?.left, + // ), + // ).merge(Style.fromTextStyle(options.textStyle)), + // }, + // extensions: [ + // TagExtension( + // tagsToExtend: {"img"}, + // builder: (imageContext) { + // final url = + // imageContext.attributes['src']!.replaceAll('../', ''); + // final content = Uint8List.fromList( + // document.Content!.Images![url]!.Content!); + // return Image( + // image: MemoryImage(content), + // ); + // }, + // ), + // ], + // ), + // ], + // ); + // } + + +static Widget _chapterBuilder( + BuildContext context, + EpubViewBuilders builders, + EpubBook document, + List chapters, + List paragraphs, + int index, + int chapterIndex, + int paragraphIndex, + ExternalLinkPressed onExternalLinkPressed, +) { + if (paragraphs.isEmpty) { + return Container(); + } - return Column( - children: [ - if (chapterIndex >= 0 && paragraphIndex == 0) - builders.chapterDividerBuilder(chapters[chapterIndex]), - Html( - data: paragraphs[index].element.outerHtml, - onLinkTap: (href, _, __) => onExternalLinkPressed(href!), - style: { - 'html': Style( - padding: HtmlPaddings.only( - top: (options.paragraphPadding as EdgeInsets?)?.top, - right: (options.paragraphPadding as EdgeInsets?)?.right, - bottom: (options.paragraphPadding as EdgeInsets?)?.bottom, - left: (options.paragraphPadding as EdgeInsets?)?.left, - ), - ).merge(Style.fromTextStyle(options.textStyle)), - }, - extensions: [ - TagExtension( - tagsToExtend: {"img"}, - builder: (imageContext) { - final url = - imageContext.attributes['src']!.replaceAll('../', ''); - final content = Uint8List.fromList( - document.Content!.Images![url]!.Content!); - return Image( - image: MemoryImage(content), - ); - }, + final defaultBuilder = builders as EpubViewBuilders; + final options = defaultBuilder.options; + + return Column( + children: [ + if (chapterIndex >= 0 && paragraphIndex == 0) + builders.chapterDividerBuilder(chapters[chapterIndex]), + Html( + data: paragraphs[index].element.outerHtml, + style: { + 'html': Style( + padding: HtmlPaddings.only( + top: (options.paragraphPadding as EdgeInsets?)?.top, + right: (options.paragraphPadding as EdgeInsets?)?.right, + bottom: (options.paragraphPadding as EdgeInsets?)?.bottom, + left: (options.paragraphPadding as EdgeInsets?)?.left, ), - ], + ).merge(Style.fromTextStyle(options.textStyle)), + }, + extensions: [ + TagExtension( + tagsToExtend: {"img"}, + builder: (imageContext) { + final url = + imageContext.attributes['src']!.replaceAll('../', ''); + final content = Uint8List.fromList( + document.Content!.Images![url]!.Content!); + return Image( + image: MemoryImage(content), + ); + }, + ), + ], + ), + Padding( + padding: options.paragraphPadding ?? EdgeInsets.zero, + child: SelectableText( + paragraphs[index].element.text, + style: options.textStyle, ), - ], - ); - } - + ), + ], + ); +} Widget _buildLoaded(BuildContext context) { return ScrollablePositionedList.builder( shrinkWrap: widget.shrinkWrap, diff --git a/packages/epub_view/pubspec.yaml b/packages/epub_view/pubspec.yaml index 92d508dd..166081ad 100644 --- a/packages/epub_view/pubspec.yaml +++ b/packages/epub_view/pubspec.yaml @@ -14,11 +14,11 @@ dependencies: epubx: ^4.0.0 equatable: ^2.0.5 html: ^0.15.4 - flutter_html: ^3.0.0-beta.2 + flutter_html: ^3.0.0-alpha.5 scrollable_positioned_list: ^0.3.8 collection: ^1.17.1 universal_file: ^1.0.0 - + dev_dependencies: flutter_test: sdk: flutter