Михаил Капелько 1 年之前
父節點
當前提交
6fb992ed0b
共有 4 個文件被更改,包括 13 次插入12 次删除
  1. 二進制
      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

二進制
iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate 查看文件


+ 9
- 8
iOS/src/Main.SectionGrid.swift 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存