David PHAM-VAN

Fix Swift 5 deprecated function

@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 4
5 - Add PdfPreview Widget 5 - Add PdfPreview Widget
6 - Implement Printing.raster() on Flutter Web 6 - Implement Printing.raster() on Flutter Web
  7 +- Fix Swift 5 deprecated function
7 8
8 ## 3.3.1 9 ## 3.3.1
9 10
@@ -247,9 +247,17 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate @@ -247,9 +247,17 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate
247 let stride = width * 4 247 let stride = width * 4
248 var data = Data(repeating: 0, count: stride * height) 248 var data = Data(repeating: 0, count: stride * height)
249 249
250 - data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in 250 + data.withUnsafeMutableBytes { (outputBytes: UnsafeMutableRawBufferPointer) in
251 let rgb = CGColorSpaceCreateDeviceRGB() 251 let rgb = CGColorSpaceCreateDeviceRGB()
252 - let context = CGContext(data: ptr, width: width, height: height, bitsPerComponent: 8, bytesPerRow: stride, space: rgb, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) 252 + let context = CGContext(
  253 + data: outputBytes.baseAddress?.assumingMemoryBound(to: UInt8.self),
  254 + width: width,
  255 + height: height,
  256 + bitsPerComponent: 8,
  257 + bytesPerRow: stride,
  258 + space: rgb,
  259 + bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue
  260 + )
253 if context != nil { 261 if context != nil {
254 context!.scaleBy(x: scale, y: scale) 262 context!.scaleBy(x: scale, y: scale)
255 context!.drawPDFPage(page) 263 context!.drawPDFPage(page)
@@ -185,9 +185,17 @@ public class PrintJob: NSView, NSSharingServicePickerDelegate { @@ -185,9 +185,17 @@ public class PrintJob: NSView, NSSharingServicePickerDelegate {
185 let stride = width * 4 185 let stride = width * 4
186 var data = Data(repeating: 0, count: stride * height) 186 var data = Data(repeating: 0, count: stride * height)
187 187
188 - data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in 188 + data.withUnsafeMutableBytes { (outputBytes: UnsafeMutableRawBufferPointer) in
189 let rgb = CGColorSpaceCreateDeviceRGB() 189 let rgb = CGColorSpaceCreateDeviceRGB()
190 - let context = CGContext(data: ptr, width: width, height: height, bitsPerComponent: 8, bytesPerRow: stride, space: rgb, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) 190 + let context = CGContext(
  191 + data: outputBytes.baseAddress?.assumingMemoryBound(to: UInt8.self),
  192 + width: width,
  193 + height: height,
  194 + bitsPerComponent: 8,
  195 + bytesPerRow: stride,
  196 + space: rgb,
  197 + bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue
  198 + )
191 if context != nil { 199 if context != nil {
192 context!.scaleBy(x: scale, y: scale) 200 context!.scaleBy(x: scale, y: scale)
193 context!.drawPDFPage(page) 201 context!.drawPDFPage(page)