Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP DNR] Allow wrapping screens to guarantee a described view controller #159

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

kyleve
Copy link
Contributor

@kyleve kyleve commented Sep 27, 2022

This PR introduces a wrapper screen that transitions its content when the underlying VC type changes; which was lost as a "standard" thing when we removed DescribedViewController usage from our apps – since it effectively doubled the VC hierarchy depth. Some folks still want this behavior, so giving them a more concrete way to achieve it.

  • Add AnyContentScreen, which is a screen-based wrapper around DescribedViewController. If the containing screen's VC changes, it'll transition per the added transition type...
  • Speaking of which, added the concept of an animated transition to DescribedViewController when it replaces its content. This in general probably always should have been a thing; since without an animation, things look pretty sudden / abrupt.

Checklist

  • Unit Tests
  • UI Tests

/// if isLoading {
/// return LoadingScreen(with: ...)
/// } else if isEmpty {
/// return ContentScreen(with ...)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returns are backwards

let content = content()

if let content = content as? Self {
self = content
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, this drops the transition


guard newPreferredContentSize != preferredContentSize else { return }

preferredContentSize = newPreferredContentSize
}

private func currentViewControllerChanged() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I think this needs update for iOS 16 and 17


#if canImport(UIKit)

/// Used by `AnyContentScreen` and `DescribedViewController` to the backing view
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Some words missing here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Add: Tests for animated and non-animated transitions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant