Михаил Капелько vor 1 Jahr
Ursprung
Commit
6fb992ed0b
4 geänderte Dateien mit 13 neuen und 12 gelöschten Zeilen
  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 Datei anzeigen


+ 9
- 8
iOS/src/Main.SectionGrid.swift Datei anzeigen

@@ -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 Datei anzeigen

@@ -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 Datei anzeigen

@@ -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()


Laden…
Abbrechen
Speichern