From 8f0999ac7a50cacec2d28e45cb8269b390d467f6 Mon Sep 17 00:00:00 2001 From: "Takuto NAKAMURA (Kyome)" Date: Thu, 18 Apr 2024 10:25:24 +0900 Subject: [PATCH] Remove unnecessary argument (useUINavigationController) --- Sources/LicenseList/LicenseListView.swift | 17 +++-------------- .../LicenseList/LicenseListViewController.swift | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Sources/LicenseList/LicenseListView.swift b/Sources/LicenseList/LicenseListView.swift index 8cf48ab..1998fc7 100644 --- a/Sources/LicenseList/LicenseListView.swift +++ b/Sources/LicenseList/LicenseListView.swift @@ -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) } @@ -65,9 +60,3 @@ public struct LicenseListView: View { } } } - -public extension LicenseListView { - init(useUINavigationController: Bool = false) { - self.init(useUINavigationController: useUINavigationController, navigationHandler: { _ in }) - } -} diff --git a/Sources/LicenseList/LicenseListViewController.swift b/Sources/LicenseList/LicenseListViewController.swift index c4a230d..00494a2 100644 --- a/Sources/LicenseList/LicenseListViewController.swift +++ b/Sources/LicenseList/LicenseListViewController.swift @@ -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)