Compare commits
3 Commits
5365469594
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56cac34baf | ||
|
|
0da783827e | ||
|
|
cafd6ca621 |
Binary file not shown.
@@ -40,9 +40,14 @@ extension Main {
|
|||||||
btn.addTarget(self, action: #selector(Main.Core.selectButton), for: .touchUpInside)
|
btn.addTarget(self, action: #selector(Main.Core.selectButton), for: .touchUpInside)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let groups = memoryGroups(c: M())
|
||||||
|
|
||||||
// Выводим номер нажатой кнопки.
|
// Выводим номер нажатой кнопки.
|
||||||
didSelectButton
|
didSelectButton
|
||||||
.sink { i in print("ИГР MainP.viewDL didSB: '\(i)'") }
|
.sink { i in
|
||||||
|
print("ИГР MainP.viewDL didSB id/group: '\(i)'/'\(groups[Float(i)])'")
|
||||||
|
}
|
||||||
.store(in: &subscriptions)
|
.store(in: &subscriptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
function memoryGap() {
|
function memoryGap() {
|
||||||
return memorySide() + memorySpace();
|
return memorySide() + memorySpace();
|
||||||
}
|
}
|
||||||
|
function memoryGroups(c) {
|
||||||
|
var items = {};
|
||||||
|
// @ts-ignore
|
||||||
|
var ids = utsIndexArray(c.itemsCount);
|
||||||
|
ids.forEach(function (i) {
|
||||||
|
// @ts-ignore
|
||||||
|
items[Number(i)] = utsFloor(Number(i) / 2);
|
||||||
|
});
|
||||||
|
return items;
|
||||||
|
}
|
||||||
function memorySide() {
|
function memorySide() {
|
||||||
return 50;
|
return 50;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,17 @@ func memoryGap() -> Float {
|
|||||||
return memorySide() + memorySpace()
|
return memorySide() + memorySpace()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func memoryGroups(c: Context) -> [Float: Float] {
|
||||||
|
var items: [Float: Float] = [:]
|
||||||
|
// @ts-ignore
|
||||||
|
let ids = utsIndexArray(c.itemsCount);
|
||||||
|
ids.forEach { i in
|
||||||
|
// @ts-ignore
|
||||||
|
items[Float(i)] = utsFloor(Float(i) / 2)
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
func memorySide() -> Float {
|
func memorySide() -> Float {
|
||||||
return 50
|
return 50
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,17 @@ function memoryGap(): number {
|
|||||||
return memorySide() + memorySpace()
|
return memorySide() + memorySpace()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function memoryGroups(c: Context): Record<number, number> {
|
||||||
|
var items: Record<number, number> = {};
|
||||||
|
// @ts-ignore
|
||||||
|
let ids = utsIndexArray(c.itemsCount);
|
||||||
|
ids.forEach(i => {
|
||||||
|
// @ts-ignore
|
||||||
|
items[Number(i)] = utsFloor(Number(i) / 2)
|
||||||
|
})
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
function memorySide(): number {
|
function memorySide(): number {
|
||||||
return 50
|
return 50
|
||||||
}
|
}
|
||||||
|
|||||||
25
toSwift
25
toSwift
@@ -39,11 +39,12 @@ function convert(line) {
|
|||||||
var result = line;
|
var result = line;
|
||||||
for (let src in globalReplacements) {
|
for (let src in globalReplacements) {
|
||||||
let dst = globalReplacements[src];
|
let dst = globalReplacements[src];
|
||||||
result = result.replace(src, dst);
|
result = result.replaceAll(src, dst);
|
||||||
}
|
}
|
||||||
result = protocolReplace(result);
|
result = protocolReplace(result);
|
||||||
result = typeArrayReplace(result);
|
result = typeArrayReplace(result);
|
||||||
result = forEachReplace(result);
|
result = forEachReplace(result);
|
||||||
|
result = recordReplace(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +101,28 @@ function protocolReplaceVariable(line) {
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Record<TypeA, TypeB> -> [TypeA: TypeB]
|
||||||
|
// Record<TypeA, TypeB> = {} -> [TypeA: TypeB] = [:]
|
||||||
|
function recordReplace(line) {
|
||||||
|
if (!line.includes("Record")) {
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
let partsR = line.split("Record<");
|
||||||
|
let typesAndEnding = partsR[1];
|
||||||
|
let partsT = typesAndEnding.split(">");
|
||||||
|
let types = partsT[0];
|
||||||
|
let ending = partsT[1];
|
||||||
|
let swiftTypes = types.split(", ");
|
||||||
|
let was = `Record<${swiftTypes[0]}, ${swiftTypes[1]}>`;
|
||||||
|
let now = `[${swiftTypes[0]}: ${swiftTypes[1]}]`;
|
||||||
|
var result = line;
|
||||||
|
result = result.replace(was, now);
|
||||||
|
result = result.replace("] = {};", "] = [:]");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Type[] -> [Type]
|
// Type[] -> [Type]
|
||||||
function typeArrayReplace(line) {
|
function typeArrayReplace(line) {
|
||||||
let parts = line.split(" ");
|
let parts = line.split(" ");
|
||||||
|
|||||||
@@ -33,12 +33,15 @@
|
|||||||
item.style.position = "absolute"
|
item.style.position = "absolute"
|
||||||
item.style.background = "blue"
|
item.style.background = "blue"
|
||||||
}
|
}
|
||||||
|
let groups = memoryGroups(M);
|
||||||
|
/**/console.log("ИГР groups:", groups);
|
||||||
|
|
||||||
// SectionSelection.
|
// SectionSelection.
|
||||||
for (let id in items) {
|
for (let id in items) {
|
||||||
var item = items[id]
|
var item = items[id]
|
||||||
item.onclick = function() {
|
item.onclick = function() {
|
||||||
console.log("ИГР select id:", id)
|
let group = groups[id];
|
||||||
|
console.log("ИГР select id/group:", id, group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
10
будущее
10
будущее
@@ -1,12 +1,8 @@
|
|||||||
|
|
||||||
НАДО:
|
НАДО:
|
||||||
* ввести словари:
|
* проводить вычисления вывода группы элемента через модель
|
||||||
* тип - цвет
|
* swift
|
||||||
* id - тип
|
* web
|
||||||
* new Map?
|
|
||||||
https://timmousk.com/blog/typescript-dictionary/
|
|
||||||
* ввести тип (цвет) элемента
|
|
||||||
* выводить тип (цвет) элемента
|
|
||||||
* окрашивать элементы в цвета по номерам при выборе
|
* окрашивать элементы в цвета по номерам при выборе
|
||||||
* разрешать выбирать лишь два элемента
|
* разрешать выбирать лишь два элемента
|
||||||
* при выборе двух элементов сравнивать их цвет
|
* при выборе двух элементов сравнивать их цвет
|
||||||
|
|||||||
Reference in New Issue
Block a user