Skip to content

Commit 4211470

Browse files
committed
Merge branch 'develop'
2 parents 1da618f + 6ed1ef6 commit 4211470

19 files changed

+772
-615
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Adheres to [Semantic Versioning](http://semver.org/).
1818
* iPad Navigation Options Setting does not open
1919
* Tapping a local attachment does not show the attachment
2020
* Distance is not being calculated correctly when navigation lines are updated
21+
* Add more informative message when an attachment fails to open
2122

2223
## 4.0.1
2324

MAGE.xcodeproj/project.pbxproj

Lines changed: 54 additions & 62 deletions
Large diffs are not rendered by default.

Mage/AttachmentCreationCoordinator.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,15 +641,15 @@ extension AttachmentCreationCoordinator: UIDocumentPickerDelegate {
641641

642642
do {
643643
try FileManager.default.createDirectory(at: fileToWriteTo.deletingLastPathComponent(), withIntermediateDirectories: true, attributes: [.protectionKey : FileProtectionType.complete]);
644-
645-
guard let attachmentData = try? Data(contentsOf: url) else { return }
644+
646645

647646
do {
647+
let attachmentData = try Data(contentsOf: url)
648648
try attachmentData.write(to: fileToWriteTo, options: .completeFileProtection)
649649
self.addAttachmentForSaving(location: fileToWriteTo, contentType: mimeType)
650650
} catch {
651651
print("Unable to write file \(fileToWriteTo): \(error)")
652-
MDCSnackbarManager.default.show(MDCSnackbarMessage(text: "Error adding attachment \(error)"))
652+
MDCSnackbarManager.default.show(MDCSnackbarMessage(text: "The file type \(filename).\(fileType) is not supported by MAGE. Try uploading a .zip version of the file instead."))
653653
}
654654

655655
} catch {

Mage/CoreData/Event+CoreDataProperties.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,29 @@ extension Event {
2828
@NSManaged var acl:[AnyHashable : Any]?
2929
}
3030

31+
extension Event {
32+
33+
var unsyncedObservations: [Observation] {
34+
guard let id = self.remoteId else {
35+
return []
36+
}
37+
38+
let predicate = NSPredicate(format: "error != nil && eventId == %@", id)
39+
let fetchRequest: NSFetchRequest<Observation> = Observation.fetchRequest()
40+
fetchRequest.predicate = predicate
41+
do {
42+
if let list = try self.managedObjectContext?.fetch(fetchRequest) {
43+
return list
44+
} else {
45+
return []
46+
}
47+
} catch let error {
48+
print("error:\(error)")
49+
return []
50+
}
51+
}
52+
}
53+
3154
// MARK: Generated accessors for teams
3255
extension Event {
3356

Mage/EventCell.xib

Lines changed: 0 additions & 82 deletions
This file was deleted.

Mage/EventChooserController.swift

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,13 @@ func actionButtonTapped()
100100
return refreshingStatus
101101
}()
102102

103-
private lazy var tableView: UITableView = {
104-
let tableView = UITableView(frame: .zero, style: .grouped)
105-
tableView.estimatedRowHeight = 52
106-
tableView.rowHeight = UITableView.automaticDimension
107-
return tableView
103+
private lazy var collectionView: UICollectionView = {
104+
var configuration = UICollectionLayoutListConfiguration(appearance: .grouped)
105+
configuration.headerMode = .supplementary
106+
configuration.footerMode = .supplementary
107+
108+
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewCompositionalLayout.list(using: configuration))
109+
return collectionView
108110
}()
109111

110112
let allEventsController = Event.caseInsensitiveSortFetchAll(sortTerm: "name", ascending: true, predicate: NSPredicate(format: "TRUEPREDICATE"), groupBy: nil, context: NSManagedObjectContext.mr_default())
@@ -119,7 +121,7 @@ func actionButtonTapped()
119121
self.modalPresentationStyle = .fullScreen
120122
self.scheme = scheme
121123
self.delegate = delegate
122-
self.eventDataSource = EventTableDataSource(tableView: tableView, eventSelectionDelegate: self, scheme: scheme)
124+
self.eventDataSource = EventTableDataSource(eventSelectionDelegate: self, scheme: scheme)
123125
self.allEventsController?.delegate = self
124126

125127
do {
@@ -140,17 +142,17 @@ func actionButtonTapped()
140142
title = "Welcome To MAGE"
141143
navigationItem.hidesBackButton = true
142144

143-
tableView.dataSource = eventDataSource
144-
tableView.delegate = eventDataSource
145-
tableView.register(UINib(nibName: "EventCell", bundle: nil), forCellReuseIdentifier: "eventCell")
146-
tableView.isAccessibilityElement = true
147-
tableView.accessibilityLabel = "Event Table"
148-
tableView.accessibilityIdentifier = "Event Table"
145+
collectionView.dataSource = eventDataSource
146+
collectionView.delegate = eventDataSource
147+
148+
collectionView.isAccessibilityElement = true
149+
collectionView.accessibilityLabel = "Event Table"
150+
collectionView.accessibilityIdentifier = "Event Table"
149151

150152
searchController.searchResultsUpdater = self
151153
applyTheme(withContainerScheme: scheme)
152154

153-
emptyState = EmptyState(frame: CGRect(x: 0, y: 0, width: self.tableView.bounds.size.width, height: self.tableView.bounds.size.height))
155+
emptyState = EmptyState(frame: CGRect(x: 0, y: 0, width: self.collectionView.bounds.size.width, height: self.collectionView.bounds.size.height))
154156
}
155157

156158
override func viewWillAppear(_ animated: Bool) {
@@ -159,7 +161,7 @@ func actionButtonTapped()
159161
if !eventsFetched && !eventsInitialized && eventDataSource?.otherFetchedResultsController?.fetchedObjects?.count == 0 && eventDataSource?.recentFetchedResultsController?.fetchedObjects?.count == 0 {
160162
emptyState?.configure(image: UIImage(systemName: "calendar"), title: "Loading Events", showActivityIndicator: true, scheme: self.scheme)
161163
emptyState?.toggleVisible(true)
162-
tableView.backgroundView = emptyState
164+
collectionView.backgroundView = emptyState
163165
}
164166
}
165167

@@ -173,7 +175,7 @@ func actionButtonTapped()
173175
eventInstructions.textColor = scheme?.colorScheme.onPrimaryColor
174176
eventInstructions.font = scheme?.typographyScheme.caption
175177
// actionbutton
176-
tableView.backgroundColor = scheme?.colorScheme.surfaceColor
178+
collectionView.backgroundColor = scheme?.colorScheme.surfaceColor
177179
refreshingButton.applySecondaryTheme(withScheme: containerScheme)
178180
searchController.searchBar.barTintColor = scheme?.colorScheme.onPrimaryColor;
179181
searchController.searchBar.tintColor = scheme?.colorScheme.onPrimaryColor;
@@ -203,7 +205,7 @@ func actionButtonTapped()
203205
searchContainer.addSubview(searchBar)
204206
}
205207
view.addSubview(searchContainer)
206-
view.addSubview(tableView)
208+
view.addSubview(collectionView)
207209
view.addSubview(refreshingButton)
208210
view.addSubview(refreshingView)
209211
searchContainerHeightConstraint = searchContainer.autoSetDimension(.height, toSize: 56)
@@ -218,19 +220,20 @@ func actionButtonTapped()
218220
searchContainer.autoPinEdge(.top, to: .bottom, of: stackView)
219221

220222
NSLayoutConstraint.autoSetPriority(.defaultHigh) {
221-
tableView.autoPinEdgesToSuperviewEdges(with: .zero, excludingEdge: .top)
222-
tableView.autoPinEdge(.top, to: .bottom, of: searchContainer)
223+
collectionView.autoPinEdgesToSuperviewEdges(with: .zero, excludingEdge: .top)
224+
collectionView.autoPinEdge(.top, to: .bottom, of: searchContainer)
223225
}
224226

225227
NSLayoutConstraint.autoSetPriority(.defaultLow) {
226-
tableView.autoPinEdgesToSuperviewEdges(with: .zero, excludingEdge: .top)
227-
tableView.autoPinEdge(.top, to: .bottom, of: stackView)
228+
collectionView.autoPinEdgesToSuperviewEdges(with: .zero, excludingEdge: .top)
229+
collectionView.autoPinEdge(.top, to: .bottom, of: stackView)
228230
}
229231

230232
eventInstructions.autoSetDimension(.height, toSize: 32)
231233

232234
refreshingButton.autoAlignAxis(toSuperviewAxis: .vertical)
233-
refreshingButton.autoPinEdge(.top, to: .top, of: tableView, withOffset: 8)
235+
236+
refreshingButton.autoPinEdge(.top, to: .top, of: collectionView, withOffset: 8)
234237

235238
refreshingStatus.autoPinEdgesToSuperviewSafeArea(with: UIEdgeInsets(top: 16, left: 8, bottom: 0, right: 8))
236239
refreshingView.autoPinEdgesToSuperviewEdges(with: .zero, excludingEdge: .top)
@@ -278,7 +281,7 @@ func actionButtonTapped()
278281
} else {
279282
UserDefaults.standard.showEventChooserOnce = false
280283
}
281-
tableView.reloadData()
284+
collectionView.reloadData()
282285
}
283286

