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

Feature/swiftui support #2

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

sabrysmk
Copy link

SwiftUI Support for Jumper

Added Components

1. UIKit Presenter Protocol

  • Added UIKitPresenter protocol for handling UIKit controller presentations from SwiftUI
  • Provides interface for presenting UIKit controllers and alerts
  • Enables seamless integration between SwiftUI views and UIKit components
public protocol UIKitPresenter {
    func present(viewController: UIViewController, animated: Bool)
    func dismiss(animated: Bool)
    func presentAlert(title: String, message: String)
}

2. SwiftUI Screen Support

  • Added SwiftUIScreen struct to wrap SwiftUI views in the Jumper navigation system
  • Maintains compatibility with existing coordinator pattern
  • Handles UIKit controller presentation through environment values
public struct SwiftUIScreen<Content: View>: ScreenViewPresentable {
    // Wraps SwiftUI content with UIKit presentation capabilities
}

3. Environment Integration

  • Added environment values for UIKit presenter
  • Enables SwiftUI views to access UIKit presentation capabilities through the environment
  • Maintains SwiftUI's declarative nature while providing UIKit functionality

Benefits

  • Native SwiftUI Support: Write views in SwiftUI while keeping Jumper's navigation system
  • No Wrapper Boilerplate: No need to manually wrap SwiftUI views in UIHostingController
  • Type Safety: Full type safety and compile-time checks for navigation
  • Backward Compatibility: Existing UIKit code continues to work without modifications
  • Clean Architecture: Maintains separation of concerns between navigation and presentation

Usage Example

// Building a screen with SwiftUI content
enum SettingsBuilder {
    static func build() -> SettingsScreen {
        let viewModel = SettingsViewModel()
        let presenter = SettingsUIKitPresenter()
        let view = SwiftUIScreen(
            content: ControlPanelView(viewModel: viewModel),
            presenter: presenter
        )
        return Screen(screenView: view, viewModel: viewModel)
    }
}

Requirements

  • iOS 14.0+
  • Swift 5.6+

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