Михаил Капелько 1 year ago
parent
commit
6fb992ed0b
4 changed files with 13 additions and 12 deletions
  1. BIN
      iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate
  2. +9
    -8
      iOS/src/Main.SectionGrid.swift
  3. +3
    -3
      iOS/src/Model.swift
  4. +1
    -1
      web/memory.html

BIN
iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate View File


+ 9
- 8
iOS/src/Main.SectionGrid.swift View File

@@ -9,15 +9,16 @@ protocol MainSectionGrid { }
extension Main {
enum SectionGrid {
static func setupCore(_ core: Main.Core) {
let side = 50
let space = 20
let gap = side + space

// Расставляем кнопки в сетке 4x4.
for btn in core.buttons {
let id = btn.tag
let row = Int(id / 4)
btn.frame = CGRect(x: gap + (id - row * 4) * gap, y: gap + row * gap, width: side, height: side)
for (id, p) in memoryItemPositions(M()).enumerated() {
let btn = core.buttons[id]
btn.frame =
CGRect(
x: p.0,
y: p.1,
width: memorySide(),
height: memorySide()
)
btn.backgroundColor = .blue
}
}


+ 3
- 3
iOS/src/Model.swift View File

@@ -1,7 +1,7 @@
import Foundation

protocol MItemsCount {
var itemsCount: Int { get }
struct M {
var itemsCount: Int = 16
}

func memorySide() -> CGFloat {
@@ -16,7 +16,7 @@ func memoryGap() -> CGFloat {
return memorySide() + memorySpace()
}

func memoryItemPositions(M: MItemsCount) -> [(CGFloat, CGFloat)] {
func memoryItemPositions(_ M: M) -> [(CGFloat, CGFloat)] {
var pos = [(CGFloat, CGFloat)]()
for i in stride(from: 0, to: M.itemsCount, by: 1) {
let row = floor(Double(i) / 4)


+ 1
- 1
web/memory.html View File

@@ -19,7 +19,7 @@
}

function memoryItemPositions(M) {
var pos = [];
var pos = []
for (var i = 0; i < M.itemsCount; i++) {
let row = Math.floor(i / 4)
let x = memoryGap() + (i - row * 4) * memoryGap()


Loading…
Cancel
Save