284287
let timer = Timer(timeInterval: 10, repeats: true) { [weak self] timer in
@@ -319,7 +322,7 @@ func actionButtonTapped()
319322
// will update the event table and if there is only one event follow the autoSelectEvent flag
320323
func updateEventTable(autoSelectEvent: Bool = true) {
321324
eventDataSource?.refreshEventData()
322-
tableView.reloadData()
325+
collectionView.reloadData()
323326
refreshingButton.isHidden = true
324327

325328
if eventDataSource?.otherFetchedResultsController?.fetchedObjects?.count == 0 && eventDataSource?.recentFetchedResultsController?.fetchedObjects?.count == 0 {
@@ -335,7 +338,7 @@ func actionButtonTapped()
335338
attributedString.addAttribute(.paragraphStyle, value: paragraph, range: NSRange(location: 0, length: attributedString.length))
336339

337340
emptyState?.configure(image: UIImage(systemName: "calendar"), title: "No Events", attributedDescription: attributedString, buttonText: "Return to Login", tapHandler: self, selector: #selector(actionButtonTapped), scheme: scheme)
338-
self.tableView.backgroundView = emptyState
341+
self.collectionView.backgroundView = emptyState
339342
emptyState?.toggleVisible(true)
340343
eventInstructions.isHidden = true
341344
searchContainerHeightConstraint?.constant = 0.0
@@ -411,6 +414,6 @@ extension EventChooserController : UISearchResultsUpdating {
411414
} else {
412415
eventDataSource?.setEventFilter(filter: nil, delegate: nil)
413416
}
414-
tableView.reloadData()
417+
collectionView.reloadData()
415418
}
416419
}

0 commit comments

Comments
 (0)