Made classes open instead of public, to access via SwiftUI

This commit is contained in:
Doron Katz
2020-01-28 10:21:17 -08:00
parent aca50feac8
commit 8e47206f83
9 changed files with 29 additions and 20 deletions
@@ -6,9 +6,13 @@
// Copyright © 2018 OpenSourceController. All rights reserved.
//
#if !os(macOS)
import UIKit
#else
import AppKit
#endif
final class LicenceListViewController: UITableViewController {
open class LicenceListViewController: UITableViewController {
// MARK: - Var
@@ -24,11 +28,11 @@ final class LicenceListViewController: UITableViewController {
super.init(style: .plain)
}
required init?(coder aDecoder: NSCoder) {
required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
override open func viewDidLoad() {
super.viewDidLoad()
self.prepareTableView()
@@ -50,22 +54,22 @@ extension LicenceListViewController {
// MARK: - Table View Data Source
override func numberOfSections(in tableView: UITableView) -> Int {
override open func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
override open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.downloadedLicence.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
override open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell: OpenSourceTableViewCell = tableView.dequeueReusableCell(for: indexPath)
guard let licence = self.downloadedLicence.get(at: indexPath.row) else { return cell }
cell.configure(licence: licence, config: self.config)
return cell
}
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
override open func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
}
@@ -8,7 +8,7 @@
import UIKit
final class LoadingViewController: UIViewController {
open class LoadingViewController: UIViewController {
// MARK: - Var
@@ -32,11 +32,11 @@ final class LoadingViewController: UIViewController {
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
override open func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = self.config.uiConfig.backgroundColor
@@ -6,7 +6,7 @@
import UIKit
final class OpenSourceTableViewCell: UITableViewCell, Reusable {
open class OpenSourceTableViewCell: UITableViewCell, Reusable {
// MARK: - Lifecycle
@@ -15,7 +15,7 @@ final class OpenSourceTableViewCell: UITableViewCell, Reusable {
self.prepareCellComponent()
}
required init?(coder aDecoder: NSCoder) {
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
@@ -6,7 +6,7 @@
import UIKit
final class OpenSourceViewController: UIViewController {
open class OpenSourceViewController: UIViewController {
// MARK: - Var
@@ -42,11 +42,11 @@ final class OpenSourceViewController: UIViewController {
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
override open func viewDidLoad() {
super.viewDidLoad()
self.title = self.config.title
+1 -1
View File
@@ -8,7 +8,7 @@
import Foundation
final class HTTPDataLoader {
open class HTTPDataLoader {
func loadData(fromUrl url: String, completion: @escaping (Data?) -> Void) {
if let url = URL(string: url) {
let task = URLSession.shared.dataTask(with: url) { (data, _, error) in
+3 -1
View File
@@ -6,7 +6,7 @@
import UIKit
final class LicenceLoader {
open class LicenceLoader {
/// Download every licence
///
@@ -32,4 +32,6 @@ final class LicenceLoader {
completion()
}
}
public init() {
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
import UIKit
public final class LicenceFile {
open class LicenceFile {
// MARK- Var
+3
View File
@@ -35,5 +35,8 @@ public struct OpenSourceControllerConfig {
public var verbose: Bool = false
/// UI-specific configuration.
public init() {
}
public var uiConfig = UIConfig()
}
+2 -2
View File
@@ -9,12 +9,12 @@
import UIKit
extension UITableView {
final func register<T: UITableViewCell>(cellType: T.Type)
open func register<T: UITableViewCell>(cellType: T.Type)
where T: Reusable {
self.register(cellType.self, forCellReuseIdentifier: cellType.reuseIdentifier)
}
final func dequeueReusableCell<T: UITableViewCell>(for indexPath: IndexPath, cellType: T.Type = T.self) -> T
open func dequeueReusableCell<T: UITableViewCell>(for indexPath: IndexPath, cellType: T.Type = T.self) -> T
where T: Reusable {
guard let cell = self.dequeueReusableCell(withIdentifier: cellType.reuseIdentifier, for: indexPath) as? T else {
fatalError(