Skip to content

Commit

Permalink
Merge pull request #33 from cybozu/remove-useUINavigationController
Browse files Browse the repository at this point in the history
Remove unnecessary argument (useUINavigationController)
  • Loading branch information
Kyome22 authored Apr 18, 2024
2 parents 857dbf3 + 8f0999a commit 0828b88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 3 additions & 14 deletions Sources/LicenseList/LicenseListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,19 @@ public struct LicenseListView: View {
@Environment(\.licenseListViewStyle) private var licenseListViewStyle: LicenseListViewStyle

let libraries = Library.libraries
let useUINavigationController: Bool
let navigationHandler: ((Library) -> Void)?

public init(
useUINavigationController: Bool = false,
navigationHandler: ((Library) -> Void)? = nil
) {
self.useUINavigationController = useUINavigationController
public init(navigationHandler: ((Library) -> Void)? = nil) {
self.navigationHandler = navigationHandler
}

public var body: some View {
List {
ForEach(libraries) { library in
if useUINavigationController {
if let navigationHandler {
HStack {
Button {
navigationHandler?(library)
navigationHandler(library)
} label: {
Text(library.name)
}
Expand Down Expand Up @@ -65,9 +60,3 @@ public struct LicenseListView: View {
}
}
}

public extension LicenseListView {
init(useUINavigationController: Bool = false) {
self.init(useUINavigationController: useUINavigationController, navigationHandler: { _ in })
}
}
2 changes: 1 addition & 1 deletion Sources/LicenseList/LicenseListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class LicenseListViewController: UIViewController {

public override func viewDidLoad() {
super.viewDidLoad()
let licenseListView = LicenseListView(useUINavigationController: true) { [weak self] library in
let licenseListView = LicenseListView() { [weak self] library in
self?.navigateTo(library: library)
}
let vc = UIHostingController(rootView: licenseListView)
Expand Down

0 comments on commit 0828b88

Please sign in to comment.