Compare commits
No commits in common. "81ac3708a3674bc925b2c23692f181f7d687c5bd" and "0c0180264edc55f81b2440dbee19096b1dafdb72" have entirely different histories.
81ac3708a3
...
0c0180264e
|
@ -218,9 +218,9 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDelegate
|
|||
} else {
|
||||
direction = .none
|
||||
}
|
||||
container.setRoot(newRoot, for: account, animating: direction)
|
||||
container.setRoot(newRoot, animating: direction)
|
||||
} else {
|
||||
window!.rootViewController = AccountSwitchingContainerViewController(root: newRoot, for: account)
|
||||
window!.rootViewController = AccountSwitchingContainerViewController(root: newRoot)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,29 @@
|
|||
import SwiftUI
|
||||
import Pachyderm
|
||||
|
||||
struct MainComposeTextView: View, PlaceholderViewProvider {
|
||||
struct MainComposeTextView: View {
|
||||
@ObservedObject var draft: Draft
|
||||
@State private var placeholder: PlaceholderView = Self.placeholderView()
|
||||
@State private var placeholder: Text = {
|
||||
let components = Calendar.current.dateComponents([.month, .day], from: Date())
|
||||
if components.month == 3 && components.day == 14 {
|
||||
if Date().formatted(date: .numeric, time: .omitted).starts(with: "3") {
|
||||
return Text("Happy π day!")
|
||||
}
|
||||
} else if components.month == 9 && components.day == 5 {
|
||||
// https://weirder.earth/@noracodes/109276419847254552
|
||||
// https://retrocomputing.stackexchange.com/questions/14763/what-warning-was-given-on-attempting-to-post-to-usenet-circa-1990
|
||||
return Text("This program posts news to thousands of machines throughout the entire populated world. Please be sure you know what you are doing.").italic()
|
||||
} else if components.month == 9 && components.day == 21 {
|
||||
return Text("Do you remember?")
|
||||
} else if components.month == 10 && components.day == 31 {
|
||||
if .random() {
|
||||
return Text("Post something spooky!")
|
||||
} else {
|
||||
return Text("Any questions?")
|
||||
}
|
||||
}
|
||||
return Text("What's on your mind?")
|
||||
}()
|
||||
|
||||
let minHeight: CGFloat = 150
|
||||
@State private var height: CGFloat?
|
||||
|
@ -48,38 +68,6 @@ struct MainComposeTextView: View, PlaceholderViewProvider {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
static func placeholderView() -> some View {
|
||||
let components = Calendar.current.dateComponents([.month, .day], from: Date())
|
||||
if components.month == 3 && components.day == 14,
|
||||
Date().formatted(date: .numeric, time: .omitted).starts(with: "3") {
|
||||
Text("Happy π day!")
|
||||
} else if components.month == 4 && components.day == 1 {
|
||||
Text("April Fool's!").rotationEffect(.radians(.pi), anchor: .center)
|
||||
} else if components.month == 9 && components.day == 5 {
|
||||
// https://weirder.earth/@noracodes/109276419847254552
|
||||
// https://retrocomputing.stackexchange.com/questions/14763/what-warning-was-given-on-attempting-to-post-to-usenet-circa-1990
|
||||
Text("This program posts news to thousands of machines throughout the entire populated world. Please be sure you know what you are doing.").italic()
|
||||
} else if components.month == 9 && components.day == 21 {
|
||||
Text("Do you remember?")
|
||||
} else if components.month == 10 && components.day == 31 {
|
||||
if .random() {
|
||||
Text("Post something spooky!")
|
||||
} else {
|
||||
Text("Any questions?")
|
||||
}
|
||||
} else {
|
||||
Text("What's on your mind?")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// exists to provide access to the type alias since the @State property needs it to be explicit
|
||||
private protocol PlaceholderViewProvider {
|
||||
associatedtype PlaceholderView: View
|
||||
@ViewBuilder
|
||||
static func placeholderView() -> PlaceholderView
|
||||
}
|
||||
|
||||
struct MainComposeWrappedTextView: UIViewRepresentable {
|
||||
|
|
|
@ -11,13 +11,9 @@ import ScreenCorners
|
|||
|
||||
class AccountSwitchingContainerViewController: UIViewController {
|
||||
|
||||
private var currentAccountID: String
|
||||
private(set) var root: TuskerRootViewController
|
||||
|
||||
private var userActivities: [String: NSUserActivity] = [:]
|
||||
|
||||
init(root: TuskerRootViewController, for account: LocalData.UserAccountInfo) {
|
||||
self.currentAccountID = account.id
|
||||
init(root: TuskerRootViewController) {
|
||||
self.root = root
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
@ -33,27 +29,14 @@ class AccountSwitchingContainerViewController: UIViewController {
|
|||
embedChild(root)
|
||||
}
|
||||
|
||||
func setRoot(_ newRoot: TuskerRootViewController, for account: LocalData.UserAccountInfo, animating direction: AnimationDirection) {
|
||||
func setRoot(_ newRoot: TuskerRootViewController, animating direction: AnimationDirection) {
|
||||
let oldRoot = self.root
|
||||
if direction == .none {
|
||||
oldRoot.removeViewAndController()
|
||||
}
|
||||
if let activity = oldRoot.stateRestorationActivity() {
|
||||
stateRestorationLogger.debug("AccountSwitchingContainer: saving \(activity.activityType, privacy: .public) for \(self.currentAccountID, privacy: .public)")
|
||||
userActivities[currentAccountID] = activity
|
||||
}
|
||||
|
||||
self.currentAccountID = account.id
|
||||
self.root = newRoot
|
||||
embedChild(newRoot)
|
||||
|
||||
if let activity = userActivities.removeValue(forKey: account.id) {
|
||||
stateRestorationLogger.debug("AccountSwitchingContainer: restoring \(activity.activityType, privacy: .public) for \(account.id, privacy: .public)")
|
||||
let context = StateRestorationUserActivityHandlingContext(root: newRoot)
|
||||
_ = activity.handleResume(manager: UserActivityManager(scene: view.window!.windowScene!, context: context))
|
||||
context.finalize(activity: activity)
|
||||
}
|
||||
|
||||
if direction != .none {
|
||||
if UIAccessibility.prefersCrossFadeTransitions {
|
||||
newRoot.view.alpha = 0
|
||||
|
|
|
@ -14,13 +14,12 @@ class TimelineGapCollectionViewCell: UICollectionViewCell {
|
|||
|
||||
private let indicator = UIActivityIndicatorView(style: .medium)
|
||||
private let chevronView = AnimatingChevronView()
|
||||
private let fillView = UIView()
|
||||
|
||||
var fillGap: ((TimelineGapDirection) async -> Void)?
|
||||
|
||||
override var isHighlighted: Bool {
|
||||
didSet {
|
||||
backgroundColor = isHighlighted ? .appFill : .appSecondaryBackground
|
||||
backgroundColor = isHighlighted ? .appFill : .appGroupedBackground
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,22 +38,17 @@ class TimelineGapCollectionViewCell: UICollectionViewCell {
|
|||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
backgroundColor = .appSecondaryBackground
|
||||
backgroundColor = .appGroupedBackground
|
||||
|
||||
fillView.backgroundColor = .tintColor
|
||||
fillView.alpha = 0.75
|
||||
fillView.layer.masksToBounds = true
|
||||
fillView.layer.cornerRadius = 8
|
||||
fillView.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentView.addSubview(fillView)
|
||||
indicator.isHidden = true
|
||||
indicator.color = .tintColor
|
||||
|
||||
let label = UILabel()
|
||||
label.text = "Load more"
|
||||
label.font = .preferredFont(forTextStyle: .headline)
|
||||
label.adjustsFontForContentSizeCategory = true
|
||||
label.textColor = .white
|
||||
label.textColor = .tintColor
|
||||
|
||||
chevronView.tintColor = .white
|
||||
chevronView.update(direction: .above)
|
||||
|
||||
let stack = UIStackView(arrangedSubviews: [
|
||||
|
@ -66,25 +60,15 @@ class TimelineGapCollectionViewCell: UICollectionViewCell {
|
|||
stack.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentView.addSubview(stack)
|
||||
|
||||
indicator.isHidden = true
|
||||
indicator.color = .tintColor
|
||||
indicator.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentView.addSubview(indicator)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
stack.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
|
||||
stack.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),
|
||||
|
||||
fillView.leadingAnchor.constraint(equalTo: stack.leadingAnchor, constant: -8),
|
||||
// optical centering, babey
|
||||
fillView.trailingAnchor.constraint(equalTo: stack.trailingAnchor, constant: 10),
|
||||
fillView.topAnchor.constraint(equalTo: stack.topAnchor, constant: -4),
|
||||
fillView.bottomAnchor.constraint(equalTo: stack.bottomAnchor, constant: 4),
|
||||
|
||||
indicator.trailingAnchor.constraint(equalTo: stack.leadingAnchor, constant: -12),
|
||||
indicator.trailingAnchor.constraint(equalTo: stack.leadingAnchor, constant: -8),
|
||||
indicator.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),
|
||||
|
||||
contentView.heightAnchor.constraint(equalToConstant: 52),
|
||||
contentView.heightAnchor.constraint(equalToConstant: 44),
|
||||
])
|
||||
}
|
||||
|
||||
|
|
|
@ -718,15 +718,27 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
}
|
||||
|
||||
@objc func refresh() {
|
||||
Task { @MainActor in
|
||||
Task {
|
||||
if case .notLoadedInitial = controller.state {
|
||||
await controller.loadInitial()
|
||||
} else {
|
||||
await controller.loadNewer()
|
||||
}
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
collectionView.refreshControl?.endRefreshing()
|
||||
#endif
|
||||
} else {
|
||||
@MainActor
|
||||
func loadNewerAndEndRefreshing() async {
|
||||
await controller.loadNewer()
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
collectionView.refreshControl?.endRefreshing()
|
||||
#endif
|
||||
}
|
||||
|
||||
// I'm not sure whether this should move into TimelineLikeController/TimelineLikeCollectionViewController
|
||||
let (_, presentItems) = await (loadNewerAndEndRefreshing(), try? loadInitial())
|
||||
if let presentItems, !presentItems.isEmpty {
|
||||
insertPresentItemsAndShowJumpToast(presentItems)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,15 @@ class UserActivityManager {
|
|||
scene.session.mastodonController!
|
||||
}
|
||||
|
||||
private func getMainViewController() -> TuskerRootViewController {
|
||||
let window = scene.windows.first { $0.isKeyWindow } ?? scene.windows.first!
|
||||
return window.rootViewController as! TuskerRootViewController
|
||||
}
|
||||
|
||||
private func present(_ vc: UIViewController, animated: Bool = true) {
|
||||
getMainViewController().present(vc, animated: animated)
|
||||
}
|
||||
|
||||
static func getAccount(from activity: NSUserActivity) -> LocalData.UserAccountInfo? {
|
||||
guard let id = activity.userInfo?["accountID"] as? String else {
|
||||
return nil
|
||||
|
@ -204,26 +213,25 @@ class UserActivityManager {
|
|||
func handleShowTimeline(activity: NSUserActivity) {
|
||||
guard let (timeline, positionInfo) = Self.getTimeline(from: activity) else { return }
|
||||
|
||||
var timelineVC: TimelineViewController?
|
||||
let timelineVC: TimelineViewController
|
||||
if let pinned = PinnedTimeline(timeline: timeline),
|
||||
mastodonController.accountPreferences.pinnedTimelines.contains(pinned) {
|
||||
context.select(route: .timelines)
|
||||
context.popToRoot()
|
||||
let pageController = context.topViewController as! TimelinesPageViewController
|
||||
pageController.selectTimeline(pinned, animated: false)
|
||||
timelineVC = pageController.currentViewController as? TimelineViewController
|
||||
timelineVC = pageController.currentViewController as! TimelineViewController
|
||||
} else if case .list(let id) = timeline {
|
||||
context.select(route: .list(id: id))
|
||||
timelineVC = context.topViewController as? TimelineViewController
|
||||
timelineVC = context.topViewController! as! TimelineViewController
|
||||
} else {
|
||||
context.select(route: .explore)
|
||||
context.popToRoot()
|
||||
timelineVC = TimelineViewController(for: timeline, mastodonController: mastodonController)
|
||||
context.push(timelineVC!)
|
||||
context.push(timelineVC)
|
||||
}
|
||||
|
||||
if let timelineVC,
|
||||
let positionInfo,
|
||||
if let positionInfo,
|
||||
context.isHandoff {
|
||||
Task {
|
||||
await timelineVC.restoreStateFromHandoff(statusIDs: positionInfo.statusIDs, centerStatusID: positionInfo.centerStatusID)
|
||||
|
|
Loading…
Reference in New Issue