From 4d8ea1adfaa0f61e0121c4421b436861a76fa10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Mon, 1 May 2023 18:25:02 +0300 Subject: [PATCH] d --- iOS/src/Main.Platform.swift | 7 +++++++ iOS/src/Main.SectionSelection.swift | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 iOS/src/Main.SectionSelection.swift diff --git a/iOS/src/Main.Platform.swift b/iOS/src/Main.Platform.swift index 9c6073a..9b6b007 100644 --- a/iOS/src/Main.Platform.swift +++ b/iOS/src/Main.Platform.swift @@ -1,9 +1,11 @@ +import Combine import UIKit // MARK: - Ядро-VC extension Main { class Core: UIViewController { + let didSelectButton = PassthroughSubject() 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) } } } diff --git a/iOS/src/Main.SectionSelection.swift b/iOS/src/Main.SectionSelection.swift new file mode 100644 index 0000000..8074ecc --- /dev/null +++ b/iOS/src/Main.SectionSelection.swift @@ -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) + } + } +}