Skip to content

Commit

Permalink
Release 3.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
PSPDFKit committed Mar 28, 2022
1 parent e8354b1 commit e8a8ffc
Show file tree
Hide file tree
Showing 13 changed files with 241 additions and 60 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
## Newest Release

### 3.2.2 - 16 Mar 2022

- Improves the example project by using the `PlatformUtils` class to check for supported platforms (#33212)
- Adds a new **Save As** example to the example project. (#33376)
- Updates for PSPDFKit 11.3.0 for iOS. (#33514)

## Previous Releases

### 3.2.1 - 04 Mar 2022

- Updates for PSPDFKit 8.1.2 for Android. (#33314)
- Updates for PSPDFKit 11.2.4 for iOS. (#33314)

## Previous Releases

### 3.2.0 - 14 Feb 2022

- This release requires you to update your Android project's `compileSdkVersion` to version 31. Please refer to [our migration guide](https://pspdfkit.com/guides/flutter/migration-guides/flutter-3-2-0-migration-guide) for this release.
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ flutter_ios_podfile_setup

target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
pod 'PSPDFKit', '~> 11.2.4'
pod 'PSPDFKit', '~> 11.3.0'
end

post_install do |installer|
Expand Down
76 changes: 45 additions & 31 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:pspdfkit_example/pspdfkit_save_as_example.dart';

import 'package:pspdfkit_flutter/src/main.dart';
import 'package:pspdfkit_flutter/src/widgets/pspdfkit_widget_controller.dart';
Expand All @@ -21,7 +22,9 @@ import 'pspdfkit_form_example.dart';
import 'pspdfkit_instantjson_example.dart';
import 'pspdfkit_annotations_example.dart';
import 'pspdfkit_manual_save_example.dart';
import 'pspdfkit_save_as_example.dart';
import 'pspdfkit_annotation_processing_example.dart';
import 'platform_utils.dart';

const String _documentPath = 'PDFs/PSPDFKit.pdf';
const String _lockedDocumentPath = 'PDFs/protected.pdf';
Expand Down Expand Up @@ -59,8 +62,11 @@ const String _annotationsExample =
const String _annotationsExampleSub =
'Programmatically adds and removes annotations using a custom Widget.';
const String _manualSaveExample = 'Manual Save';
const String _saveAsExample = 'Save As';
const String _manualSaveExampleSub =
'Add a save button at the bottom and disable automatic saving.';
const String _saveAsExampleSub =
'Embed and save the changes made to a document into a new file';
const String _annotationProcessingExample = 'Process Annotations';
const String _annotationProcessingExampleSub =
'Programmatically adds and removes annotations using a custom Widget.';
Expand Down Expand Up @@ -145,31 +151,18 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
return file;
}

bool isCupertino(BuildContext context) {
final defaultTargetPlatform = Theme.of(context).platform;
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return true;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return false;
}
}

void showDocument() async {
final extractedDocument = await extractAsset(_documentPath);
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
builder: (_) => Scaffold(
extendBodyBehindAppBar: isCupertino(context) ? false : true,
extendBodyBehindAppBar:
PlatformUtils.isCupertino(context) ? false : true,
appBar: AppBar(),
body: SafeArea(
top: false,
bottom: false,
child: Container(
padding: isCupertino(context)
padding: PlatformUtils.isCupertino(context)
? null
: const EdgeInsets.only(top: kToolbarHeight),
child: PspdfkitWidget(
Expand All @@ -179,7 +172,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
void showDocumentPlatformStyle() async {
final extractedDocument = await extractAsset(_documentPath);

if (isCupertino(context)) {
if (PlatformUtils.isCupertino(context)) {
await Navigator.of(context).push<dynamic>(CupertinoPageRoute<dynamic>(
builder: (_) => CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(),
Expand All @@ -206,13 +199,14 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
final extractedImage = await extractAsset(_imagePath);
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
builder: (_) => Scaffold(
extendBodyBehindAppBar: isCupertino(context) ? false : true,
extendBodyBehindAppBar:
PlatformUtils.isCupertino(context) ? false : true,
appBar: AppBar(),
body: SafeArea(
top: false,
bottom: false,
child: Container(
padding: isCupertino(context)
padding: PlatformUtils.isCupertino(context)
? null
: const EdgeInsets.only(top: kToolbarHeight),
child:
Expand All @@ -223,13 +217,14 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
final extractedDocument = await extractAsset(_documentPath);
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
builder: (_) => Scaffold(
extendBodyBehindAppBar: isCupertino(context) ? false : true,
extendBodyBehindAppBar:
PlatformUtils.isCupertino(context) ? false : true,
appBar: AppBar(),
body: SafeArea(
top: false,
bottom: false,
child: Container(
padding: isCupertino(context)
padding: PlatformUtils.isCupertino(context)
? null
: const EdgeInsets.only(top: kToolbarHeight),
child: PspdfkitWidget(
Expand All @@ -245,13 +240,14 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
final extractedDocument = await extractAsset(_documentPath);
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
builder: (_) => Scaffold(
extendBodyBehindAppBar: isCupertino(context) ? false : true,
extendBodyBehindAppBar:
PlatformUtils.isCupertino(context) ? false : true,
appBar: AppBar(),
body: SafeArea(
top: false,
bottom: false,
child: Container(
padding: isCupertino(context)
padding: PlatformUtils.isCupertino(context)
? null
: const EdgeInsets.only(top: kToolbarHeight),
child: PspdfkitWidget(
Expand Down Expand Up @@ -312,13 +308,14 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
final extractedLockedDocument = await extractAsset(_lockedDocumentPath);
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
builder: (_) => Scaffold(
extendBodyBehindAppBar: isCupertino(context) ? false : true,
extendBodyBehindAppBar:
PlatformUtils.isCupertino(context) ? false : true,
appBar: AppBar(),
body: SafeArea(
top: false,
bottom: false,
child: Container(
padding: isCupertino(context)
padding: PlatformUtils.isCupertino(context)
? null
: const EdgeInsets.only(top: kToolbarHeight),
child: PspdfkitWidget(
Expand Down Expand Up @@ -350,8 +347,8 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
}

void manualSaveExample() async {
final extractedWritableDocument =
await extractAsset(_documentPath, shouldOverwrite: false, prefix: 'persist');
final extractedWritableDocument = await extractAsset(_documentPath,
shouldOverwrite: false, prefix: 'persist');

// Automatic Saving of documents is enabled by default in certain scenarios [see for details: https://pspdfkit.com/guides/flutter/save-a-document/#auto-save]
// In order to manually save documents, you might consider disabling automatic saving with disableAutosave: true in the config
Expand All @@ -361,6 +358,18 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
configuration: const {disableAutosave: true})));
}

void saveAsExample() async {
final extractedWritableDocument = await extractAsset(_documentPath,
shouldOverwrite: false, prefix: 'persist');

// Automatic Saving of documents is enabled by default in certain scenarios [see for details: https://pspdfkit.com/guides/flutter/save-a-document/#auto-save]
// In order to manually save documents, you might consider disabling automatic saving with disableAutosave: true in the config
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
builder: (_) => PspdfkitSaveAsExampleWidget(
documentPath: extractedWritableDocument.path,
configuration: const {disableAutosave: true})));
}

void annotationProcessingExample() async {
final extractedDocument = await extractAsset(_documentPath);
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
Expand All @@ -374,7 +383,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
final extractedDocument = await extractAsset(_documentPath);
final extractedFormDocument = await extractAsset(_formPath);

if (isCupertino(context)) {
if (PlatformUtils.isCupertino(context)) {
await Navigator.of(context).push<dynamic>(CupertinoPageRoute<dynamic>(
builder: (_) => CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(),
Expand Down Expand Up @@ -669,20 +678,25 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
title: const Text(_manualSaveExample),
subtitle: const Text(_manualSaveExampleSub),
onTap: () => manualSaveExample()),
if (PlatformUtils.isCupertino(context))
ListTile(
title: const Text(_saveAsExample),
subtitle: const Text(_saveAsExampleSub),
onTap: () => saveAsExample()),
// The annotation processing example is supported by iOS only for now.
if (isCupertino(context))
if (PlatformUtils.isCupertino(context))
ListTile(
title: const Text(_annotationProcessingExample),
subtitle: const Text(_annotationProcessingExampleSub),
onTap: () => annotationProcessingExample()),
// The import Instant JSON example is supported by iOS only for now.
if (isCupertino(context))
if (PlatformUtils.isCupertino(context))
ListTile(
title: const Text(_importInstantJsonExample),
subtitle: const Text(_importInstantJsonExampleSub),
onTap: () => importInstantJsonExample()),
// The push two PspdfWidgets simultaneously example is supported by iOS only for now.
if (isCupertino(context))
if (PlatformUtils.isCupertino(context))
ListTile(
title: const Text(_widgetExampleFullScreen),
subtitle: const Text(_widgetExampleFullScreenSub),
Expand Down
15 changes: 15 additions & 0 deletions example/lib/platform_utils.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

class PlatformUtils {
static bool isCurrentPlatformSupported() {
Expand All @@ -13,4 +14,18 @@ class PlatformUtils {
static bool isIOS() {
return defaultTargetPlatform == TargetPlatform.iOS;
}

static bool isCupertino(BuildContext context) {
final defaultTargetPlatform = Theme.of(context).platform;
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return true;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return false;
}
}
}
5 changes: 3 additions & 2 deletions example/lib/pspdfkit_annotation_processing_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:flutter/services.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pspdfkit_example/platform_utils.dart';

import 'package:pspdfkit_flutter/src/main.dart';
import 'package:pspdfkit_flutter/src/widgets/pspdfkit_widget_controller.dart';
Expand Down Expand Up @@ -64,7 +65,7 @@ class _PspdfkitAnnotationProcessingExampleWidgetState
'configuration': widget.configuration
};

if (defaultTargetPlatform == TargetPlatform.iOS) {
if (PlatformUtils.isIOS()) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(),
child: SafeArea(
Expand Down Expand Up @@ -117,7 +118,7 @@ class _PspdfkitAnnotationProcessingExampleWidgetState
child: Text('Print Annotations'))
]))
])));
} else if (defaultTargetPlatform == TargetPlatform.android) {
} else if (PlatformUtils.isAndroid()) {
// This example is only supported in iOS at the moment.
// Support for Android is coming soon.
return Text('Unsupported Widget');
Expand Down
14 changes: 7 additions & 7 deletions example/lib/pspdfkit_annotations_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import 'package:flutter/material.dart';

import 'package:pspdfkit_flutter/src/widgets/pspdfkit_widget_controller.dart';

import 'platform_utils.dart';

const annotationJsonHashMap = {
'uuid': 'A92AA288-B11D-490C-847B-D1A0BC64D3E9',
'bbox': [
Expand Down Expand Up @@ -130,22 +132,20 @@ class _PspdfkitAnnotationsExampleWidgetState
'document': widget.documentPath,
'configuration': widget.configuration
};
if (defaultTargetPlatform == TargetPlatform.android ||
defaultTargetPlatform == TargetPlatform.iOS) {
if (PlatformUtils.isCurrentPlatformSupported()) {
return Scaffold(
extendBodyBehindAppBar:
defaultTargetPlatform == TargetPlatform.android,
extendBodyBehindAppBar: PlatformUtils.isAndroid(),
appBar: AppBar(),
body: SafeArea(
top: false,
bottom: false,
child: Container(
padding: defaultTargetPlatform == TargetPlatform.iOS
padding: PlatformUtils.isIOS()
? null
: const EdgeInsets.only(top: kToolbarHeight),
child: Column(children: <Widget>[
Expanded(
child: defaultTargetPlatform == TargetPlatform.android
child: PlatformUtils.isAndroid()
? PlatformViewLink(
viewType: viewType,
surfaceFactory: (BuildContext context,
Expand Down Expand Up @@ -197,7 +197,7 @@ class _PspdfkitAnnotationsExampleWidgetState
// E.g: `await view.addAnnotation(annotationJsonString);`
},
child: const Text('Add Annotation')),
if (defaultTargetPlatform == TargetPlatform.iOS)
if (PlatformUtils.isIOS())
ElevatedButton(
onPressed: () async {
dynamic annotationsJson =
Expand Down
16 changes: 7 additions & 9 deletions example/lib/pspdfkit_form_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pspdfkit_example/platform_utils.dart';

import 'package:pspdfkit_flutter/src/widgets/pspdfkit_widget_controller.dart';

Expand Down Expand Up @@ -53,25 +54,23 @@ class _PspdfkitFormExampleWidgetState extends State<PspdfkitFormExampleWidget> {
'document': widget.documentPath,
'configuration': widget.configuration
};
if (defaultTargetPlatform == TargetPlatform.android ||
defaultTargetPlatform == TargetPlatform.iOS) {
if (PlatformUtils.isCurrentPlatformSupported()) {
return Scaffold(
extendBodyBehindAppBar:
defaultTargetPlatform == TargetPlatform.android,
extendBodyBehindAppBar: PlatformUtils.isAndroid(),
// Do not resize the the document view on Android or
// it won't be rendered correctly when filling forms.
resizeToAvoidBottomInset: defaultTargetPlatform == TargetPlatform.iOS,
resizeToAvoidBottomInset: PlatformUtils.isIOS(),
appBar: AppBar(),
body: SafeArea(
top: false,
bottom: false,
child: Container(
padding: defaultTargetPlatform == TargetPlatform.iOS
padding: PlatformUtils.isIOS()
? null
: const EdgeInsets.only(top: kToolbarHeight),
child: Column(children: <Widget>[
Expanded(
child: defaultTargetPlatform == TargetPlatform.android
child: PlatformUtils.isAndroid()
? PlatformViewLink(
viewType: viewType,
surfaceFactory: (BuildContext context,
Expand Down Expand Up @@ -117,8 +116,7 @@ class _PspdfkitFormExampleWidgetState extends State<PspdfkitFormExampleWidget> {
// On Android do not show the buttons when the Keyboard
// is visible. PSPDFKit for Android automatically
// fills the space available and re-render the document view.
if (!_keyboardVisible ||
defaultTargetPlatform == TargetPlatform.iOS)
if (!_keyboardVisible || PlatformUtils.isIOS())
SizedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
Expand Down
Loading

0 comments on commit e8a8ffc

Please sign in to comment.