textor icon indicating copy to clipboard operation
textor copied to clipboard

Preview is rendered wrong in dark mode

Open LeoNatan opened this issue 7 years ago • 8 comments

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 avatar Mar 17 '18 11:03 LeoNatan

Not sure if this is a UIKit bug.

LeoNatan avatar Mar 17 '18 11:03 LeoNatan

I believe this is a UIKit bug.

louisdh avatar Mar 17 '18 12:03 louisdh

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

louisdh avatar Mar 17 '18 12:03 louisdh

I use 11.3 šŸ˜„

LeoNatan avatar Mar 17 '18 12:03 LeoNatan

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

LeoNatan avatar Mar 17 '18 12:03 LeoNatan

The system creates it, so out of our control I’m afraid šŸ˜•.

louisdh avatar Mar 17 '18 13:03 louisdh

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

alessaba avatar Mar 19 '18 13:03 alessaba

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:

  • https://developer.apple.com/videos/play/wwdc2017/229/
  • https://developer.apple.com/documentation/uikit/uidocument/1619947-fileattributestowrite
  • https://developer.apple.com/documentation/foundation/urlresourcekey/1410313-thumbnaildictionarykey

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:

  • https://developer.apple.com/videos/play/wwdc2017/229/
  • https://developer.apple.com/documentation/quicklook/qlthumbnailprovider/2875787-providethumbnail

aamct2 avatar Apr 10 '18 18:04 aamct2