Preview is rendered wrong in dark mode

To reproduce, quickly tap the Add button, type a short word and tap Done. After editing several times, it becomes fully white as expected.
Not sure if this is a UIKit bug.
I believe this is a UIKit bug.
I heard iOS 11.3 will fix a lot of bugs in UIDocumentBrowserViewController, hopefully fixes this glitch.
I use 11.3 š
How are previews generated? Does the system create the thumbnail or is the app rendering it in an extension?
The system creates it, so out of our control Iām afraid š.
Yeah, it's just a simple line of code and iOS should automatically set colors, previews, and everything. It's definitely a UIKit bug
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