Compare commits

..

No commits in common. "f448090c2a990a534443c54d238b12d89ddb030c" and "3a3b7aaee4bf4c658935cc2e2c09f71af4702655" have entirely different histories.

7 changed files with 10 additions and 45 deletions

View File

@ -10,7 +10,7 @@ import UIKit
import Pachyderm
import Combine
public final class Preferences: Codable, ObservableObject {
public class Preferences: Codable, ObservableObject {
public static var shared: Preferences = load()
@ -60,7 +60,6 @@ public final class Preferences: Codable, ObservableObject {
self.showLinkPreviews = try container.decodeIfPresent(Bool.self, forKey: .showLinkPreviews) ?? true
self.leadingStatusSwipeActions = try container.decodeIfPresent([StatusSwipeAction].self, forKey: .leadingStatusSwipeActions) ?? leadingStatusSwipeActions
self.trailingStatusSwipeActions = try container.decodeIfPresent([StatusSwipeAction].self, forKey: .trailingStatusSwipeActions) ?? trailingStatusSwipeActions
self.widescreenNavigationMode = try container.decodeIfPresent(WidescreenNavigationMode.self, forKey: .widescreenNavigationMode) ?? Self.defaultWidescreenNavigationMode
self.defaultPostVisibility = try container.decode(Visibility.self, forKey: .defaultPostVisibility)
self.defaultReplyVisibility = try container.decodeIfPresent(ReplyVisibility.self, forKey: .defaultReplyVisibility) ?? .sameAsPost
@ -120,7 +119,6 @@ public final class Preferences: Codable, ObservableObject {
try container.encode(showLinkPreviews, forKey: .showLinkPreviews)
try container.encode(leadingStatusSwipeActions, forKey: .leadingStatusSwipeActions)
try container.encode(trailingStatusSwipeActions, forKey: .trailingStatusSwipeActions)
try container.encode(widescreenNavigationMode, forKey: .widescreenNavigationMode)
try container.encode(defaultPostVisibility, forKey: .defaultPostVisibility)
try container.encode(defaultReplyVisibility, forKey: .defaultReplyVisibility)
@ -173,8 +171,7 @@ public final class Preferences: Codable, ObservableObject {
@Published public var showLinkPreviews = true
@Published public var leadingStatusSwipeActions: [StatusSwipeAction] = [.favorite, .reblog]
@Published public var trailingStatusSwipeActions: [StatusSwipeAction] = [.reply, .share]
private static var defaultWidescreenNavigationMode = WidescreenNavigationMode.splitScreen
@Published public var widescreenNavigationMode = Preferences.defaultWidescreenNavigationMode
@Published public var widescreenNavigationMode = WidescreenNavigationMode.multiColumn
// MARK: Composing
@Published public var defaultPostVisibility = Visibility.public
@ -244,7 +241,6 @@ public final class Preferences: Codable, ObservableObject {
case showLinkPreviews
case leadingStatusSwipeActions
case trailingStatusSwipeActions
case widescreenNavigationMode
case defaultPostVisibility
case defaultReplyVisibility
@ -436,7 +432,6 @@ extension Preferences {
public enum FeatureFlag: String, Codable {
case iPadMultiColumn = "ipad-multi-column"
case iPadBrowserNavigation = "ipad-browser-navigation"
case iPadNavigationMode = "ipad-navigation-mode"
}
}

View File

@ -54,13 +54,7 @@ class AccountFollowsListViewController: UIViewController, CollectionViewControll
}
return config
}
let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
section.contentInsetsReference = .readableContent
}
return section
}
let layout = UICollectionViewCompositionalLayout.list(using: config)
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.delegate = self
collectionView.dragDelegate = self

View File

@ -33,13 +33,7 @@ class AccountListViewController: UIViewController, CollectionViewController {
override func loadView() {
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
config.backgroundColor = .appGroupedBackground
let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
section.contentInsetsReference = .readableContent
}
return section
}
let layout = UICollectionViewCompositionalLayout.list(using: config)
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.delegate = self
collectionView.dragDelegate = self

View File

@ -90,8 +90,7 @@ struct AppearancePrefsView : View {
@ViewBuilder
private var interfaceSection: some View {
if preferences.hasFeatureFlag(.iPadNavigationMode),
UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
Section(header: Text("Interface")) {
WidescreenNavigationPrefsView()
}

View File

@ -71,11 +71,7 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect
config.trailingSwipeActionsConfigurationProvider = { [unowned self] in
(collectionView.cellForItem(at: $0) as? TimelineStatusCollectionViewCell)?.trailingSwipeActions()
}
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
section.contentInsetsReference = .readableContent
}
return section
return NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
case .accounts:
return NSCollectionLayoutSection.list(using: accountsConfig, layoutEnvironment: environment)
}

View File

@ -48,10 +48,6 @@ class StatusEditHistoryViewController: UIViewController, CollectionViewControlle
}
return config
}
if let status = mastodonController.persistentContainer.status(for: statusID),
status.url?.host != mastodonController.instanceURL.host {
config.footerMode = .supplementary
}
let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
@ -81,7 +77,7 @@ class StatusEditHistoryViewController: UIViewController, CollectionViewControlle
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, itemIdentifier in
cell.indicator.startAnimating()
}
let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
return UICollectionViewDiffableDataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
switch itemIdentifier {
case .edit(let edit, let state, index: let index):
return collectionView.dequeueConfiguredReusableCell(using: editCell, for: indexPath, item: (edit, state, index))
@ -89,15 +85,6 @@ class StatusEditHistoryViewController: UIViewController, CollectionViewControlle
return collectionView.dequeueConfiguredReusableCell(using: loadingCell, for: indexPath, item: ())
}
}
let footerCell = UICollectionView.SupplementaryRegistration<UICollectionViewListCell>(elementKind: UICollectionView.elementKindSectionFooter) { supplementaryView, elementKind, indexPath in
var config = supplementaryView.defaultContentConfiguration()
config.text = "Edit history for posts originating from instances other than your own may not be complete."
supplementaryView.contentConfiguration = config
}
dataSource.supplementaryViewProvider = { collectionView, elementKind, indexPath in
return collectionView.dequeueConfiguredReusableSupplementary(using: footerCell, for: indexPath)
}
return dataSource
}
override func viewWillAppear(_ animated: Bool) {

View File

@ -110,9 +110,9 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
// just setting layout.configuration.contentInsetsReference doesn't work with UICollectionViewCompositionalLayout.list
let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
section.contentInsetsReference = .readableContent
}
// if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
// section.contentInsetsReference = .readableContent
// }
return section
}
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)