Commit 337fdfb3 authored by Andres Käver's avatar Andres Käver

tictac

parent c1e5042e
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## User settings
xcuserdata/
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
## Obj-C/Swift specific
*.hmap
## App packaging
*.ipa
*.dSYM.zip
*.dSYM
## Playgrounds
timeline.xctimeline
playground.xcworkspace
# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm
.build/
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build/
# Accio dependency management
Dependencies/
.accio/
# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17126"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
......@@ -11,10 +13,22 @@
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="TicTacToe 2020 2" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2Az-Y2-KEE">
<rect key="frame" x="93" y="435" width="228.5" height="36"/>
<fontDescription key="fontDescription" type="system" pointSize="30"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="2Az-Y2-KEE" firstAttribute="centerX" secondItem="6Tk-OE-BBY" secondAttribute="centerX" id="HPF-TL-9Lh"/>
<constraint firstItem="2Az-Y2-KEE" firstAttribute="centerY" secondItem="6Tk-OE-BBY" secondAttribute="centerY" id="rxi-J4-aqN"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
......@@ -22,4 +36,9 @@
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_0" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17126"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="TicTacToe2020_2" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="390" height="844"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" alignment="center" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="59E-ET-K8x">
<rect key="frame" x="0.0" y="44" width="390" height="766"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" alignment="top" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="lZM-7Q-Fey">
<rect key="frame" x="120" y="0.0" width="150" height="379"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3Cx-Jf-qKH">
<rect key="frame" x="0.0" y="0.0" width="30" height="30"/>
<color key="backgroundColor" systemColor="systemOrangeColor"/>
<state key="normal" title="R+"/>
<connections>
<action selector="RowPlusClicked:" destination="BYZ-38-t0r" eventType="touchUpInside" id="bSy-Rz-NVC"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hBm-Q2-WcP">
<rect key="frame" x="40" y="0.0" width="30" height="30"/>
<color key="backgroundColor" systemColor="systemOrangeColor"/>
<state key="normal" title="R-"/>
<connections>
<action selector="RowMinusClicked:" destination="BYZ-38-t0r" eventType="touchUpInside" id="TPm-Bu-ysX"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="F8r-E8-Pce">
<rect key="frame" x="80" y="0.0" width="30" height="30"/>
<color key="backgroundColor" systemColor="systemOrangeColor"/>
<state key="normal" title="C+"/>
<connections>
<action selector="ColPlusClicked:" destination="BYZ-38-t0r" eventType="touchUpInside" id="JZ2-JS-Wy4"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="elS-Vx-ADQ">
<rect key="frame" x="120" y="0.0" width="30" height="30"/>
<color key="backgroundColor" systemColor="systemOrangeColor"/>
<state key="normal" title="C-"/>
<connections>
<action selector="ColMinusClicked:" destination="BYZ-38-t0r" eventType="touchUpInside" id="pRk-5p-Uv4"/>
</connections>
</button>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="TUO-Pj-UK5">
<rect key="frame" x="5.6666666666666572" y="387" width="379" height="379"/>
<color key="backgroundColor" systemColor="systemYellowColor"/>
<constraints>
<constraint firstAttribute="width" secondItem="TUO-Pj-UK5" secondAttribute="height" multiplier="1:1" id="nEk-cf-X3Z"/>
</constraints>
</stackView>
</subviews>
<variation key="heightClass=compact" axis="horizontal"/>
</stackView>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="59E-ET-K8x" firstAttribute="bottom" secondItem="6Tk-OE-BBY" secondAttribute="bottom" id="1P7-LV-1Xt"/>
<constraint firstItem="59E-ET-K8x" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="K9j-5p-8IE"/>
<constraint firstItem="59E-ET-K8x" firstAttribute="trailing" secondItem="6Tk-OE-BBY" secondAttribute="trailing" id="eao-D8-MxK"/>
<constraint firstItem="59E-ET-K8x" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="tXU-1u-9Dx"/>
</constraints>
</view>
<connections>
<outlet property="GameBoard" destination="TUO-Pj-UK5" id="cKt-Cs-BPX"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="140.57971014492756" y="56.919642857142854"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemOrangeColor">
<color red="1" green="0.58431372549019611" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemYellowColor">
<color red="1" green="0.80000000000000004" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
......@@ -9,6 +9,84 @@ import UIKit
class ViewController: UIViewController {
@IBOutlet weak var GameBoard: UIStackView!
var buttonCounter = 0
@objc func buttonClicked(_ sender: UIButton) {
print("\(String(describing: sender.title(for: UIControl.State.normal)))")
}
@IBAction func RowPlusClicked(_ sender: UIButton) {
print("RowPlusClicked")
if (GameBoard.arrangedSubviews.count == 0) {
// nothing on screen yet
let columnStack = UIStackView()
columnStack.axis = .vertical
columnStack.alignment = .fill
columnStack.distribution = .fillEqually
columnStack.spacing = 8.0
GameBoard.addArrangedSubview(columnStack)
}
for subView in GameBoard.arrangedSubviews {
if let stack = subView as? UIStackView {
let button = UIButton()
button.backgroundColor = #colorLiteral(red: 0.1764705926, green: 0.4980392158, blue: 0.7568627596, alpha: 1)
button.setTitle("\(buttonCounter)", for: UIControl.State.normal)
buttonCounter += 1
button.addTarget(self, action: #selector(buttonClicked(_:)), for: UIControl.Event.touchUpInside)
stack.addArrangedSubview(button)
}
}
}
@IBAction func RowMinusClicked(_ sender: UIButton) {
}
@IBAction func ColPlusClicked(_ sender: UIButton) {
print("RowPlusClicked")
if (GameBoard.arrangedSubviews.count == 0) {
RowPlusClicked(sender)
}
let columnStack = UIStackView()
columnStack.axis = .vertical
columnStack.alignment = .fill
columnStack.distribution = .fillEqually
columnStack.spacing = 8.0
GameBoard.addArrangedSubview(columnStack)
if let firstColumnView = GameBoard.arrangedSubviews.first {
if let firstColumnStack = firstColumnView as? UIStackView {
let rowCount = firstColumnStack.arrangedSubviews.count
for _ in 0..<rowCount {
let button = UIButton()
button.backgroundColor = #colorLiteral(red: 0.1764705926, green: 0.4980392158, blue: 0.7568627596, alpha: 1)
button.setTitle("\(buttonCounter)", for: UIControl.State.normal)
buttonCounter += 1
button.addTarget(self, action: #selector(buttonClicked(_:)), for: UIControl.Event.touchUpInside)
columnStack.addArrangedSubview(button)
}
}
}
}
@IBAction func ColMinusClicked(_ sender: UIButton) {
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment