Fixed displaying debug info
This commit is contained in:
parent
5b344d9cf3
commit
e3cf3aa7cf
@ -7,7 +7,6 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
6841A85D4B60DB71D1E68DA0 /* ImageGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6841AC687EA6293A0757678C /* ImageGrid.swift */; };
|
||||
7A1022692C55197D00B84627 /* RealmSwift in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 7ADF23052C25B5BF002624FF /* RealmSwift */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
7A10226C2C551EC500B84627 /* LocationEditScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A10226B2C551EC500B84627 /* LocationEditScreen.swift */; };
|
||||
7A10226E2C551EE000B84627 /* LocationEditViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A10226D2C551EE000B84627 /* LocationEditViewModel.swift */; };
|
||||
@ -45,7 +44,6 @@
|
||||
7A27ADF5249FD2F90035F39E /* FileManagerExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A27ADF4249FD2F90035F39E /* FileManagerExt.swift */; };
|
||||
7A27ADF7249FEF690035F39E /* Recorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A27ADF6249FEF690035F39E /* Recorder.swift */; };
|
||||
7A2C96122C3B155B00AE46B5 /* NoteAlertModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A2C96112C3B155B00AE46B5 /* NoteAlertModifier.swift */; };
|
||||
7A2DE69E2589606A00A113FC /* ImageGridRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A2DE69D2589606A00A113FC /* ImageGridRow.swift */; };
|
||||
7A2E6FA72C42B3AD00C40DA7 /* AutoCatCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7AF6D1EF2677C03B0086EA64 /* AutoCatCore.framework */; };
|
||||
7A33381124990DAE00D878F1 /* FiltersController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A33381024990DAE00D878F1 /* FiltersController.swift */; };
|
||||
7A3399AB299063370087DF98 /* SearchControllerExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A3399AA299063370087DF98 /* SearchControllerExt.swift */; };
|
||||
@ -234,7 +232,6 @@
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
6841A913FABBB0AB20DEF4FC /* PagedResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PagedResponse.swift; sourceTree = "<group>"; };
|
||||
6841AC687EA6293A0757678C /* ImageGrid.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageGrid.swift; sourceTree = "<group>"; };
|
||||
7A000AA124C2EEDE001F5B00 /* Location.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Location.swift; sourceTree = "<group>"; };
|
||||
7A0420A925619AEC00034941 /* Osago.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Osago.swift; sourceTree = "<group>"; };
|
||||
7A0516192414FF0900FC55AC /* DateSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateSection.swift; sourceTree = "<group>"; };
|
||||
@ -281,7 +278,6 @@
|
||||
7A27ADF824A09CAD0035F39E /* CocoaError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CocoaError.swift; sourceTree = "<group>"; };
|
||||
7A2C96112C3B155B00AE46B5 /* NoteAlertModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteAlertModifier.swift; sourceTree = "<group>"; };
|
||||
7A2DE69725868AC800A113FC /* VehicleAd.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VehicleAd.swift; sourceTree = "<group>"; };
|
||||
7A2DE69D2589606A00A113FC /* ImageGridRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageGridRow.swift; sourceTree = "<group>"; };
|
||||
7A2E6FA32C42B3AD00C40DA7 /* AutoCatCoreTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AutoCatCoreTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
7A33381024990DAE00D878F1 /* FiltersController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FiltersController.swift; sourceTree = "<group>"; };
|
||||
7A333813249A532400D878F1 /* Filter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Filter.swift; sourceTree = "<group>"; };
|
||||
@ -465,7 +461,6 @@
|
||||
7A0B969D257D6CB3000B39AD /* eureka */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7A2DE69D2589606A00A113FC /* ImageGridRow.swift */,
|
||||
7A8AB76A25A1D95500ECF2C1 /* SourceStatusRow.swift */,
|
||||
);
|
||||
path = eureka;
|
||||
@ -760,7 +755,6 @@
|
||||
7A1090EB24A4E3E100B4F0B2 /* CellProgressView.swift */,
|
||||
7ADF6C96250F41B000F237B2 /* PNKeyboard.swift */,
|
||||
7A1DC38D2517ED98002E9C99 /* BlockBarButtonItem.swift */,
|
||||
6841AC687EA6293A0757678C /* ImageGrid.swift */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
@ -1188,7 +1182,6 @@
|
||||
7A761C0B267E8FF90005F28F /* Error.swift in Sources */,
|
||||
7AC3555029696D5A00889457 /* NewNumberController.swift in Sources */,
|
||||
7AE26A3524F31B0700625033 /* EventsController.swift in Sources */,
|
||||
7A2DE69E2589606A00A113FC /* ImageGridRow.swift in Sources */,
|
||||
7AB67E8C2435C38700258F61 /* CustomTextField.swift in Sources */,
|
||||
7A27ADF5249FD2F90035F39E /* FileManagerExt.swift in Sources */,
|
||||
7A17CE4A2A2E820300626A6E /* UIStackView.swift in Sources */,
|
||||
@ -1262,7 +1255,6 @@
|
||||
7A7158042C43EAA200852088 /* OwnersCoordinator.swift in Sources */,
|
||||
7A7547E024032CB6004E8406 /* VehiclePhotoCell.swift in Sources */,
|
||||
7A17CE4C2A2E850200626A6E /* UISegmentedControl.swift in Sources */,
|
||||
6841A85D4B60DB71D1E68DA0 /* ImageGrid.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -1531,7 +1523,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 131;
|
||||
CURRENT_PROJECT_VERSION = 132;
|
||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
||||
@ -1557,7 +1549,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 131;
|
||||
CURRENT_PROJECT_VERSION = 132;
|
||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
||||
|
||||
@ -1,122 +0,0 @@
|
||||
import UIKit
|
||||
import Kingfisher
|
||||
|
||||
class ImageCell: UICollectionViewCell {
|
||||
private var imgView: UIImageView!
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
}
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
self.imgView = UIImageView()
|
||||
self.contentView.addSubview(self.imgView)
|
||||
self.imgView.translatesAutoresizingMaskIntoConstraints = false
|
||||
self.imgView.contentMode = .scaleAspectFill
|
||||
self.imgView.layer.masksToBounds = true
|
||||
NSLayoutConstraint.activate([
|
||||
self.imgView.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor),
|
||||
self.imgView.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor),
|
||||
self.imgView.topAnchor.constraint(equalTo: self.contentView.topAnchor),
|
||||
self.imgView.bottomAnchor.constraint(equalTo: self.contentView.bottomAnchor)
|
||||
])
|
||||
}
|
||||
|
||||
override func prepareForReuse() {
|
||||
super.prepareForReuse()
|
||||
self.imgView.kf.cancelDownloadTask()
|
||||
}
|
||||
|
||||
func configure(with image: String) {
|
||||
guard let url = URL(string: image) else { return }
|
||||
self.imgView.kf.setImage(with: url, options: [
|
||||
.processor(DownsamplingImageProcessor(size: self.frame.size)),
|
||||
.scaleFactor(UIScreen.main.scale),
|
||||
.cacheOriginalImage
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
class ImageGrid: UICollectionView, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
|
||||
private var images: [String] = []
|
||||
private var columnsCount: Int = 1
|
||||
private var spacing: CGFloat = 0
|
||||
|
||||
var selectionChanged: ((Int) -> Void)?
|
||||
var preferredMaxLayoutWidth: CGFloat = 0
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
}
|
||||
|
||||
override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
|
||||
super.init(frame: frame, collectionViewLayout: layout)
|
||||
|
||||
self.register(ImageCell.self, forCellWithReuseIdentifier: "ImageCell")
|
||||
self.dataSource = self
|
||||
self.delegate = self
|
||||
}
|
||||
|
||||
convenience init(columns: Int, spacing: CGFloat = 0) {
|
||||
let layout = UICollectionViewFlowLayout()
|
||||
layout.scrollDirection = .vertical
|
||||
layout.minimumInteritemSpacing = spacing
|
||||
layout.minimumLineSpacing = spacing
|
||||
layout.estimatedItemSize = .zero
|
||||
self.init(frame: .zero, collectionViewLayout: layout)
|
||||
self.backgroundColor = .clear
|
||||
self.columnsCount = columns
|
||||
self.spacing = spacing
|
||||
}
|
||||
|
||||
override var intrinsicContentSize: CGSize {
|
||||
let size = self.collectionViewLayout.collectionViewContentSize
|
||||
if size == .zero && self.preferredMaxLayoutWidth != 0 {
|
||||
let cellSize: CGFloat = (self.preferredMaxLayoutWidth - self.spacing*(CGFloat(self.columnsCount) - 1))/CGFloat(self.columnsCount)
|
||||
let rows: Int = self.images.count/self.columnsCount + (self.images.count % self.columnsCount == 0 ? 0 : 1)
|
||||
let height = cellSize*CGFloat(rows) + CGFloat(rows - 1)*self.spacing
|
||||
print("intrinsicContentSize: \(CGSize(width: self.preferredMaxLayoutWidth, height: height))")
|
||||
return CGSize(width: self.preferredMaxLayoutWidth, height: height)
|
||||
}
|
||||
|
||||
print("intrinsicContentSize: \(size)")
|
||||
return size
|
||||
}
|
||||
|
||||
func set(images: [String]) {
|
||||
self.images = images
|
||||
self.reloadData()
|
||||
self.invalidateIntrinsicContentSize()
|
||||
}
|
||||
|
||||
func set(columnsCount: Int) {
|
||||
self.columnsCount = columnsCount
|
||||
self.reloadData()
|
||||
self.invalidateIntrinsicContentSize()
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDataSource
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return self.images.count
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
guard let cell = self.dequeueReusableCell(withReuseIdentifier: "ImageCell", for: indexPath) as? ImageCell else { return UICollectionViewCell() }
|
||||
cell.configure(with: self.images[indexPath.row])
|
||||
return cell
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDelegateFlowLayout
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
||||
let cellSize = (self.bounds.size.width - self.spacing*(CGFloat(self.columnsCount) - 1))/CGFloat(self.columnsCount)
|
||||
return CGSize(width: cellSize, height: cellSize)
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
collectionView.deselectItem(at: indexPath, animated: false)
|
||||
self.selectionChanged?(indexPath.row)
|
||||
}
|
||||
}
|
||||
@ -1,67 +0,0 @@
|
||||
import UIKit
|
||||
import Eureka
|
||||
|
||||
final class ImageGridCell: Cell<[String]>, CellType {
|
||||
private var grid: ImageGrid!
|
||||
|
||||
required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
|
||||
self.grid = ImageGrid(columns: 3, spacing: 2)
|
||||
self.grid.translatesAutoresizingMaskIntoConstraints = false
|
||||
self.contentView.addSubview(self.grid)
|
||||
NSLayoutConstraint.activate([
|
||||
self.grid.leadingAnchor.constraint(equalTo: self.contentView.layoutMarginsGuide.leadingAnchor),
|
||||
self.grid.trailingAnchor.constraint(equalTo: self.contentView.layoutMarginsGuide.trailingAnchor),
|
||||
self.grid.topAnchor.constraint(equalTo: self.contentView.layoutMarginsGuide.topAnchor),
|
||||
self.grid.bottomAnchor.constraint(equalTo: self.contentView.layoutMarginsGuide.bottomAnchor)
|
||||
])
|
||||
self.height = { UITableView.automaticDimension }
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
}
|
||||
|
||||
override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority,
|
||||
verticalFittingPriority: UILayoutPriority) -> CGSize {
|
||||
self.grid.preferredMaxLayoutWidth = self.bounds.size.width - self.layoutMargins.left - self.layoutMargins.right
|
||||
return super.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: horizontalFittingPriority, verticalFittingPriority: verticalFittingPriority)
|
||||
}
|
||||
|
||||
override func setup() {
|
||||
super.setup()
|
||||
|
||||
self.grid.selectionChanged = { index in
|
||||
if let row = self.row as? ImageGridRow {
|
||||
row.select(at: index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func update() {
|
||||
super.update()
|
||||
self.textLabel?.text = nil
|
||||
self.detailTextLabel?.text = nil
|
||||
self.grid.set(images: row.value ?? [])
|
||||
}
|
||||
}
|
||||
|
||||
final class ImageGridRow: Row<ImageGridCell>, RowType {
|
||||
private var selectionCallback: ((Int) -> Void)?
|
||||
|
||||
required init(tag: String?) {
|
||||
super.init(tag: tag)
|
||||
cellProvider = CellProvider<ImageGridCell>()
|
||||
}
|
||||
|
||||
fileprivate func select(at index: Int) {
|
||||
self.selectionCallback?(index)
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
func onDidSelected(_ callback: @escaping (Int) -> Void) -> ImageGridRow {
|
||||
self.selectionCallback = callback
|
||||
return self
|
||||
}
|
||||
}
|
||||
@ -44,10 +44,10 @@ class SourceStatusCell: Cell<DebugInfoEntryDto>, CellType {
|
||||
self.detailTextLabel?.text = nil
|
||||
if let value = row.value {
|
||||
self.circle.tintColor = value.status.color
|
||||
//self.accessoryType = value.error == nil ? .none : .disclosureIndicator
|
||||
self.accessoryType = value.error == nil ? .none : .disclosureIndicator
|
||||
} else {
|
||||
self.circle.tintColor = .systemGray
|
||||
//self.accessoryType = .none
|
||||
self.accessoryType = .none
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -57,12 +57,19 @@ final class SourceStatusRow: Row<SourceStatusCell>, RowType {
|
||||
super.init(tag: tag)
|
||||
cellProvider = CellProvider<SourceStatusCell>()
|
||||
self.onCellSelection { cell, row in
|
||||
// TODO: Fix isolation problems
|
||||
// if let error = row.value?.error, let controller = cell.parentViewController {
|
||||
// let alert = UIAlertController(title: row.title, message: error, preferredStyle: .alert)
|
||||
// alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
||||
// controller.present(alert, animated: true)
|
||||
// }
|
||||
guard let error = row.value?.error else {
|
||||
return
|
||||
}
|
||||
|
||||
let title = row.title
|
||||
|
||||
DispatchQueue.main.async {
|
||||
if let controller = cell.parentViewController {
|
||||
let alert = UIAlertController(title: title, message: error, preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
||||
controller.present(alert, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user