Skip to content

Commit

Permalink
Merge pull request #391 from ualch9/list_prep
Browse files Browse the repository at this point in the history
OBAListView iOS 14 list
  • Loading branch information
aaronbrethorst authored Jun 25, 2021
2 parents 4bedd68 + 986f9d7 commit 58fe017
Show file tree
Hide file tree
Showing 66 changed files with 466 additions and 4,095 deletions.
18 changes: 13 additions & 5 deletions OBAKit/Alerts/TransitAlertViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct TransitAlertDataListViewModel: OBAListViewItem {
var subtitle: String { return String(body.prefix(256)) }
var onSelectAction: OBAListViewAction<TransitAlertDataListViewModel>?

var contentConfiguration: OBAContentConfiguration {
var configuration: OBAListViewItemConfiguration {
var config = OBAListRowConfiguration(
text: .string(title),
secondaryText: .string(subtitle),
Expand All @@ -40,12 +40,18 @@ struct TransitAlertDataListViewModel: OBAListViewItem {

config.textConfig.accessibilityNumberOfLines = 5
config.secondaryTextConfig.accessibilityNumberOfLines = 8
return config

return .custom(config)
}

init(_ transitAlert: TransitAlertViewModel, isUnread: Bool = false, forLocale locale: Locale, onSelectAction: OBAListViewAction<TransitAlertDataListViewModel>? = nil) {
init<TA: TransitAlertViewModel>(
_ transitAlert: TA,
isUnread: Bool = false,
forLocale locale: Locale,
onSelectAction: OBAListViewAction<TransitAlertDataListViewModel>? = nil)
where TA: Hashable {
self.transitAlert = transitAlert
self.id = transitAlert.id
self.id = "\(transitAlert.hashValue)"
self.title = transitAlert.title(forLocale: locale) ?? ""
self.body = transitAlert.body(forLocale: locale) ?? ""
self.localizedURL = transitAlert.url(forLocale: locale)
Expand All @@ -58,12 +64,14 @@ struct TransitAlertDataListViewModel: OBAListViewItem {
hasher.combine(title)
hasher.combine(body)
hasher.combine(localizedURL)
hasher.combine(isUnread)
}

static func == (lhs: TransitAlertDataListViewModel, rhs: TransitAlertDataListViewModel) -> Bool {
return lhs.id == rhs.id &&
lhs.title == rhs.title &&
lhs.body == rhs.body &&
lhs.localizedURL == rhs.localizedURL
lhs.localizedURL == rhs.localizedURL &&
lhs.isUnread == rhs.isUnread
}
}
4 changes: 3 additions & 1 deletion OBAKit/Bookmarks/BookmarksViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ public class BookmarksViewController: UIViewController,
let groupID: String = group?.id.uuidString ?? "unknown_group"
let groupName = group?.name ?? OBALoc("bookmarks_controller.ungrouped_bookmarks_section.title", value: "Bookmarks", comment: "The title for the bookmarks controller section that shows bookmarks that aren't in a group.")

return OBAListViewSection(id: groupID, title: groupName, contents: arrivalData)
var section = OBAListViewSection(id: groupID, title: groupName, contents: arrivalData)
section.configuration = .appearance(.plain)
return section
}

public func emptyData(for listView: OBAListView) -> OBAListView.EmptyData? {
Expand Down
4 changes: 2 additions & 2 deletions OBAKit/Bookmarks/BookmarksViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ struct BookmarkArrivalViewModel: OBAListViewItem {
return TripBookmarkTableCell.self
}

var contentConfiguration: OBAContentConfiguration {
return BookmarkArrivalContentConfiguration(viewModel: self)
var configuration: OBAListViewItemConfiguration {
return .custom(BookmarkArrivalContentConfiguration(viewModel: self))
}

var onSelectAction: OBAListViewAction<BookmarkArrivalViewModel>?
Expand Down
2 changes: 0 additions & 2 deletions OBAKit/Bookmarks/TripBookmarkCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ final class TripBookmarkTableCell: OBAListViewCell {
override init(frame: CGRect) {
super.init(frame: frame)

fixiOS13AutoLayoutBug()

contentView.backgroundColor = ThemeColors.shared.systemBackground

contentView.addSubview(stackView)
Expand Down
8 changes: 4 additions & 4 deletions OBAKit/Controls/ListView/Helpers/OBAListViewDebug.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ struct DEBUG_Person: OBAListViewItem {

var onSelectAction: OBAListViewAction<DEBUG_Person>?

var contentConfiguration: OBAContentConfiguration {
return OBAListRowConfiguration(image: UIImage(systemName: "person.fill"), text: .string(name), secondaryText: .string(address), appearance: .subtitle, accessoryType: .disclosureIndicator)
var configuration: OBAListViewItemConfiguration {
return .custom(OBAListRowConfiguration(image: UIImage(systemName: "person.fill"), text: .string(name), secondaryText: .string(address), appearance: .subtitle, accessoryType: .disclosureIndicator))
}

func hash(into hasher: inout Hasher) {
Expand Down Expand Up @@ -64,8 +64,8 @@ struct DEBUG_CustomContent: OBAListViewItem {
return [action]
}

var contentConfiguration: OBAContentConfiguration {
return DEBUG_CustomContentConfiguration(text: text)
var configuration: OBAListViewItemConfiguration {
return .custom(DEBUG_CustomContentConfiguration(text: text))
}

func hash(into hasher: inout Hasher) {
Expand Down
Loading

0 comments on commit 58fe017

Please sign in to comment.