d
This commit is contained in:
@@ -8,13 +8,9 @@
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1F083A14C69F20A6BA92A63E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F16A7DD61EF6CD4FB4E3DE25 /* AppDelegate.swift */; };
|
||||
3D03666F3BC2B1F2CBB49530 /* Main.SectionSelection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5F2B2E3A26F03F6825608E /* Main.SectionSelection.swift */; };
|
||||
79FB208C9DADDA6179E588C3 /* Main.SectionGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AC22F19366076CF4168BFBD /* Main.SectionGrid.swift */; };
|
||||
89086E3972F560A9A1A76CE4 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C71EDBDFFDBC96F6E8E7762 /* Model.swift */; };
|
||||
B19B3998FA2BA651ACB1E53C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C1742EFC5A1E818780679340 /* Assets.xcassets */; };
|
||||
BE2994BF2FFF272E62883953 /* swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = D414A6174931F533B0B286E8 /* swift.swift */; };
|
||||
CAFD870CA84084E45011CC23 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4E32B0495E4BCEA4EE0508D4 /* LaunchScreen.storyboard */; };
|
||||
D505E64F4CD6EAEB530BF851 /* Main.Section16Buttons.swift in Sources */ = {isa = PBXBuildFile; fileRef = A38A1AA6B57483F6B44CDF78 /* Main.Section16Buttons.swift */; };
|
||||
DB1010B8A246D47BEC6B3FA6 /* Main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DF762100A8EDF105B6E136D /* Main.swift */; };
|
||||
EB8CC50236A211D932BA0DB0 /* Main.Platform.swift in Sources */ = {isa = PBXBuildFile; fileRef = A355A898E25602F45B88CCBA /* Main.Platform.swift */; };
|
||||
F368609CC7635D385838A386 /* platfrom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F3E3A0EC0B9264E001C3DBC /* platfrom.swift */; };
|
||||
@@ -24,12 +20,8 @@
|
||||
0DF762100A8EDF105B6E136D /* Main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.swift; sourceTree = "<group>"; };
|
||||
0F3E3A0EC0B9264E001C3DBC /* platfrom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = platfrom.swift; sourceTree = "<group>"; };
|
||||
4E32B0495E4BCEA4EE0508D4 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
6D5F2B2E3A26F03F6825608E /* Main.SectionSelection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.SectionSelection.swift; sourceTree = "<group>"; };
|
||||
9AC22F19366076CF4168BFBD /* Main.SectionGrid.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.SectionGrid.swift; sourceTree = "<group>"; };
|
||||
9C71EDBDFFDBC96F6E8E7762 /* Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = "<group>"; };
|
||||
9D774FEE86833E8A0A74387C /* App.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A355A898E25602F45B88CCBA /* Main.Platform.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.Platform.swift; sourceTree = "<group>"; };
|
||||
A38A1AA6B57483F6B44CDF78 /* Main.Section16Buttons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.Section16Buttons.swift; sourceTree = "<group>"; };
|
||||
C1742EFC5A1E818780679340 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
D414A6174931F533B0B286E8 /* swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = swift.swift; sourceTree = "<group>"; };
|
||||
F16A7DD61EF6CD4FB4E3DE25 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
@@ -52,11 +44,7 @@
|
||||
C1742EFC5A1E818780679340 /* Assets.xcassets */,
|
||||
4E32B0495E4BCEA4EE0508D4 /* LaunchScreen.storyboard */,
|
||||
A355A898E25602F45B88CCBA /* Main.Platform.swift */,
|
||||
A38A1AA6B57483F6B44CDF78 /* Main.Section16Buttons.swift */,
|
||||
9AC22F19366076CF4168BFBD /* Main.SectionGrid.swift */,
|
||||
6D5F2B2E3A26F03F6825608E /* Main.SectionSelection.swift */,
|
||||
0DF762100A8EDF105B6E136D /* Main.swift */,
|
||||
9C71EDBDFFDBC96F6E8E7762 /* Model.swift */,
|
||||
0F3E3A0EC0B9264E001C3DBC /* platfrom.swift */,
|
||||
);
|
||||
name = src;
|
||||
@@ -144,11 +132,7 @@
|
||||
files = (
|
||||
1F083A14C69F20A6BA92A63E /* AppDelegate.swift in Sources */,
|
||||
EB8CC50236A211D932BA0DB0 /* Main.Platform.swift in Sources */,
|
||||
D505E64F4CD6EAEB530BF851 /* Main.Section16Buttons.swift in Sources */,
|
||||
79FB208C9DADDA6179E588C3 /* Main.SectionGrid.swift in Sources */,
|
||||
3D03666F3BC2B1F2CBB49530 /* Main.SectionSelection.swift in Sources */,
|
||||
DB1010B8A246D47BEC6B3FA6 /* Main.swift in Sources */,
|
||||
89086E3972F560A9A1A76CE4 /* Model.swift in Sources */,
|
||||
F368609CC7635D385838A386 /* platfrom.swift in Sources */,
|
||||
BE2994BF2FFF272E62883953 /* swift.swift in Sources */,
|
||||
);
|
||||
|
||||
Binary file not shown.
@@ -17,3 +17,7 @@ extension AppDelegate {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
struct M: Context {
|
||||
var itemsCount: Float = 16
|
||||
}
|
||||
|
||||
@@ -14,9 +14,36 @@ extension Main {
|
||||
|
||||
view.backgroundColor = .white
|
||||
|
||||
Main.Section16Buttons.setupCore(self)
|
||||
Main.SectionGrid.setupCore(self)
|
||||
Main.SectionSelection.setupCore(self)
|
||||
// Создаём 16 кнопок.
|
||||
for i in 0..<16 {
|
||||
let btn = UIButton()
|
||||
btn.tag = i
|
||||
view.addSubview(btn)
|
||||
buttons.append(btn)
|
||||
}
|
||||
|
||||
// Расставляем кнопки в сетке 4x4.
|
||||
for (id, p) in memoryItemPositions(c: M()).enumerated() {
|
||||
let btn = buttons[id]
|
||||
btn.frame =
|
||||
CGRect(
|
||||
x: CGFloat(p.x),
|
||||
y: CGFloat(p.y),
|
||||
width: CGFloat(memorySide()),
|
||||
height: CGFloat(memorySide())
|
||||
)
|
||||
btn.backgroundColor = .blue
|
||||
}
|
||||
|
||||
// Учитываем нажатия кнопок.
|
||||
for btn in buttons {
|
||||
btn.addTarget(self, action: #selector(Main.Core.selectButton), for: .touchUpInside)
|
||||
}
|
||||
|
||||
// Выводим номер нажатой кнопки.
|
||||
didSelectButton
|
||||
.sink { i in print("ИГР MainP.viewDL didSB: '\(i)'") }
|
||||
.store(in: &subscriptions)
|
||||
}
|
||||
|
||||
@objc func selectButton(_ btn: UIButton) {
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import UIKit
|
||||
|
||||
// MARK: - Протоколы
|
||||
|
||||
protocol MainSection16Buttons { }
|
||||
|
||||
// MARK: - Реализация
|
||||
|
||||
extension Main {
|
||||
enum Section16Buttons {
|
||||
static func setupCore(_ core: Main.Core) {
|
||||
// Создаём 16 кнопок.
|
||||
for i in 0..<16 {
|
||||
let btn = UIButton()
|
||||
btn.tag = i
|
||||
core.view.addSubview(btn)
|
||||
core.buttons.append(btn)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import UIKit
|
||||
|
||||
// MARK: - Протоколы
|
||||
|
||||
protocol MainSectionGrid { }
|
||||
|
||||
// MARK: - Реализация
|
||||
|
||||
extension Main {
|
||||
enum SectionGrid {
|
||||
static func setupCore(_ core: Main.Core) {
|
||||
// Расставляем кнопки в сетке 4x4.
|
||||
for (id, p) in memoryItemPositions(M()).enumerated() {
|
||||
let btn = core.buttons[id]
|
||||
btn.frame =
|
||||
CGRect(
|
||||
x: CGFloat(p.0),
|
||||
y: CGFloat(p.1),
|
||||
width: CGFloat(memorySide()),
|
||||
height: CGFloat(memorySide())
|
||||
)
|
||||
btn.backgroundColor = .blue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
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)
|
||||
}
|
||||
|
||||
// Выводим номер нажатой кнопки.
|
||||
core.didSelectButton
|
||||
.sink { i in print("ИГР MainSS.setupC didSB: '\(i)'") }
|
||||
.store(in: &core.subscriptions)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import Foundation
|
||||
|
||||
struct M {
|
||||
var itemsCount: Int = 16
|
||||
}
|
||||
|
||||
func memoryItemPositions(_ M: M) -> [(Float, Float)] {
|
||||
var pos = [(Float, Float)]()
|
||||
for i in stride(from: 0, to: M.itemsCount, by: 1) {
|
||||
let row = floor(Float(i) / 4)
|
||||
let x = memoryGap() + (Float(i) - row * 4) * memoryGap()
|
||||
let y = memoryGap() + row * memoryGap()
|
||||
pos.append((x, y))
|
||||
}
|
||||
return pos
|
||||
}
|
||||
Reference in New Issue
Block a user