Михаил Капелько 1年前
コミット
a0fbb4132b
13個のファイルの変更53行の追加116行の削除
  1. +0
    -16
      iOS/app/MMMemory.xcodeproj/project.pbxproj
  2. バイナリ
      iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate
  3. +4
    -0
      iOS/src/AppDelegate.swift
  4. +30
    -3
      iOS/src/Main.Platform.swift
  5. +0
    -21
      iOS/src/Main.Section16Buttons.swift
  6. +0
    -26
      iOS/src/Main.SectionGrid.swift
  7. +0
    -23
      iOS/src/Main.SectionSelection.swift
  8. +0
    -16
      iOS/src/Model.swift
  9. +2
    -2
      shared/javaScript.js
  10. +4
    -5
      shared/swift.swift
  11. +2
    -2
      shared/typeScript.ts
  12. +2
    -0
      toSwift
  13. +9
    -2
      будущее

+ 0
- 16
iOS/app/MMMemory.xcodeproj/project.pbxproj ファイルの表示

@@ -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 */,
);


バイナリ
iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate ファイルの表示


+ 4
- 0
iOS/src/AppDelegate.swift ファイルの表示

@@ -17,3 +17,7 @@ extension AppDelegate {
return true
}
}

struct M: Context {
var itemsCount: Float = 16
}

+ 30
- 3
iOS/src/Main.Platform.swift ファイルの表示

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


+ 0
- 21
iOS/src/Main.Section16Buttons.swift ファイルの表示

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

+ 0
- 26
iOS/src/Main.SectionGrid.swift ファイルの表示

@@ -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
}
}
}
}

+ 0
- 23
iOS/src/Main.SectionSelection.swift ファイルの表示

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

+ 0
- 16
iOS/src/Model.swift ファイルの表示

@@ -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
}

+ 2
- 2
shared/javaScript.js ファイルの表示

@@ -13,8 +13,8 @@ function memoryItemPositions(c) {
var ids = utsIndexArray(c.itemsCount);
ids.forEach(function (i) {
// @ts-ignore
var row = utsFloor(i / 4);
var x = memoryGap() + (i - row * 4) * memoryGap();
var row = utsFloor(Number(i) / 4);
var x = memoryGap() + (Number(i) - row * 4) * memoryGap();
var y = memoryGap() + row * memoryGap();
// @ts-ignore
pos.push(memoryCreatePosition(x, y));


+ 4
- 5
shared/swift.swift ファイルの表示

@@ -24,14 +24,13 @@ func memoryItemPositions(c: Context) -> [Position] {
// @ts-ignore
let ids = utsIndexArray(c.itemsCount);
ids.forEach { ii in
let i = Float(ii);
ids.forEach { i in
// @ts-ignore
let row = utsFloor(i / 4)
let x = memoryGap() + (i - row * 4) * memoryGap()
let row = utsFloor(Float(i) / 4)
let x = memoryGap() + (Float(i) - row * 4) * memoryGap()
let y = memoryGap() + row * memoryGap()
// @ts-ignore
pos.push(memoryCreatePosition(x, y))
pos.append(memoryCreatePosition(x, y))
}
return pos
}

+ 2
- 2
shared/typeScript.ts ファイルの表示

@@ -26,8 +26,8 @@ function memoryItemPositions(c: Context): Position[] {
let ids = utsIndexArray(c.itemsCount);
ids.forEach(i => {
// @ts-ignore
let row = utsFloor(i / 4)
let x = memoryGap() + (i - row * 4) * memoryGap()
let row = utsFloor(Number(i) / 4)
let x = memoryGap() + (Number(i) - row * 4) * memoryGap()
let y = memoryGap() + row * memoryGap()
// @ts-ignore
pos.push(memoryCreatePosition(x, y))


+ 2
- 0
toSwift ファイルの表示

@@ -13,9 +13,11 @@ let fileDst = process.argv[3];
let globalReplacements = {
"function": "func",
"number": "Float",
"Number": "Float",
"):": ") ->",
"interface": "protocol",
"})": "}", // forEach
".push(": ".append(", // array
};

console.log(`Converting '${fileSrc}' to '${fileDst}'`);


+ 9
- 2
будущее ファイルの表示

@@ -1,9 +1,16 @@
15.06: 19:10-

НАДО:
* поправить Floor i/4
* попробовать number(i)
* поправить push
* переводить в append
* перейти на один файл swift
* генерить memoryItemPositions.swift
* ввести общую библиотеку?
* ввёл пока platform с функциями uts
* упростить структуру iOS помещением содержимого секций в платформу

НАДО:

* в конце: разделить функции на разные файлы
* в конце прототипа: разделить функции на разные файлы
* будет ошибка tsc: cannot find name, так что придётся покумекать

読み込み中…
キャンセル
保存