Skip to content

Commit 18c9051

Browse files
committed
settings working on iOS
1 parent 892aef9 commit 18c9051

File tree

7 files changed

+155
-8
lines changed

7 files changed

+155
-8
lines changed

common/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ kotlin {
1818
framework('common')
1919
}
2020
}
21+
// fromPreset(presets.iosArm64, 'ios') {
22+
// binaries {
23+
// framework('common')
24+
// }
25+
// }
26+
2127
}
2228
sourceSets {
2329
commonMain {

iOS/NameGame/NameGame.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1E19EEA6224019610094EA01 /* StartViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E19EEA5224019610094EA01 /* StartViewController.swift */; };
1111
1E37F67F225C064E00CC126B /* common.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E37F67E225C064E00CC126B /* common.framework */; };
1212
1E37F682225C078400CC126B /* common.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 1E37F680225C078400CC126B /* common.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
13+
1E37F684225C21A700CC126B /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E37F683225C21A700CC126B /* SettingsViewController.swift */; };
1314
1E43892D224013860034263E /* IosNavigator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E43892C224013860034263E /* IosNavigator.swift */; };
1415
1E43892F224015A80034263E /* QuestionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E43892E224015A80034263E /* QuestionViewController.swift */; };
1516
1E9D6D35224EA56200F5C0B8 /* SAConfettiView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E9D6D34224EA55800F5C0B8 /* SAConfettiView.swift */; };
@@ -66,6 +67,7 @@
6667
1E37F67C225C063C00CC126B /* common.framework.dSYM */ = {isa = PBXFileReference; lastKnownFileType = wrapper.dsym; name = common.framework.dSYM; path = "../../common/build/xcode-frameworks/common.framework.dSYM"; sourceTree = "<group>"; };
6768
1E37F67E225C064E00CC126B /* common.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = common.framework; sourceTree = "<group>"; };
6869
1E37F680225C078400CC126B /* common.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = common.framework; sourceTree = "<group>"; };
70+
1E37F683225C21A700CC126B /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
6971
1E43892C224013860034263E /* IosNavigator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IosNavigator.swift; sourceTree = "<group>"; };
7072
1E43892E224015A80034263E /* QuestionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionViewController.swift; sourceTree = "<group>"; };
7173
1E9D6D34224EA55800F5C0B8 /* SAConfettiView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAConfettiView.swift; sourceTree = "<group>"; };
@@ -164,6 +166,7 @@
164166
1E43892C224013860034263E /* IosNavigator.swift */,
165167
1E43892E224015A80034263E /* QuestionViewController.swift */,
166168
1E19EEA5224019610094EA01 /* StartViewController.swift */,
169+
1E37F683225C21A700CC126B /* SettingsViewController.swift */,
167170
);
168171
path = NameGame;
169172
sourceTree = "<group>";
@@ -409,6 +412,7 @@
409412
1E9D6D39224EA64800F5C0B8 /* GameResultsViewController.swift in Sources */,
410413
1E9D6D35224EA56200F5C0B8 /* SAConfettiView.swift in Sources */,
411414
1E9D6D38224EA64800F5C0B8 /* ImageUtils.swift in Sources */,
415+
1E37F684225C21A700CC126B /* SettingsViewController.swift in Sources */,
412416
);
413417
runOnlyForDeploymentPostprocessing = 0;
414418
};
@@ -583,6 +587,7 @@
583587
isa = XCBuildConfiguration;
584588
buildSettings = {
585589
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
590+
CODE_SIGN_IDENTITY = "iPhone Developer";
586591
CODE_SIGN_STYLE = Automatic;
587592
DEVELOPMENT_TEAM = 9W3M6638YZ;
588593
ENABLE_BITCODE = NO;
@@ -597,6 +602,7 @@
597602
);
598603
PRODUCT_BUNDLE_IDENTIFIER = willowtree.NameGame;
599604
PRODUCT_NAME = "$(TARGET_NAME)";
605+
PROVISIONING_PROFILE_SPECIFIER = "";
600606
SWIFT_VERSION = 4.2;
601607
TARGETED_DEVICE_FAMILY = "1,2";
602608
};
@@ -606,6 +612,7 @@
606612
isa = XCBuildConfiguration;
607613
buildSettings = {
608614
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
615+
CODE_SIGN_IDENTITY = "iPhone Developer";
609616
CODE_SIGN_STYLE = Automatic;
610617
DEVELOPMENT_TEAM = 9W3M6638YZ;
611618
ENABLE_BITCODE = NO;
@@ -620,6 +627,7 @@
620627
);
621628
PRODUCT_BUNDLE_IDENTIFIER = willowtree.NameGame;
622629
PRODUCT_NAME = "$(TARGET_NAME)";
630+
PROVISIONING_PROFILE_SPECIFIER = "";
623631
SWIFT_VERSION = 4.2;
624632
TARGETED_DEVICE_FAMILY = "1,2";
625633
};

