|
|
@ -23,6 +23,8 @@ public class DocumentTileViewController: UIViewController, UITableViewDelegate,
|
|
|
|
private var isAutoLoadingNextPage: Bool = false
|
|
|
|
private var isAutoLoadingNextPage: Bool = false
|
|
|
|
private var currentTargetOffset: CGPoint?
|
|
|
|
private var currentTargetOffset: CGPoint?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public var delegate: DocumentTileViewControllerDelegate?
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - Initialization
|
|
|
|
// MARK: - Initialization
|
|
|
|
|
|
|
|
|
|
|
|
init(viewModel: MediaGalleryViewModel) {
|
|
|
|
init(viewModel: MediaGalleryViewModel) {
|
|
|
@ -313,9 +315,29 @@ public class DocumentTileViewController: UIViewController, UITableViewDelegate,
|
|
|
|
|
|
|
|
|
|
|
|
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
|
|
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
|
|
tableView.deselectRow(at: indexPath, animated: false)
|
|
|
|
tableView.deselectRow(at: indexPath, animated: false)
|
|
|
|
|
|
|
|
let attachment: Attachment = self.viewModel.galleryData[indexPath.section].elements[indexPath.row].attachment
|
|
|
|
|
|
|
|
guard let originalFilePath: String = attachment.originalFilePath else { return }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let fileUrl: URL = URL(fileURLWithPath: originalFilePath)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Open a preview of the document for text, pdf or microsoft files
|
|
|
|
|
|
|
|
if
|
|
|
|
|
|
|
|
attachment.isText ||
|
|
|
|
|
|
|
|
attachment.isMicrosoftDoc ||
|
|
|
|
|
|
|
|
attachment.contentType == OWSMimeTypeApplicationPdf
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delegate?.preview(fileUrl: fileUrl)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise share the file
|
|
|
|
|
|
|
|
delegate?.share(fileUrl: fileUrl)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - View
|
|
|
|
|
|
|
|
|
|
|
|
class DocumentCell: UITableViewCell {
|
|
|
|
class DocumentCell: UITableViewCell {
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - Initialization
|
|
|
|
// MARK: - Initialization
|
|
|
@ -472,3 +494,10 @@ class DocumentStaticHeaderView: UIView {
|
|
|
|
self.label.text = title
|
|
|
|
self.label.text = title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - DocumentTitleViewControllerDelegate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public protocol DocumentTileViewControllerDelegate: AnyObject {
|
|
|
|
|
|
|
|
func share(fileUrl: URL)
|
|
|
|
|
|
|
|
func preview(fileUrl: URL)
|
|
|
|
|
|
|
|
}
|
|
|
|