forked from organicmaps/organicmaps-tmp
Merge pull request #2635 from VladiMihaylenko/vm-master
[ios] Refactored work with text fields in editor.
This commit is contained in:
commit
518b60fd0e
4 changed files with 18 additions and 30 deletions
|
@ -1,8 +1,11 @@
|
|||
@protocol MWMEditorCellProtocol <NSObject>
|
||||
|
||||
- (void)cellBeginEditing:(UITableViewCell *)cell;
|
||||
- (void)cell:(UITableViewCell *)cell changeText:(NSString *)changeText;
|
||||
@required
|
||||
- (void)cell:(UITableViewCell *)cell changedText:(NSString *)changeText;
|
||||
- (void)cell:(UITableViewCell *)cell changeSwitch:(BOOL)changeSwitch;
|
||||
- (void)cellSelect:(UITableViewCell *)cell;
|
||||
|
||||
@optional
|
||||
- (void)fieldIsCorrect:(BOOL)isCorrect;
|
||||
|
||||
@end
|
||||
|
|
|
@ -33,26 +33,9 @@
|
|||
|
||||
#pragma mark - UITextFieldDelegate
|
||||
|
||||
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
|
||||
- (void)textFieldDidEndEditing:(UITextField *)textField
|
||||
{
|
||||
[self.delegate cellBeginEditing:self];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)textField:(UITextField *)textField
|
||||
shouldChangeCharactersInRange:(NSRange)range
|
||||
replacementString:(NSString *)string
|
||||
{
|
||||
NSAssert(string, @"String can't be nil!");
|
||||
if (!string)
|
||||
return YES;
|
||||
|
||||
NSString * newString =
|
||||
[textField.text stringByReplacingCharactersInRange:range withString:string];
|
||||
BOOL const isCorrect = [textField.validator validateString:newString];
|
||||
if (isCorrect)
|
||||
[self.delegate cell:self changeText:newString];
|
||||
return YES;
|
||||
[self.delegate cell:self changedText:textField.text];
|
||||
}
|
||||
|
||||
- (BOOL)textFieldShouldReturn:(UITextField *)textField
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
|
@ -11,7 +11,7 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="5uK-5Q-cg0">
|
||||
|
@ -34,7 +34,6 @@
|
|||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular17"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackPrimaryText"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="validatorName" value="MWMInputValidator"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="_placeholderLabel.colorName" value="blackHintText"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
|
|
|
@ -155,6 +155,12 @@ NSString * reuseIdentifier(MWMPlacePageCellType cellType)
|
|||
|
||||
- (void)onSave
|
||||
{
|
||||
if (![self.view endEditing:YES])
|
||||
{
|
||||
NSAssert(false, @"We can't save map object because one of text fields can't apply it's text!");
|
||||
return;
|
||||
}
|
||||
|
||||
auto & f = GetFramework();
|
||||
auto const & featureID = m_mapObject.GetID();
|
||||
NSDictionary * info = @{kStatEditorMWMName : @(featureID.GetMwmName().c_str()),
|
||||
|
@ -472,12 +478,9 @@ NSString * reuseIdentifier(MWMPlacePageCellType cellType)
|
|||
|
||||
#pragma mark - MWMEditorCellProtocol
|
||||
|
||||
- (void)cellBeginEditing:(UITableViewCell *)cell
|
||||
{
|
||||
}
|
||||
|
||||
- (void)cell:(UITableViewCell *)cell changeText:(NSString *)changeText
|
||||
- (void)cell:(UITableViewCell *)cell changedText:(NSString *)changeText
|
||||
{
|
||||
NSAssert(changeText != nil, @"String can't be nil!");
|
||||
NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
|
||||
MWMPlacePageCellType const cellType = [self cellTypeForIndexPath:indexPath];
|
||||
string const val = changeText.UTF8String;
|
||||
|
|
Loading…
Add table
Reference in a new issue