d
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
23
iOS/src/Main.SectionSelection.swift
Normal file
23
iOS/src/Main.SectionSelection.swift
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user