Skip to content

Commit

Permalink
fix: Move Extensions to Main Class (#17)
Browse files Browse the repository at this point in the history
Move the plugin's classes extensions to the main class, in order to avoid conflicts when importing these on Objective C code on an edge case where the project's name has special chars on it.
  • Loading branch information
OS-ricardomoreirasilva authored Aug 23, 2022
1 parent 669697d commit 0cfbc85
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Version 1.0.6]
### Fixes
- Moved the plugin's class extensions to the class itself. (https://outsystemsrd.atlassian.net/browse/RMET-1769)

## [Version 1.0.5]
### Fixes
- Removed hook that adds swift support and added the plugin as dependecy. (https://outsystemsrd.atlassian.net/browse/RMET-1680)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.outsystems.plugins.fileviewer",
"version": "1.0.5",
"version": "1.0.6",
"description": "OutSystems Cordova Plugin to provide the functionality of a file viewer to mobile applications.",
"keywords": [
"ecosystem:cordova",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<plugin id="com.outsystems.plugins.fileviewer" version="1.0.5" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="com.outsystems.plugins.fileviewer" version="1.0.6" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>OSFileViewer</name>
<description>OutSystems Cordova Plugin to provide the functionality of a file viewer to mobile applications.</description>
<author>OutSystems Inc</author>
Expand Down
4 changes: 1 addition & 3 deletions src/ios/FileViewerErrors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@

import Foundation

enum FileViewerErrors: String, Error {
enum FileViewerErrors: String, Error, LocalizedError {
case fileDoesNotExist = "The file you are trying to open does not exist"
case emptyFileName = "No file name or/and extension was provided"
case couldNotOpenDocument = "Could not open the document"
case invalidURL = "The URL you are trying to open is malformed"
case invalidEmptyURL = "Path of the file to open is either null or empty"
case downloadFailed = "The download failed"
case missingFileExtension = "The file has no extension"
}

extension FileViewerErrors : LocalizedError {
var errorDescription: String? { return NSLocalizedString(rawValue, comment: "") }
}
11 changes: 4 additions & 7 deletions src/ios/FileViewerOpenDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import UIKit

class FileViewerOpenDocument: NSObject {
class FileViewerOpenDocument: NSObject, UIDocumentInteractionControllerDelegate {

var documentInteractionController:UIDocumentInteractionController?
weak var viewController: UIViewController?
Expand Down Expand Up @@ -45,17 +45,14 @@ class FileViewerOpenDocument: NSObject {
self.documentInteractionController?.presentPreview(animated: true)
}

}

extension FileViewerOpenDocument: UIDocumentInteractionControllerDelegate {
//MARK: UIDocumentInteractionControllerDelegate
// MARK: - UIDocumentInteractionControllerDelegate

func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
return self.viewController!
}

}

extension URL {
fileprivate extension URL {
var uti: String {
return (try? self.resourceValues(forKeys: [.typeIdentifierKey]))?.typeIdentifier ?? "public.data"
}
Expand Down
9 changes: 3 additions & 6 deletions src/ios/FileViewerPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import QuickLook
import AVKit

class FileViewerPreview {
class FileViewerPreview: QLPreviewControllerDataSource {

lazy var previewItem = NSURL()
weak var viewController: UIViewController?
Expand Down Expand Up @@ -54,15 +54,12 @@ class FileViewerPreview {
playerViewController.player!.play()
}
}

}

//MARK:- QLPreviewController DataSource
extension FileViewerPreview: QLPreviewControllerDataSource {
// MARK: - QLPreviewController DataSource
func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
return 1
}

func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
return self.previewItem as QLPreviewItem
}
Expand Down

0 comments on commit 0cfbc85

Please sign in to comment.