Adds boolean field to MCFormFields.
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
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 */; };
|
||||
E2805514251E03BE00C87527 /* MCBooleanFieldTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E2805513251E03BE00C87527 /* MCBooleanFieldTableViewCell.m */; };
|
||||
E288744A25148BA0005CA948 /* MCFormFieldConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = E288744925148BA0005CA948 /* MCFormFieldConstants.m */; };
|
||||
E2D3E3B0250827110052A8EC /* EditMonsterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D3E3AF250827110052A8EC /* EditMonsterViewController.m */; };
|
||||
E2D3E3B42508C3360052A8EC /* MCShortStringFieldTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D3E3B32508C3360052A8EC /* MCShortStringFieldTableViewCell.m */; };
|
||||
@@ -113,6 +114,8 @@
|
||||
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>"; };
|
||||
E2805512251E03BE00C87527 /* MCBooleanFieldTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCBooleanFieldTableViewCell.h; sourceTree = "<group>"; };
|
||||
E2805513251E03BE00C87527 /* MCBooleanFieldTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MCBooleanFieldTableViewCell.m; 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>"; };
|
||||
@@ -277,6 +280,8 @@
|
||||
E20C315325146708003AB1AA /* MCIntegerFieldTableViewCell.m */,
|
||||
E2D3E3B22508C3360052A8EC /* MCShortStringFieldTableViewCell.h */,
|
||||
E2D3E3B32508C3360052A8EC /* MCShortStringFieldTableViewCell.m */,
|
||||
E2805512251E03BE00C87527 /* MCBooleanFieldTableViewCell.h */,
|
||||
E2805513251E03BE00C87527 /* MCBooleanFieldTableViewCell.m */,
|
||||
);
|
||||
path = FormFields;
|
||||
sourceTree = "<group>";
|
||||
@@ -613,6 +618,7 @@
|
||||
E25BD60425036CF0007B04EF /* Ability.m in Sources */,
|
||||
E20D032E25031BEF00FB6E43 /* CollectionsViewController.m in Sources */,
|
||||
E26A73572511BA1900C5677E /* HTMLHelper.m in Sources */,
|
||||
E2805514251E03BE00C87527 /* MCBooleanFieldTableViewCell.m in Sources */,
|
||||
E25BD5F5250352C4007B04EF /* Monster.m in Sources */,
|
||||
E25BD5F8250368A8007B04EF /* SavingThrow.m in Sources */,
|
||||
E2F7248C25005E8A007D87ED /* main.m in Sources */,
|
||||
|
||||
@@ -348,6 +348,42 @@
|
||||
<outlet property="textField" destination="vSp-Bb-6Ii" id="LsH-bK-Vns"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="MCBooleanField" id="aNO-fN-IMT" userLabel="MCBooleanField" customClass="MCBooleanFieldTableViewCell">
|
||||
<rect key="frame" x="0.0" y="115" width="414" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="aNO-fN-IMT" id="S88-r0-N1u">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tsg-zB-HOv">
|
||||
<rect key="frame" x="20" y="11.5" width="305" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="L1a-6J-Yco">
|
||||
<rect key="frame" x="345" y="6.5" width="51" height="31"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="49" id="b2p-dO-cAL"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<action selector="valueChanged:" destination="aNO-fN-IMT" eventType="valueChanged" id="uHk-k4-oPq"/>
|
||||
</connections>
|
||||
</switch>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="L1a-6J-Yco" firstAttribute="leading" secondItem="tsg-zB-HOv" secondAttribute="trailing" constant="20" id="3ic-3b-OlQ"/>
|
||||
<constraint firstItem="tsg-zB-HOv" firstAttribute="leading" secondItem="S88-r0-N1u" secondAttribute="leadingMargin" id="Meq-RD-TyE"/>
|
||||
<constraint firstItem="L1a-6J-Yco" firstAttribute="centerY" secondItem="S88-r0-N1u" secondAttribute="centerY" id="Oei-MK-jz1"/>
|
||||
<constraint firstAttribute="trailing" secondItem="L1a-6J-Yco" secondAttribute="trailing" constant="20" id="Ubb-zC-MdW"/>
|
||||
<constraint firstItem="tsg-zB-HOv" firstAttribute="centerY" secondItem="S88-r0-N1u" secondAttribute="centerY" id="WUA-gu-TZ7"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<outlet property="labelView" destination="tsg-zB-HOv" id="ky7-dd-2zz"/>
|
||||
<outlet property="switchView" destination="L1a-6J-Yco" id="tTF-vZ-9gZ"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
</tableView>
|
||||
</subviews>
|
||||
|
||||
26
MonsterCards/Views/FormFields/MCBooleanFieldTableViewCell.h
Normal file
26
MonsterCards/Views/FormFields/MCBooleanFieldTableViewCell.h
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// MCBooleanFieldTableViewCell.h
|
||||
// MonsterCards
|
||||
//
|
||||
// Created by Tom Hicks on 9/25/20.
|
||||
// Copyright © 2020 Tom Hicks. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "MCFormFieldDelegate.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MCBooleanFieldTableViewCell : UITableViewCell
|
||||
|
||||
@property NSString* identifier;
|
||||
@property NSString* label;
|
||||
@property BOOL value;
|
||||
|
||||
@property (weak, nonatomic) id<MCFormFieldDelegate> delegate;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *labelView;
|
||||
@property (weak, nonatomic) IBOutlet UISwitch *switchView;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
58
MonsterCards/Views/FormFields/MCBooleanFieldTableViewCell.m
Normal file
58
MonsterCards/Views/FormFields/MCBooleanFieldTableViewCell.m
Normal file
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// MCBooleanFieldTableViewCell.m
|
||||
// MonsterCards
|
||||
//
|
||||
// Created by Tom Hicks on 9/25/20.
|
||||
// Copyright © 2020 Tom Hicks. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MCBooleanFieldTableViewCell.h"
|
||||
|
||||
@implementation MCBooleanFieldTableViewCell
|
||||
|
||||
@synthesize value = _value;
|
||||
|
||||
- (void)setValue:(BOOL)value {
|
||||
if (value != _value) {
|
||||
_value = value;
|
||||
if (self.switchView) {
|
||||
self.switchView.on = _value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)value {
|
||||
return _value;
|
||||
}
|
||||
|
||||
@synthesize label = _label;
|
||||
|
||||
- (void)setLabel:(NSString*)label {
|
||||
if (![_label isEqualToString:label]) {
|
||||
_label = label;
|
||||
if (self.labelView) {
|
||||
self.labelView.text = label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString*)label {
|
||||
return _label;
|
||||
}
|
||||
|
||||
- (void)awakeFromNib {
|
||||
[super awakeFromNib];
|
||||
self.switchView.on = self.value;
|
||||
self.labelView.text = self.label;
|
||||
}
|
||||
|
||||
- (IBAction)valueChanged:(id)sender {
|
||||
self.value = self.switchView.on;
|
||||
if (self.delegate != nil) {
|
||||
[self.delegate editableValueDidChange:[NSNumber numberWithBool:self.value]
|
||||
forIdentifier:self.identifier
|
||||
andType:kMCFieldValueTypeBoolean];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -11,5 +11,6 @@
|
||||
|
||||
extern NSString* const kMCFieldValueTypeInteger;
|
||||
extern NSString* const kMCFieldValueTypeString;
|
||||
extern NSString* const kMCFieldValueTypeBoolean;
|
||||
|
||||
#endif /* MCFormFieldConstants_h */
|
||||
|
||||
@@ -11,3 +11,4 @@
|
||||
|
||||
NSString* const kMCFieldValueTypeInteger = @"Integer";
|
||||
NSString* const kMCFieldValueTypeString = @"String";
|
||||
NSString* const kMCFieldValueTypeBoolean = @"Boolean";
|
||||
|
||||
@@ -66,4 +66,5 @@
|
||||
- (IBAction)stepperValueChanged:(id)sender {
|
||||
self.value = self.stepper.value;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user