iOS/NameGame/NameGame/Base.lproj/Main.storyboard

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,28 @@
3535
<rect key="frame" x="0.0" y="0.0" width="414" height="600"/>
3636
</imageView>
3737
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wD0-YU-lMf">
38-
<rect key="frame" x="186" y="741" width="42" height="0.0"/>
38+
<rect key="frame" x="186" y="821" width="42" height="0.0"/>
3939
<fontDescription key="fontDescription" type="system" pointSize="17"/>
4040
<nil key="textColor"/>
4141
<nil key="highlightedColor"/>
4242
</label>
43+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XdR-4Z-8JC">
44+
<rect key="frame" x="32" y="751" width="350" height="30"/>
45+
<state key="normal" title="Settings"/>
46+
<connections>
47+
<action selector="settingsTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="6b1-XL-H2I"/>
48+
<action selector="viewTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="9B9-ve-hjE"/>
49+
</connections>
50+
</button>
4351
<progressView hidden="YES" opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" ambiguous="YES" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="n28-dW-Adq">
44-
<rect key="frame" x="121" y="741" width="182" height="2"/>
52+
<rect key="frame" x="116" y="811" width="182" height="2"/>
4553
</progressView>
4654
</subviews>
4755
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4856
<constraints>
4957
<constraint firstItem="WSc-GW-qUL" firstAttribute="trailing" secondItem="GUO-Ha-3tU" secondAttribute="trailing" constant="170" id="1OK-9b-N1k"/>
5058
<constraint firstItem="4Bf-oQ-a1f" firstAttribute="top" secondItem="WSc-GW-qUL" secondAttribute="top" constant="352" id="3WI-GH-bK8"/>
59+
<constraint firstItem="XdR-4Z-8JC" firstAttribute="leading" secondItem="WSc-GW-qUL" secondAttribute="leading" constant="32" id="3ng-Co-h32"/>
5160
<constraint firstItem="4Bf-oQ-a1f" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="5gW-FT-CAT"/>
5261
<constraint firstItem="9pF-JP-06A" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="8Hv-0A-om9"/>
5362
<constraint firstItem="WSc-GW-qUL" firstAttribute="bottom" secondItem="GUO-Ha-3tU" secondAttribute="bottom" constant="137" id="8xE-SG-MNl"/>
@@ -61,14 +70,17 @@
6170
<constraint firstItem="GUO-Ha-3tU" firstAttribute="leading" secondItem="WSc-GW-qUL" secondAttribute="leading" constant="170" id="KWH-fM-iWG"/>
6271
<constraint firstItem="9pF-JP-06A" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="LL5-Hw-zQm"/>
6372
<constraint firstItem="WSc-GW-qUL" firstAttribute="trailing" secondItem="4Bf-oQ-a1f" secondAttribute="trailing" constant="16" id="NWS-vm-WIf"/>
73+
<constraint firstItem="XdR-4Z-8JC" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="QrK-5p-t3U"/>
6474
<constraint firstItem="4Bf-oQ-a1f" firstAttribute="leading" secondItem="WSc-GW-qUL" secondAttribute="leading" constant="142.5" id="Vk7-fJ-VME"/>
6575
<constraint firstItem="9pF-JP-06A" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" id="Y1S-F4-Zum"/>
66-
<constraint firstItem="n28-dW-Adq" firstAttribute="top" secondItem="GUO-Ha-3tU" secondAttribute="bottom" constant="16" id="dYm-1H-qY3"/>
76+
<constraint firstItem="GUO-Ha-3tU" firstAttribute="top" secondItem="XdR-4Z-8JC" secondAttribute="bottom" constant="-86" id="dYm-1H-qY3"/>
6777
<constraint firstItem="9pF-JP-06A" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="eNo-20-5tD"/>
6878
<constraint firstItem="wD0-YU-lMf" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="eev-lg-Fk3"/>
79+
<constraint firstItem="XdR-4Z-8JC" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="fhe-d9-jeL"/>
6980
<constraint firstItem="4Bf-oQ-a1f" firstAttribute="top" secondItem="WSc-GW-qUL" secondAttribute="top" constant="352" id="gAw-jf-lqS"/>
7081
<constraint firstItem="WSc-GW-qUL" firstAttribute="trailing" secondItem="4Bf-oQ-a1f" secondAttribute="trailing" constant="16" id="hH0-1P-AAY"/>
71-
<constraint firstItem="wD0-YU-lMf" firstAttribute="top" secondItem="GUO-Ha-3tU" secondAttribute="bottom" constant="16" id="kYe-va-7Xa"/>
82+
<constraint firstItem="XdR-4Z-8JC" firstAttribute="leading" secondItem="WSc-GW-qUL" secondAttribute="leading" constant="32" id="i2q-fu-XYp"/>
83+
<constraint firstItem="wD0-YU-lMf" firstAttribute="top" secondItem="XdR-4Z-8JC" secondAttribute="bottom" constant="40" id="kYe-va-7Xa"/>
7284
<constraint firstItem="GUO-Ha-3tU" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="mtS-BI-LLK"/>
7385
<constraint firstItem="9pF-JP-06A" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="nWF-yJ-wy0"/>
7486
<constraint firstItem="n28-dW-Adq" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="rbZ-3k-OiS"/>
@@ -84,11 +96,12 @@
8496
<outlet property="labelError" destination="wD0-YU-lMf" id="256-c0-6Yx"/>
8597
<outlet property="viewName" destination="n28-dW-Adq" id="DuE-dp-uS2"/>
8698
<segue destination="Tfp-4c-tog" kind="show" id="fdP-Ys-gQc"/>
99+
<segue destination="zDO-k1-Up7" kind="presentation" id="SlI-yx-la8"/>
87100
</connections>
88101
</viewController>
89102
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
90103
</objects>
91-
<point key="canvasLocation" x="795.6521739130435" y="105.13392857142857"/>
104+
<point key="canvasLocation" x="796" y="105"/>
92105
</scene>
93106
<!--Question View Controller-->
94107
<scene sceneID="m0h-Dt-EkC">
@@ -282,12 +295,56 @@
282295
</objects>
283296
<point key="canvasLocation" x="-143.19999999999999" y="105.69715142428787"/>
284297
</scene>
298+
<!--Settings View Controller-->
299+
<scene sceneID="RHk-Jt-sTD">
300+
<objects>
301+
<viewController storyboardIdentifier="settingsScreen" id="zDO-k1-Up7" customClass="SettingsViewController" customModule="NameGame" customModuleProvider="target" sceneMemberID="viewController">
302+
<view key="view" contentMode="scaleToFill" id="Lu3-CE-vvh">
303+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
304+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
305+
<subviews>
306+
<pickerView contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fFq-x9-dFj">
307+
<rect key="frame" x="0.0" y="166" width="414" height="216"/>
308+
</pickerView>
309+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2fu-Sa-y1Y">
310+
<rect key="frame" x="192" y="439" width="30" height="30"/>
311+
<state key="normal" title="Ok"/>
312+
<connections>
313+
<action selector="okButtonTap:" destination="zDO-k1-Up7" eventType="touchUpInside" id="cTa-x2-rRN"/>
314+
</connections>
315+
</button>
316+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Number of Questions" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eSc-Sj-18O">
317+
<rect key="frame" x="125" y="390" width="164" height="21"/>
318+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
319+
<nil key="textColor"/>
320+
<nil key="highlightedColor"/>
321+
</label>
322+
</subviews>
323+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
324+
<constraints>
325+
<constraint firstItem="eSc-Sj-18O" firstAttribute="centerX" secondItem="fFq-x9-dFj" secondAttribute="centerX" id="622-6C-L1g"/>
326+
<constraint firstItem="eSc-Sj-18O" firstAttribute="top" secondItem="fFq-x9-dFj" secondAttribute="bottom" constant="8" symbolic="YES" id="PId-I8-ttv"/>
327+
<constraint firstItem="2fu-Sa-y1Y" firstAttribute="centerX" secondItem="Lu3-CE-vvh" secondAttribute="centerX" id="UvU-7w-NjO"/>
328+
<constraint firstItem="eSc-Sj-18O" firstAttribute="top" secondItem="Lu3-CE-vvh" secondAttribute="top" constant="390" id="fvH-Sj-gTg"/>
329+
<constraint firstItem="eSc-Sj-18O" firstAttribute="centerX" secondItem="Lu3-CE-vvh" secondAttribute="centerX" id="uoW-Fq-QrO"/>
330+
<constraint firstItem="2fu-Sa-y1Y" firstAttribute="top" secondItem="eSc-Sj-18O" secondAttribute="bottom" constant="28" id="zQX-ov-Yig"/>
331+
</constraints>
332+
<viewLayoutGuide key="safeArea" id="8bI-my-tH5"/>
333+
</view>
334+
<connections>
335+
<outlet property="numPicker" destination="fFq-x9-dFj" id="iQv-DQ-ROI"/>
336+
</connections>
337+
</viewController>
338+
<placeholder placeholderIdentifier="IBFirstResponder" id="z28-gr-Ghd" userLabel="First Responder" sceneMemberID="firstResponder"/>
339+
</objects>
340+
<point key="canvasLocation" x="796" y="844"/>
341+
</scene>
285342
</scenes>
286343
<resources>
287344
<image name="willowtree_banner.png" width="1400" height="600"/>
288345
</resources>
289346
<inferredMetricsTieBreakers>
290-
<segue reference="aaD-EB-GK7"/>
347+
<segue reference="fdP-Ys-gQc"/>
291348
<segue reference="LZ0-bS-HDb"/>
292349
</inferredMetricsTieBreakers>
293350
</document>

