Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Preview is rendered wrong in dark mode #11

Open
LeoNatan opened this issue Mar 17, 2018 · 8 comments
Open

Preview is rendered wrong in dark mode #11

LeoNatan opened this issue Mar 17, 2018 · 8 comments
Labels
bug Something isn't working

Comments

@LeoNatan
Copy link

3cbb06ad-a499-424a-9735-c0540cb99b12

To reproduce, quickly tap the Add button, type a short word and tap Done.
After editing several times, it becomes fully white as expected.

@LeoNatan
Copy link
Author

Not sure if this is a UIKit bug.

@louisdh louisdh added the bug Something isn't working label Mar 17, 2018
@louisdh
Copy link
Owner

louisdh commented Mar 17, 2018

I believe this is a UIKit bug.

@louisdh
Copy link
Owner

louisdh commented Mar 17, 2018

I heard iOS 11.3 will fix a lot of bugs in UIDocumentBrowserViewController, hopefully fixes this glitch.

@LeoNatan
Copy link
Author

I use 11.3 😄

@LeoNatan
Copy link
Author

How are previews generated? Does the system create the thumbnail or is the app rendering it in an extension?

@louisdh
Copy link
Owner

louisdh commented Mar 17, 2018

The system creates it, so out of our control I’m afraid 😕.

@alessaba
Copy link
Contributor

Yeah, it's just a simple line of code and iOS should automatically set colors, previews, and everything.
It's definitely a UIKit bug

@aamct2
Copy link

aamct2 commented Apr 10, 2018

If iOS isn't providing correct/good thumbnail renderings, we do have a couple options to work around it.

Option 1

We could manually generate a thumbnail and set the appropriate resource key as part of the save process for the UIDocument. It looks something like:

override func fileAttributesToWrite(to url: URL, for saveOperation: UIDocumentSaveOperation) throws -> [AnyHashable : Any] {
    let thumbnail = thumbnailForDocument(at: url)
    return [
        URLResourceKey.thumbnailDictionaryKey: [
            URLThumbnailDictionaryItem.NSThumbnail1024x1024SizeKey: thumbnail
        ]
    ]
}

This would be the option I'd recommend as we're only handling it for documents that Textor has created/edited and not text documents system wide.

For further reference see:

Option 2

We could support the new thumbnail extension that came with iOS 11. There's an Xcode template for this. Essentially, the core method is:

func provideThumbnail(for request: QLFileThumbnailRequest, _ handler: @escaping (QLThumbnailReply?, Error?) -> Void)

I don't recommend this as we aren't the primary owners of the text UTI type. We aren't dealing with a custom document format, which is what this is designed for.

For further reference see:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants