This repository has been archived by the owner on Aug 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
239 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Pod::Spec.new do |s| | ||
s.name = "Bohr" | ||
s.version = "3.0.0-alpha.3" | ||
s.version = "3.0.0-alpha.4" | ||
s.summary = "Settings screen composing framework" | ||
s.homepage = "https://github.com/DavdRoman/Bohr" | ||
s.author = { "David Román" => "[email protected]" } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// BONumberTableViewCell.h | ||
// Bohr | ||
// | ||
// Created by David Román Aguirre on 01/09/15. | ||
// | ||
// | ||
|
||
#import "BOTextTableViewCell.h" | ||
|
||
@interface BONumberTableViewCell : BOTextTableViewCell | ||
|
||
/// The maximum number of decimals shown in the text field. | ||
@property (nonatomic) NSInteger numberOfDecimals; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// | ||
// BONumberTableViewCell.m | ||
// Bohr | ||
// | ||
// Created by David Román Aguirre on 01/09/15. | ||
// | ||
// | ||
|
||
#import "BONumberTableViewCell.h" | ||
|
||
#import "BOTableViewCell+Subclass.h" | ||
#import "BOTextTableViewCell+Subclass.h" | ||
|
||
@implementation NSNumber (String) | ||
|
||
- (NSString *)stringWithDecimals:(NSInteger)decimals { | ||
NSNumberFormatter *formatter = [NSNumberFormatter new]; | ||
formatter.locale = [NSLocale currentLocale]; | ||
formatter.maximumFractionDigits = decimals; | ||
return [formatter stringFromNumber:self]; | ||
} | ||
|
||
@end | ||
|
||
@implementation NSString (Number) | ||
|
||
- (BOOL)isNumeric { | ||
if (self.length > 0) { | ||
NSScanner *scanner = [NSScanner scannerWithString:self]; | ||
scanner.locale = [NSLocale currentLocale]; | ||
return [scanner scanDecimal:nil] && scanner.atEnd; | ||
} | ||
|
||
return YES; | ||
} | ||
|
||
- (NSNumber *)number { | ||
NSNumberFormatter *formatter = [NSNumberFormatter new]; | ||
formatter.locale = [NSLocale currentLocale]; | ||
return [formatter numberFromString:self]; | ||
} | ||
|
||
@end | ||
|
||
@implementation BONumberTableViewCell | ||
|
||
- (void)setup { | ||
[super setup]; | ||
|
||
self.textField.keyboardType = UIKeyboardTypeDecimalPad; | ||
} | ||
|
||
- (void)settingValueDidChange { | ||
self.textField.text = [self.setting.value stringWithDecimals:self.numberOfDecimals]; | ||
} | ||
|
||
#pragma mark UITextFieldDelegate | ||
|
||
- (BOTextFieldInputError)validateTextFieldInput:(NSString *)input { | ||
return ![input isNumeric] ? BOTextFieldInputNotNumericError : [super validateTextFieldInput:input]; | ||
} | ||
|
||
- (id)settingValueForInput:(NSString *)input { | ||
return [input number]; | ||
} | ||
|
||
@end |
37 changes: 0 additions & 37 deletions
37
Bohr/BOTableViewCell (MacBook Pro de David's conflicted copy 2015-08-26).h
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// BOTextTableViewCell+Subclass.h | ||
// Bohr | ||
// | ||
// Created by David Román Aguirre on 02/09/15. | ||
// | ||
// | ||
|
||
#import <Bohr/Bohr.h> | ||
|
||
@interface BOTextTableViewCell (Subclass) | ||
|
||
/** | ||
* Validation method implemented by a BOTextTableViewCell class in order to check for possible errors in its input. | ||
* @param filteredInput The input string with whitespace and new line characters trimmed. | ||
* @return Some BOTextFieldInputError, or BOTextFieldInputNoError if there's no error with input. | ||
*/ | ||
- (BOTextFieldInputError)validateTextFieldInput:(NSString *)input; | ||
|
||
/** | ||
* Conversion method implemented by a BOTextTableViewCell class in order to make any necessary transformations to the input before assigning it as a setting value. | ||
* @param input The input string. | ||
* @return Some object resulting from the transformation of the input. | ||
*/ | ||
- (id)settingValueForInput:(NSString *)input; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.