iOS/NameGame/NameGame/Info.plist

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
<string>1</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
23+
<key>NSAllowsArbitraryLoads</key>
24+
<true/>
25+
<key>NSIncludesSubdomains</key>
26+
<true/>
2327
<key>UILaunchStoryboardName</key>
2428
<string>LaunchScreen</string>
2529
<key>UIMainStoryboardFile</key>
@@ -41,7 +45,5 @@
4145
<string>UIInterfaceOrientationLandscapeLeft</string>
4246
<string>UIInterfaceOrientationLandscapeRight</string>
4347
</array>
44-
<key>NSAllowsArbitraryLoads</key> <true/>
45-
<key>NSIncludesSubdomains</key> <true/>
4648
</dict>
4749
</plist>

iOS/NameGame/NameGame/IosNavigator.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class IosNavigator: NSObject, Navigator {
1313
pushViewController(identifier: "gameResultsScreen")
1414
case Screen.start:
1515
UIApplication.topViewController()!.navigationController?.popToRootViewController(animated: true)
16+
case Screen.settings:
17+
presentModal(identifier: "settingsScreen")
1618
default:
1719
Logger().d(message: "Unhandled navigation goto: " + screen.name)
1820
}
@@ -28,4 +30,12 @@ class IosNavigator: NSObject, Navigator {
2830
navi?.pushViewController(newViewController, animated: true)
2931
}
3032
}
33+
34+
private func presentModal(identifier: String) {
35+
if let rootViewController = UIApplication.topViewController() {
36+
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
37+
let modalVC = storyBoard.instantiateViewController(withIdentifier: identifier)
38+
rootViewController.present(modalVC, animated: true, completion: nil)
39+
}
40+
}
3141
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//
2+
// SettingsViewController.swift
3+
// NameGame
4+
//
5+
// Created by Patrick Jackson on 4/8/19.
6+
// Copyright © 2019 Willowtree. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import UIKit
11+
import common
12+
13+
class SettingsViewController: UIViewController,
14+
UIPickerViewDelegate,
15+
UIPickerViewDataSource,
16+
SettingsView {
17+
18+
@IBAction func okButtonTap(_ sender: Any?) {
19+
var selectedValue = pickerData[numPicker.selectedRow(inComponent: 0)]
20+
21+
presenter?.numQuestionsChanged(numQuestions: Int32(selectedValue))
22+
self.dismiss(animated: true)
23+
}
24+
25+
@IBOutlet weak var numPicker: UIPickerView!
26+
27+
var presenter: SettingsPresenter?
28+
29+
let pickerData: [Int] = Array(1...20)
30+
31+
override func viewDidLoad() {
32+
super.viewDidLoad()
33+
numPicker.dataSource = self
34+
numPicker.delegate = self
35+
let appDelegate = UIApplication.shared.delegate as! AppDelegate
36+
presenter = appDelegate.gameEngine?.attachView(view: self) as! SettingsPresenter?
37+
}
38+
39+
override func viewDidDisappear(_ animated: Bool) {
40+
let appDelegate = UIApplication.shared.delegate as! AppDelegate
41+
appDelegate.gameEngine?.detachView(view: self)
42+
}
43+
44+
func showSettings(viewState: SettingsViewState) {
45+
numPicker.selectRow((Int(viewState.numQuestions - 1)) , inComponent:0, animated:true)
46+
}
47+
48+
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
49+
return String(pickerData[row])
50+
}
51+
52+
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
53+
return pickerData.count
54+
}
55+
56+
// Number of columns of data
57+
func numberOfComponents(in pickerView: UIPickerView) -> Int {
58+
return 1
59+
}
60+
61+
}

iOS/NameGame/NameGame/StartViewController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class StartViewController: UIViewController, StartView {
1111
@IBAction func viewTapped(_ sender: Any) {
1212
presenter?.startGame()
1313
}
14+
@IBAction func settingsTapped(_ sender: Any) {
15+
presenter?.settingsTapped()
16+
}
1417

1518
override func viewDidAppear(_ animated: Bool) {
1619
let appDelegate = UIApplication.shared.delegate as! AppDelegate

0 commit comments

Comments
 (0)