Skip to content

Commit

Permalink
Add debug parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreGUI committed Jun 25, 2015
1 parent 4ef7bc8 commit 33f3fda
Show file tree
Hide file tree
Showing 21 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ You can pass properties during initialization or later:
| floatingLabelFontSize | int | Size of the floating label above field |
| floatingLabelTextColor | String | Color of the floating label above field |
| value | String | Value of the field (user input) |
| debug | Bool | Switch module logging on with `debug: true` |
## Public methods
Expand Down
2 changes: 2 additions & 0 deletions ios/Classes/TsFloatlabelfieldView.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
float floatLabelFontSize;
NSString *placeholderTextColor; // to be converted
NSString *floatLabelTextColor; // to be converted

NSNumber *debug;
}

-(void)updatePlaceholder;
Expand Down
27 changes: 16 additions & 11 deletions ios/Classes/TsFloatlabelfieldView.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ -(JVFloatLabeledTextField*)FLTF

-(void)updatePlaceholder
{
NSLog(@"updatePlaceholder: %@, %f", placeholderText, placeholderFontSize);
if(debug) NSLog(@"[FLF] updatePlaceholder: %@, %f", placeholderText, placeholderFontSize);
NSString *_placeholderText = placeholderText.length>0 ? placeholderText : @"";
UIColor *_placeholderColor = [[TiUtils colorValue:placeholderTextColor] _color];
if(!_placeholderColor) {
Expand All @@ -34,7 +34,7 @@ -(void)updatePlaceholder

-(void)updateIntrinsicView
{
NSLog(@"updateIntrinsicView");
if(debug) NSLog(@"[FLF] updateIntrinsicView");
CGSize size = [[self FLTF] intrinsicContentSize];
[fltf setFrame:CGRectMake(fltf.frame.origin.x, fltf.frame.origin.y, size.width, size.height)];
[fltf setBounds:CGRectMake(0, 0, size.width, size.height)];
Expand All @@ -44,7 +44,7 @@ -(void)updateIntrinsicView

-(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds
{
NSLog(@"frameSizeChanged frame %@ : %@ ", NSStringFromCGRect(frame), NSStringFromCGRect(fltf.frame));
if(debug) NSLog(@"[FLF] frameSizeChanged frame %@ : %@ ", NSStringFromCGRect(frame), NSStringFromCGRect(fltf.frame));
// If using Ti.UI.SIZE, frameSizeChanged is called with size (0,0)
if(bounds.size.height == 0 && bounds.size.width == 0) {
return [self updateIntrinsicView];
Expand Down Expand Up @@ -72,12 +72,12 @@ - (void) dealloc

-(void)setValue:(id)text
{
NSLog(@"[FLF] setValue %@", text);
if(debug) NSLog(@"[FLF] setValue %@", text);
[self FLTF].text = text;
}
-(id)getValue
{
NSLog(@"[FLF] getValue");
if(debug) NSLog(@"[FLF] getValue");
return [self FLTF].text;
}

Expand All @@ -89,14 +89,14 @@ -(void)setValue_:(id)text

-(void)setFontSize_:(id)size
{
NSLog(@"[FLF] setFontSize_");
if(debug) NSLog(@"[FLF] setFontSize_");
[self FLTF].font = [UIFont systemFontOfSize:[TiUtils floatValue:size def:20]];
}

-(void)setTextColor_:(id)color
{
ENSURE_SINGLE_ARG(color, NSString);
NSLog(@"[FLF] setTextColor %@", color);
if(debug) NSLog(@"[FLF] setTextColor %@", color);

[self FLTF].tintColor = [[TiUtils colorValue:color] _color];
[self FLTF].textColor = [[TiUtils colorValue:color] _color];
Expand All @@ -105,7 +105,7 @@ -(void)setTextColor_:(id)color
-(void)setPlaceholderText_:(id)text
{
ENSURE_SINGLE_ARG(text, NSString);
NSLog(@"[FLF] setPlaceholderText %@", text);
if(debug) NSLog(@"[FLF] setPlaceholderText %@", text);

placeholderText = text;
[self updatePlaceholder];
Expand All @@ -114,25 +114,30 @@ -(void)setPlaceholderText_:(id)text
-(void)setPlaceholderTextColor_:(id)color
{
ENSURE_SINGLE_ARG(color, NSString);
NSLog(@"[FLF] setPlaceholderTextColor %@", color);
if(debug) NSLog(@"[FLF] setPlaceholderTextColor %@", color);

placeholderTextColor = color;
[self updatePlaceholder];
}

-(void)setFloatingLabelFontSize_:(id)size
{
NSLog(@"[FLF] setFloatingLabelFontSize_");
if(debug) NSLog(@"[FLF] setFloatingLabelFontSize_");
[self FLTF].floatingLabelFont = [UIFont boldSystemFontOfSize:[TiUtils floatValue:size def:10]];
}

-(void)setFloatingLabelTextColor_:(id)color
{
NSLog(@"[FLF] setFloatingLabelTextColor_");
if(debug) NSLog(@"[FLF] setFloatingLabelTextColor_");
ENSURE_SINGLE_ARG(color, NSString);
// Use the TiUtils methods to get the values from the arguments
[self FLTF].floatingLabelTextColor = [[TiUtils colorValue:color] _color];
[self FLTF].floatingLabelActiveTextColor = [[TiUtils colorValue:color] _color];
}

-(void)setDebug_:(id)yesno
{
debug = [TiUtils boolValue:yesno];
}

@end
Binary file modified ios/build/Release-iphoneos/libTsFloatlabelfield.a
Binary file not shown.
Binary file modified ios/build/Release-iphonesimulator/libTsFloatlabelfield.a
Binary file not shown.
Binary file modified ios/build/libts.floatlabelfield.a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 33f3fda

Please sign in to comment.