Skip to content

Commit

Permalink
Release 3.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
PSPDFKit committed Jan 12, 2024
1 parent 1a04ff4 commit 2d8f16d
Show file tree
Hide file tree
Showing 15 changed files with 318 additions and 97 deletions.
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
## Newest Release

### 3.7.1 - 18 Oct 2023
### 3.7.2 - 12 Jan 2024

- Fixed issue where iOS Appstore upload fails due to PSPDFKit Flutter missing "CFBundleShortVersionString" key. (#42166)
- Fixed issue where Plugin returned "Document is missing or invalid" during pdfViewControllerWillDismiss events. (#42255)
- Adds `flutterPdfFragmentAdded` callback for Android. (#42631)
- Updates FlutterAppCompatActivity to Support Flutter 3.16.0. (#42767)

## Previous Releases

### 3.7.1 - 18 Oct 2023

- Fixes issue where iOS Appstore upload fails due to PSPDFKit Flutter missing "CFBundleShortVersionString" key. (#42166)
- Fixes issue where Plugin returned "Document is missing or invalid" during pdfViewControllerWillDismiss events. (#42255)

### 3.7.0 - 07 Sep 2023

- Adds annotation preset customization. (#41669)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public void notifyActivityOnPause() {
sendEvent("flutterPdfActivityOnPause");
}


public void notifyPdfFragmentAdded() {
sendEvent("flutterPdfFragmentAdded");
}

public void notifyInstantSyncStarted(String documentId) {
sendEvent("pspdfkitInstantSyncStarted", documentId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.pspdfkit.flutter.pspdfkit

import android.content.Context
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager

class FlutterPdfUiFragmentCallbacks: FragmentManager.FragmentLifecycleCallbacks() {

override fun onFragmentAttached(
fm: FragmentManager,
f: Fragment,
context: Context
) {
if (f.tag?.contains("PSPDFKit.Fragment") == true) {
EventDispatcher.getInstance().notifyPdfFragmentAdded()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ internal class PSPDFKitView(
.build()
}
}
getFragmentActivity(context).supportFragmentManager.registerFragmentLifecycleCallbacks(FlutterPdfUiFragmentCallbacks(), true)

fragmentContainerView?.let {
it.addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener {
Expand Down

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ end
require File.expand_path(File.join("packages", "flutter_tools", "bin", "podhelper"), flutter_root)

flutter_ios_podfile_setup
host_cpu = RbConfig::CONFIG["host_cpu"]

target "Runner" do
flutter_install_all_ios_pods __dir__
Expand All @@ -39,5 +40,10 @@ end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |target_config|
if host_cpu.eql?("x86_64")
target_config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
end
end
2 changes: 1 addition & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
59 changes: 28 additions & 31 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,17 @@ class MyApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const MaterialApp(home: HomePage());
return MaterialApp(
home: const HomePage(),
theme: ThemeData(
useMaterial3: false,
primaryColor: Colors.blue,
appBarTheme: const AppBarTheme(
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
),
),
);
}
}

Expand All @@ -142,13 +152,7 @@ class HomePage extends StatefulWidget {
}

class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
static final ThemeData lightTheme =
ThemeData(primaryColor: Colors.black, dividerColor: Colors.grey[400]);

static final ThemeData darkTheme =
ThemeData(primaryColor: Colors.white, dividerColor: Colors.grey[800]);
String _frameworkVersion = '';
ThemeData currentTheme = lightTheme;

void showDocument() async {
final extractedDocument = await extractAsset(context, _documentPath);
Expand Down Expand Up @@ -576,18 +580,6 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
super.dispose();
}

@override
void didChangePlatformBrightness() {
currentTheme =
WidgetsBinding.instance.window.platformBrightness == Brightness.light
? lightTheme
: darkTheme;
setState(() {
build(context);
});
super.didChangePlatformBrightness();
}

String frameworkVersion() {
return '$_pspdfkitFor $_frameworkVersion\n';
}
Expand Down Expand Up @@ -637,6 +629,14 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
print('pdfViewControllerDidDismissHandler');
}

void flutterPdfFragmentAdded() {
print('flutterPdfFragmentAdded');
}

void pspdfkitDocumentLoaded(String? documentId) {
print('pspdfkitDocumentLoaded: $documentId');
}

@override
Widget build(BuildContext context) {
Pspdfkit.flutterPdfActivityOnPause =
Expand All @@ -645,17 +645,16 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
() => pdfViewControllerWillDismissHandler();
Pspdfkit.pdfViewControllerDidDismiss =
() => pdfViewControllerDidDismissHandler();

currentTheme = MediaQuery.of(context).platformBrightness == Brightness.light
? lightTheme
: darkTheme;
Pspdfkit.flutterPdfFragmentAdded = () => flutterPdfFragmentAdded();
Pspdfkit.pspdfkitDocumentLoaded =
(documentId) => pspdfkitDocumentLoaded(documentId);

final listTiles = <Widget>[
Container(
color: Colors.grey[200],
padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),
child: Text(_pspdfkitWidgetExamples,
style: currentTheme.textTheme.headline4?.copyWith(
style: Theme.of(context).textTheme.headline4?.copyWith(
fontSize: _fontSize, fontWeight: FontWeight.bold))),
ListTile(
title: const Text(_basicExample),
Expand Down Expand Up @@ -738,7 +737,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
color: Colors.grey[200],
padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),
child: Text(_pspdfkitGlobalPluginExamples,
style: currentTheme.textTheme.headline4?.copyWith(
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
fontSize: _fontSize, fontWeight: FontWeight.bold))),
ListTile(
title: const Text(_basicExampleGlobal),
Expand Down Expand Up @@ -779,17 +778,15 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
];
return Scaffold(
appBar: AppBar(title: const Text(_pspdfkitFlutterPluginTitle)),
body: ExampleListView(currentTheme, frameworkVersion(), listTiles));
body: ExampleListView(frameworkVersion(), listTiles));
}
}

class ExampleListView extends StatelessWidget {
final ThemeData themeData;
final String frameworkVersion;
final List<Widget> widgets;

const ExampleListView(this.themeData, this.frameworkVersion, this.widgets,
{Key? key})
const ExampleListView(this.frameworkVersion, this.widgets, {Key? key})
: super(key: key);

@override
Expand All @@ -800,10 +797,10 @@ class ExampleListView extends StatelessWidget {
padding: const EdgeInsets.only(top: 24),
child: Center(
child: Text(frameworkVersion,
style: themeData.textTheme.headline4?.copyWith(
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
fontSize: _fontSize,
fontWeight: FontWeight.bold,
color: themeData.primaryColor)))),
color: Theme.of(context).primaryColor)))),
Expanded(
child: ListView.separated(
itemCount: widgets.length,
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pspdfkit_example
description: Demonstrates how to use the pspdfkit plugin.
version: 3.7.1
version: 3.7.2
homepage: https://pspdfkit.com/
environment:
sdk: '>=2.17.0 <4.0.0'
Expand Down
19 changes: 16 additions & 3 deletions ios/Classes/PspdfPlatformView.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@interface PspdfPlatformView() <PSPDFViewControllerDelegate>
@property int64_t platformViewId;
@property (nonatomic) FlutterMethodChannel *channel;
@property (nonatomic) FlutterMethodChannel *broadcastChannel;
@property (nonatomic, weak) UIViewController *flutterViewController;
@property (nonatomic) PSPDFViewController *pdfViewController;
@property (nonatomic) PSPDFNavigationController *navigationController;
Expand All @@ -29,10 +30,10 @@ - (nonnull UIView *)view {
}

- (instancetype)initWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId arguments:(id)args messenger:(NSObject<FlutterBinaryMessenger> *)messenger {

if ((self = [super init])) {
NSString *name = [NSString stringWithFormat:@"com.pspdfkit.widget.%lld", viewId];
_platformViewId = viewId;
_channel = [FlutterMethodChannel methodChannelWithName:name binaryMessenger:messenger];
_channel = [FlutterMethodChannel methodChannelWithName:[NSString stringWithFormat:@"com.pspdfkit.widget.%lld", viewId] binaryMessenger:messenger];
_broadcastChannel = [FlutterMethodChannel methodChannelWithName:@"com.pspdfkit.global" binaryMessenger:messenger];

_navigationController = [PSPDFNavigationController new];
_navigationController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Expand Down Expand Up @@ -64,6 +65,7 @@ - (instancetype)initWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId argum
_pdfViewController.appearanceModeManager.appearanceMode = [PspdfkitFlutterConverter appearanceMode:configurationDictionary];
_pdfViewController.pageIndex = [PspdfkitFlutterConverter pageIndex:configurationDictionary];
_pdfViewController.delegate = self;
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(documentDidFinishRendering) name:PSPDFDocumentViewControllerDidConfigureSpreadViewNotification object:nil];

if ((id)configurationDictionary != NSNull.null) {
NSString *key = @"leftBarButtonItems";
Expand Down Expand Up @@ -100,6 +102,17 @@ - (instancetype)initWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId argum
return self;
}

- (void)documentDidFinishRendering {
// Remove observer after the initial notification
[NSNotificationCenter.defaultCenter removeObserver:self
name:PSPDFDocumentViewControllerDidConfigureSpreadViewNotification
object:nil];
NSString *documentId = self.pdfViewController.document.UID;
if (documentId != nil) {
[_broadcastChannel invokeMethod:@"pspdfkitDocumentLoaded" arguments:documentId];
}
}

- (void)dealloc {
[self cleanup];
}
Expand Down
4 changes: 2 additions & 2 deletions ios/pspdfkit_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
Pod::Spec.new do |s|
s.name = "pspdfkit_flutter"
s.version = "3.7.1"
s.version = "3.7.2"
s.homepage = "https://PSPDFKit.com"
s.documentation_url = "https://pspdfkit.com/guides/flutter"
s.license = { type: "Commercial", file: "../LICENSE" }
Expand All @@ -22,6 +22,6 @@ Pod::Spec.new do |s|
s.dependency("Instant")
s.swift_version = "5.0"
s.platform = :ios, "15.0"
s.version = "3.7.1"
s.version = "3.7.2"
s.pod_target_xcconfig = { "DEFINES_MODULE" => "YES", "SWIFT_INSTALL_OBJC_HEADER" => "NO" }
end
14 changes: 13 additions & 1 deletion lib/pspdfkit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,12 @@ class Pspdfkit {
return Directory(path);
}

/// onPAuse callback for FlutterPdfActivity
/// onPause callback for FlutterPdfActivity
static void Function()? flutterPdfActivityOnPause;

/// Added callback for FlutterPdfFragment
static void Function()? flutterPdfFragmentAdded;

/// ViewControllerWillDismiss callback for PDFViewController
static void Function()? pdfViewControllerWillDismiss;

Expand Down Expand Up @@ -305,12 +308,18 @@ class Pspdfkit {
static void Function(String? documentId, String? error)?
instantDownloadFailed;

/// Called with the document has been loaded
static void Function(String? documentId)? pspdfkitDocumentLoaded;

static Future<void> _platformCallHandler(MethodCall call) {
try {
switch (call.method) {
case 'flutterPdfActivityOnPause':
flutterPdfActivityOnPause?.call();
break;
case 'flutterPdfFragmentAdded':
flutterPdfFragmentAdded?.call();
break;
case 'pdfViewControllerWillDismiss':
pdfViewControllerWillDismiss?.call();
break;
Expand Down Expand Up @@ -358,6 +367,9 @@ class Pspdfkit {
arguments['error'] as String);
break;
}
case 'pspdfkitDocumentLoaded':
pspdfkitDocumentLoaded?.call(call.arguments as String);
break;
default:
if (kDebugMode) {
print('Unknown method ${call.method} ');
Expand Down
8 changes: 8 additions & 0 deletions lib/src/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ class Pspdfkit {
static late VoidCallback flutterPdfActivityOnPause;
static late VoidCallback pdfViewControllerWillDismiss;
static late VoidCallback pdfViewControllerDidDismiss;
static late VoidCallback flutterPdfFragmentAdded;
static late Function(String) pspdfkitDocumentLoaded;

static Future<void> _platformCallHandler(MethodCall call) {
try {
Expand All @@ -203,6 +205,12 @@ class Pspdfkit {
case 'pdfViewControllerDidDismiss':
pdfViewControllerDidDismiss();
break;
case 'flutterPdfFragmentAdded':
flutterPdfFragmentAdded();
break;
case 'pspdfkitDocumentLoaded':
pspdfkitDocumentLoaded(call.arguments as String);
break;
default:
if (kDebugMode) {
print('Unknown method ${call.method} ');
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pspdfkit_flutter
description: A Flutter plugin providing a feature-rich PDF viewing and editing experience to your users with the powerful PSPDFKit PDF SDK.
version: 3.7.1
version: 3.7.2
homepage: https://pspdfkit.com/
repository: https://github.com/PSPDFKit/pspdfkit-flutter
issue_tracker: https://support.pspdfkit.com/hc/en-us/requests/new
Expand Down

0 comments on commit 2d8f16d

Please sign in to comment.