Skip to content

Align annotations changed with ios #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-pspdfkit",
"version": "1.23.11",
"version": "1.23.12",
"description": "A React Native module for the PSPDFKit library.",
"keywords": [
"react native",
Expand Down
2 changes: 1 addition & 1 deletion samples/Catalog/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Catalog",
"version": "1.23.11",
"version": "1.23.12",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Newtonsoft.Json.Linq;
using PSPDFKit.Pdf.Annotation;
using ReactNative.UIManager.Events;
using System.Collections.Generic;

namespace ReactNativePSPDFKit.Events
{
Expand All @@ -15,22 +16,28 @@ class PdfViewAnnotationChangedEvent : Event
public const string EVENT_TYPE_REMOVED = "removed";

private readonly string _eventType;
private readonly IAnnotation _annotation;
private readonly IList<IAnnotation> _annotations;

public PdfViewAnnotationChangedEvent(int viewId, string eventType, IAnnotation annotation) : base(viewId)
public PdfViewAnnotationChangedEvent(int viewId, string eventType, IList<IAnnotation> annotations) : base(viewId)
{
this._eventType = eventType;
this._annotation = annotation;
_eventType = eventType;
_annotations = annotations;
}

public override string EventName => EVENT_NAME;

public override void Dispatch(RCTEventEmitter rctEventEmitter)
{
var annotationsJson = new JArray();
foreach (var annotation in _annotations)
{
annotationsJson.Add(JObject.Parse(annotation.ToJson().Stringify()));
}

var eventData = new JObject
{
{ "change", _eventType },
{ "annotations", JObject.Parse(_annotation.ToJson().Stringify()) }
{ "annotations", annotationsJson }
};

rctEventEmitter.receiveEvent(ViewTag, EventName, eventData);
Expand Down
39 changes: 15 additions & 24 deletions windows/ReactNativePSPDFKit/ReactNativePSPDFKit/PDFViewPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,37 +216,28 @@ private async void PDFView_InitializationCompletedHandlerAsync(PdfView sender, P
_pdfViewInitialised = true;
}

private void DocumentOnAnnotationsCreated(object sender, IList<IAnnotation> annotationList)
private void DocumentOnAnnotationsCreated(object sender, IList<IAnnotation> annotations)
{
foreach (var annotation in annotationList)
{
this.GetReactContext().GetNativeModule<UIManagerModule>().EventDispatcher.DispatchEvent(
new PdfViewAnnotationChangedEvent(this.GetTag(),
PdfViewAnnotationChangedEvent.EVENT_TYPE_ADDED, annotation)
);
}
this.GetReactContext().GetNativeModule<UIManagerModule>().EventDispatcher.DispatchEvent(
new PdfViewAnnotationChangedEvent(this.GetTag(),
PdfViewAnnotationChangedEvent.EVENT_TYPE_ADDED, annotations)
);
}

private void DocumentOnAnnotationsUpdated(object sender, IList<IAnnotation> annotationList)
private void DocumentOnAnnotationsUpdated(object sender, IList<IAnnotation> annotations)
{
foreach (var annotation in annotationList)
{
this.GetReactContext().GetNativeModule<UIManagerModule>().EventDispatcher.DispatchEvent(
new PdfViewAnnotationChangedEvent(this.GetTag(),
PdfViewAnnotationChangedEvent.EVENT_TYPE_CHANGED, annotation)
);
}
this.GetReactContext().GetNativeModule<UIManagerModule>().EventDispatcher.DispatchEvent(
new PdfViewAnnotationChangedEvent(this.GetTag(),
PdfViewAnnotationChangedEvent.EVENT_TYPE_CHANGED, annotations)
);
}

private void DocumentOnAnnotationsDeleted(object sender, IList<IAnnotation> annotationList)
private void DocumentOnAnnotationsDeleted(object sender, IList<IAnnotation> annotations)
{
foreach (var annotation in annotationList)
{
this.GetReactContext().GetNativeModule<UIManagerModule>().EventDispatcher.DispatchEvent(
new PdfViewAnnotationChangedEvent(this.GetTag(),
PdfViewAnnotationChangedEvent.EVENT_TYPE_REMOVED, annotation)
);
}
this.GetReactContext().GetNativeModule<UIManagerModule>().EventDispatcher.DispatchEvent(
new PdfViewAnnotationChangedEvent(this.GetTag(),
PdfViewAnnotationChangedEvent.EVENT_TYPE_REMOVED, annotations)
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@
//

using System;
using System.Collections.Generic;
using System.Linq;
using Windows.Data.Json;
using ReactNative.UIManager;
using ReactNative.UIManager.Annotations;
using Windows.Storage;
using Newtonsoft.Json.Linq;
using PSPDFKit.Pdf.Annotation;
using PSPDFKit.UI;
using ReactNativePSPDFKit.Events;

Expand Down