Skip to content

Commit

Permalink
Merge pull request #118 from baronha/feat/preview-ios
Browse files Browse the repository at this point in the history
[] Preview Controller
  • Loading branch information
baronha authored Sep 16, 2023
2 parents 7d7f5c9 + 4b3b326 commit cf915ea
Show file tree
Hide file tree
Showing 52 changed files with 3,351 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@
"${PODS_ROOT}/TLPhotoPicker/TLPhotoPicker/TLPhotoPickerController.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/TLPhotoPicker/TLPhotoPicker.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/react-native-multiple-image-picker/MultipleImagePicker.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/react-native-multiple-image-picker/Viewer.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
Expand All @@ -375,6 +376,7 @@
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/TLPhotoPickerController.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/TLPhotoPicker.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/MultipleImagePicker.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Viewer.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
13 changes: 9 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,12 @@ PODS:
- React-jsinspector (0.71.5)
- React-logger (0.71.5):
- glog
- react-native-multiple-image-picker (1.0.1):
- react-native-multiple-image-picker (1.0.3):
- CropViewController (= 2.6.1)
- React-Core
- react-native-multiple-image-picker/Viewer (= 1.0.3)
- TLPhotoPicker (= 2.1.9)
- react-native-multiple-image-picker/Viewer (1.0.3):
- CropViewController (= 2.6.1)
- React-Core
- TLPhotoPicker (= 2.1.9)
Expand Down Expand Up @@ -418,7 +423,7 @@ PODS:
- React-jsi (= 0.71.5)
- React-logger (= 0.71.5)
- React-perflogger (= 0.71.5)
- SocketRocket (0.6.0)
- SocketRocket (0.6.1)
- TLPhotoPicker (2.1.9)
- Yoga (1.14.0)
- YogaKit (1.18.1):
Expand Down Expand Up @@ -613,7 +618,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: 1579bf3207afadc72ac3638a66a102d1bf5263e3
React-jsinspector: 14a342151ab810862998dfc99e2720746734e9b3
React-logger: 94ec392ae471683635e4bf874d4e82f675399d2d
react-native-multiple-image-picker: 418868907d4ffb9c7a279009ee5645c43c941d1e
react-native-multiple-image-picker: 83b0fe4a14eaa7ae6fd5e5af46d7706ce26b2c7b
React-perflogger: 883a55a9a899535eaf06d0029108ef9ef22cce92
React-RCTActionSheet: 1a3b8416688a3d291367be645022886f71d6842a
React-RCTAnimation: e5560cb72d91ba35151d51e2eb0d467b42763f43
Expand All @@ -627,7 +632,7 @@ SPEC CHECKSUMS:
React-RCTVibration: f0f5ad6417803de42e022d99247a6b1ddaf46c13
React-runtimeexecutor: 511f4301d85daf85abface9afb8d2df2d49f87d3
ReactCommon: 4f43b72066f27bfe1f63838c61763f59e7112536
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
TLPhotoPicker: 939c40eaad130b69f9571e61e021e8120fa76329
Yoga: cd7d7f509dbfac14ee7f31a6c750acb957cd5022
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
Expand Down
51 changes: 43 additions & 8 deletions ios/CustomPhotoPicker/Cell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,57 @@
//

import Foundation
import TLPhotoPicker
import PhotosUI
import TLPhotoPicker

class Cell: TLPhotoCollectionViewCell {

var configure = MultipleImagePickerConfigure

static let longPressNotification = Notification.Name("CellLongPressNotification")

// Khởi tạo cell và thiết lập sự kiện Long Press
override init(frame: CGRect) {
super.init(frame: frame)
self.setupLongPressGesture()
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.setupLongPressGesture()
}

private func setupLongPressGesture() {
let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(self.handleLongPress(_:)))
addGestureRecognizer(longPressGesture)
}

// Xử lý sự kiện Long Press
@objc private func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
guard gestureRecognizer.state == .began && !self.isCameraCell
else {
return
}

NotificationCenter.default.post(name: Cell.longPressNotification, object: self)
}

private func findViewController() -> UIViewController? {
var responder: UIResponder? = self
while let currentResponder = responder {
if let viewController = currentResponder as? UIViewController {
return viewController
}
responder = currentResponder.next
}
return nil
}

override var duration: TimeInterval? {
didSet {
self.durationLabel?.isHidden = self.duration == nil ? true : false
guard let duration = self.duration else { return }
self.durationLabel?.text = timeFormatted(timeInterval: duration)
}
}

override var isCameraCell: Bool {
didSet {
self.orderLabel?.isHidden = self.isCameraCell
Expand All @@ -31,7 +67,7 @@ class Cell: TLPhotoCollectionViewCell {

override public var selectedAsset: Bool {
willSet(newValue) {
self.orderLabel?.backgroundColor = newValue ? self.configure.selectedColor : UIColor(red: 1, green: 1, blue: 1, alpha: 0.3)
self.orderLabel?.backgroundColor = newValue ? config.selectedColor : UIColor(red: 1, green: 1, blue: 1, alpha: 0.3)
}
}

Expand All @@ -43,13 +79,12 @@ class Cell: TLPhotoCollectionViewCell {
self.orderLabel?.layer.cornerRadius = 12
self.orderLabel?.layer.borderWidth = 2
self.orderLabel?.layer.borderColor = UIColor.white.cgColor
self.videoIconImageView?.image = self.configure.videoIcon
self.videoIconImageView?.image = config.videoIcon
if #available(iOS 11.0, *) {
self.imageView?.accessibilityIgnoresInvertColors = true
self.playerView?.accessibilityIgnoresInvertColors = true
self.livePhotoView?.accessibilityIgnoresInvertColors = true
self.videoIconImageView?.accessibilityIgnoresInvertColors = true
}
}

}
Loading

0 comments on commit cf915ea

Please sign in to comment.