Skip to content

Commit

Permalink
Adding basic conversion to swiftUI (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrayatnia authored Jul 29, 2023
1 parent 0084399 commit 1a1d46d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/NetShears/NetShears.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import UIKit
import SwiftUI

public protocol BodyExporterDelegate: AnyObject {
func netShears(exportResponseBodyFor request: NetShearsRequestModel) -> BodyExportType
Expand Down Expand Up @@ -90,6 +91,11 @@ public final class NetShears: NSObject {
UIViewController.currentViewController()?.present(initialVC, animated: true, completion: nil)
}
}

@available(iOS 13.0, *)
public func view() -> some View {
NetshearsFlowView()
}

public func addCustomRequest(url: String,
host: String,
Expand Down
23 changes: 23 additions & 0 deletions Sources/NetShears/UI/NetshearsFlowView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// NetshearsFlowView.swift
//
//
// Created by Sam Rayatnia on 09.02.23.
//

import SwiftUI

@available(iOS 13.0, *)
public struct NetshearsFlowView: UIViewControllerRepresentable {

public func makeUIViewController(context: Context) -> some UIViewController {
let storyboard = UIStoryboard.NetShearsStoryBoard
guard let initialVC = storyboard.instantiateInitialViewController() else { preconditionFailure() }
((initialVC as? UINavigationController)?.topViewController as? RequestsViewController)?.delegate = NetShears.shared.bodyExportDelegate
return initialVC
}

public func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}


}

0 comments on commit 1a1d46d

Please sign in to comment.