Compare commits
4 Commits
6c5909c800
...
2febb37a8e
Author | SHA1 | Date |
---|---|---|
Shadowfacts | 2febb37a8e | |
Shadowfacts | a20e8b2f48 | |
Shadowfacts | b3d5ed8505 | |
Shadowfacts | 4401503b85 |
|
@ -244,6 +244,13 @@ public final class ComposeController: ViewController {
|
|||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
navRoot
|
||||
}
|
||||
.navigationViewStyle(.stack)
|
||||
}
|
||||
|
||||
private var navRoot: some View {
|
||||
ZStack(alignment: .top) {
|
||||
// just using .background doesn't work; for some reason it gets inset immediately after the software keyboard is dismissed
|
||||
config.backgroundColor
|
||||
|
@ -291,6 +298,7 @@ public final class ComposeController: ViewController {
|
|||
})
|
||||
.onDisappear(perform: controller.onDisappear)
|
||||
.navigationTitle(controller.navigationTitle)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
|
||||
private var mainList: some View {
|
||||
|
|
|
@ -58,6 +58,13 @@ public final class DraftAttachment: NSManagedObject, Identifiable {
|
|||
case file(URL, UTType)
|
||||
}
|
||||
|
||||
public override func prepareForDeletion() {
|
||||
super.prepareForDeletion()
|
||||
if let fileURL {
|
||||
try? FileManager.default.removeItem(at: fileURL)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension DraftAttachment {
|
||||
|
|
|
@ -10,6 +10,8 @@ import UIKit
|
|||
public protocol DuckableViewController: UIViewController {
|
||||
var duckableDelegate: DuckableViewControllerDelegate? { get set }
|
||||
|
||||
func duckableViewControllerShouldDuck() -> Bool
|
||||
|
||||
func duckableViewControllerMayAttemptToDuck()
|
||||
|
||||
func duckableViewControllerWillAnimateDuck(withDuration duration: CGFloat, afterDelay delay: CGFloat)
|
||||
|
@ -18,6 +20,7 @@ public protocol DuckableViewController: UIViewController {
|
|||
}
|
||||
|
||||
extension DuckableViewController {
|
||||
public func duckableViewControllerShouldDuck() -> Bool { true }
|
||||
public func duckableViewControllerMayAttemptToDuck() {}
|
||||
public func duckableViewControllerWillAnimateDuck(withDuration duration: CGFloat, afterDelay delay: CGFloat) {}
|
||||
public func duckableViewControllerDidFinishAnimatingDuck() {}
|
||||
|
|
|
@ -63,6 +63,9 @@ class DuckAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
|
|||
let fadeAnimator = UIViewPropertyAnimator(duration: 0.1, curve: .linear) {
|
||||
presented.view.layer.opacity = 0
|
||||
}
|
||||
fadeAnimator.addCompletion { _ in
|
||||
presented.view.layer.opacity = 1
|
||||
}
|
||||
fadeAnimator.startAnimation(afterDelay: 0.3)
|
||||
|
||||
} else {
|
||||
|
@ -80,6 +83,7 @@ class DuckAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
|
|||
presented.view.layer.opacity = 0
|
||||
}
|
||||
fadeAnimator.addCompletion { _ in
|
||||
presented.view.layer.opacity = 1
|
||||
duckable.duckableViewControllerDidFinishAnimatingDuck()
|
||||
transitionContext.completeTransition(true)
|
||||
}
|
||||
|
|
|
@ -88,10 +88,9 @@ public class DuckableContainerViewController: UIViewController, DuckableViewCont
|
|||
|
||||
private func doPresentDuckable(_ viewController: DuckableViewController, animated: Bool, completion: (() -> Void)?) {
|
||||
viewController.duckableDelegate = self
|
||||
let nav = UINavigationController(rootViewController: viewController)
|
||||
nav.modalPresentationStyle = .custom
|
||||
nav.transitioningDelegate = self
|
||||
present(nav, animated: animated) {
|
||||
viewController.modalPresentationStyle = .custom
|
||||
viewController.transitioningDelegate = self
|
||||
present(viewController, animated: animated) {
|
||||
self.configureChildForDuckedPlaceholder()
|
||||
completion?()
|
||||
}
|
||||
|
@ -136,6 +135,10 @@ public class DuckableContainerViewController: UIViewController, DuckableViewCont
|
|||
guard case .presentingDucked(let viewController, isFirstPresentation: _) = state else {
|
||||
return
|
||||
}
|
||||
guard viewController.duckableViewControllerShouldDuck() else {
|
||||
viewController.sheetPresentationController!.selectedDetentIdentifier = .large
|
||||
return
|
||||
}
|
||||
let placeholder = createPlaceholderForDuckedViewController(viewController)
|
||||
state = .ducked(viewController, placeholder: placeholder)
|
||||
configureChildForDuckedPlaceholder()
|
||||
|
@ -236,4 +239,3 @@ extension DuckableContainerViewController: UISheetPresentationControllerDelegate
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,12 @@ public final class Status: StatusProtocol, Decodable, Sendable {
|
|||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.id = try container.decode(String.self, forKey: .id)
|
||||
self.uri = try container.decode(String.self, forKey: .uri)
|
||||
self.url = try container.decodeIfPresent(WebURL.self, forKey: .url)
|
||||
do {
|
||||
self.url = try container.decodeIfPresent(WebURL.self, forKey: .url)
|
||||
} catch {
|
||||
let s = (try? container.decode(String.self, forKey: .url)) ?? "<failed to decode string>"
|
||||
throw DecodingError.dataCorruptedError(forKey: .url, in: container, debugDescription: "Could not decode URL '\(s)', reason: \(String(describing: error))")
|
||||
}
|
||||
self.account = try container.decode(Account.self, forKey: .account)
|
||||
self.inReplyToID = try container.decodeIfPresent(String.self, forKey: .inReplyToID)
|
||||
self.inReplyToAccountID = try container.decodeIfPresent(String.self, forKey: .inReplyToAccountID)
|
||||
|
|
Loading…
Reference in New Issue