Михаил Капелько 1 year ago
parent
commit
4d8ea1adfa
2 changed files with 30 additions and 0 deletions
  1. +7
    -0
      iOS/src/Main.Platform.swift
  2. +23
    -0
      iOS/src/Main.SectionSelection.swift

+ 7
- 0
iOS/src/Main.Platform.swift 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)
}
}
}

+ 23
- 0
iOS/src/Main.SectionSelection.swift 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)
}
}
}

Loading…
Cancel
Save