Skip to content

Commit

Permalink
fix issue#2 iOS, web platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
jepiqueau committed Sep 19, 2021
1 parent 8b9f12f commit 1d5e8c1
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 66 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 0.0.3 (2021-09-19)

## Chore

- Update to @capacitor/core@3.2.3
- Update to [email protected]

## Add Features (Web, iOS)

- Display a fullscreen view when the image list contains one image

# 0.0.2 (2021-08-12)

## Chore
Expand Down
22 changes: 18 additions & 4 deletions ios/Plugin/PhotoSlider/SliderViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class SliderViewController: UIViewController {
private var _compressionQuality: Double = 0.8
private var _movieOptions: [String: Any] = [:]
private var _movieObserver: Any?
private var _closeButton: String = "yes"
// MARK: - Set-up position

var position: IndexPath {
Expand Down Expand Up @@ -90,6 +91,17 @@ class SliderViewController: UIViewController {
}
}

// MARK: - Set-up closebutton

var closebutton: String {
get {
return self._closeButton
}
set {
self._closeButton = newValue
}
}

// MARK: - Set-up Navigation Items

lazy var navBar: UINavigationBar = { () -> UINavigationBar in
Expand All @@ -100,10 +112,12 @@ class SliderViewController: UIViewController {
navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationBar.shadowImage = UIImage()
let navigationItem = UINavigationItem()
if self._isFilm {
navigationItem.rightBarButtonItems = [mClose, mFilm]
} else {
navigationItem.rightBarButtonItem = mClose
if self._closeButton == "yes" {
if self._isFilm {
navigationItem.rightBarButtonItems = [mClose, mFilm]
} else {
navigationItem.rightBarButtonItem = mClose
}
}
if self._isShare {
navigationItem.leftBarButtonItem = mShare
Expand Down
25 changes: 20 additions & 5 deletions ios/Plugin/PhotoViewer.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation
import Capacitor
import UIKit

enum PhotoViewerError: Error {
case failed(message: String)
Expand All @@ -12,6 +13,11 @@ enum PhotoViewerError: Error {
@objc var viewController: CollectionViewController? {
return collectionViewController
}
var sliderVC: SliderViewController?

@objc var sliderController: SliderViewController? {
return sliderVC
}

// MARK: echo

Expand All @@ -23,10 +29,19 @@ enum PhotoViewerError: Error {

@objc public func show(_ imageList: [[String: String]],
options: [String: Any]) -> Bool {

collectionViewController = CollectionViewController()
collectionViewController?.imageList = imageList
collectionViewController?.options = options
return true
if imageList.count > 1 {
collectionViewController = CollectionViewController()
collectionViewController?.imageList = imageList
collectionViewController?.options = options
return true
} else {
sliderVC = SliderViewController()
sliderVC?.modalPresentationStyle = .overFullScreen
sliderVC?.position = IndexPath(row: 0, section: 0)
sliderVC?.imageList = imageList
sliderVC?.options = options
sliderVC?.closebutton = "no"
return true
}
}
}
29 changes: 21 additions & 8 deletions ios/Plugin/PhotoViewerPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,28 @@ public class PhotoViewerPlugin: CAPPlugin {

// Display
DispatchQueue.main.async { [weak self] in
guard ((self?.implementation.show(imageList, options: options)) != nil),
let viewController = self?.implementation.viewController else {
call.reject("Show : Unable to show the CollectionViewController")
return
if imageList.count > 1 {
guard ((self?.implementation.show(imageList, options: options)) != nil),
let viewController = self?.implementation.viewController else {
call.reject("Show : Unable to show the CollectionViewController")
return
}
viewController.modalPresentationStyle = .fullScreen
self?.bridge?.viewController?.present(viewController, animated: true, completion: {
call.resolve(["result": true])
})
} else if imageList.count == 1 {
guard ((self?.implementation.show(imageList, options: options)) != nil),
let sliderController = self?.implementation.sliderController else {
call.reject("Show : Unable to show the SliderViewController")
return
}
sliderController.modalPresentationStyle = .fullScreen
self?.bridge?.viewController?.present(sliderController, animated: true, completion: {
call.resolve(["result": true])
})

}
viewController.modalPresentationStyle = .fullScreen
self?.bridge?.viewController?.present(viewController, animated: true, completion: {
call.resolve(["result": true])
})
}

}
Expand Down
1 change: 1 addition & 0 deletions node_modules/@capacitor/android/capacitor/build.gradle

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 41 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
"prepublishOnly": "npm run build"
},
"devDependencies": {
"@capacitor/android": "^3.1.2",
"@capacitor/core": "3.1.2",
"@capacitor/android": "^3.2.3",
"@capacitor/core": "3.2.3",
"@capacitor/docgen": "^0.0.17",
"@capacitor/ios": "^3.1.2",
"@capacitor/ios": "^3.2.3",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "^1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
Expand All @@ -62,8 +62,8 @@
"typescript": "~4.0.3"
},
"peerDependencies": {
"@capacitor/core": "^3.1.2",
"jeep-photoviewer": "^0.0.7"
"@capacitor/core": "^3.2.3",
"jeep-photoviewer": "^1.0.1"
},
"prettier": "@ionic/prettier-config",
"swiftlint": "@ionic/swiftlint-config",
Expand All @@ -79,6 +79,6 @@
}
},
"dependencies": {
"jeep-photoviewer": "^0.0.7"
"jeep-photoviewer": "^1.0.1"
}
}

0 comments on commit 1d5e8c1

Please sign in to comment.