diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintJobInfoExt.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintJobInfoExt.java index f2aafe6e..8c1305b0 100644 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintJobInfoExt.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintJobInfoExt.java @@ -48,7 +48,9 @@ public class PrintJobInfoExt { obj.put("numberOfPages", numberOfPages); obj.put("creationTime", creationTime); obj.put("label", label); - obj.put("printerId", printerId); + Map printer = new HashMap<>(); + printer.put("id", printerId); + obj.put("printer", printer); obj.put("attributes", attributes != null ? attributes.toMap() : null); return obj; } diff --git a/build.yaml b/build.yaml new file mode 100644 index 00000000..e2b3acf3 --- /dev/null +++ b/build.yaml @@ -0,0 +1,5 @@ +targets: + $default: + sources: + exclude: + - example/**.dart diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index 9e98dd5e..fae63896 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -3,12 +3,11 @@ export "FLUTTER_ROOT=/Users/lorenzopichilli/fvm/versions/2.10.4" export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example" export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/lib/main.dart" +export "FLUTTER_TARGET=lib/main.dart" export "FLUTTER_BUILD_DIR=build" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" -export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=true" export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/.dart_tool/package_config.json" +export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj index f9c8aaaf..f53831be 100644 --- a/example/macos/Runner.xcodeproj/project.pbxproj +++ b/example/macos/Runner.xcodeproj/project.pbxproj @@ -167,7 +167,6 @@ 7D4269DF6E938B573DA3AB1B /* Pods-Runner.release.xcconfig */, B44881B5FC807BDF77BD81E9 /* Pods-Runner.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; diff --git a/ios/Classes/PrintJob/PrintJobInfo.swift b/ios/Classes/PrintJob/PrintJobInfo.swift index 9eb8aba1..84a00261 100644 --- a/ios/Classes/PrintJob/PrintJobInfo.swift +++ b/ios/Classes/PrintJob/PrintJobInfo.swift @@ -37,7 +37,9 @@ public class PrintJobInfo : NSObject { "numberOfPages": numberOfPages, "creationTime": creationTime, "label": label, - "printerId": printerId + "printer": [ + "id": printerId + ] ] } } diff --git a/ios/Classes/Types/BaseCallbackResult.swift b/ios/Classes/Types/BaseCallbackResult.swift index f7edb4a5..a76caf72 100644 --- a/ios/Classes/Types/BaseCallbackResult.swift +++ b/ios/Classes/Types/BaseCallbackResult.swift @@ -1,8 +1,8 @@ // // BaseCallbackResult.swift -// flutter_inappwebview +// shared-apple // -// Created by Lorenzo Pichilli on 06/05/22. +// Created by Lorenzo Pichilli on 17/10/22. // import Foundation diff --git a/lib/src/print_job/print_job_settings.dart b/lib/src/print_job/print_job_settings.dart index 26673efc..1c4d7a80 100644 --- a/lib/src/print_job/print_job_settings.dart +++ b/lib/src/print_job/print_job_settings.dart @@ -13,6 +13,7 @@ class PrintJobSettings { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS bool handledByClient; ///The name of the print job. @@ -22,6 +23,7 @@ class PrintJobSettings { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS String? jobName; ///`true` to animate the display of the sheet, `false` to display the sheet immediately. @@ -35,12 +37,14 @@ class PrintJobSettings { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS PrintJobOrientation? orientation; ///The number of pages to render. /// ///**Supported Platforms/Implementations**: ///- iOS + ///- MacOS int? numberOfPages; ///Force rendering quality. @@ -57,6 +61,7 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- iOS + ///- MacOS EdgeInsets? margins; ///The media size. @@ -69,6 +74,7 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView + ///- MacOS PrintJobColorMode? colorMode; ///The duplex mode to use for the print job. @@ -97,6 +103,7 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- iOS + ///- MacOS bool showsNumberOfCopies; ///A Boolean value that determines whether the paper selection menu displays. @@ -115,8 +122,73 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- iOS + ///- MacOS bool showsPaperOrientation; + ///A Boolean value that determines whether the print panel includes a control for manipulating the paper size of the printer. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool showsPaperSize; + + ///A Boolean value that determines whether the Print panel includes a control for scaling the printed output. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool showsScaling; + + ///A Boolean value that determines whether the Print panel includes a set of fields for manipulating the range of pages being printed. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool showsPageRange; + + ///A Boolean value that determines whether the Print panel includes a separate accessory view for manipulating the paper size, orientation, and scaling attributes. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool showsPageSetupAccessory; + + ///A Boolean value that determines whether the Print panel displays a built-in preview of the document contents. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool showsPreview; + + ///A Boolean value that determines whether the Print panel includes an additional selection option for paper range. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool showsPrintSelection; + + ///A Boolean value that determines whether the print operation displays a print panel. + ///The default value is `true`. + /// + ///This property does not affect the display of a progress panel; + ///that operation is controlled by the [showsProgressPanel] property. + ///Operations that generate EPS or PDF data do no display a progress panel, regardless of the value in the flag parameter. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool showsPrintPanel; + + ///A Boolean value that determines whether the print operation displays a progress panel. + ///The default value is `true`. + /// + ///This property does not affect the display of a print panel; + ///that operation is controlled by the [showsPrintPanel] property. + ///Operations that generate EPS or PDF data do no display a progress panel, regardless of the value in the flag parameter. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool showsProgressPanel; + ///The height of the page footer. /// ///The footer is measured in points from the bottom of [printableRect] and is below the content area. @@ -156,6 +228,132 @@ class PrintJobSettings { ///- iOS double? maximumContentWidth; + ///The current scaling factor. From `0.0` to `1.0`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + double? scalingFactor; + + ///The action specified for the job. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobDisposition? jobDisposition; + + ///An URL containing the location to which the job file will be saved when the [jobDisposition] is [PrintJobDisposition.SAVE]. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + Uri? jobSavingURL; + + ///The name of the currently selected paper size. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + String? paperName; + + ///The horizontal pagination mode. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobPaginationMode? horizontalPagination; + + ///The vertical pagination to the specified mode. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobPaginationMode? verticalPagination; + + ///Indicates whether the image is centered horizontally. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool isHorizontallyCentered; + + ///Indicates whether the image is centered vertically. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool isVerticallyCentered; + + ///The print order for the pages of the operation. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobPageOrder? pageOrder; + + ///Whether the print operation should spawn a separate thread in which to run itself. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool canSpawnSeparateThread; + + ///How many copies to print. + ///The default value is `1`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int copies; + + ///An integer value that specifies the first page in the print job. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? firstPage; + + ///An integer value that specifies the last page in the print job. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? lastPage; + + ///If `true`, produce detailed reports when an error occurs. + ///The default value is `false`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool detailedErrorReporting; + + ///A fax number. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + String? faxNumber; + + ///If `true`, a standard header and footer are added outside the margins of each page. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool headerAndFooter; + + ///If `true`, collates output. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? mustCollate; + + ///The number of logical pages to be tiled horizontally on a physical sheet of paper. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? pagesAcross; + + ///The number of logical pages to be tiled vertically on a physical sheet of paper. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? pagesDown; + + ///A timestamp that specifies the time at which printing should begin. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? time; + PrintJobSettings( {this.handledByClient = false, this.jobName, @@ -175,35 +373,94 @@ class PrintJobSettings { this.maximumContentHeight, this.maximumContentWidth, this.footerHeight, - this.headerHeight}); + this.headerHeight, + this.showsPaperSize = true, + this.showsScaling = true, + this.showsPageRange = true, + this.showsPageSetupAccessory = true, + this.showsPreview = true, + this.showsPrintSelection = true, + this.scalingFactor, + this.showsPrintPanel = true, + this.showsProgressPanel = true, + this.jobDisposition, + this.jobSavingURL, + this.paperName, + this.horizontalPagination, + this.verticalPagination, + this.isHorizontallyCentered = true, + this.isVerticallyCentered = true, + this.pageOrder, + this.canSpawnSeparateThread = true, + this.copies = 1, + this.firstPage, + this.lastPage, + this.detailedErrorReporting = false, + this.faxNumber, + this.headerAndFooter = true, + this.mustCollate, + this.pagesAcross, + this.pagesDown, + this.time}); ///Gets a [PrintJobSettings] instance from a [Map] value. factory PrintJobSettings.fromMap(Map map) { return PrintJobSettings( - handledByClient: map["handledByClient"], - jobName: map["jobName"], - animated: map["animated"], - orientation: PrintJobOrientation.fromNativeValue(map["orientation"]), - numberOfPages: map["numberOfPages"], - forceRenderingQuality: PrintJobRenderingQuality.fromNativeValue( - map["forceRenderingQuality"]), - margins: MapEdgeInsets.fromMap(map["margins"]?.cast()), - mediaSize: - PrintJobMediaSize.fromMap(map["mediaSize"]?.cast()), - colorMode: PrintJobColorMode.fromNativeValue(map["colorMode"]), - duplexMode: PrintJobDuplexMode.fromNativeValue(map["duplexMode"]), - outputType: PrintJobOutputType.fromNativeValue(map["outputType"]), - resolution: PrintJobResolution.fromMap( - map["resolution"]?.cast()), - showsNumberOfCopies: map["showsNumberOfCopies"], - showsPaperSelectionForLoadedPapers: - map["showsPaperSelectionForLoadedPapers"], - showsPaperOrientation: map["showsPaperOrientation"], - maximumContentHeight: map["maximumContentHeight"], - maximumContentWidth: map["maximumContentWidth"], - footerHeight: map["footerHeight"], - headerHeight: map["headerHeight"], - ); + handledByClient: map["handledByClient"], + jobName: map["jobName"], + animated: map["animated"], + orientation: PrintJobOrientation.fromNativeValue(map["orientation"]), + numberOfPages: map["numberOfPages"], + forceRenderingQuality: PrintJobRenderingQuality.fromNativeValue( + map["forceRenderingQuality"]), + margins: MapEdgeInsets.fromMap(map["margins"]?.cast()), + mediaSize: PrintJobMediaSize.fromMap( + map["mediaSize"]?.cast()), + colorMode: PrintJobColorMode.fromNativeValue(map["colorMode"]), + duplexMode: PrintJobDuplexMode.fromNativeValue(map["duplexMode"]), + outputType: PrintJobOutputType.fromNativeValue(map["outputType"]), + resolution: PrintJobResolution.fromMap( + map["resolution"]?.cast()), + showsNumberOfCopies: map["showsNumberOfCopies"], + showsPaperSelectionForLoadedPapers: + map["showsPaperSelectionForLoadedPapers"], + showsPaperOrientation: map["showsPaperOrientation"], + maximumContentHeight: map["maximumContentHeight"], + maximumContentWidth: map["maximumContentWidth"], + footerHeight: map["footerHeight"], + headerHeight: map["headerHeight"], + showsPaperSize: map["showsPaperSize"], + showsScaling: map["showsScaling"], + showsPageRange: map["showsPageRange"], + showsPageSetupAccessory: map["showsPageSetupAccessory"], + showsPreview: map["showsPreview"], + showsPrintSelection: map["showsPrintSelection"], + scalingFactor: map["scalingFactor"], + showsPrintPanel: map["showsPrintPanel"], + showsProgressPanel: map["showsProgressPanel"], + jobDisposition: + PrintJobDisposition.fromNativeValue(map["jobDisposition"]), + jobSavingURL: + map["jobSavingURL"] != null ? Uri.parse(map["jobSavingURL"]) : null, + paperName: map["paperName"], + horizontalPagination: + PrintJobPaginationMode.fromNativeValue(map["horizontalPagination"]), + verticalPagination: + PrintJobPaginationMode.fromNativeValue(map["verticalPagination"]), + isHorizontallyCentered: map["isHorizontallyCentered"], + isVerticallyCentered: map["isVerticallyCentered"], + pageOrder: PrintJobPageOrder.fromNativeValue(map["pageOrder"]), + canSpawnSeparateThread: map["canSpawnSeparateThread"], + copies: map["copies"], + firstPage: map["firstPage"], + lastPage: map["lastPage"], + detailedErrorReporting: map["detailedErrorReporting"], + faxNumber: map["faxNumber"], + headerAndFooter: map["headerAndFooter"], + mustCollate: map["mustCollate"], + pagesAcross: map["pagesAcross"], + pagesDown: map["pagesDown"], + time: map["time"]); } Map toMap() { @@ -227,6 +484,34 @@ class PrintJobSettings { "maximumContentWidth": maximumContentWidth, "footerHeight": footerHeight, "headerHeight": headerHeight, + "showsPaperSize": showsPaperSize, + "showsScaling": showsScaling, + "showsPageRange": showsPageRange, + "showsPageSetupAccessory": showsPageSetupAccessory, + "showsPreview": showsPreview, + "showsPrintSelection": showsPrintSelection, + "scalingFactor": scalingFactor, + "showsPrintPanel": showsPrintPanel, + "showsProgressPanel": showsProgressPanel, + "jobDisposition": jobDisposition?.toNativeValue(), + "jobSavingURL": jobSavingURL.toString(), + "paperName": paperName, + "horizontalPagination": horizontalPagination?.toNativeValue(), + "verticalPagination": verticalPagination?.toNativeValue(), + "isHorizontallyCentered": isHorizontallyCentered, + "isVerticallyCentered": isVerticallyCentered, + "pageOrder": pageOrder?.toNativeValue(), + "canSpawnSeparateThread": canSpawnSeparateThread, + "copies": copies, + "firstPage": firstPage, + "lastPage": lastPage, + "detailedErrorReporting": detailedErrorReporting, + "faxNumber": faxNumber, + "headerAndFooter": headerAndFooter, + "mustCollate": mustCollate, + "pagesAcross": pagesAcross, + "pagesDown": pagesDown, + "time": time }; } diff --git a/lib/src/types/main.dart b/lib/src/types/main.dart index 84cbe04b..b427d132 100644 --- a/lib/src/types/main.dart +++ b/lib/src/types/main.dart @@ -208,3 +208,7 @@ export 'find_session.dart' show FindSession; export 'search_result_display_style.dart' show SearchResultDisplayStyle; export 'content_blocker_trigger_load_context.dart' show ContentBlockerTriggerLoadContext; +export 'print_job_page_order.dart' show PrintJobPageOrder; +export 'print_job_pagination_mode.dart' show PrintJobPaginationMode; +export 'print_job_disposition.dart' show PrintJobDisposition; +export 'printer.dart' show Printer; diff --git a/lib/src/types/print_job_attributes.dart b/lib/src/types/print_job_attributes.dart index 800a80cd..4ca454e6 100644 --- a/lib/src/types/print_job_attributes.dart +++ b/lib/src/types/print_job_attributes.dart @@ -9,6 +9,8 @@ import 'print_job_duplex_mode.dart'; import 'print_job_orientation.dart'; import 'print_job_media_size.dart'; import 'print_job_resolution.dart'; +import 'print_job_pagination_mode.dart'; +import 'print_job_disposition.dart'; part 'print_job_attributes.g.dart'; @@ -17,12 +19,12 @@ part 'print_job_attributes.g.dart'; @ExchangeableObject() class PrintJobAttributes_ { ///The color mode. - @SupportedPlatforms(platforms: [AndroidPlatform()]) + @SupportedPlatforms(platforms: [AndroidPlatform(), MacOSPlatform()]) PrintJobColorMode_? colorMode; ///The duplex mode to use for the print job. @SupportedPlatforms( - platforms: [AndroidPlatform(available: "23"), IOSPlatform()]) + platforms: [AndroidPlatform(available: "23"), IOSPlatform(), MacOSPlatform()]) PrintJobDuplexMode_? duplex; ///The orientation of the printed content, portrait or landscape. @@ -39,7 +41,7 @@ class PrintJobAttributes_ { ///The margins for each printed page. ///Margins define the white space around the content where the left margin defines ///the amount of white space on the left of the content and so on. - @SupportedPlatforms(platforms: [IOSPlatform()]) + @SupportedPlatforms(platforms: [IOSPlatform(), MacOSPlatform()]) EdgeInsets? margins; ///The height of the page footer. @@ -60,14 +62,14 @@ class PrintJobAttributes_ { /// ///The value of this property is a rectangle that defines the area in which the printer can print content. ///Sometimes this is referred to as the imageable area of the paper. - @SupportedPlatforms(platforms: [IOSPlatform()]) + @SupportedPlatforms(platforms: [IOSPlatform(), MacOSPlatform()]) InAppWebViewRect_? printableRect; ///The size of the paper used for printing. /// ///The value of this property is a rectangle that defines the size of paper chosen for the print job. ///The origin is always (0,0). - @SupportedPlatforms(platforms: [IOSPlatform()]) + @SupportedPlatforms(platforms: [IOSPlatform(), MacOSPlatform()]) InAppWebViewRect_? paperRect; ///The maximum height of the content area. @@ -87,6 +89,74 @@ class PrintJobAttributes_ { @SupportedPlatforms(platforms: [IOSPlatform()]) double? maximumContentWidth; + ///The name of the currently selected paper size. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + String? paperName; + + ///The human-readable name of the currently selected paper size, suitable for presentation in user interfaces. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + String? localizedPaperName; + + ///The horizontal pagination mode. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + PrintJobPaginationMode_? horizontalPagination; + + ///The vertical pagination to the specified mode. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + PrintJobPaginationMode_? verticalPagination; + + ///The action specified for the job. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + PrintJobDisposition_? jobDisposition; + + ///Indicates whether the image is centered horizontally. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + bool? isHorizontallyCentered; + + ///Indicates whether the image is centered vertically. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + bool? isVerticallyCentered; + + ///Indicates whether only the currently selected contents should be printed. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + bool? isSelectionOnly; + + ///The current scaling factor. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + double? scalingFactor; + + ///An URL containing the location to which the job file will be saved when the [jobDisposition] is [PrintJobDisposition.SAVE]. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + Uri? jobSavingURL; + + ///If `true`, produce detailed reports when an error occurs. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + bool? detailedErrorReporting; + + ///A fax number. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + String? faxNumber; + + ///If `true`, a standard header and footer are added outside the margins of each page. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + bool? headerAndFooter; + + ///If `true`, collates output. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + bool? mustCollate; + + ///The number of logical pages to be tiled horizontally on a physical sheet of paper. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + int? pagesAcross; + + ///The number of logical pages to be tiled vertically on a physical sheet of paper. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + int? pagesDown; + + ///A timestamp that specifies the time at which printing should begin. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + int? time; + PrintJobAttributes_( {this.colorMode, this.duplex, @@ -99,5 +169,22 @@ class PrintJobAttributes_ { this.footerHeight, this.headerHeight, this.paperRect, - this.printableRect}); + this.printableRect, + this.paperName, + this.localizedPaperName, + this.horizontalPagination, + this.verticalPagination, + this.jobDisposition, + this.isHorizontallyCentered, + this.isVerticallyCentered, + this.isSelectionOnly, + this.scalingFactor, + this.jobSavingURL, + this.detailedErrorReporting, + this.faxNumber, + this.headerAndFooter, + this.mustCollate, + this.pagesAcross, + this.pagesDown, + this.time}); } diff --git a/lib/src/types/print_job_attributes.g.dart b/lib/src/types/print_job_attributes.g.dart index 16e16fa1..e4218a70 100644 --- a/lib/src/types/print_job_attributes.g.dart +++ b/lib/src/types/print_job_attributes.g.dart @@ -13,6 +13,7 @@ class PrintJobAttributes { /// ///**Supported Platforms/Implementations**: ///- Android native WebView + ///- MacOS PrintJobColorMode? colorMode; ///The duplex mode to use for the print job. @@ -20,6 +21,7 @@ class PrintJobAttributes { ///**Supported Platforms/Implementations**: ///- Android native WebView 23+ ///- iOS + ///- MacOS PrintJobDuplexMode? duplex; ///The orientation of the printed content, portrait or landscape. @@ -43,6 +45,7 @@ class PrintJobAttributes { /// ///**Supported Platforms/Implementations**: ///- iOS + ///- MacOS EdgeInsets? margins; ///The height of the page footer. @@ -70,6 +73,7 @@ class PrintJobAttributes { /// ///**Supported Platforms/Implementations**: ///- iOS + ///- MacOS InAppWebViewRect? printableRect; ///The size of the paper used for printing. @@ -79,6 +83,7 @@ class PrintJobAttributes { /// ///**Supported Platforms/Implementations**: ///- iOS + ///- MacOS InAppWebViewRect? paperRect; ///The maximum height of the content area. @@ -101,6 +106,108 @@ class PrintJobAttributes { ///**Supported Platforms/Implementations**: ///- iOS double? maximumContentWidth; + + ///The name of the currently selected paper size. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + String? paperName; + + ///The human-readable name of the currently selected paper size, suitable for presentation in user interfaces. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + String? localizedPaperName; + + ///The horizontal pagination mode. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobPaginationMode? horizontalPagination; + + ///The vertical pagination to the specified mode. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobPaginationMode? verticalPagination; + + ///The action specified for the job. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobDisposition? jobDisposition; + + ///Indicates whether the image is centered horizontally. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? isHorizontallyCentered; + + ///Indicates whether the image is centered vertically. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? isVerticallyCentered; + + ///Indicates whether only the currently selected contents should be printed. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? isSelectionOnly; + + ///The current scaling factor. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + double? scalingFactor; + + ///An URL containing the location to which the job file will be saved when the [jobDisposition] is [PrintJobDisposition.SAVE]. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + Uri? jobSavingURL; + + ///If `true`, produce detailed reports when an error occurs. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? detailedErrorReporting; + + ///A fax number. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + String? faxNumber; + + ///If `true`, a standard header and footer are added outside the margins of each page. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? headerAndFooter; + + ///If `true`, collates output. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? mustCollate; + + ///The number of logical pages to be tiled horizontally on a physical sheet of paper. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? pagesAcross; + + ///The number of logical pages to be tiled vertically on a physical sheet of paper. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? pagesDown; + + ///A timestamp that specifies the time at which printing should begin. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? time; PrintJobAttributes( {this.colorMode, this.duplex, @@ -113,7 +220,24 @@ class PrintJobAttributes { this.printableRect, this.paperRect, this.maximumContentHeight, - this.maximumContentWidth}); + this.maximumContentWidth, + this.paperName, + this.localizedPaperName, + this.horizontalPagination, + this.verticalPagination, + this.jobDisposition, + this.isHorizontallyCentered, + this.isVerticallyCentered, + this.isSelectionOnly, + this.scalingFactor, + this.jobSavingURL, + this.detailedErrorReporting, + this.faxNumber, + this.headerAndFooter, + this.mustCollate, + this.pagesAcross, + this.pagesDown, + this.time}); ///Gets a possible [PrintJobAttributes] instance from a [Map] value. static PrintJobAttributes? fromMap(Map? map) { @@ -137,6 +261,27 @@ class PrintJobAttributes { InAppWebViewRect.fromMap(map['paperRect']?.cast()), maximumContentHeight: map['maximumContentHeight'], maximumContentWidth: map['maximumContentWidth'], + paperName: map['paperName'], + localizedPaperName: map['localizedPaperName'], + horizontalPagination: + PrintJobPaginationMode.fromNativeValue(map['horizontalPagination']), + verticalPagination: + PrintJobPaginationMode.fromNativeValue(map['verticalPagination']), + jobDisposition: + PrintJobDisposition.fromNativeValue(map['jobDisposition']), + isHorizontallyCentered: map['isHorizontallyCentered'], + isVerticallyCentered: map['isVerticallyCentered'], + isSelectionOnly: map['isSelectionOnly'], + scalingFactor: map['scalingFactor'], + jobSavingURL: + map['jobSavingURL'] != null ? Uri.parse(map['jobSavingURL']) : null, + detailedErrorReporting: map['detailedErrorReporting'], + faxNumber: map['faxNumber'], + headerAndFooter: map['headerAndFooter'], + mustCollate: map['mustCollate'], + pagesAcross: map['pagesAcross'], + pagesDown: map['pagesDown'], + time: map['time'], ); return instance; } @@ -156,6 +301,23 @@ class PrintJobAttributes { "paperRect": paperRect?.toMap(), "maximumContentHeight": maximumContentHeight, "maximumContentWidth": maximumContentWidth, + "paperName": paperName, + "localizedPaperName": localizedPaperName, + "horizontalPagination": horizontalPagination?.toNativeValue(), + "verticalPagination": verticalPagination?.toNativeValue(), + "jobDisposition": jobDisposition?.toNativeValue(), + "isHorizontallyCentered": isHorizontallyCentered, + "isVerticallyCentered": isVerticallyCentered, + "isSelectionOnly": isSelectionOnly, + "scalingFactor": scalingFactor, + "jobSavingURL": jobSavingURL?.toString(), + "detailedErrorReporting": detailedErrorReporting, + "faxNumber": faxNumber, + "headerAndFooter": headerAndFooter, + "mustCollate": mustCollate, + "pagesAcross": pagesAcross, + "pagesDown": pagesDown, + "time": time, }; } @@ -166,6 +328,6 @@ class PrintJobAttributes { @override String toString() { - return 'PrintJobAttributes{colorMode: $colorMode, duplex: $duplex, orientation: $orientation, mediaSize: $mediaSize, resolution: $resolution, margins: $margins, footerHeight: $footerHeight, headerHeight: $headerHeight, printableRect: $printableRect, paperRect: $paperRect, maximumContentHeight: $maximumContentHeight, maximumContentWidth: $maximumContentWidth}'; + return 'PrintJobAttributes{colorMode: $colorMode, duplex: $duplex, orientation: $orientation, mediaSize: $mediaSize, resolution: $resolution, margins: $margins, footerHeight: $footerHeight, headerHeight: $headerHeight, printableRect: $printableRect, paperRect: $paperRect, maximumContentHeight: $maximumContentHeight, maximumContentWidth: $maximumContentWidth, paperName: $paperName, localizedPaperName: $localizedPaperName, horizontalPagination: $horizontalPagination, verticalPagination: $verticalPagination, jobDisposition: $jobDisposition, isHorizontallyCentered: $isHorizontallyCentered, isVerticallyCentered: $isVerticallyCentered, isSelectionOnly: $isSelectionOnly, scalingFactor: $scalingFactor, jobSavingURL: $jobSavingURL, detailedErrorReporting: $detailedErrorReporting, faxNumber: $faxNumber, headerAndFooter: $headerAndFooter, mustCollate: $mustCollate, pagesAcross: $pagesAcross, pagesDown: $pagesDown, time: $time}'; } } diff --git a/lib/src/types/print_job_disposition.dart b/lib/src/types/print_job_disposition.dart new file mode 100644 index 00000000..7f788009 --- /dev/null +++ b/lib/src/types/print_job_disposition.dart @@ -0,0 +1,38 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +import '../print_job/main.dart'; + +part 'print_job_disposition.g.dart'; + +///Class representing the constants that specify values for the print job disposition of a [PrintJobController]. +@ExchangeableEnum() +class PrintJobDisposition_ { + // ignore: unused_field + final String _value; + const PrintJobDisposition_._internal(this._value); + + ///Normal print job. + @EnumSupportedPlatforms(platforms: [ + EnumMacOSPlatform(value: 'spool') + ]) + static const SPOOL = const PrintJobDisposition_._internal('SPOOL'); + + ///Send to Preview application. + @EnumSupportedPlatforms(platforms: [ + EnumMacOSPlatform(value: 'preview') + ]) + static const PREVIEW = const PrintJobDisposition_._internal("PREVIEW"); + + ///Save to a file. + @EnumSupportedPlatforms(platforms: [ + EnumMacOSPlatform(value: 'save') + ]) + static const SAVE = const PrintJobDisposition_._internal("SAVE"); + + ///Cancel print job. + @EnumSupportedPlatforms(platforms: [ + EnumMacOSPlatform(value: 'cancel') + ]) + static const CANCEL = const PrintJobDisposition_._internal("CANCEL"); +} diff --git a/lib/src/types/print_job_disposition.g.dart b/lib/src/types/print_job_disposition.g.dart new file mode 100644 index 00000000..a48ca101 --- /dev/null +++ b/lib/src/types/print_job_disposition.g.dart @@ -0,0 +1,127 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_disposition.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing the constants that specify values for the print job disposition of a [PrintJobController]. +class PrintJobDisposition { + final String _value; + final String _nativeValue; + const PrintJobDisposition._internal(this._value, this._nativeValue); +// ignore: unused_element + factory PrintJobDisposition._internalMultiPlatform( + String value, Function nativeValue) => + PrintJobDisposition._internal(value, nativeValue()); + + ///Normal print job. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + static final SPOOL = PrintJobDisposition._internalMultiPlatform('SPOOL', () { + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + return 'spool'; + default: + break; + } + return null; + }); + + ///Send to Preview application. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + static final PREVIEW = + PrintJobDisposition._internalMultiPlatform('PREVIEW', () { + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + return 'preview'; + default: + break; + } + return null; + }); + + ///Save to a file. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + static final SAVE = PrintJobDisposition._internalMultiPlatform('SAVE', () { + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + return 'save'; + default: + break; + } + return null; + }); + + ///Cancel print job. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + static final CANCEL = + PrintJobDisposition._internalMultiPlatform('CANCEL', () { + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + return 'cancel'; + default: + break; + } + return null; + }); + + ///Set of all values of [PrintJobDisposition]. + static final Set values = [ + PrintJobDisposition.SPOOL, + PrintJobDisposition.PREVIEW, + PrintJobDisposition.SAVE, + PrintJobDisposition.CANCEL, + ].toSet(); + + ///Gets a possible [PrintJobDisposition] instance from [String] value. + static PrintJobDisposition? fromValue(String? value) { + if (value != null) { + try { + return PrintJobDisposition.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [PrintJobDisposition] instance from a native value. + static PrintJobDisposition? fromNativeValue(String? value) { + if (value != null) { + try { + return PrintJobDisposition.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [String] native value. + String toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/lib/src/types/print_job_info.dart b/lib/src/types/print_job_info.dart index ec5e0b43..c544d02d 100644 --- a/lib/src/types/print_job_info.dart +++ b/lib/src/types/print_job_info.dart @@ -2,7 +2,10 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_i import '../print_job/main.dart'; import 'print_job_attributes.dart'; +import 'print_job_rendering_quality.dart'; import 'print_job_state.dart'; +import 'print_job_page_order.dart'; +import 'printer.dart'; part 'print_job_info.g.dart'; @@ -15,12 +18,14 @@ class PrintJobInfo_ { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS PrintJobState_? state; ///How many copies to print. /// ///**Supported Platforms/Implementations**: ///- Android native WebView + ///- MacOS int? copies; ///The number of pages to print. @@ -28,6 +33,7 @@ class PrintJobInfo_ { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS int? numberOfPages; ///The timestamp when the print job was created. @@ -35,6 +41,7 @@ class PrintJobInfo_ { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS int? creationTime; ///The human readable print job label. @@ -42,20 +49,80 @@ class PrintJobInfo_ { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS String? label; - ///The unique id of the printer. + ///The printer object to be used for printing. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - String? printerId; + ///- MacOS + Printer_? printer; + + ///The page order that will be used to generate the pages in this job. + ///This is the physical page order of the pages. + ///It depends on the stacking order of the printer, the capability of the app to reverse page order, etc. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobPageOrder_? pageOrder; + + ///The printing quality. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobRenderingQuality_? preferredRenderingQuality; + + ///Whether the progress panel is shown during the operation. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? showsProgressPanel; + + ///Whether the print panel is shown during the operation. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? showsPrintPanel; + + ///Whether the print operation should spawn a separate thread in which to run itself. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? canSpawnSeparateThread; + + ///A Boolean value that indicates whether the print operation is an EPS or PDF copy operation. + ///It's `true` if the receiver is an EPS or PDF copy operation; otherwise, `false`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? isCopyingOperation; + + ///The current page number being previewed or printed. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? currentPage; + + ///An integer value that specifies the first page in the print job. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? firstPage; + + ///An integer value that specifies the last page in the print job. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? lastPage; ///The attributes of a print job. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS PrintJobAttributes_? attributes; PrintJobInfo_( @@ -64,6 +131,15 @@ class PrintJobInfo_ { this.numberOfPages, this.creationTime, this.label, - this.printerId, + this.printer, + this.pageOrder, + this.preferredRenderingQuality, + this.showsProgressPanel, + this.showsPrintPanel, + this.canSpawnSeparateThread, + this.isCopyingOperation, + this.currentPage, + this.firstPage, + this.lastPage, this.attributes}); } diff --git a/lib/src/types/print_job_info.g.dart b/lib/src/types/print_job_info.g.dart index ef8ca5c5..97670a03 100644 --- a/lib/src/types/print_job_info.g.dart +++ b/lib/src/types/print_job_info.g.dart @@ -14,12 +14,14 @@ class PrintJobInfo { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS PrintJobState? state; ///How many copies to print. /// ///**Supported Platforms/Implementations**: ///- Android native WebView + ///- MacOS int? copies; ///The number of pages to print. @@ -27,6 +29,7 @@ class PrintJobInfo { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS int? numberOfPages; ///The timestamp when the print job was created. @@ -34,6 +37,7 @@ class PrintJobInfo { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS int? creationTime; ///The human readable print job label. @@ -41,20 +45,80 @@ class PrintJobInfo { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS String? label; - ///The unique id of the printer. + ///The printer object to be used for printing. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - String? printerId; + ///- MacOS + Printer? printer; + + ///The page order that will be used to generate the pages in this job. + ///This is the physical page order of the pages. + ///It depends on the stacking order of the printer, the capability of the app to reverse page order, etc. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobPageOrder? pageOrder; + + ///The printing quality. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobRenderingQuality? preferredRenderingQuality; + + ///Whether the progress panel is shown during the operation. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? showsProgressPanel; + + ///Whether the print panel is shown during the operation. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? showsPrintPanel; + + ///Whether the print operation should spawn a separate thread in which to run itself. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? canSpawnSeparateThread; + + ///A Boolean value that indicates whether the print operation is an EPS or PDF copy operation. + ///It's `true` if the receiver is an EPS or PDF copy operation; otherwise, `false`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? isCopyingOperation; + + ///The current page number being previewed or printed. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? currentPage; + + ///An integer value that specifies the first page in the print job. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? firstPage; + + ///An integer value that specifies the last page in the print job. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? lastPage; ///The attributes of a print job. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS PrintJobAttributes? attributes; PrintJobInfo( {this.state, @@ -62,7 +126,16 @@ class PrintJobInfo { this.numberOfPages, this.creationTime, this.label, - this.printerId, + this.printer, + this.pageOrder, + this.preferredRenderingQuality, + this.showsProgressPanel, + this.showsPrintPanel, + this.canSpawnSeparateThread, + this.isCopyingOperation, + this.currentPage, + this.firstPage, + this.lastPage, this.attributes}); ///Gets a possible [PrintJobInfo] instance from a [Map] value. @@ -76,7 +149,17 @@ class PrintJobInfo { numberOfPages: map['numberOfPages'], creationTime: map['creationTime'], label: map['label'], - printerId: map['printerId'], + printer: Printer.fromMap(map['printer']?.cast()), + pageOrder: PrintJobPageOrder.fromNativeValue(map['pageOrder']), + preferredRenderingQuality: PrintJobRenderingQuality.fromNativeValue( + map['preferredRenderingQuality']), + showsProgressPanel: map['showsProgressPanel'], + showsPrintPanel: map['showsPrintPanel'], + canSpawnSeparateThread: map['canSpawnSeparateThread'], + isCopyingOperation: map['isCopyingOperation'], + currentPage: map['currentPage'], + firstPage: map['firstPage'], + lastPage: map['lastPage'], attributes: PrintJobAttributes.fromMap( map['attributes']?.cast()), ); @@ -91,7 +174,16 @@ class PrintJobInfo { "numberOfPages": numberOfPages, "creationTime": creationTime, "label": label, - "printerId": printerId, + "printer": printer?.toMap(), + "pageOrder": pageOrder?.toNativeValue(), + "preferredRenderingQuality": preferredRenderingQuality?.toNativeValue(), + "showsProgressPanel": showsProgressPanel, + "showsPrintPanel": showsPrintPanel, + "canSpawnSeparateThread": canSpawnSeparateThread, + "isCopyingOperation": isCopyingOperation, + "currentPage": currentPage, + "firstPage": firstPage, + "lastPage": lastPage, "attributes": attributes?.toMap(), }; } @@ -103,6 +195,6 @@ class PrintJobInfo { @override String toString() { - return 'PrintJobInfo{state: $state, copies: $copies, numberOfPages: $numberOfPages, creationTime: $creationTime, label: $label, printerId: $printerId, attributes: $attributes}'; + return 'PrintJobInfo{state: $state, copies: $copies, numberOfPages: $numberOfPages, creationTime: $creationTime, label: $label, printer: $printer, pageOrder: $pageOrder, preferredRenderingQuality: $preferredRenderingQuality, showsProgressPanel: $showsProgressPanel, showsPrintPanel: $showsPrintPanel, canSpawnSeparateThread: $canSpawnSeparateThread, isCopyingOperation: $isCopyingOperation, currentPage: $currentPage, firstPage: $firstPage, lastPage: $lastPage, attributes: $attributes}'; } } diff --git a/lib/src/types/print_job_orientation.dart b/lib/src/types/print_job_orientation.dart index 0694737d..b43d7d26 100644 --- a/lib/src/types/print_job_orientation.dart +++ b/lib/src/types/print_job_orientation.dart @@ -14,23 +14,15 @@ class PrintJobOrientation_ { ///Pages are printed in portrait orientation. @EnumSupportedPlatforms(platforms: [ - EnumIOSPlatform( - value: 0 - ), - EnumMacOSPlatform( - value: 0 - ) + EnumIOSPlatform(value: 0), + EnumMacOSPlatform(value: 0) ]) static const PORTRAIT = const PrintJobOrientation_._internal(0); ///Pages are printed in landscape orientation. @EnumSupportedPlatforms(platforms: [ - EnumIOSPlatform( - value: 1 - ), - EnumMacOSPlatform( - value: 1 - ) + EnumIOSPlatform(value: 1), + EnumMacOSPlatform(value: 1) ]) static const LANDSCAPE = const PrintJobOrientation_._internal(1); } diff --git a/lib/src/types/print_job_page_order.dart b/lib/src/types/print_job_page_order.dart new file mode 100644 index 00000000..386dfe6d --- /dev/null +++ b/lib/src/types/print_job_page_order.dart @@ -0,0 +1,38 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +import '../print_job/main.dart'; + +part 'print_job_page_order.g.dart'; + +///Class representing the page order that will be used to generate the pages of a [PrintJobController]. +@ExchangeableEnum() +class PrintJobPageOrder_ { + // ignore: unused_field + final int _value; + const PrintJobPageOrder_._internal(this._value); + + ///Descending (front to back) page order. + @EnumSupportedPlatforms(platforms: [ + EnumMacOSPlatform(value: -1) + ]) + static const DESCENDING = const PrintJobPageOrder_._internal(-1); + + ///The spooler does not rearrange pages—they are printed in the order received by the spooler. + @EnumSupportedPlatforms(platforms: [ + EnumMacOSPlatform(value: 0) + ]) + static const SPECIAL = const PrintJobPageOrder_._internal(0); + + ///Ascending (back to front) page order. + @EnumSupportedPlatforms(platforms: [ + EnumMacOSPlatform(value: 1) + ]) + static const ASCENDING = const PrintJobPageOrder_._internal(1); + + ///No page order specified. + @EnumSupportedPlatforms(platforms: [ + EnumMacOSPlatform(value: 2) + ]) + static const UNKNOWN = const PrintJobPageOrder_._internal(2); +} diff --git a/lib/src/types/print_job_page_order.g.dart b/lib/src/types/print_job_page_order.g.dart new file mode 100644 index 00000000..26598972 --- /dev/null +++ b/lib/src/types/print_job_page_order.g.dart @@ -0,0 +1,135 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_page_order.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing the page order that will be used to generate the pages of a [PrintJobController]. +class PrintJobPageOrder { + final int _value; + final int _nativeValue; + const PrintJobPageOrder._internal(this._value, this._nativeValue); +// ignore: unused_element + factory PrintJobPageOrder._internalMultiPlatform( + int value, Function nativeValue) => + PrintJobPageOrder._internal(value, nativeValue()); + + ///Descending (front to back) page order. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + static final DESCENDING = PrintJobPageOrder._internalMultiPlatform(-1, () { + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + return -1; + default: + break; + } + return null; + }); + + ///The spooler does not rearrange pages—they are printed in the order received by the spooler. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + static final SPECIAL = PrintJobPageOrder._internalMultiPlatform(0, () { + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + return 0; + default: + break; + } + return null; + }); + + ///Ascending (back to front) page order. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + static final ASCENDING = PrintJobPageOrder._internalMultiPlatform(1, () { + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + return 1; + default: + break; + } + return null; + }); + + ///No page order specified. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + static final UNKNOWN = PrintJobPageOrder._internalMultiPlatform(2, () { + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + return 2; + default: + break; + } + return null; + }); + + ///Set of all values of [PrintJobPageOrder]. + static final Set values = [ + PrintJobPageOrder.DESCENDING, + PrintJobPageOrder.SPECIAL, + PrintJobPageOrder.ASCENDING, + PrintJobPageOrder.UNKNOWN, + ].toSet(); + + ///Gets a possible [PrintJobPageOrder] instance from [int] value. + static PrintJobPageOrder? fromValue(int? value) { + if (value != null) { + try { + return PrintJobPageOrder.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [PrintJobPageOrder] instance from a native value. + static PrintJobPageOrder? fromNativeValue(int? value) { + if (value != null) { + try { + return PrintJobPageOrder.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case -1: + return 'DESCENDING'; + case 0: + return 'SPECIAL'; + case 1: + return 'ASCENDING'; + case 2: + return 'UNKNOWN'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/print_job_pagination_mode.dart b/lib/src/types/print_job_pagination_mode.dart new file mode 100644 index 00000000..90bfad7d --- /dev/null +++ b/lib/src/types/print_job_pagination_mode.dart @@ -0,0 +1,34 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +import '../print_job/main.dart'; + +part 'print_job_pagination_mode.g.dart'; + +///Class representing the constants that specify the different ways in which an image is divided into pages of a [PrintJobController]. +@ExchangeableEnum() +class PrintJobPaginationMode_ { + // ignore: unused_field + final String _value; + // ignore: unused_field + final int? _nativeValue = null; + const PrintJobPaginationMode_._internal(this._value); + + /// + @EnumSupportedPlatforms(platforms: [ + EnumMacOSPlatform(value: 0) + ]) + static const AUTOMATIC = const PrintJobPaginationMode_._internal('AUTOMATIC'); + + /// + @EnumSupportedPlatforms(platforms: [ + EnumMacOSPlatform(value: 1) + ]) + static const FIT = const PrintJobPaginationMode_._internal("FIT"); + + /// + @EnumSupportedPlatforms(platforms: [ + EnumMacOSPlatform(value: 2) + ]) + static const CLIP = const PrintJobPaginationMode_._internal("CLIP"); +} diff --git a/lib/src/types/print_job_pagination_mode.g.dart b/lib/src/types/print_job_pagination_mode.g.dart new file mode 100644 index 00000000..9b75951a --- /dev/null +++ b/lib/src/types/print_job_pagination_mode.g.dart @@ -0,0 +1,111 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_pagination_mode.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing the constants that specify the different ways in which an image is divided into pages of a [PrintJobController]. +class PrintJobPaginationMode { + final String _value; + final int? _nativeValue; + const PrintJobPaginationMode._internal(this._value, this._nativeValue); +// ignore: unused_element + factory PrintJobPaginationMode._internalMultiPlatform( + String value, Function nativeValue) => + PrintJobPaginationMode._internal(value, nativeValue()); + + /// + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + static final AUTOMATIC = + PrintJobPaginationMode._internalMultiPlatform('AUTOMATIC', () { + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + return 0; + default: + break; + } + return null; + }); + + /// + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + static final FIT = PrintJobPaginationMode._internalMultiPlatform('FIT', () { + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + return 1; + default: + break; + } + return null; + }); + + /// + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + static final CLIP = PrintJobPaginationMode._internalMultiPlatform('CLIP', () { + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + return 2; + default: + break; + } + return null; + }); + + ///Set of all values of [PrintJobPaginationMode]. + static final Set values = [ + PrintJobPaginationMode.AUTOMATIC, + PrintJobPaginationMode.FIT, + PrintJobPaginationMode.CLIP, + ].toSet(); + + ///Gets a possible [PrintJobPaginationMode] instance from [String] value. + static PrintJobPaginationMode? fromValue(String? value) { + if (value != null) { + try { + return PrintJobPaginationMode.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [PrintJobPaginationMode] instance from a native value. + static PrintJobPaginationMode? fromNativeValue(int? value) { + if (value != null) { + try { + return PrintJobPaginationMode.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [int?] native value. + int? toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/lib/src/types/print_job_rendering_quality.dart b/lib/src/types/print_job_rendering_quality.dart index 9f25ecd5..e765a3dc 100644 --- a/lib/src/types/print_job_rendering_quality.dart +++ b/lib/src/types/print_job_rendering_quality.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import '../print_job/main.dart'; @@ -12,9 +13,17 @@ class PrintJobRenderingQuality_ { const PrintJobRenderingQuality_._internal(this._value); ///Renders the printing at the best possible quality, regardless of speed. + @EnumSupportedPlatforms(platforms: [ + EnumIOSPlatform(value: 0), + EnumMacOSPlatform(value: 0) + ]) static const BEST = const PrintJobRenderingQuality_._internal(0); ///Sacrifices the least possible amount of rendering quality for speed to maintain a responsive user interface. ///This option should be used only after establishing that best quality rendering does indeed make the user interface unresponsive. + @EnumSupportedPlatforms(platforms: [ + EnumIOSPlatform(value: 1), + EnumMacOSPlatform(value: 1) + ]) static const RESPONSIVE = const PrintJobRenderingQuality_._internal(1); } diff --git a/lib/src/types/print_job_rendering_quality.g.dart b/lib/src/types/print_job_rendering_quality.g.dart index 94a9534d..b836c8fc 100644 --- a/lib/src/types/print_job_rendering_quality.g.dart +++ b/lib/src/types/print_job_rendering_quality.g.dart @@ -17,11 +17,40 @@ class PrintJobRenderingQuality { PrintJobRenderingQuality._internal(value, nativeValue()); ///Renders the printing at the best possible quality, regardless of speed. - static const BEST = PrintJobRenderingQuality._internal(0, 0); + /// + ///**Supported Platforms/Implementations**: + ///- iOS + ///- MacOS + static final BEST = PrintJobRenderingQuality._internalMultiPlatform(0, () { + switch (defaultTargetPlatform) { + case TargetPlatform.iOS: + return 0; + case TargetPlatform.macOS: + return 0; + default: + break; + } + return null; + }); ///Sacrifices the least possible amount of rendering quality for speed to maintain a responsive user interface. ///This option should be used only after establishing that best quality rendering does indeed make the user interface unresponsive. - static const RESPONSIVE = PrintJobRenderingQuality._internal(1, 1); + /// + ///**Supported Platforms/Implementations**: + ///- iOS + ///- MacOS + static final RESPONSIVE = + PrintJobRenderingQuality._internalMultiPlatform(1, () { + switch (defaultTargetPlatform) { + case TargetPlatform.iOS: + return 1; + case TargetPlatform.macOS: + return 1; + default: + break; + } + return null; + }); ///Set of all values of [PrintJobRenderingQuality]. static final Set values = [ diff --git a/lib/src/types/print_job_state.dart b/lib/src/types/print_job_state.dart index beab9e07..84f5438f 100644 --- a/lib/src/types/print_job_state.dart +++ b/lib/src/types/print_job_state.dart @@ -10,6 +10,8 @@ part 'print_job_state.g.dart'; class PrintJobState_ { // ignore: unused_field final int _value; + // ignore: unused_field + final int? _nativeValue = null; const PrintJobState_._internal(this._value); ///Print job state: The print job is being created but not yet ready to be printed. @@ -21,7 +23,8 @@ class PrintJobState_ { apiUrl: 'https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CREATED', value: 1), - EnumIOSPlatform(value: 1) + EnumIOSPlatform(value: 1), + EnumMacOSPlatform(value: 1) ]) static const CREATED = const PrintJobState_._internal(1); @@ -46,7 +49,8 @@ class PrintJobState_ { apiUrl: 'https://developer.android.com/reference/android/print/PrintJobInfo#STATE_STARTED', value: 3), - EnumIOSPlatform(value: 3) + EnumIOSPlatform(value: 3), + EnumMacOSPlatform(value: 3) ]) static const STARTED = const PrintJobState_._internal(3); @@ -71,7 +75,8 @@ class PrintJobState_ { apiUrl: 'https://developer.android.com/reference/android/print/PrintJobInfo#STATE_COMPLETED', value: 5), - EnumIOSPlatform(value: 5) + EnumIOSPlatform(value: 5), + EnumMacOSPlatform(value: 5) ]) static const COMPLETED = const PrintJobState_._internal(5); @@ -97,7 +102,8 @@ class PrintJobState_ { apiUrl: 'https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CANCELED', value: 7), - EnumIOSPlatform(value: 7) + EnumIOSPlatform(value: 7), + EnumMacOSPlatform(value: 7) ]) static const CANCELED = const PrintJobState_._internal(7); } diff --git a/lib/src/types/print_job_state.g.dart b/lib/src/types/print_job_state.g.dart index 06f4ad2d..e5ac9e19 100644 --- a/lib/src/types/print_job_state.g.dart +++ b/lib/src/types/print_job_state.g.dart @@ -9,7 +9,7 @@ part of 'print_job_state.dart'; ///Class representing the state of a [PrintJobController]. class PrintJobState { final int _value; - final int _nativeValue; + final int? _nativeValue; const PrintJobState._internal(this._value, this._nativeValue); // ignore: unused_element factory PrintJobState._internalMultiPlatform( @@ -23,12 +23,15 @@ class PrintJobState { ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - PrintJobInfo.STATE_CREATED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CREATED)) ///- iOS + ///- MacOS static final CREATED = PrintJobState._internalMultiPlatform(1, () { switch (defaultTargetPlatform) { case TargetPlatform.android: return 1; case TargetPlatform.iOS: return 1; + case TargetPlatform.macOS: + return 1; default: break; } @@ -58,12 +61,15 @@ class PrintJobState { ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - PrintJobInfo.STATE_STARTED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_STARTED)) ///- iOS + ///- MacOS static final STARTED = PrintJobState._internalMultiPlatform(3, () { switch (defaultTargetPlatform) { case TargetPlatform.android: return 3; case TargetPlatform.iOS: return 3; + case TargetPlatform.macOS: + return 3; default: break; } @@ -93,12 +99,15 @@ class PrintJobState { ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - PrintJobInfo.STATE_COMPLETED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_COMPLETED)) ///- iOS + ///- MacOS static final COMPLETED = PrintJobState._internalMultiPlatform(5, () { switch (defaultTargetPlatform) { case TargetPlatform.android: return 5; case TargetPlatform.iOS: return 5; + case TargetPlatform.macOS: + return 5; default: break; } @@ -131,12 +140,15 @@ class PrintJobState { ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - PrintJobInfo.STATE_CANCELED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CANCELED)) ///- iOS + ///- MacOS static final CANCELED = PrintJobState._internalMultiPlatform(7, () { switch (defaultTargetPlatform) { case TargetPlatform.android: return 7; case TargetPlatform.iOS: return 7; + case TargetPlatform.macOS: + return 7; default: break; } @@ -183,8 +195,8 @@ class PrintJobState { ///Gets [int] value. int toValue() => _value; - ///Gets [int] native value. - int toNativeValue() => _nativeValue; + ///Gets [int?] native value. + int? toNativeValue() => _nativeValue; @override int get hashCode => _value.hashCode; diff --git a/lib/src/types/printer.dart b/lib/src/types/printer.dart new file mode 100644 index 00000000..e54a99e4 --- /dev/null +++ b/lib/src/types/printer.dart @@ -0,0 +1,27 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +import '../print_job/main.dart'; + +part 'printer.g.dart'; + +///Class representing the printer used by a [PrintJobController]. +@ExchangeableObject() +class Printer_ { + ///The unique id of the printer. + @SupportedPlatforms(platforms: [AndroidPlatform(), IOSPlatform()]) + String? id; + + ///A description of the printer’s make and model. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + String? type; + + ///The PostScript language level recognized by the printer. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + int? languageLevel; + + ///The printer’s name. + @SupportedPlatforms(platforms: [MacOSPlatform()]) + String? name; + + Printer_({this.id, this.type, this.languageLevel, this.name}); +} diff --git a/lib/src/types/printer.g.dart b/lib/src/types/printer.g.dart new file mode 100644 index 00000000..4ca68f98 --- /dev/null +++ b/lib/src/types/printer.g.dart @@ -0,0 +1,70 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'printer.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class representing the printer used by a [PrintJobController]. +class Printer { + ///The unique id of the printer. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + String? id; + + ///A description of the printer’s make and model. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + String? type; + + ///The PostScript language level recognized by the printer. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? languageLevel; + + ///The printer’s name. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + String? name; + Printer({this.id, this.type, this.languageLevel, this.name}); + + ///Gets a possible [Printer] instance from a [Map] value. + static Printer? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = Printer( + id: map['id'], + type: map['type'], + languageLevel: map['languageLevel'], + name: map['name'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "id": id, + "type": type, + "languageLevel": languageLevel, + "name": name, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'Printer{id: $id, type: $type, languageLevel: $languageLevel, name: $name}'; + } +} diff --git a/macos/Classes/FindInteraction/FindInteractionChannelDelegate.swift b/macos/Classes/FindInteraction/FindInteractionChannelDelegate.swift new file mode 100644 index 00000000..fe1ab455 --- /dev/null +++ b/macos/Classes/FindInteraction/FindInteractionChannelDelegate.swift @@ -0,0 +1,112 @@ +// +// FindInteractionChannelDelegate.swift +// flutter_inappwebview +// +// Created by Lorenzo Pichilli on 07/10/22. +// + +import Foundation +import FlutterMacOS + +public class FindInteractionChannelDelegate : ChannelDelegate { + private weak var findInteractionController: FindInteractionController? + + public init(findInteractionController: FindInteractionController, channel: FlutterMethodChannel) { + super.init(channel: channel) + self.findInteractionController = findInteractionController + } + + public override func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + let arguments = call.arguments as? NSDictionary + + switch call.method { + case "findAll": + if let findInteractionController = findInteractionController { + let find = arguments!["find"] as! String + findInteractionController.findAll(find: find, completionHandler: {(value, error) in + if error != nil { + result(FlutterError(code: "FindInteractionChannelDelegate", message: error?.localizedDescription, details: nil)) + return + } + result(true) + }) + } else { + result(false) + } + break + case "findNext": + if let findInteractionController = findInteractionController { + let forward = arguments!["forward"] as! Bool + findInteractionController.findNext(forward: forward, completionHandler: {(value, error) in + if error != nil { + result(FlutterError(code: "FindInteractionChannelDelegate", message: error?.localizedDescription, details: nil)) + return + } + result(true) + }) + } else { + result(false) + } + break + case "clearMatches": + if let findInteractionController = findInteractionController { + findInteractionController.clearMatches(completionHandler: {(value, error) in + if error != nil { + result(FlutterError(code: "FindInteractionChannelDelegate", message: error?.localizedDescription, details: nil)) + return + } + result(true) + }) + } else { + result(false) + } + break + case "setSearchText": + if let findInteractionController = findInteractionController { + let searchText = arguments!["searchText"] as? String + findInteractionController.searchText = searchText + result(true) + } else { + result(false) + } + break + case "getSearchText": + result(findInteractionController?.searchText) + break + case "getActiveFindSession": + if let findInteractionController = findInteractionController { + result(findInteractionController.activeFindSession?.toMap()) + } else { + result(nil) + } + break + default: + result(FlutterMethodNotImplemented) + break + } + } + + public func onFindResultReceived(activeMatchOrdinal: Int, numberOfMatches: Int, isDoneCounting: Bool) { + if isDoneCounting, let findInteractionController = findInteractionController { + findInteractionController.activeFindSession = FindSession(resultCount: numberOfMatches, + highlightedResultIndex: activeMatchOrdinal, + searchResultDisplayStyle: 2) // matches UIFindSession.SearchResultDisplayStyle.none + } + + let arguments: [String : Any?] = [ + "activeMatchOrdinal": activeMatchOrdinal, + "numberOfMatches": numberOfMatches, + "isDoneCounting": isDoneCounting + ] + channel?.invokeMethod("onFindResultReceived", arguments: arguments) + } + + public override func dispose() { + super.dispose() + findInteractionController = nil + } + + deinit { + dispose() + } +} diff --git a/macos/Classes/FindInteraction/FindInteractionController.swift b/macos/Classes/FindInteraction/FindInteractionController.swift new file mode 100644 index 00000000..d1973db5 --- /dev/null +++ b/macos/Classes/FindInteraction/FindInteractionController.swift @@ -0,0 +1,96 @@ +// +// FindInteractionController.swift +// flutter_inappwebview +// +// Created by Lorenzo Pichilli on 07/10/22. +// + +import Foundation +import FlutterMacOS + +public class FindInteractionController : NSObject, Disposable { + + static var METHOD_CHANNEL_NAME_PREFIX = "com.pichillilorenzo/flutter_inappwebview_find_interaction_"; + var webView: InAppWebView? + var channelDelegate: FindInteractionChannelDelegate? + var settings: FindInteractionSettings? + var shouldCallOnRefresh = false + var searchText: String? + var activeFindSession: FindSession? + + public init(registrar: FlutterPluginRegistrar, id: Any, webView: InAppWebView, settings: FindInteractionSettings?) { + super.init() + self.webView = webView + self.settings = settings + let channel = FlutterMethodChannel(name: FindInteractionController.METHOD_CHANNEL_NAME_PREFIX + String(describing: id), + binaryMessenger: registrar.messenger) + self.channelDelegate = FindInteractionChannelDelegate(findInteractionController: self, channel: channel) + } + + public func prepare() { +// if let settings = settings { +// +// } + } + + public func findAll(find: String?, completionHandler: ((Any?, Error?) -> Void)?) { + guard let webView else { + if let completionHandler = completionHandler { + completionHandler(nil, nil) + } + return + } + + var find = find + if find == nil { + find = searchText + } else { + // updated searchText + searchText = find + } + + guard let find else { + if let completionHandler = completionHandler { + completionHandler(nil, nil) + } + return + } + + if find != "" { + let startSearch = "window.\(JAVASCRIPT_BRIDGE_NAME)._findAllAsync('\(find)');" + webView.evaluateJavaScript(startSearch, completionHandler: completionHandler) + } + } + + public func findNext(forward: Bool, completionHandler: ((Any?, Error?) -> Void)?) { + guard let webView else { + if let completionHandler = completionHandler { + completionHandler(nil, nil) + } + return + } + webView.evaluateJavaScript("window.\(JAVASCRIPT_BRIDGE_NAME)._findNext(\(forward ? "true" : "false"));", completionHandler: completionHandler) + } + + public func clearMatches(completionHandler: ((Any?, Error?) -> Void)?) { + guard let webView else { + if let completionHandler = completionHandler { + completionHandler(nil, nil) + } + return + } + webView.evaluateJavaScript("window.\(JAVASCRIPT_BRIDGE_NAME)._clearMatches();", completionHandler: completionHandler) + } + + public func dispose() { + channelDelegate?.dispose() + channelDelegate = nil + webView = nil + activeFindSession = nil + } + + deinit { + debugPrint("FindInteractionControl - dealloc") + dispose() + } +} diff --git a/macos/Classes/FindInteraction/FindInteractionSettings.swift b/macos/Classes/FindInteraction/FindInteractionSettings.swift new file mode 100644 index 00000000..1c34c5bd --- /dev/null +++ b/macos/Classes/FindInteraction/FindInteractionSettings.swift @@ -0,0 +1,25 @@ +// +// FindInteractionSettings.swift +// flutter_inappwebview +// +// Created by Lorenzo Pichilli on 07/10/22. +// + +import Foundation + +public class FindInteractionSettings : ISettings { + + override init(){ + super.init() + } + + override func parse(settings: [String: Any?]) -> FindInteractionSettings { + let _ = super.parse(settings: settings) + return self + } + + override func getRealSettings(obj: FindInteractionController?) -> [String: Any?] { + let realSettings: [String: Any?] = toMap() + return realSettings + } +} diff --git a/macos/Classes/InAppBrowser/InAppBrowserManager.swift b/macos/Classes/InAppBrowser/InAppBrowserManager.swift index 8811fa67..c1e9f629 100755 --- a/macos/Classes/InAppBrowser/InAppBrowserManager.swift +++ b/macos/Classes/InAppBrowser/InAppBrowserManager.swift @@ -84,6 +84,8 @@ public class InAppBrowserManager: ChannelDelegate { if browserSettings.hidden { window.hide() + } else { + window.makeKeyAndOrderFront(self) } } diff --git a/macos/Classes/InAppBrowser/InAppBrowserWebViewController.swift b/macos/Classes/InAppBrowser/InAppBrowserWebViewController.swift index a0982ffa..284b9db4 100755 --- a/macos/Classes/InAppBrowser/InAppBrowserWebViewController.swift +++ b/macos/Classes/InAppBrowser/InAppBrowserWebViewController.swift @@ -62,6 +62,12 @@ public class InAppBrowserWebViewController: NSViewController, InAppBrowserDelega webView.id = id webView.channelDelegate = WebViewChannelDelegate(webView: webView, channel: channel) + let findInteractionController = FindInteractionController( + registrar: SwiftFlutterPlugin.instance!.registrar!, + id: id, webView: webView, settings: nil) + webView.findInteractionController = findInteractionController + findInteractionController.prepare() + prepareWebView() webView.windowCreated = true diff --git a/macos/Classes/InAppWebView/FlutterWebViewController.swift b/macos/Classes/InAppWebView/FlutterWebViewController.swift index e4b7e702..69206434 100755 --- a/macos/Classes/InAppWebView/FlutterWebViewController.swift +++ b/macos/Classes/InAppWebView/FlutterWebViewController.swift @@ -54,6 +54,12 @@ public class FlutterWebViewController: NSObject, /*FlutterPlatformView,*/ Dispos userScripts: userScripts) } + let findInteractionController = FindInteractionController( + registrar: SwiftFlutterPlugin.instance!.registrar!, + id: viewId, webView: webView!, settings: nil) + webView!.findInteractionController = findInteractionController + findInteractionController.prepare() + webView!.autoresizingMask = [.width, .height] myView!.autoresizesSubviews = true myView!.autoresizingMask = [.width, .height] diff --git a/macos/Classes/InAppWebView/InAppWebView.swift b/macos/Classes/InAppWebView/InAppWebView.swift index c8894aad..9236eeef 100755 --- a/macos/Classes/InAppWebView/InAppWebView.swift +++ b/macos/Classes/InAppWebView/InAppWebView.swift @@ -21,6 +21,7 @@ public class InAppWebView: WKWebView, WKUIDelegate, var inAppBrowserDelegate: InAppBrowserDelegate? var channelDelegate: WebViewChannelDelegate? var settings: InAppWebViewSettings? + var findInteractionController: FindInteractionController? var webMessageChannels: [String:WebMessageChannel] = [:] var webMessageListeners: [WebMessageListener] = [] var currentOriginalUrl: URL? @@ -1650,7 +1651,7 @@ public class InAppWebView: WKWebView, WKUIDelegate, let cancelButton = cancelButtonTitle != nil && !cancelButtonTitle!.isEmpty ? cancelButtonTitle : NSLocalizedString("Cancel", comment: "") let alert = NSAlert() - alert.messageText = title ?? "" + alert.messageText = dialogMessage ?? "" alert.alertStyle = .informational alert.addButton(withTitle: okButton ?? "") alert.addButton(withTitle: cancelButton ?? "") @@ -1702,7 +1703,7 @@ public class InAppWebView: WKWebView, WKUIDelegate, let cancelButton = cancelButtonTitle != nil && !cancelButtonTitle!.isEmpty ? cancelButtonTitle : NSLocalizedString("Cancel", comment: "") let alert = NSAlert() - alert.messageText = title ?? "" + alert.messageText = dialogMessage ?? "" alert.alertStyle = .informational alert.addButton(withTitle: okButton ?? "") alert.addButton(withTitle: cancelButton ?? "") @@ -2113,6 +2114,7 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) { if let wId = _windowId, let webViewTransport = InAppWebView.windowWebViews[wId] { webView = webViewTransport.webView } + webView.findInteractionController?.channelDelegate?.onFindResultReceived(activeMatchOrdinal: activeMatchOrdinal, numberOfMatches: numberOfMatches, isDoneCounting: isDoneCounting) webView.channelDelegate?.onFindResultReceived(activeMatchOrdinal: activeMatchOrdinal, numberOfMatches: numberOfMatches, isDoneCounting: isDoneCounting) } else if message.name == "onScrollChanged" { let body = message.body as! [String: Any?] @@ -2212,7 +2214,36 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) { printJobId = NSUUID().uuidString } - let printInfo = NSPrintInfo() + var printInfoDictionary: [NSPrintInfo.AttributeKey : Any] = [:] + if let settings = settings { + if let jobSavingURL = settings.jobSavingURL, let url = URL(string: jobSavingURL) { + printInfoDictionary[.jobSavingURL] = url + } + printInfoDictionary[.copies] = settings.copies + if let firstPage = settings.firstPage { + printInfoDictionary[.firstPage] = firstPage + } + if let lastPage = settings.lastPage { + printInfoDictionary[.lastPage] = lastPage + } + printInfoDictionary[.detailedErrorReporting] = settings.detailedErrorReporting + printInfoDictionary[.faxNumber] = settings.faxNumber ?? "" + printInfoDictionary[.headerAndFooter] = settings.headerAndFooter + if let mustCollate = settings.mustCollate { + printInfoDictionary[.mustCollate] = mustCollate + } + if let pagesAcross = settings.pagesAcross { + printInfoDictionary[.pagesAcross] = pagesAcross + } + if let pagesDown = settings.pagesDown { + printInfoDictionary[.pagesDown] = pagesDown + } + if let time = settings.time { + printInfoDictionary[.time] = Date(timeIntervalSince1970: TimeInterval(Double(time)/1000)) + } + } + + let printInfo = NSPrintInfo(dictionary: printInfoDictionary) if let settings = settings { if let orientationValue = settings.orientation, @@ -2225,13 +2256,84 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) { printInfo.bottomMargin = margins.bottom printInfo.leftMargin = margins.left } + if let numberOfPages = settings.numberOfPages { + printInfo.printSettings["com_apple_print_PrintSettings_PMLastPage"] = numberOfPages + } + if let colorMode = settings.colorMode { + printInfo.printSettings["ColorModel"] = colorMode + } + if let scalingFactor = settings.scalingFactor { + printInfo.scalingFactor = scalingFactor + } + if let jobDisposition = settings.jobDisposition { + printInfo.jobDisposition = Util.getNSPrintInfoJobDisposition(name: jobDisposition) + } + if let paperName = settings.paperName { + printInfo.paperName = NSPrinter.PaperName.init(rawValue: paperName) + } + if let horizontalPagination = settings.horizontalPagination, + let pagination = NSPrintInfo.PaginationMode.init(rawValue: horizontalPagination) { + printInfo.horizontalPagination = pagination + } + if let verticalPagination = settings.verticalPagination, + let pagination = NSPrintInfo.PaginationMode.init(rawValue: verticalPagination) { + printInfo.verticalPagination = pagination + } + printInfo.isHorizontallyCentered = settings.isHorizontallyCentered + printInfo.isVerticallyCentered = settings.isVerticallyCentered } let printOperation = printOperation(with: printInfo) printOperation.jobTitle = settings?.jobName ?? (title ?? url?.absoluteString ?? "") + " Document" printOperation.view?.frame = bounds - printOperation.printPanel.options.insert(.showsOrientation) - printOperation.printPanel.options.insert(.showsPaperSize) - printOperation.printPanel.options.insert(.showsScaling) + + if let settings = settings { + if let pageOrder = settings.pageOrder, let order = NSPrintOperation.PageOrder.init(rawValue: pageOrder) { + printOperation.pageOrder = order + } + printOperation.canSpawnSeparateThread = settings.canSpawnSeparateThread + printOperation.showsPrintPanel = settings.showsPrintPanel + printOperation.showsProgressPanel = settings.showsProgressPanel + if settings.showsPaperOrientation { + printOperation.printPanel.options.insert(.showsOrientation) + } else { + printOperation.printPanel.options.remove(.showsOrientation) + } + if settings.showsNumberOfCopies { + printOperation.printPanel.options.insert(.showsCopies) + } else { + printOperation.printPanel.options.remove(.showsCopies) + } + if settings.showsPaperSize { + printOperation.printPanel.options.insert(.showsPaperSize) + } else { + printOperation.printPanel.options.remove(.showsPaperSize) + } + if settings.showsScaling { + printOperation.printPanel.options.insert(.showsScaling) + } else { + printOperation.printPanel.options.remove(.showsScaling) + } + if settings.showsPageRange { + printOperation.printPanel.options.insert(.showsPageRange) + } else { + printOperation.printPanel.options.remove(.showsPageRange) + } + if settings.showsPageSetupAccessory { + printOperation.printPanel.options.insert(.showsPageSetupAccessory) + } else { + printOperation.printPanel.options.remove(.showsPageSetupAccessory) + } + if settings.showsPreview { + printOperation.printPanel.options.insert(.showsPreview) + } else { + printOperation.printPanel.options.remove(.showsPreview) + } + if settings.showsPrintSelection { + printOperation.printPanel.options.insert(.showsPrintSelection) + } else { + printOperation.printPanel.options.remove(.showsPrintSelection) + } + } if let id = printJobId { let printJob = PrintJobController(id: id, job: printOperation, settings: settings) @@ -2471,6 +2573,8 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) { for imp in customIMPs { imp_removeBlock(imp) } + findInteractionController?.dispose() + findInteractionController = nil uiDelegate = nil navigationDelegate = nil isPausedTimersCompletionHandler = nil diff --git a/macos/Classes/InAppWebView/WebViewChannelDelegate.swift b/macos/Classes/InAppWebView/WebViewChannelDelegate.swift index b32b9baa..b2ec738c 100644 --- a/macos/Classes/InAppWebView/WebViewChannelDelegate.swift +++ b/macos/Classes/InAppWebView/WebViewChannelDelegate.swift @@ -207,6 +207,47 @@ public class WebViewChannelDelegate : ChannelDelegate { case .getCopyBackForwardList: result(webView?.getCopyBackForwardList()) break + case .findAll: + if let webView = webView, let findInteractionController = webView.findInteractionController { + let find = arguments!["find"] as! String + findInteractionController.findAll(find: find, completionHandler: {(value, error) in + if error != nil { + result(FlutterError(code: "WebViewChannelDelegate", message: error?.localizedDescription, details: nil)) + return + } + result(true) + }) + } else { + result(false) + } + break + case .findNext: + if let webView = webView, let findInteractionController = webView.findInteractionController { + let forward = arguments!["forward"] as! Bool + findInteractionController.findNext(forward: forward, completionHandler: {(value, error) in + if error != nil { + result(FlutterError(code: "WebViewChannelDelegate", message: error?.localizedDescription, details: nil)) + return + } + result(true) + }) + } else { + result(false) + } + break + case .clearMatches: + if let webView = webView, let findInteractionController = webView.findInteractionController { + findInteractionController.clearMatches(completionHandler: {(value, error) in + if error != nil { + result(FlutterError(code: "WebViewChannelDelegate", message: error?.localizedDescription, details: nil)) + return + } + result(true) + }) + } else { + result(false) + } + break case .clearCache: webView?.clearCache() result(true) diff --git a/macos/Classes/InAppWebView/WebViewChannelDelegateMethods.swift b/macos/Classes/InAppWebView/WebViewChannelDelegateMethods.swift index da6dba91..658c096f 100644 --- a/macos/Classes/InAppWebView/WebViewChannelDelegateMethods.swift +++ b/macos/Classes/InAppWebView/WebViewChannelDelegateMethods.swift @@ -35,6 +35,12 @@ public enum WebViewChannelDelegateMethods: String { case show = "show" case hide = "hide" case getCopyBackForwardList = "getCopyBackForwardList" + @available(*, deprecated, message: "Use FindInteractionController.findAll instead.") + case findAll = "findAll" + @available(*, deprecated, message: "Use FindInteractionController.findNext instead.") + case findNext = "findNext" + @available(*, deprecated, message: "Use FindInteractionController.clearMatches instead.") + case clearMatches = "clearMatches" case clearCache = "clearCache" case scrollTo = "scrollTo" case scrollBy = "scrollBy" diff --git a/macos/Classes/PrintJob/PrintAttributes.swift b/macos/Classes/PrintJob/PrintAttributes.swift index 21178457..c6cfdd6b 100644 --- a/macos/Classes/PrintJob/PrintAttributes.swift +++ b/macos/Classes/PrintJob/PrintAttributes.swift @@ -13,11 +13,30 @@ public class PrintAttributes : NSObject { var paperRect: CGRect? var colorMode: String? var duplex: Int? + var paperName: String? + var localizedPaperName: String? + var horizontalPagination: UInt? + var verticalPagination: UInt? + var jobDisposition: String? + var printableRect: NSRect? + var isHorizontallyCentered: Bool? + var isVerticallyCentered: Bool? + var isSelectionOnly: Bool? + var scalingFactor: CGFloat? + var jobSavingURL: String? + var detailedErrorReporting: Bool? + var faxNumber: String? + var headerAndFooter: Bool? + var mustCollate: Bool? + var pagesAcross: Int? + var pagesDown: Int? + var time: Int? public init(fromPrintJobController: PrintJobController) { super.init() if let job = fromPrintJobController.job { let printInfo = job.printInfo + let printInfoDictionary = printInfo.dictionary() orientation = printInfo.orientation margins = NSEdgeInsets(top: printInfo.topMargin, left: printInfo.leftMargin, @@ -26,7 +45,26 @@ public class PrintAttributes : NSObject { paperRect = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: printInfo.paperSize) colorMode = printInfo.printSettings["ColorModel"] as? String duplex = printInfo.printSettings["com_apple_print_PrintSettings_PMDuplexing"] as? Int - print(printInfo.printSettings) + paperName = printInfo.paperName?.rawValue + localizedPaperName = printInfo.localizedPaperName + horizontalPagination = printInfo.horizontalPagination.rawValue + verticalPagination = printInfo.verticalPagination.rawValue + jobDisposition = printInfo.jobDisposition.rawValue + printableRect = printInfo.imageablePageBounds + isHorizontallyCentered = printInfo.isHorizontallyCentered + isVerticallyCentered = printInfo.isVerticallyCentered + isSelectionOnly = printInfo.isSelectionOnly + scalingFactor = printInfo.scalingFactor + jobSavingURL = (printInfoDictionary[NSPrintInfo.AttributeKey.jobSavingURL] as? URL)?.absoluteString + detailedErrorReporting = printInfoDictionary[NSPrintInfo.AttributeKey.detailedErrorReporting] as? Bool + faxNumber = printInfoDictionary[NSPrintInfo.AttributeKey.faxNumber] as? String + headerAndFooter = printInfoDictionary[NSPrintInfo.AttributeKey.headerAndFooter] as? Bool + mustCollate = printInfoDictionary[NSPrintInfo.AttributeKey.mustCollate] as? Bool + pagesAcross = printInfoDictionary[NSPrintInfo.AttributeKey.pagesAcross] as? Int + pagesDown = printInfoDictionary[NSPrintInfo.AttributeKey.pagesDown] as? Int + if let timestamp = (printInfoDictionary[NSPrintInfo.AttributeKey.time] as? Date)?.timeIntervalSince1970 { + time = Int(timestamp) + } } } @@ -36,7 +74,25 @@ public class PrintAttributes : NSObject { "margins": margins?.toMap(), "orientation": orientation?.rawValue, "colorMode": colorMode, - "duplex": duplex + "duplex": duplex, + "paperName": paperName, + "localizedPaperName": localizedPaperName, + "horizontalPagination": horizontalPagination, + "verticalPagination": verticalPagination, + "jobDisposition": jobDisposition, + "printableRect": printableRect?.toMap(), + "isHorizontallyCentered": isHorizontallyCentered, + "isVerticallyCentered": isVerticallyCentered, + "isSelectionOnly": isSelectionOnly, + "scalingFactor": scalingFactor, + "jobSavingURL": jobSavingURL, + "detailedErrorReporting": detailedErrorReporting, + "faxNumber": faxNumber, + "headerAndFooter": headerAndFooter, + "mustCollate": mustCollate, + "pagesAcross": pagesAcross, + "pagesDown": pagesDown, + "time": time ] } } diff --git a/macos/Classes/PrintJob/PrintJobController.swift b/macos/Classes/PrintJob/PrintJobController.swift index 30637c2b..998038e9 100644 --- a/macos/Classes/PrintJob/PrintJobController.swift +++ b/macos/Classes/PrintJob/PrintJobController.swift @@ -12,7 +12,6 @@ public enum PrintJobState: Int { case created = 1 case started = 3 case completed = 5 - case failed = 6 case canceled = 7 } diff --git a/macos/Classes/PrintJob/PrintJobInfo.swift b/macos/Classes/PrintJob/PrintJobInfo.swift index 6937c077..d522558a 100644 --- a/macos/Classes/PrintJob/PrintJobInfo.swift +++ b/macos/Classes/PrintJob/PrintJobInfo.swift @@ -14,27 +14,46 @@ public class PrintJobInfo : NSObject { var numberOfPages: Int? var copies: Int? var label: String? - var printerName: String? - var printerType: String? + var printer: NSPrinter? + var pageOrder: Int? + var preferredRenderingQuality: Int? + var showsProgressPanel: Bool? + var showsPrintPanel: Bool? + var canSpawnSeparateThread: Bool? + var isCopyingOperation: Bool? + var currentPage: Int? + var firstPage: Int? + var lastPage: Int? public init(fromPrintJobController: PrintJobController) { state = fromPrintJobController.state creationTime = fromPrintJobController.creationTime attributes = PrintAttributes.init(fromPrintJobController: fromPrintJobController) - if let job = fromPrintJobController.job { - let printInfo = job.printInfo - printerName = printInfo.printer.name - printerType = printInfo.printer.type.rawValue - copies = printInfo.printSettings["com_apple_print_PrintSettings_PMCopies"] as? Int - } super.init() if let job = fromPrintJobController.job { let printInfo = job.printInfo + let printInfoDictionary = printInfo.dictionary() + printer = printInfo.printer + copies = printInfo.printSettings["com_apple_print_PrintSettings_PMCopies"] as? Int label = job.jobTitle - numberOfPages = printInfo.printSettings["com_apple_print_PrintSettings_PMLastPage"] as? Int - if numberOfPages == nil || numberOfPages! > job.pageRange.length { - numberOfPages = job.pageRange.length + firstPage = printInfoDictionary[NSPrintInfo.AttributeKey.firstPage] as? Int + lastPage = printInfoDictionary[NSPrintInfo.AttributeKey.lastPage] as? Int + if let firstPage = firstPage, let lastPage = lastPage { + numberOfPages = lastPage - firstPage + 1 } + if numberOfPages == nil { + numberOfPages = printInfo.printSettings["com_apple_print_PrintSettings_PMLastPage"] as? Int + if numberOfPages == nil || numberOfPages! > job.pageRange.length { + numberOfPages = job.pageRange.length + } + } + pageOrder = job.pageOrder.rawValue + preferredRenderingQuality = job.preferredRenderingQuality.rawValue + showsProgressPanel = job.showsProgressPanel + showsPrintPanel = job.showsPrintPanel + canSpawnSeparateThread = job.canSpawnSeparateThread + isCopyingOperation = job.isCopyingOperation + currentPage = job.currentPage } } @@ -46,8 +65,16 @@ public class PrintJobInfo : NSObject { "copies": copies, "creationTime": creationTime, "label": label, - "printerName": printerName, - "printerType": printerType + "printer": printer?.toMap(), + "pageOrder": pageOrder, + "preferredRenderingQuality": preferredRenderingQuality, + "showsProgressPanel": showsProgressPanel, + "showsPrintPanel": showsPrintPanel, + "canSpawnSeparateThread": canSpawnSeparateThread, + "isCopyingOperation": isCopyingOperation, + "currentPage": currentPage, + "firstPage": firstPage, + "lastPage": lastPage ] } } diff --git a/macos/Classes/PrintJob/PrintJobSettings.swift b/macos/Classes/PrintJob/PrintJobSettings.swift index 15abee8c..a3fe36b4 100644 --- a/macos/Classes/PrintJob/PrintJobSettings.swift +++ b/macos/Classes/PrintJob/PrintJobSettings.swift @@ -12,7 +12,6 @@ public class PrintJobSettings: ISettings { public var handledByClient = false public var jobName: String? - public var animated = true public var _orientation: NSNumber? public var orientation: Int? { get { @@ -27,9 +26,9 @@ public class PrintJobSettings: ISettings { } } public var _numberOfPages: NSNumber? - public var numberOfPages: Int? { + public var numberOfPages: Int64? { get { - return _numberOfPages?.intValue + return _numberOfPages?.int64Value } set { if let newValue = newValue { @@ -39,98 +38,155 @@ public class PrintJobSettings: ISettings { } } } - public var _forceRenderingQuality: NSNumber? - public var forceRenderingQuality: Int? { - get { - return _forceRenderingQuality?.intValue - } - set { - if let newValue = newValue { - _forceRenderingQuality = NSNumber.init(value: newValue) - } else { - _forceRenderingQuality = nil - } - } - } public var margins: NSEdgeInsets? - public var _duplexMode: NSNumber? - public var duplexMode: Int? { - get { - return _duplexMode?.intValue - } - set { - if let newValue = newValue { - _duplexMode = NSNumber.init(value: newValue) - } else { - _duplexMode = nil - } - } - } - public var _outputType: NSNumber? - public var outputType: Int? { - get { - return _outputType?.intValue - } - set { - if let newValue = newValue { - _outputType = NSNumber.init(value: newValue) - } else { - _outputType = nil - } - } - } + public var colorMode: String? public var showsNumberOfCopies = true - public var showsPaperSelectionForLoadedPapers = false public var showsPaperOrientation = true - public var _maximumContentHeight: NSNumber? - public var maximumContentHeight: Double? { + public var showsPaperSize = true + public var showsScaling = true + public var showsPageRange = true + public var showsPageSetupAccessory = true + public var showsPreview = true + public var showsPrintSelection = true + public var showsPrintPanel = true + public var showsProgressPanel = true + public var _scalingFactor: NSNumber? + public var scalingFactor: Double? { get { - return _maximumContentHeight?.doubleValue + return _scalingFactor?.doubleValue } set { if let newValue = newValue { - _maximumContentHeight = NSNumber.init(value: newValue) + _scalingFactor = NSNumber.init(value: newValue) } else { - _maximumContentHeight = nil + _scalingFactor = nil } } } - public var _maximumContentWidth: NSNumber? - public var maximumContentWidth: Double? { + public var jobDisposition: String? + public var jobSavingURL: String? + public var paperName: String? + public var _horizontalPagination: NSNumber? + public var horizontalPagination: UInt? { get { - return _maximumContentWidth?.doubleValue + return _horizontalPagination?.uintValue } set { if let newValue = newValue { - _maximumContentWidth = NSNumber.init(value: newValue) + _horizontalPagination = NSNumber.init(value: newValue) } else { - _maximumContentWidth = nil + _horizontalPagination = nil } } } - public var _footerHeight: NSNumber? - public var footerHeight: Double? { + public var _verticalPagination: NSNumber? + public var verticalPagination: UInt? { get { - return _footerHeight?.doubleValue + return _verticalPagination?.uintValue } set { if let newValue = newValue { - _footerHeight = NSNumber.init(value: newValue) + _verticalPagination = NSNumber.init(value: newValue) } else { - _footerHeight = nil + _verticalPagination = nil } } } - public var _headerHeight: NSNumber? - public var headerHeight: Double? { + public var isHorizontallyCentered = true + public var isVerticallyCentered = true + public var _pageOrder: NSNumber? + public var pageOrder: Int? { get { - return _headerHeight?.doubleValue + return _pageOrder?.intValue } set { if let newValue = newValue { - _headerHeight = NSNumber.init(value: newValue) + _pageOrder = NSNumber.init(value: newValue) } else { - _headerHeight = nil + _pageOrder = nil + } + } + } + public var canSpawnSeparateThread = true + public var copies = 1 + public var _firstPage: NSNumber? + public var firstPage: Int64? { + get { + return _firstPage?.int64Value + } + set { + if let newValue = newValue { + _firstPage = NSNumber.init(value: newValue) + } else { + _firstPage = nil + } + } + } + public var _lastPage: NSNumber? + public var lastPage: Int64? { + get { + return _lastPage?.int64Value + } + set { + if let newValue = newValue { + _lastPage = NSNumber.init(value: newValue) + } else { + _lastPage = nil + } + } + } + public var detailedErrorReporting = false + public var faxNumber: String? + public var headerAndFooter = true + public var _mustCollate: NSNumber? + public var mustCollate: Bool? { + get { + return _mustCollate?.boolValue + } + set { + if let newValue = newValue { + _mustCollate = NSNumber.init(value: newValue) + } else { + _mustCollate = nil + } + } + } + public var _pagesAcross: NSNumber? + public var pagesAcross: Int64? { + get { + return _pagesAcross?.int64Value + } + set { + if let newValue = newValue { + _pagesAcross = NSNumber.init(value: newValue) + } else { + _pagesAcross = nil + } + } + } + public var _pagesDown: NSNumber? + public var pagesDown: Int64? { + get { + return _pagesDown?.int64Value + } + set { + if let newValue = newValue { + _pagesDown = NSNumber.init(value: newValue) + } else { + _pagesDown = nil + } + } + } + public var _time: NSNumber? + public var time: Int64? { + get { + return _time?.int64Value + } + set { + if let newValue = newValue { + _time = NSNumber.init(value: newValue) + } else { + _time = nil } } } diff --git a/macos/Classes/Types/BaseCallbackResult.swift b/macos/Classes/Types/BaseCallbackResult.swift index f7edb4a5..a76caf72 100644 --- a/macos/Classes/Types/BaseCallbackResult.swift +++ b/macos/Classes/Types/BaseCallbackResult.swift @@ -1,8 +1,8 @@ // // BaseCallbackResult.swift -// flutter_inappwebview +// shared-apple // -// Created by Lorenzo Pichilli on 06/05/22. +// Created by Lorenzo Pichilli on 17/10/22. // import Foundation diff --git a/macos/Classes/Types/CallbackResult.swift b/macos/Classes/Types/CallbackResult.swift index 5b0ba2b5..628082c0 100644 --- a/macos/Classes/Types/CallbackResult.swift +++ b/macos/Classes/Types/CallbackResult.swift @@ -1,8 +1,8 @@ // // CallbackResult.swift -// flutter_inappwebview +// shared-apple // -// Created by Lorenzo Pichilli on 06/05/22. +// Created by Lorenzo Pichilli on 17/10/22. // import Foundation diff --git a/macos/Classes/Types/MethodChannelResult.swift b/macos/Classes/Types/MethodChannelResult.swift index d1555e39..cba7eb24 100644 --- a/macos/Classes/Types/MethodChannelResult.swift +++ b/macos/Classes/Types/MethodChannelResult.swift @@ -1,8 +1,8 @@ // // MethodChannelResult.swift -// flutter_inappwebview +// shared-apple // -// Created by Lorenzo Pichilli on 06/05/22. +// Created by Lorenzo Pichilli on 17/10/22. // import Foundation diff --git a/macos/Classes/Types/NSPrinter.swift b/macos/Classes/Types/NSPrinter.swift new file mode 100644 index 00000000..58717866 --- /dev/null +++ b/macos/Classes/Types/NSPrinter.swift @@ -0,0 +1,18 @@ +// +// NSPrinter.swift +// flutter_inappwebview +// +// Created by Lorenzo Pichilli on 17/10/22. +// + +import Foundation + +extension NSPrinter { + public func toMap () -> [String:Any?] { + return [ + "type": type.rawValue, + "languageLevel": languageLevel, + "name": name + ] + } +} diff --git a/macos/Classes/Util.swift b/macos/Classes/Util.swift index d248748e..762cc416 100644 --- a/macos/Classes/Util.swift +++ b/macos/Classes/Util.swift @@ -64,6 +64,21 @@ public class Util { } } + public static func getNSPrintInfoJobDisposition(name: String) -> NSPrintInfo.JobDisposition { + switch name { + case "save": + return NSPrintInfo.JobDisposition.save + case "cancel": + return NSPrintInfo.JobDisposition.cancel + case "preview": + return NSPrintInfo.JobDisposition.preview + case "spool": + return NSPrintInfo.JobDisposition.spool + default: + return NSPrintInfo.JobDisposition.spool + } + } + public static func isIPv4(address: String) -> Bool { var sin = sockaddr_in() return address.withCString({ cstring in inet_pton(AF_INET, cstring, &sin.sin_addr) }) == 1