Compare commits
No commits in common. "f448090c2a990a534443c54d238b12d89ddb030c" and "3a3b7aaee4bf4c658935cc2e2c09f71af4702655" have entirely different histories.
f448090c2a
...
3a3b7aaee4
|
@ -10,7 +10,7 @@ import UIKit
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
public final class Preferences: Codable, ObservableObject {
|
public class Preferences: Codable, ObservableObject {
|
||||||
|
|
||||||
public static var shared: Preferences = load()
|
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.showLinkPreviews = try container.decodeIfPresent(Bool.self, forKey: .showLinkPreviews) ?? true
|
||||||
self.leadingStatusSwipeActions = try container.decodeIfPresent([StatusSwipeAction].self, forKey: .leadingStatusSwipeActions) ?? leadingStatusSwipeActions
|
self.leadingStatusSwipeActions = try container.decodeIfPresent([StatusSwipeAction].self, forKey: .leadingStatusSwipeActions) ?? leadingStatusSwipeActions
|
||||||
self.trailingStatusSwipeActions = try container.decodeIfPresent([StatusSwipeAction].self, forKey: .trailingStatusSwipeActions) ?? trailingStatusSwipeActions
|
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.defaultPostVisibility = try container.decode(Visibility.self, forKey: .defaultPostVisibility)
|
||||||
self.defaultReplyVisibility = try container.decodeIfPresent(ReplyVisibility.self, forKey: .defaultReplyVisibility) ?? .sameAsPost
|
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(showLinkPreviews, forKey: .showLinkPreviews)
|
||||||
try container.encode(leadingStatusSwipeActions, forKey: .leadingStatusSwipeActions)
|
try container.encode(leadingStatusSwipeActions, forKey: .leadingStatusSwipeActions)
|
||||||
try container.encode(trailingStatusSwipeActions, forKey: .trailingStatusSwipeActions)
|
try container.encode(trailingStatusSwipeActions, forKey: .trailingStatusSwipeActions)
|
||||||
try container.encode(widescreenNavigationMode, forKey: .widescreenNavigationMode)
|
|
||||||
|
|
||||||
try container.encode(defaultPostVisibility, forKey: .defaultPostVisibility)
|
try container.encode(defaultPostVisibility, forKey: .defaultPostVisibility)
|
||||||
try container.encode(defaultReplyVisibility, forKey: .defaultReplyVisibility)
|
try container.encode(defaultReplyVisibility, forKey: .defaultReplyVisibility)
|
||||||
|
@ -173,8 +171,7 @@ public final class Preferences: Codable, ObservableObject {
|
||||||
@Published public var showLinkPreviews = true
|
@Published public var showLinkPreviews = true
|
||||||
@Published public var leadingStatusSwipeActions: [StatusSwipeAction] = [.favorite, .reblog]
|
@Published public var leadingStatusSwipeActions: [StatusSwipeAction] = [.favorite, .reblog]
|
||||||
@Published public var trailingStatusSwipeActions: [StatusSwipeAction] = [.reply, .share]
|
@Published public var trailingStatusSwipeActions: [StatusSwipeAction] = [.reply, .share]
|
||||||
private static var defaultWidescreenNavigationMode = WidescreenNavigationMode.splitScreen
|
@Published public var widescreenNavigationMode = WidescreenNavigationMode.multiColumn
|
||||||
@Published public var widescreenNavigationMode = Preferences.defaultWidescreenNavigationMode
|
|
||||||
|
|
||||||
// MARK: Composing
|
// MARK: Composing
|
||||||
@Published public var defaultPostVisibility = Visibility.public
|
@Published public var defaultPostVisibility = Visibility.public
|
||||||
|
@ -244,7 +241,6 @@ public final class Preferences: Codable, ObservableObject {
|
||||||
case showLinkPreviews
|
case showLinkPreviews
|
||||||
case leadingStatusSwipeActions
|
case leadingStatusSwipeActions
|
||||||
case trailingStatusSwipeActions
|
case trailingStatusSwipeActions
|
||||||
case widescreenNavigationMode
|
|
||||||
|
|
||||||
case defaultPostVisibility
|
case defaultPostVisibility
|
||||||
case defaultReplyVisibility
|
case defaultReplyVisibility
|
||||||
|
@ -436,7 +432,6 @@ extension Preferences {
|
||||||
public enum FeatureFlag: String, Codable {
|
public enum FeatureFlag: String, Codable {
|
||||||
case iPadMultiColumn = "ipad-multi-column"
|
case iPadMultiColumn = "ipad-multi-column"
|
||||||
case iPadBrowserNavigation = "ipad-browser-navigation"
|
case iPadBrowserNavigation = "ipad-browser-navigation"
|
||||||
case iPadNavigationMode = "ipad-navigation-mode"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,13 +54,7 @@ class AccountFollowsListViewController: UIViewController, CollectionViewControll
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in
|
let layout = UICollectionViewCompositionalLayout.list(using: config)
|
||||||
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
|
|
||||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
|
||||||
section.contentInsetsReference = .readableContent
|
|
||||||
}
|
|
||||||
return section
|
|
||||||
}
|
|
||||||
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||||
collectionView.delegate = self
|
collectionView.delegate = self
|
||||||
collectionView.dragDelegate = self
|
collectionView.dragDelegate = self
|
||||||
|
|
|
@ -33,13 +33,7 @@ class AccountListViewController: UIViewController, CollectionViewController {
|
||||||
override func loadView() {
|
override func loadView() {
|
||||||
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
|
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||||
config.backgroundColor = .appGroupedBackground
|
config.backgroundColor = .appGroupedBackground
|
||||||
let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in
|
let layout = UICollectionViewCompositionalLayout.list(using: config)
|
||||||
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
|
|
||||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
|
||||||
section.contentInsetsReference = .readableContent
|
|
||||||
}
|
|
||||||
return section
|
|
||||||
}
|
|
||||||
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||||
collectionView.delegate = self
|
collectionView.delegate = self
|
||||||
collectionView.dragDelegate = self
|
collectionView.dragDelegate = self
|
||||||
|
|
|
@ -90,8 +90,7 @@ struct AppearancePrefsView : View {
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private var interfaceSection: some View {
|
private var interfaceSection: some View {
|
||||||
if preferences.hasFeatureFlag(.iPadNavigationMode),
|
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||||
UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
|
||||||
Section(header: Text("Interface")) {
|
Section(header: Text("Interface")) {
|
||||||
WidescreenNavigationPrefsView()
|
WidescreenNavigationPrefsView()
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,11 +71,7 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect
|
||||||
config.trailingSwipeActionsConfigurationProvider = { [unowned self] in
|
config.trailingSwipeActionsConfigurationProvider = { [unowned self] in
|
||||||
(collectionView.cellForItem(at: $0) as? TimelineStatusCollectionViewCell)?.trailingSwipeActions()
|
(collectionView.cellForItem(at: $0) as? TimelineStatusCollectionViewCell)?.trailingSwipeActions()
|
||||||
}
|
}
|
||||||
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
|
return NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
|
||||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
|
||||||
section.contentInsetsReference = .readableContent
|
|
||||||
}
|
|
||||||
return section
|
|
||||||
case .accounts:
|
case .accounts:
|
||||||
return NSCollectionLayoutSection.list(using: accountsConfig, layoutEnvironment: environment)
|
return NSCollectionLayoutSection.list(using: accountsConfig, layoutEnvironment: environment)
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,10 +48,6 @@ class StatusEditHistoryViewController: UIViewController, CollectionViewControlle
|
||||||
}
|
}
|
||||||
return config
|
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 layout = UICollectionViewCompositionalLayout { sectionIndex, environment in
|
||||||
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
|
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
|
||||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
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
|
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, itemIdentifier in
|
||||||
cell.indicator.startAnimating()
|
cell.indicator.startAnimating()
|
||||||
}
|
}
|
||||||
let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
|
return UICollectionViewDiffableDataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
|
||||||
switch itemIdentifier {
|
switch itemIdentifier {
|
||||||
case .edit(let edit, let state, index: let index):
|
case .edit(let edit, let state, index: let index):
|
||||||
return collectionView.dequeueConfiguredReusableCell(using: editCell, for: indexPath, item: (edit, state, 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: ())
|
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) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
|
|
|
@ -110,9 +110,9 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
||||||
// just setting layout.configuration.contentInsetsReference doesn't work with UICollectionViewCompositionalLayout.list
|
// just setting layout.configuration.contentInsetsReference doesn't work with UICollectionViewCompositionalLayout.list
|
||||||
let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in
|
let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in
|
||||||
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
|
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
|
||||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
// if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||||
section.contentInsetsReference = .readableContent
|
// section.contentInsetsReference = .readableContent
|
||||||
}
|
// }
|
||||||
return section
|
return section
|
||||||
}
|
}
|
||||||
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||||
|
|
Loading…
Reference in New Issue