mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various Fixes
This commit is contained in:
parent
22f9a91f97
commit
a47c3777e6
@ -230,7 +230,7 @@ static void setViewFrame(UIView *view, CGRect frame)
|
||||
if (_inputField.internalTextView.isFirstResponder)
|
||||
[TGHacks applyCurrentKeyboardAutocorrectionVariant];
|
||||
|
||||
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithAttributedString:_inputField.text == nil ? [[NSAttributedString alloc] initWithString:@""] : _inputField.attributedText]; //[[NSMutableAttributedString alloc] initWithString:_inputField.text == nil ? @"" : _inputField.text];
|
||||
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithAttributedString:_inputField.text == nil ? [[NSAttributedString alloc] initWithString:@""] : _inputField.attributedText];
|
||||
NSMutableString *usualString = [text.string mutableCopy];
|
||||
int textLength = (int)text.length;
|
||||
for (int i = 0; i < textLength; i++)
|
||||
@ -248,20 +248,6 @@ static void setViewFrame(UIView *view, CGRect frame)
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = textLength - 1; i >= 0; i--)
|
||||
{
|
||||
unichar c = [usualString characterAtIndex:i];
|
||||
|
||||
if (c == ' ' || c == '\t' || c == '\n')
|
||||
{
|
||||
[text deleteCharactersInRange:NSMakeRange(i, 1)];
|
||||
[usualString deleteCharactersInRange:NSMakeRange(i, 1)];
|
||||
textLength--;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
_inputField.internalTextView.attributedText = text;
|
||||
|
||||
__autoreleasing NSArray *entities = nil;
|
||||
|
@ -3,6 +3,6 @@
|
||||
@interface TGPhotoEditorHUDView : UIView
|
||||
|
||||
- (void)setText:(NSString *)text;
|
||||
- (void)setAttributedText:(NSAttributedString *)text;
|
||||
- (void)setTitle:(NSString *)title value:(NSString *)value;
|
||||
|
||||
@end
|
||||
|
@ -9,6 +9,7 @@
|
||||
{
|
||||
UIImageView *_backgroundView;
|
||||
UILabel *_label;
|
||||
UILabel *_valueLabel;
|
||||
}
|
||||
@end
|
||||
|
||||
@ -41,12 +42,37 @@
|
||||
_backgroundView.image = background;
|
||||
[self addSubview:_backgroundView];
|
||||
|
||||
UIFont *font;
|
||||
|
||||
if (iosMajorVersion() >= 13) {
|
||||
UIFontDescriptor *fontDescriptor = [UIFont systemFontOfSize:14.0f weight:UIFontWeightMedium].fontDescriptor;
|
||||
NSArray *monospacedSetting = @[@{UIFontFeatureTypeIdentifierKey: @(kNumberSpacingType),
|
||||
UIFontFeatureSelectorIdentifierKey: @(kMonospacedNumbersSelector)}];
|
||||
UIFontDescriptor *updatedDescriptor = [fontDescriptor fontDescriptorByAddingAttributes:@{
|
||||
UIFontDescriptorFeatureSettingsAttribute: monospacedSetting
|
||||
}];
|
||||
if (updatedDescriptor != nil) {
|
||||
font = [UIFont fontWithDescriptor:updatedDescriptor size:14.0];
|
||||
} else {
|
||||
font = [UIFont systemFontOfSize:14];
|
||||
}
|
||||
} else {
|
||||
font = [UIFont systemFontOfSize:14];
|
||||
}
|
||||
|
||||
_label = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_label.backgroundColor = [UIColor clearColor];
|
||||
_label.font = TGSystemFontOfSize(14);
|
||||
_label.textAlignment = NSTextAlignmentCenter;
|
||||
_label.font = [UIFont systemFontOfSize:14];
|
||||
_label.textAlignment = NSTextAlignmentLeft;
|
||||
_label.textColor = [UIColor whiteColor];
|
||||
[_backgroundView addSubview:_label];
|
||||
|
||||
_valueLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_valueLabel.backgroundColor = [UIColor clearColor];
|
||||
_valueLabel.font = font;
|
||||
_valueLabel.textAlignment = NSTextAlignmentRight;
|
||||
_valueLabel.textColor = [TGPhotoEditorInterfaceAssets accentColor];
|
||||
[_backgroundView addSubview:_valueLabel];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -62,22 +88,27 @@
|
||||
_label.text = text;
|
||||
[_label sizeToFit];
|
||||
|
||||
_valueLabel.hidden = true;
|
||||
|
||||
[self setNeedsLayout];
|
||||
|
||||
[self setHidden:false animated:true];
|
||||
}
|
||||
|
||||
- (void)setAttributedText:(NSAttributedString *)text
|
||||
- (void)setTitle:(NSString *)title value:(NSString *)value
|
||||
{
|
||||
if (text.length == 0)
|
||||
if (title.length == 0)
|
||||
{
|
||||
[self setHidden:true animated:true];
|
||||
return;
|
||||
}
|
||||
|
||||
_label.attributedText = text;
|
||||
_label.text = title;
|
||||
[_label sizeToFit];
|
||||
|
||||
_valueLabel.text = value;
|
||||
[_valueLabel sizeToFit];
|
||||
|
||||
[self setNeedsLayout];
|
||||
|
||||
[self setHidden:false animated:true];
|
||||
@ -104,7 +135,15 @@
|
||||
|
||||
_label.frame = CGRectMake(padding, 6.0f, CGCeil(_label.frame.size.width), CGCeil(_label.frame.size.height));
|
||||
|
||||
CGFloat width = _label.frame.size.width + 2.0f * padding;
|
||||
CGFloat width;
|
||||
if (_valueLabel.isHidden) {
|
||||
width = _label.frame.size.width + 2.0f * padding;
|
||||
} else {
|
||||
width = 2.0f * padding + _label.frame.size.width + 50.0f + 3.0f;
|
||||
}
|
||||
|
||||
_valueLabel.frame = CGRectMake(width - padding - 50.0f, 6.0f, 50.0f, CGCeil(_valueLabel.frame.size.height));
|
||||
|
||||
_backgroundView.frame = CGRectMake((self.frame.size.width - width) / 2, 15, width, 30);
|
||||
}
|
||||
|
||||
|
@ -336,9 +336,7 @@ const CGFloat TGPhotoEditorToolsLandscapePanelSize = TGPhotoEditorToolsPanelSize
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@", tool.title, [tool stringValue:true]] attributes:@{NSFontAttributeName: TGMediumSystemFontOfSize(14.0f), NSForegroundColorAttributeName: [TGPhotoEditorInterfaceAssets accentColor]}];
|
||||
[text addAttributes:@{NSFontAttributeName: TGSystemFontOfSize(14.0f), NSForegroundColorAttributeName: [UIColor whiteColor]} range:NSMakeRange(0, tool.title.length)];
|
||||
[_hudView setAttributedText:text];
|
||||
[_hudView setTitle:tool.title value:[tool stringValue:true]];
|
||||
}
|
||||
|
||||
#pragma mark - Transition
|
||||
|
Loading…
x
Reference in New Issue
Block a user