scientifichackers/flutter_pdf_viewer

Support Inline Pdf Viewing

MaskyS opened this issue · 32 comments

Thank you a lot for this plugin. It's amazing, the one thing it lacks is to add an AppBar in the pdfViewer activity. Any idea how it could be done? Maybe like the flutter webview plugin does?

Thanks again!

I can get you a Android native appBar, but that's pretty useless since its just a top bar with the name of the app.

In Android, we have the back button so going back to the app is not an issue?

To get any sort of flutter component onto that PDF screen requires some sort of compositing engine that combines both flutter and Android views into one.

I'll look more into how webview plugin does it, with it's rect analogy, whether that applies to Android PDF viewer...

Update-

The webview plugin uses a FrameLayout, which works fine. But IMO, provides a mediocre experience. It feels like a weird mix of android and flutter views to me...

I personally, would like to try out flutter Texture. I believe that it should look and feel like a non-GMO flutter widget.

For instance, it's used by fluttie.

The library can render the animations by piping the output from the Lottie Android library into a Flutter texture.

Great, thanks for the prompt reply. I look forward to this :D

I look forward to this too :D

Been quite busy with zproc.

This is definitely on my to-do list.

Thanks, will check it out.

zproc is also compatible with TCP btw.

I'm trying to get a stable feature-set first. (Working on a PUSH-PULL model right now)

But if NATS really is faster than ZMQ, I wouldn't mind putting it as an alternative backend.

Checkout liftbridge.
It's NATS exposed over grpc.
Replaces Kafka.
I can then use this high transaction MQ to talk to flutter over grpc.
Grpc Dart with grpc golang - easy.

Also because it's like Kafka you get distributed logs.
You also get multi data centre multi master for free.

When you add another node it joins and load balancers. Nothing else needed.

Liftbridge is just one of the many systems you can build on top of NATS.

Not fast of course.

What exactly was the bottleneck, the 3d rendering library or the Textures API?

Pumping the textures to the flutter texture object is not fast.
The fluttie team use it and when you try it it's not that fast.
But I would still go with it to just get going.

I saw another flutter project also using the Texture Flutter object. It was a 3d model viewer. Slow but worked.
They were designed to use opengl I think.
Can't find the link now.

Anyway I think getting a MVP going is first Step

Would it be possible to use the new AndroidView created for Inline Google Maps?

flutter/flutter#19030 (comment)
flutter/plugins#743 (review)

@allanwolski thats looks very interesting !

I think it worth trying and then comparing what it gives with the Flutter Texture approach.

One thing i noticed between the two approaches is he z buffer.
With Android Views it seems to be top always.
With Flutter Texture you have control of the z buffer.
I have not tried it but only read it.

SO when you open the drawer you might get bad UX experience with android view.
But gotta try it, and its very new

Yes, I want written in dart.

This is the layout I need port to Flutter:

e4b37cb9-c35a-4911-9cbd-0a3089b367c4

Quick Status update - will look into this issue after iOS support is enabled.

Any progress on this?

@allanwolski

I have a MVP working at the inline branch.

(example)

Screenshot

However, it seems that there are still some rough edges;
Here are some I encountered.

  • Hot reload breaks the view
  • Changing orientation breaks the view

Once these are ironed out, I will merge into master.

Current implementation uses flutter's new AndroidView, which is considered a beta feature as of now. It is possible that bugs are inherited from upstream.

I might not be closing the PDFView on the Java side properly. Anyone with more experience here?

Great job, @devxpy!

I tested here and found only the problems reported by you.
The performance is very good!

I experience crashes with multiple tabs and the plugin of the inline branch. Maybe i can send logs later.

But anyways thank you very much for this 👍

@Borduni multiple tabs, can you please provide more context?

I have a layout with a bottom navigation bar (3 pages). The app crashes when switching between them after implementing this plugin. If I revert it everything is fine again

@Borduni I think it would really help if you could provide some error logs 😸

Okay I think the error was because of my phone. I have installed a custom rom. Tried it on the same phone without any modifications and it worked, thanks!

That's weird. This could be an issue upstream with flutter. Let me try upgrading to flutter 1.0

@devxpy

Do you have any idea when this will merge into master?
Also wanted to know if you have plans for iOS?

@allanwolski I cannot say for sure when this will merge into master. I still have these issues, with really no idea why they're happening. The flutter Platform views are still a preview feature.

I really want to do ios, but cannot seem to get my hands on a compiler :/

@devxpy, any updates on this? Do the bugs still occur?

I found i out that if you add to AndroidManifest.xml
<application> <activity android:name=".PdfActivity" android:configChanges="orientation" /> </application>
and create Activity Listener

class PdfActivity : Activity() {}
and include it in PdfViewerThread
class PdfViewerThread( val instance: FlutterPdfViewerPlugin, val methodCall: MethodCall, val result: MethodChannel.Result, val activity: PdfActivity = PdfActivity() ) : Thread()

the view will rerender after changing orientation. But some stack trace error occurs during that

@Xaeroxaero where is PdfViewerThread?