diff --git a/iOS/app/MMMemory.xcodeproj/project.pbxproj b/iOS/app/MMMemory.xcodeproj/project.pbxproj index cf84228..f27b9e8 100644 --- a/iOS/app/MMMemory.xcodeproj/project.pbxproj +++ b/iOS/app/MMMemory.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 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 */; }; + A8118182ABE97FA935A1A4F9 /* model.iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3A95F2FA5C43AF82C7A97FC /* model.iOS.swift */; }; B19B3998FA2BA651ACB1E53C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C1742EFC5A1E818780679340 /* Assets.xcassets */; }; CAFD870CA84084E45011CC23 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4E32B0495E4BCEA4EE0508D4 /* LaunchScreen.storyboard */; }; D505E64F4CD6EAEB530BF851 /* Main.Section16Buttons.swift in Sources */ = {isa = PBXBuildFile; fileRef = A38A1AA6B57483F6B44CDF78 /* Main.Section16Buttons.swift */; }; @@ -28,10 +29,20 @@ A355A898E25602F45B88CCBA /* Main.Platform.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.Platform.swift; sourceTree = ""; }; A38A1AA6B57483F6B44CDF78 /* Main.Section16Buttons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.Section16Buttons.swift; sourceTree = ""; }; C1742EFC5A1E818780679340 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + E3A95F2FA5C43AF82C7A97FC /* model.iOS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = model.iOS.swift; sourceTree = ""; }; F16A7DD61EF6CD4FB4E3DE25 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXGroup section */ + 4F93BC5459F4AF4391816D4A /* shared */ = { + isa = PBXGroup; + children = ( + E3A95F2FA5C43AF82C7A97FC /* model.iOS.swift */, + ); + name = shared; + path = ../../shared; + sourceTree = ""; + }; 667BC26EA8068A9FA707FC02 /* src */ = { isa = PBXGroup; children = ( @@ -60,6 +71,7 @@ CD7F0F0C9CA1BA5EAFD5CA09 = { isa = PBXGroup; children = ( + 4F93BC5459F4AF4391816D4A /* shared */, 667BC26EA8068A9FA707FC02 /* src */, AE7B74413EC292E802CC5C70 /* Products */, ); @@ -134,6 +146,7 @@ 3D03666F3BC2B1F2CBB49530 /* Main.SectionSelection.swift in Sources */, DB1010B8A246D47BEC6B3FA6 /* Main.swift in Sources */, 89086E3972F560A9A1A76CE4 /* Model.swift in Sources */, + A8118182ABE97FA935A1A4F9 /* model.iOS.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate b/iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate index 5b9881c..0bd332e 100644 Binary files a/iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate and b/iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/iOS/app/project.yml b/iOS/app/project.yml index 01f5e56..4cd13c3 100644 --- a/iOS/app/project.yml +++ b/iOS/app/project.yml @@ -8,6 +8,7 @@ targets: deploymentTarget: "16.0" sources: - path: "../src" + - path: "../../shared/model.iOS.swift" settings: base: INFOPLIST_FILE: Info.plist diff --git a/iOS/src/Main.SectionGrid.swift b/iOS/src/Main.SectionGrid.swift index 5c89e1d..4f54493 100644 --- a/iOS/src/Main.SectionGrid.swift +++ b/iOS/src/Main.SectionGrid.swift @@ -14,10 +14,10 @@ extension Main { let btn = core.buttons[id] btn.frame = CGRect( - x: p.0, - y: p.1, - width: memorySide(), - height: memorySide() + x: CGFloat(p.0), + y: CGFloat(p.1), + width: CGFloat(memorySide()), + height: CGFloat(memorySide()) ) btn.backgroundColor = .blue } diff --git a/iOS/src/Model.swift b/iOS/src/Model.swift index c7d8cd8..0b64e15 100644 --- a/iOS/src/Model.swift +++ b/iOS/src/Model.swift @@ -4,23 +4,11 @@ struct M { var itemsCount: Int = 16 } -func memorySide() -> CGFloat { - return 50 -} - -func memorySpace() -> CGFloat { - return 20 -} - -func memoryGap() -> CGFloat { - return memorySide() + memorySpace() -} - -func memoryItemPositions(_ M: M) -> [(CGFloat, CGFloat)] { - var pos = [(CGFloat, CGFloat)]() +func memoryItemPositions(_ M: M) -> [(Float, Float)] { + var pos = [(Float, Float)]() for i in stride(from: 0, to: M.itemsCount, by: 1) { - let row = floor(Double(i) / 4) - let x = memoryGap() + (Double(i) - row * 4) * memoryGap() + let row = floor(Float(i) / 4) + let x = memoryGap() + (Float(i) - row * 4) * memoryGap() let y = memoryGap() + row * memoryGap() pos.append((x, y)) } diff --git a/shared/model.iOS.swift b/shared/model.iOS.swift new file mode 100644 index 0000000..044f484 --- /dev/null +++ b/shared/model.iOS.swift @@ -0,0 +1,11 @@ +func memorySide() -> Float { + return 50 +} + +func memorySpace() -> Float { + return 20 +} + +func memoryGap() -> Float { + return memorySide() + memorySpace() +}