Skip to content

Commit

Permalink
Added hidden property for all objects and placeholder property for UI…
Browse files Browse the repository at this point in the history
…TextFields
  • Loading branch information
dalewebster48 committed Mar 22, 2017
1 parent 518981c commit 8c01413
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion EverLayout.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "EverLayout"
s.version = "0.5.0"
s.version = "0.5.1"
s.summary = "Reusable, downloadable, up-datable iOS layouts"

s.homepage = "https://github.com/acrocat/EverLayout"
Expand Down
4 changes: 4 additions & 0 deletions EverLayout.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
2DB7F2801E7C762300175CCB /* ELLayoutTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DB7F27F1E7C762300175CCB /* ELLayoutTemplate.swift */; };
2DB7F2821E7C765300175CCB /* LayoutTemplateParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DB7F2811E7C765300175CCB /* LayoutTemplateParser.swift */; };
2DBAE95C1E5DCE9200677D98 /* ELJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DBAE95B1E5DCE9200677D98 /* ELJSON.swift */; };
2DD03C301E82B606006A65A7 /* TextFieldPropertyResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DD03C2F1E82B606006A65A7 /* TextFieldPropertyResolver.swift */; };
2DD12DAD1E4C9B2300F2057B /* EverLayoutBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DD12DAC1E4C9B2300F2057B /* EverLayoutBuilder.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -89,6 +90,7 @@
2DB7F27F1E7C762300175CCB /* ELLayoutTemplate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ELLayoutTemplate.swift; sourceTree = "<group>"; };
2DB7F2811E7C765300175CCB /* LayoutTemplateParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutTemplateParser.swift; sourceTree = "<group>"; };
2DBAE95B1E5DCE9200677D98 /* ELJSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ELJSON.swift; sourceTree = "<group>"; };
2DD03C2F1E82B606006A65A7 /* TextFieldPropertyResolver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldPropertyResolver.swift; sourceTree = "<group>"; };
2DD12DAC1E4C9B2300F2057B /* EverLayoutBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EverLayoutBuilder.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -203,6 +205,7 @@
2D57FA821E46182E0043B897 /* ScrollViewPropertyResolver.swift */,
2D57FA831E46182E0043B897 /* LabelPropertyResolver.swift */,
2D57FA841E46182E0043B897 /* ButtonPropertyResolver.swift */,
2DD03C2F1E82B606006A65A7 /* TextFieldPropertyResolver.swift */,
);
path = Resolvers;
sourceTree = "<group>";
Expand Down Expand Up @@ -305,6 +308,7 @@
2D659AA91E54990900D11E20 /* UIView+EverLayout.swift in Sources */,
2D57FA671E4617C80043B897 /* ELConstraint.swift in Sources */,
2D57FA741E4617D40043B897 /* LayoutConstraintJSONParser.swift in Sources */,
2DD03C301E82B606006A65A7 /* TextFieldPropertyResolver.swift in Sources */,
2D57FA891E46182E0043B897 /* ButtonPropertyResolver.swift in Sources */,
2DD12DAD1E4C9B2300F2057B /* EverLayoutBuilder.swift in Sources */,
2D57FA8F1E4618610043B897 /* EverLayoutBridge.swift in Sources */,
Expand Down
3 changes: 3 additions & 0 deletions EverLayout/Resolvers/PropertyResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public class PropertyResolver
},
"contentMode": {source in
self.view?.contentMode = PropertyResolver.contentMode(source: source) ?? .scaleToFill
},
"hidden": {source in
self.view?.isHidden = PropertyResolver.bool(value: source)
}
]
}
Expand Down
31 changes: 31 additions & 0 deletions EverLayout/Resolvers/TextFieldPropertyResolver.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// TextFieldPropertyParser.swift
// EverLayout
//
// Created by Dale Webster on 22/03/2017.
// Copyright © 2017 Dale Webster. All rights reserved.
//

import UIKit

class TextFieldPropertyResolver: PropertyResolver {
override public var exposedProperties: [String : (String) -> Void] {
var props = super.exposedProperties

props["placeholder"] = {(source) in
if let textField = self.view as? UITextField {
textField.placeholder = PropertyResolver.string(value: source) ?? ""
}
}

return props
}
}

extension UITextField {
override open func applyViewProperty(viewProperty: ELViewProperty) {
super.applyViewProperty(viewProperty: viewProperty)

TextFieldPropertyResolver(view: self).apply(viewProperty: viewProperty)
}
}

0 comments on commit 8c01413

Please sign in to comment.