Renames old form field class and delegate.

Adds new form field for integers.
This commit is contained in:
2020-09-17 23:41:22 -07:00
parent da6a03144a
commit e21c755e62
12 changed files with 320 additions and 107 deletions

View File

@@ -10,6 +10,7 @@
1D2A61B332F293AB365B59E7 /* Pods_MonsterCards_MonsterCardsUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 89F0D2EC2EC3C99EFD9A6949 /* Pods_MonsterCards_MonsterCardsUITests.framework */; };
92967C3D4DFE1D9C66FF994F /* Pods_MonsterCards.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8D56491D6CAB92316D2C1B /* Pods_MonsterCards.framework */; };
CE281520762D69A9E98D19CF /* Pods_MonsterCardsTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9F017069E22ED575758F9E2 /* Pods_MonsterCardsTests.framework */; };
E20C315425146708003AB1AA /* MCIntegerFieldTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E20C315325146708003AB1AA /* MCIntegerFieldTableViewCell.m */; };
E20D032425031B9D00FB6E43 /* SearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E20D032325031B9D00FB6E43 /* SearchViewController.m */; };
E20D032825031BDA00FB6E43 /* MonsterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E20D032725031BDA00FB6E43 /* MonsterViewController.m */; };
E20D032B25031BE500FB6E43 /* LibraryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E20D032A25031BE500FB6E43 /* LibraryViewController.m */; };
@@ -28,8 +29,9 @@
E25BD60725036CFA007B04EF /* Action.m in Sources */ = {isa = PBXBuildFile; fileRef = E25BD60625036CFA007B04EF /* Action.m */; };
E26A73572511BA1900C5677E /* HTMLHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E26A73562511BA1900C5677E /* HTMLHelper.m */; };
E278E21B250DFFCA00D3EC0E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E278E21A250DFFCA00D3EC0E /* Images.xcassets */; };
E288744A25148BA0005CA948 /* MCFormFieldConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = E288744925148BA0005CA948 /* MCFormFieldConstants.m */; };
E2D3E3B0250827110052A8EC /* EditMonsterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D3E3AF250827110052A8EC /* EditMonsterViewController.m */; };
E2D3E3B42508C3360052A8EC /* EditableShortStringTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D3E3B32508C3360052A8EC /* EditableShortStringTableViewCell.m */; };
E2D3E3B42508C3360052A8EC /* MCShortStringFieldTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D3E3B32508C3360052A8EC /* MCShortStringFieldTableViewCell.m */; };
E2E25805250CC3A7002E7308 /* MonsterCards.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = E2F7248225005E89007D87ED /* MonsterCards.xcdatamodeld */; };
E2ECA8F32504AC3300C1FFA5 /* SkillTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E2ECA8F22504AC3300C1FFA5 /* SkillTests.m */; };
E2ECA8F52504BAAD00C1FFA5 /* MonsterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E2ECA8F42504BAAD00C1FFA5 /* MonsterTests.m */; };
@@ -74,6 +76,8 @@
A7E1FCC69D4538591C4D289B /* Pods-MonsterCards.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MonsterCards.debug.xcconfig"; path = "Target Support Files/Pods-MonsterCards/Pods-MonsterCards.debug.xcconfig"; sourceTree = "<group>"; };
A9F017069E22ED575758F9E2 /* Pods_MonsterCardsTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MonsterCardsTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D079B8CF0ADA838AAA0A13EA /* Pods-MonsterCards.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MonsterCards.release.xcconfig"; path = "Target Support Files/Pods-MonsterCards/Pods-MonsterCards.release.xcconfig"; sourceTree = "<group>"; };
E20C315225146708003AB1AA /* MCIntegerFieldTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCIntegerFieldTableViewCell.h; sourceTree = "<group>"; };
E20C315325146708003AB1AA /* MCIntegerFieldTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MCIntegerFieldTableViewCell.m; sourceTree = "<group>"; };
E20D032225031B9D00FB6E43 /* SearchViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SearchViewController.h; sourceTree = "<group>"; };
E20D032325031B9D00FB6E43 /* SearchViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SearchViewController.m; sourceTree = "<group>"; };
E20D032625031BDA00FB6E43 /* MonsterViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MonsterViewController.h; sourceTree = "<group>"; };
@@ -89,7 +93,7 @@
E22F837E2511E8500072105C /* JSONHelperTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JSONHelperTests.m; sourceTree = "<group>"; };
E2532E8725038DE100CA4CBA /* StringHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StringHelper.h; sourceTree = "<group>"; };
E2532E8825038DE100CA4CBA /* StringHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StringHelper.m; sourceTree = "<group>"; };
E2591EB62509DD4900B396FD /* EditableFormFieldDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EditableFormFieldDelegate.h; sourceTree = "<group>"; };
E2591EB62509DD4900B396FD /* MCFormFieldDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCFormFieldDelegate.h; sourceTree = "<group>"; };
E2592B8C250D6B8100906A40 /* EditMonsterViewControllerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EditMonsterViewControllerTests.m; sourceTree = "<group>"; };
E25BD5F3250352C4007B04EF /* Monster.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Monster.h; sourceTree = "<group>"; };
E25BD5F4250352C4007B04EF /* Monster.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Monster.m; sourceTree = "<group>"; };
@@ -109,10 +113,12 @@
E26A73552511BA1900C5677E /* HTMLHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HTMLHelper.h; sourceTree = "<group>"; };
E26A73562511BA1900C5677E /* HTMLHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HTMLHelper.m; sourceTree = "<group>"; };
E278E21A250DFFCA00D3EC0E /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
E288744925148BA0005CA948 /* MCFormFieldConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MCFormFieldConstants.m; sourceTree = "<group>"; };
E288744E25148BAD005CA948 /* MCFormFieldConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCFormFieldConstants.h; sourceTree = "<group>"; };
E2D3E3AE250827110052A8EC /* EditMonsterViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EditMonsterViewController.h; sourceTree = "<group>"; };
E2D3E3AF250827110052A8EC /* EditMonsterViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EditMonsterViewController.m; sourceTree = "<group>"; };
E2D3E3B22508C3360052A8EC /* EditableShortStringTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EditableShortStringTableViewCell.h; sourceTree = "<group>"; };
E2D3E3B32508C3360052A8EC /* EditableShortStringTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EditableShortStringTableViewCell.m; sourceTree = "<group>"; };
E2D3E3B22508C3360052A8EC /* MCShortStringFieldTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCShortStringFieldTableViewCell.h; sourceTree = "<group>"; };
E2D3E3B32508C3360052A8EC /* MCShortStringFieldTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MCShortStringFieldTableViewCell.m; sourceTree = "<group>"; };
E2ECA8F22504AC3300C1FFA5 /* SkillTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SkillTests.m; sourceTree = "<group>"; };
E2ECA8F42504BAAD00C1FFA5 /* MonsterTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MonsterTests.m; sourceTree = "<group>"; };
E2F7247025005E89007D87ED /* Monster Cards.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Monster Cards.app"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -264,9 +270,13 @@
E2D3E3B12508C2FE0052A8EC /* FormFields */ = {
isa = PBXGroup;
children = (
E2D3E3B22508C3360052A8EC /* EditableShortStringTableViewCell.h */,
E2D3E3B32508C3360052A8EC /* EditableShortStringTableViewCell.m */,
E2591EB62509DD4900B396FD /* EditableFormFieldDelegate.h */,
E2591EB62509DD4900B396FD /* MCFormFieldDelegate.h */,
E288744E25148BAD005CA948 /* MCFormFieldConstants.h */,
E288744925148BA0005CA948 /* MCFormFieldConstants.m */,
E20C315225146708003AB1AA /* MCIntegerFieldTableViewCell.h */,
E20C315325146708003AB1AA /* MCIntegerFieldTableViewCell.m */,
E2D3E3B22508C3360052A8EC /* MCShortStringFieldTableViewCell.h */,
E2D3E3B32508C3360052A8EC /* MCShortStringFieldTableViewCell.m */,
);
path = FormFields;
sourceTree = "<group>";
@@ -592,11 +602,13 @@
E20D032825031BDA00FB6E43 /* MonsterViewController.m in Sources */,
E25BD60725036CFA007B04EF /* Action.m in Sources */,
E2D3E3B0250827110052A8EC /* EditMonsterViewController.m in Sources */,
E288744A25148BA0005CA948 /* MCFormFieldConstants.m in Sources */,
E2F7247525005E89007D87ED /* AppDelegate.m in Sources */,
E2D3E3B42508C3360052A8EC /* EditableShortStringTableViewCell.m in Sources */,
E2D3E3B42508C3360052A8EC /* MCShortStringFieldTableViewCell.m in Sources */,
E20D032B25031BE500FB6E43 /* LibraryViewController.m in Sources */,
E20D033125031BFD00FB6E43 /* DashboardViewController.m in Sources */,
E25BD5FE25036A76007B04EF /* DamageType.m in Sources */,
E20C315425146708003AB1AA /* MCIntegerFieldTableViewCell.m in Sources */,
E2F7248425005E89007D87ED /* MonsterCards.xcdatamodeld in Sources */,
E25BD60425036CF0007B04EF /* Ability.m in Sources */,
E20D032E25031BEF00FB6E43 /* CollectionsViewController.m in Sources */,

View File

@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097.3" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="49e-Tb-3d3">
<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="49e-Tb-3d3">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<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>
@@ -34,8 +36,8 @@
<view key="view" contentMode="scaleToFill" id="JUJ-wP-ffb">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="QQV-YX-2Yb"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<tabBarItem key="tabBarItem" title="Dashboard" image="rectangle.3.offgrid.fill" catalog="system" id="wgb-7v-3jq"/>
</viewController>
@@ -50,8 +52,8 @@
<view key="view" contentMode="scaleToFill" id="j0E-Ka-SnM">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="Rkq-9l-CBb"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<tabBarItem key="tabBarItem" title="Collections" image="tray.full.fill" catalog="system" id="7og-Zf-zGt"/>
</viewController>
@@ -66,7 +68,7 @@
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="oCq-Hl-UA9">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<searchBar key="tableHeaderView" contentMode="redraw" text="" id="fQb-XL-QZB">
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
@@ -149,7 +151,7 @@
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="NgM-um-5Ur">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="MonsterCell" id="Boi-md-853">
<rect key="frame" x="0.0" y="28" width="414" height="43.5"/>
@@ -194,7 +196,7 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pZa-ia-7UT">
<rect key="frame" x="8" y="96" width="398" height="14.5"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" systemColor="secondaryLabelColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="section-divider" translatesAutoresizingMaskIntoConstraints="NO" id="WYM-ya-Yje">
@@ -210,7 +212,8 @@
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="WIX-Yu-LXJ"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="WIX-Yu-LXJ" firstAttribute="trailing" secondItem="pZa-ia-7UT" secondAttribute="trailing" constant="8" id="8F1-nO-xrO"/>
<constraint firstItem="pZa-ia-7UT" firstAttribute="leading" secondItem="WIX-Yu-LXJ" secondAttribute="leading" constant="8" id="9Yo-N3-VeP"/>
@@ -222,7 +225,6 @@
<constraint firstItem="WYM-ya-Yje" firstAttribute="top" secondItem="pZa-ia-7UT" secondAttribute="bottom" constant="8" id="mO1-0h-hFW"/>
<constraint firstItem="WYM-ya-Yje" firstAttribute="leading" secondItem="WIX-Yu-LXJ" secondAttribute="leading" constant="8" id="wB4-zH-APV"/>
</constraints>
<viewLayoutGuide key="safeArea" id="WIX-Yu-LXJ"/>
</view>
<navigationItem key="navigationItem" id="U0U-wB-eVJ">
<barButtonItem key="rightBarButtonItem" title="Edit" id="JQh-6t-vKa">
@@ -250,43 +252,91 @@
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="Ph7-w5-jbm">
<rect key="frame" x="0.0" y="88" width="414" height="725"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="EditableShortString" id="s66-ds-RzY" customClass="EditableShortStringTableViewCell">
<rect key="frame" x="0.0" y="28" width="414" height="39.5"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="MCIntegerField" id="KwC-8P-1dy" userLabel="MCIntegerField" customClass="MCIntegerFieldTableViewCell">
<rect key="frame" x="0.0" y="28" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="s66-ds-RzY" id="hip-Sr-WMn">
<rect key="frame" x="0.0" y="0.0" width="414" height="39.5"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="KwC-8P-1dy" id="Dwe-Tg-VQ6">
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="vSp-Bb-6Ii">
<rect key="frame" x="20" y="10" width="374" height="19.5"/>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="RCc-cF-BI3" userLabel="Text Field">
<rect key="frame" x="20" y="5" width="254" height="34"/>
<constraints>
<constraint firstAttribute="height" constant="34" id="8Nj-FL-Ab6"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<action selector="textFieldValueChanged:" destination="KwC-8P-1dy" eventType="valueChanged" id="5In-Xx-LJB"/>
</connections>
</textField>
<stepper opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="100" translatesAutoresizingMaskIntoConstraints="NO" id="vgc-Rg-Zc8">
<rect key="frame" x="294" y="6" width="100" height="32"/>
<constraints>
<constraint firstAttribute="height" constant="32" id="HhX-Qt-vVP"/>
<constraint firstAttribute="width" constant="100" id="Qn1-ca-Tsy"/>
</constraints>
<connections>
<action selector="stepperValueChanged:" destination="KwC-8P-1dy" eventType="valueChanged" id="BKh-dh-f3d"/>
</connections>
</stepper>
</subviews>
<constraints>
<constraint firstItem="vSp-Bb-6Ii" firstAttribute="top" secondItem="hip-Sr-WMn" secondAttribute="top" constant="10" id="0dV-mK-UWQ"/>
<constraint firstAttribute="bottom" secondItem="vSp-Bb-6Ii" secondAttribute="bottom" constant="10" id="FUw-mZ-a2e"/>
<constraint firstItem="vSp-Bb-6Ii" firstAttribute="leading" secondItem="hip-Sr-WMn" secondAttribute="leadingMargin" id="aQK-cB-xb2"/>
<constraint firstAttribute="trailingMargin" secondItem="vSp-Bb-6Ii" secondAttribute="trailing" id="b5f-5M-OTX"/>
<constraint firstItem="vgc-Rg-Zc8" firstAttribute="centerY" secondItem="Dwe-Tg-VQ6" secondAttribute="centerY" id="6as-ZA-8B4"/>
<constraint firstAttribute="trailing" secondItem="vgc-Rg-Zc8" secondAttribute="trailing" constant="20" id="GHC-1H-v20"/>
<constraint firstItem="vgc-Rg-Zc8" firstAttribute="leading" secondItem="RCc-cF-BI3" secondAttribute="trailing" constant="20" id="T1Y-Pj-gsO"/>
<constraint firstItem="RCc-cF-BI3" firstAttribute="centerY" secondItem="Dwe-Tg-VQ6" secondAttribute="centerY" id="ett-1I-J0L"/>
<constraint firstItem="RCc-cF-BI3" firstAttribute="leading" secondItem="Dwe-Tg-VQ6" secondAttribute="leading" constant="20" id="mBk-4r-ebJ"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="textField" destination="vSp-Bb-6Ii" id="yff-c9-CXK"/>
<outlet property="stepper" destination="vgc-Rg-Zc8" id="QT0-L8-npw"/>
<outlet property="textField" destination="RCc-cF-BI3" id="JpG-sb-BPS"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="MCShortStringField" id="s66-ds-RzY" userLabel="MCShortStringField" customClass="MCShortStringFieldTableViewCell">
<rect key="frame" x="0.0" y="71.5" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="s66-ds-RzY" id="hip-Sr-WMn">
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="vSp-Bb-6Ii">
<rect key="frame" x="20" y="5" width="374" height="34"/>
<constraints>
<constraint firstAttribute="height" constant="34" id="bOl-6v-0Mc"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="34" id="wG5-Lz-PNz"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<action selector="textFieldValueChanged:" destination="s66-ds-RzY" eventType="valueChanged" id="aXL-JN-6WT"/>
</connections>
</textField>
</subviews>
<constraints>
<constraint firstItem="vSp-Bb-6Ii" firstAttribute="centerY" secondItem="hip-Sr-WMn" secondAttribute="centerY" id="8vy-Pl-D15"/>
<constraint firstItem="vSp-Bb-6Ii" firstAttribute="leading" secondItem="hip-Sr-WMn" secondAttribute="leading" constant="20" id="QZR-Jm-4WV"/>
<constraint firstAttribute="trailing" secondItem="vSp-Bb-6Ii" secondAttribute="trailing" constant="20" id="x9A-uQ-TpO"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="textField" destination="vSp-Bb-6Ii" id="LsH-bK-Vns"/>
</connections>
</tableViewCell>
</prototypes>
</tableView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="PhC-ja-AcN"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="Ph7-w5-jbm" firstAttribute="leading" secondItem="PhC-ja-AcN" secondAttribute="leading" id="Z21-h9-5uc"/>
<constraint firstItem="PhC-ja-AcN" firstAttribute="bottom" secondItem="Ph7-w5-jbm" secondAttribute="bottom" id="sSZ-aH-KLX"/>
<constraint firstItem="Ph7-w5-jbm" firstAttribute="top" secondItem="PhC-ja-AcN" secondAttribute="top" id="utK-QF-3ZS"/>
<constraint firstItem="PhC-ja-AcN" firstAttribute="trailing" secondItem="Ph7-w5-jbm" secondAttribute="trailing" id="y6Z-Sy-84h"/>
</constraints>
<viewLayoutGuide key="safeArea" id="PhC-ja-AcN"/>
</view>
<navigationItem key="navigationItem" title="Edit Monster" id="6DN-Xf-XAZ">
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="4Ld-nj-3La">
@@ -314,11 +364,17 @@
<segue reference="W6E-7q-Wzb"/>
</inferredMetricsTieBreakers>
<resources>
<image name="book.fill" catalog="system" width="128" height="100"/>
<image name="book.fill" catalog="system" width="128" height="102"/>
<image name="magnifyingglass" catalog="system" width="128" height="115"/>
<image name="plus" catalog="system" width="128" height="113"/>
<image name="rectangle.3.offgrid.fill" catalog="system" width="128" height="81"/>
<image name="section-divider" width="800" height="20"/>
<image name="tray.full.fill" catalog="system" width="128" height="88"/>
<systemColor name="secondaryLabelColor">
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>

View File

@@ -8,11 +8,11 @@
#import <UIKit/UIKit.h>
#import "Monster.h"
#import "EditableShortStringTableViewCell.h"
#import "MCShortStringFieldTableViewCell.h"
NS_ASSUME_NONNULL_BEGIN
@interface EditMonsterViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, EditableShortStringDelegate>
@interface EditMonsterViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, MCFormFieldDelegate>
@property Monster* originalMonster;
@property (weak, nonatomic) IBOutlet UITableView *monsterTableView;

View File

@@ -7,7 +7,8 @@
//
#import "EditMonsterViewController.h"
#import "EditableShortStringTableViewCell.h"
#import "MCShortStringFieldTableViewCell.h"
#import "MCIntegerFieldTableViewCell.h"
#import "AppDelegate.h"
@interface EditMonsterViewController ()
@@ -16,6 +17,9 @@
@end
const int kSectionIndexBasicInfo = 0;
const int kSectionIndexAbilityScores = 1;
@implementation EditMonsterViewController {
NSManagedObjectContext *_context;
}
@@ -34,6 +38,24 @@
self.editingMonster = [[Monster alloc] initWithMonster:self.originalMonster];
}
- (MCShortStringFieldTableViewCell*) makeShortStringCellFromCell:(UITableViewCell*)cell {
if (cell == nil || ![cell isKindOfClass:[MCShortStringFieldTableViewCell class]]) {
// TODO: Figure out how to make this cell generate child views.
return [[MCShortStringFieldTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MCShortStringField"];
} else {
return (MCShortStringFieldTableViewCell*)cell;
}
}
- (MCIntegerFieldTableViewCell*) makeIntegerCellFromCell:(UITableViewCell*)cell {
if (cell == nil || ![cell isKindOfClass:[MCIntegerFieldTableViewCell class]]) {
// TODO: Figure out how to make this cell generate child views.
return [[MCIntegerFieldTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MCIntegerField"];
} else {
return (MCIntegerFieldTableViewCell*)cell;
}
}
#pragma mark - Navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
@@ -52,65 +74,80 @@
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section {
// Section 0 is basic info
// * Name
// * Size
// * Type
// * Subtype
// * Alignment
return 5;
switch(section) {
case kSectionIndexBasicInfo:
// Section 0 is basic info
// * Name
// * Size
// * Type
// * Subtype
// * Alignment
return 5;
case kSectionIndexAbilityScores:
return 0;
default:
return 0;
}
}
- (EditableShortStringTableViewCell*) makeShortStringCellFromCell:(UITableViewCell*)cell {
if (cell == nil || ![cell isKindOfClass:[EditableShortStringTableViewCell class]]) {
// TODO: Figure out why this doesn't create a cell with a text field.
return [[EditableShortStringTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"EditableShortString"];
} else {
return (EditableShortStringTableViewCell*)cell;
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section {
switch(section) {
case kSectionIndexBasicInfo:
return NSLocalizedString(@"Basic Info", @"Section title");
case kSectionIndexAbilityScores:
return NSLocalizedString(@"Ability Scores", @"Section title");
default:
return nil;
}
}
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
EditableShortStringTableViewCell *shortStringCell = nil;
MCShortStringFieldTableViewCell *shortStringCell = nil;
MCIntegerFieldTableViewCell *integerCell = nil;
switch (indexPath.section) {
case 0:
case kSectionIndexBasicInfo:
switch (indexPath.row) {
case 0:
shortStringCell = [self makeShortStringCellFromCell:[self.monsterTableView dequeueReusableCellWithIdentifier:@"EditableShortString"]];
shortStringCell = [self makeShortStringCellFromCell:[self.monsterTableView dequeueReusableCellWithIdentifier:@"MCShortStringField"]];
shortStringCell.delegate = self;
shortStringCell.identifier = @"monster.name";
// TODO: make these use setters on EditableShortStringTableViewCell
// TODO: make these use setters on MCShortStringFieldTableViewCell
shortStringCell.textField.text = self.editingMonster.name;
shortStringCell.textField.placeholder = NSLocalizedString(@"Name", @"Placeholder text for the name of a monster or NPC.");
return shortStringCell;
case 1:
shortStringCell = [self makeShortStringCellFromCell:[self.monsterTableView dequeueReusableCellWithIdentifier:@"EditableShortString"]];
shortStringCell = [self makeShortStringCellFromCell:[self.monsterTableView dequeueReusableCellWithIdentifier:@"MCShortStringField"]];
shortStringCell.delegate = self;
shortStringCell.identifier = @"monster.size";
// TODO: make these use setters on EditableShortStringTableViewCell
// TODO: make these use setters on MCShortStringFieldTableViewCell
shortStringCell.textField.text = self.editingMonster.size;
shortStringCell.textField.placeholder = NSLocalizedString(@"Size", @"Placehodler text for the size of a monster or NPC.");
return shortStringCell;
case 2:
shortStringCell = [self makeShortStringCellFromCell:[self.monsterTableView dequeueReusableCellWithIdentifier:@"EditableShortString"]];
shortStringCell = [self makeShortStringCellFromCell:[self.monsterTableView dequeueReusableCellWithIdentifier:@"MCShortStringField"]];
shortStringCell.delegate = self;
shortStringCell.identifier = @"monster.type";
// TODO: make these use setters on EditableShortStringTableViewCell
// TODO: make these use setters on MCShortStringFieldTableViewCell
shortStringCell.textField.text = self.editingMonster.type;
shortStringCell.textField.placeholder = NSLocalizedString(@"Type", @"Placehodler text for the type of a monster or NPC.");
return shortStringCell;
case 3:
shortStringCell = [self makeShortStringCellFromCell:[self.monsterTableView dequeueReusableCellWithIdentifier:@"EditableShortString"]];
shortStringCell = [self makeShortStringCellFromCell:[self.monsterTableView dequeueReusableCellWithIdentifier:@"MCShortStringField"]];
shortStringCell.delegate = self;
shortStringCell.identifier = @"monster.subtype";
shortStringCell.textField.text = self.editingMonster.subtype;
shortStringCell.textField.placeholder = NSLocalizedString(@"Subtype", @"Placeholder text for the subtype of a monster or NPC.");
return shortStringCell;
case 4:
shortStringCell = [self makeShortStringCellFromCell: [self.monsterTableView dequeueReusableCellWithIdentifier:@"EditableShortString"]];
shortStringCell = [self makeShortStringCellFromCell: [self.monsterTableView dequeueReusableCellWithIdentifier:@"MCShortStringField"]];
shortStringCell.delegate = self;
shortStringCell.identifier = @"monster.alignment";
shortStringCell.textField.text = self.editingMonster.alignment;
@@ -120,13 +157,18 @@
break;
}
#if DEBUG
NSLog(@"ERROR: Unable to build a cell for %@", indexPath);
return nil;
#else
return [[UITableViewCell alloc] init];
#endif
}
#pragma mark - EditableShortStringDelegate
#pragma mark - MCShortStringFieldDelegate
- (void)editableValueDidChange:(NSObject*)value forIdentifier:(NSString*)identifier andType:(NSString*)type {
if ([@"String" isEqualToString:type]) {
if ([kMCFieldValueTypeString isEqualToString:type]) {
if ([@"monster.name" isEqualToString:identifier]) {
self.editingMonster.name = (NSString*)value;
} else if ([@"monster.size" isEqualToString:identifier]) {
@@ -139,6 +181,11 @@
self.editingMonster.alignment = (NSString*)value;
}
}
if ([kMCFieldValueTypeInteger isEqualToString:type]) {
if ([@"monster.strengthScore" isEqualToString:identifier]) {
self.editingMonster.strengthScore = [(NSNumber*)value intValue];
}
}
}
@end

View File

@@ -1,32 +0,0 @@
//
// EditableShortStringTableViewCell.m
// MonsterCards
//
// Created by Tom Hicks on 9/9/20.
// Copyright © 2020 Tom Hicks. All rights reserved.
//
#import "EditableShortStringTableViewCell.h"
@implementation EditableShortStringTableViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
self.textField.delegate = self;
}
#pragma mark - UITextFieldDelegate
- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string {
// TODO: See this link for a potentially better way to get this text https://stackoverflow.com/questions/19110617/uitextfieldtextdidchangenotification-ios7-not-fired
NSString *finalString = [textField.text stringByReplacingCharactersInRange:range withString:string];
if (self.delegate != nil) {
[self.delegate editableValueDidChange:finalString forIdentifier:self.identifier andType:@"String"];
}
return YES;
}
@end

View File

@@ -0,0 +1,15 @@
//
// MCFormFieldConstants.h
// MonsterCards
//
// Created by Tom Hicks on 9/17/20.
// Copyright © 2020 Tom Hicks. All rights reserved.
//
#ifndef MCFormFieldConstants_h
#define MCFormFieldConstants_h
extern NSString* const kMCFieldValueTypeInteger;
extern NSString* const kMCFieldValueTypeString;
#endif /* MCFormFieldConstants_h */

View File

@@ -0,0 +1,13 @@
//
// MCFormFieldConstants.m
// MonsterCards
//
// Created by Tom Hicks on 9/17/20.
// Copyright © 2020 Tom Hicks. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "MCFormFieldConstants.h"
NSString* const kMCFieldValueTypeInteger = @"Integer";
NSString* const kMCFieldValueTypeString = @"String";

View File

@@ -1,15 +1,17 @@
//
// EditableFormFieldDelegate.h
// MCFormFieldDelegate.h
// MonsterCards
//
// Created by Tom Hicks on 9/9/20.
// Copyright © 2020 Tom Hicks. All rights reserved.
//
#ifndef EditableFormFieldDelegate_h
#define EditableFormFieldDelegate_h
#ifndef MCFormFieldDelegate_h
#define MCFormFieldDelegate_h
@protocol EditableFormFieldDelegate <NSObject>
#import "MCFormFieldConstants.h"
@protocol MCFormFieldDelegate <NSObject>
@optional
-(void)editableValueDidChange:(NSObject*)value forIdentifier:(NSString*)identifier andType:(NSString*)type;
@@ -17,4 +19,4 @@
@end
#endif /* EditableFormFieldDelegate_h */
#endif /* MCFormFieldDelegate_h */

View File

@@ -0,0 +1,27 @@
//
// MCIntegerFieldTableViewCell.h
// MonsterCards
//
// Created by Tom Hicks on 9/17/20.
// Copyright © 2020 Tom Hicks. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MCFormFieldDelegate.h"
NS_ASSUME_NONNULL_BEGIN
@interface MCIntegerFieldTableViewCell : UITableViewCell <UITextFieldDelegate>
@property NSString* identifier;
@property NSString* label;
@property int value;
@property (weak, nonatomic) id<MCFormFieldDelegate> delegate;
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UIStepper *stepper;
- (IBAction)stepperValueChanged:(id)sender;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,51 @@
//
// MCIntegerFieldTableViewCell.m
// MonsterCards
//
// Created by Tom Hicks on 9/17/20.
// Copyright © 2020 Tom Hicks. All rights reserved.
//
#import "MCIntegerFieldTableViewCell.h"
@implementation MCIntegerFieldTableViewCell
@synthesize value = _value;
-(void) setValue:(int)number {
if (_value != number) {
NSNumber *newValue = [NSNumber numberWithInt:number];
_value = number;
if (self.textField) {
self.textField.text = [newValue stringValue];
}
if (self.stepper) {
self.stepper.value = number;
}
if (self.delegate) {
[self.delegate editableValueDidChange:newValue
forIdentifier:self.identifier
andType:kMCFieldValueTypeInteger];
}
}
}
- (int) value {
return _value;
}
- (void)awakeFromNib {
[super awakeFromNib];
[self.textField addTarget:self
action:@selector(textFieldValueChanged:)
forControlEvents:UIControlEventEditingChanged];
}
- (void)textFieldValueChanged:(UITextField*)textField {
self.value = [textField.text intValue];
}
- (IBAction)stepperValueChanged:(id)sender {
self.value = self.stepper.value;
}
@end

View File

@@ -7,22 +7,17 @@
//
#import <UIKit/UIKit.h>
#import "MCFormFieldDelegate.h"
NS_ASSUME_NONNULL_BEGIN
@protocol EditableShortStringDelegate <NSObject>
@optional
-(void)editableValueDidChange:(NSString*)value forIdentifier:(NSString*)identifier andType:(NSString*)type;
@end
@interface EditableShortStringTableViewCell : UITableViewCell <UITextFieldDelegate>
@interface MCShortStringFieldTableViewCell : UITableViewCell
@property NSString* identifier;
@property NSString* label;
@property NSString* value;
@property (nonatomic, weak) id<EditableShortStringDelegate> delegate;
@property (weak, nonatomic) id<MCFormFieldDelegate> delegate;
@property (weak, nonatomic) IBOutlet UITextField *textField;
@end

View File

@@ -0,0 +1,27 @@
//
// EditableShortStringTableViewCell.m
// MonsterCards
//
// Created by Tom Hicks on 9/9/20.
// Copyright © 2020 Tom Hicks. All rights reserved.
//
#import "MCShortStringFieldTableViewCell.h"
@implementation MCShortStringFieldTableViewCell
- (void)awakeFromNib {
[super awakeFromNib];
[self.textField addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventEditingChanged];
}
- (void)valueChanged:(UITextField*)textField {
NSString *newValue = textField.text;
if (self.delegate != nil) {
[self.delegate editableValueDidChange:newValue
forIdentifier:self.identifier
andType:kMCFieldValueTypeString];
}
}
@end