mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 05:52:58 +00:00
minor code cleanup on value transformers
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12120"/>
|
||||
<capability name="box content view" minToolsVersion="7.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPPluginSettingsController">
|
||||
@@ -19,14 +19,12 @@
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="520" height="434"/>
|
||||
<subviews>
|
||||
<box title="Box" borderType="line" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="vBs-Ga-aq0">
|
||||
<box borderType="line" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="vBs-Ga-aq0">
|
||||
<rect key="frame" x="175" y="16" width="328" height="342"/>
|
||||
<view key="contentView" id="tD5-Na-7XI">
|
||||
<rect key="frame" x="1" y="1" width="326" height="340"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
</view>
|
||||
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
|
||||
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</box>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="CqP-oK-S8k">
|
||||
<rect key="frame" x="18" y="398" width="159" height="18"/>
|
||||
@@ -35,7 +33,7 @@
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="aoG-FD-ds8">
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aoG-FD-ds8">
|
||||
<rect key="frame" x="18" y="364" width="484" height="28"/>
|
||||
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="2bX-8S-9XM">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
@@ -51,7 +49,7 @@
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="Ocu-C0-03d">
|
||||
<rect key="frame" x="0.0" y="0.0" width="148" height="0.0"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="148" height="334"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<size key="intercellSpacing" width="3" height="2"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -74,8 +72,9 @@
|
||||
<rect key="frame" x="1" y="1" width="145" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="q1P-PD-0LW">
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="q1P-PD-0LW">
|
||||
<rect key="frame" x="0.0" y="0.0" width="100" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="fug-79-n9g">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -92,7 +91,6 @@
|
||||
</tableColumns>
|
||||
</tableView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</clipView>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="150" id="ZpW-Bc-fSx"/>
|
||||
@@ -122,7 +120,7 @@
|
||||
<constraint firstItem="vBs-Ga-aq0" firstAttribute="leading" secondItem="fCk-fL-jU8" secondAttribute="trailing" constant="8" id="xNu-Sj-xQO"/>
|
||||
<constraint firstItem="aoG-FD-ds8" firstAttribute="top" secondItem="CqP-oK-S8k" secondAttribute="bottom" constant="8" symbolic="YES" id="zSW-h3-BrT"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="-288" y="133"/>
|
||||
<point key="canvasLocation" x="-174" y="134"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
||||
|
||||
@@ -386,7 +386,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
[self.expiresCheckButton bind:NSTitleBinding
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(expirationDate))]
|
||||
options:@{ NSValueTransformerNameBindingOption:MPExpiryDateValueTransformer }];
|
||||
options:@{ NSValueTransformerNameBindingOption:MPExpiryDateValueTransformerName }];
|
||||
[self.expiresCheckButton bind:NSValueBinding
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(expires))]
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
[self.expiresCheckButton bind:NSTitleBinding
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(expirationDate))]
|
||||
options:@{ NSValueTransformerNameBindingOption:MPExpiryDateValueTransformer }];
|
||||
options:@{ NSValueTransformerNameBindingOption:MPExpiryDateValueTransformerName }];
|
||||
[self.autotypePopupButton bind:NSSelectedTagBinding
|
||||
toObject:self
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(isAutoTypeEnabled))]
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
FOUNDATION_EXPORT NSString *const MPStripLineBreaksTransformerName;
|
||||
FOUNDATION_EXPORT NSString *const MPExpiryDateValueTransformer;
|
||||
FOUNDATION_EXPORT NSString *const MPExpiryDateValueTransformerName;
|
||||
|
||||
@interface MPValueTransformerHelper : NSObject
|
||||
|
||||
|
||||
@@ -10,33 +10,33 @@
|
||||
#import "NSValueTransformer+TransformerKit.h"
|
||||
|
||||
NSString *const MPStripLineBreaksTransformerName = @"com.hicknhack.macpass.MPStripLineBreaksTransformerName";
|
||||
NSString *const MPExpiryDateValueTransformer = @"com.hicknhack.macpass.kMPExpiryDateValueTransformer";
|
||||
NSString *const MPExpiryDateValueTransformerName = @"com.hicknhack.macpass.MPExpiryDateValueTransformer";
|
||||
|
||||
@implementation MPValueTransformerHelper
|
||||
|
||||
+ (void)registerValueTransformer {
|
||||
[NSValueTransformer registerValueTransformerWithName:MPStripLineBreaksTransformerName
|
||||
transformedValueClass:[NSString class]
|
||||
transformedValueClass:NSString.class
|
||||
returningTransformedValueWithBlock:^id(id value) {
|
||||
if(![value isKindOfClass:[NSString class]]) {
|
||||
if(![value isKindOfClass:NSString.class]) {
|
||||
return @"";
|
||||
}
|
||||
NSArray *elements = [value componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
|
||||
NSArray *elements = [value componentsSeparatedByCharactersInSet:NSCharacterSet.newlineCharacterSet];
|
||||
return [elements componentsJoinedByString:@" "];
|
||||
}];
|
||||
|
||||
|
||||
[NSValueTransformer registerValueTransformerWithName:MPExpiryDateValueTransformer
|
||||
transformedValueClass:[NSString class]
|
||||
[NSValueTransformer registerValueTransformerWithName:MPExpiryDateValueTransformerName
|
||||
transformedValueClass:NSString.class
|
||||
returningTransformedValueWithBlock:^id(id value) {
|
||||
if(![value isKindOfClass:[NSDate class]]) {
|
||||
if(![value isKindOfClass:NSDate.class]) {
|
||||
return NSLocalizedString(@"NO_EXPIRE_DATE_SET","");
|
||||
}
|
||||
static NSDateFormatter *formatter;
|
||||
if(!formatter) {
|
||||
formatter = [[NSDateFormatter alloc] init];
|
||||
[formatter setDateStyle:NSDateFormatterFullStyle];
|
||||
[formatter setTimeStyle:NSDateFormatterNoStyle];
|
||||
formatter.dateStyle = NSDateFormatterFullStyle;
|
||||
formatter.timeStyle = NSDateFormatterNoStyle;
|
||||
}
|
||||
NSString *template = NSLocalizedString(@"EXPIRES_AT_DATE_%@", "");
|
||||
return [[NSString alloc] initWithFormat:template, [formatter stringFromDate:value]];
|
||||
|
||||
Reference in New Issue
Block a user