This commit is contained in:
Михаил Капелько
2023-05-01 18:25:02 +03:00
parent 43061e16f3
commit 4d8ea1adfa
2 changed files with 30 additions and 0 deletions

View File

@@ -1,9 +1,11 @@
import Combine
import UIKit
// MARK: - Ядро-VC
extension Main {
class Core: UIViewController {
let didSelectButton = PassthroughSubject<Int, Never>()
var buttons = [UIButton]()
override func viewDidLoad() {
@@ -13,6 +15,11 @@ extension Main {
Main.Section16Buttons.setupCore(self)
Main.SectionGrid.setupCore(self)
Main.SectionSelection.setupCore(self)
}
@objc func selectButton(_ btn: UIButton) {
didSelectButton.send(btn.tag)
}
}
}

View File

@@ -0,0 +1,23 @@
import UIKit
// MARK: - Протоколы
protocol MainSectionSelection { }
// MARK: - Реализация
extension Main {
enum SectionSelection {
static func setupCore(_ core: Main.Core) {
// Учитываем нажатия кнопок.
for btn in core.buttons {
btn.addTarget(core, action: #selector(Main.Core.selectButton), for: .touchUpInside)
}
// Выводим номер нажатой кнопки.
didSelectButton
.sink { i in print("ИГР MainSS.setupC didSB: '\(i)'") }
.store(in: &core.subscriptions)
}
}
}