Various fixes

This commit is contained in:
Ilya Laktyushin 2020-11-12 20:12:00 +04:00
parent 8081430ad2
commit 40e28d769d
13 changed files with 138 additions and 138 deletions

View File

@ -226,25 +226,23 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
self.paneContainerNode.interaction = interaction self.paneContainerNode.interaction = interaction
self.paneContainerNode.currentPaneUpdated = { [weak self] key, transitionFraction, transition in self.paneContainerNode.currentPaneUpdated = { [weak self] key, transitionFraction, transition in
if let strongSelf = self { if let strongSelf = self, let key = key {
var filterKey: ChatListSearchFilter? var filterKey: ChatListSearchFilter
if let key = key { switch key {
switch key { case .chats:
case .chats: filterKey = .chats
filterKey = .chats case .media:
case .media: filterKey = .media
filterKey = .media case .links:
case .links: filterKey = .links
filterKey = .links case .files:
case .files: filterKey = .files
filterKey = .files case .music:
case .music: filterKey = .music
filterKey = .music case .voice:
case .voice: filterKey = .voice
filterKey = .voice
}
} }
strongSelf.selectedFilterKey = filterKey.flatMap { .filter($0.id) } strongSelf.selectedFilterKey = .filter(filterKey.id)
strongSelf.selectedFilterKeyPromise.set(.single(strongSelf.selectedFilterKey)) strongSelf.selectedFilterKeyPromise.set(.single(strongSelf.selectedFilterKey))
strongSelf.transitionFraction = transitionFraction strongSelf.transitionFraction = transitionFraction

View File

@ -694,7 +694,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
if !content.enableSound { if !content.enableSound {
isPaused = false isPaused = false
} }
} else { } else if strongSelf.actionAtEnd == .stop {
strongSelf.updateControlsVisibility(true) strongSelf.updateControlsVisibility(true)
strongSelf.controlsTimer?.invalidate() strongSelf.controlsTimer?.invalidate()
strongSelf.controlsTimer = nil strongSelf.controlsTimer = nil

View File

@ -59,7 +59,7 @@ NSString *const TGMediaAssetsGifCellKind = @"TGMediaAssetsGifCellKind";
_typeLabel.textColor = [UIColor whiteColor]; _typeLabel.textColor = [UIColor whiteColor];
_typeLabel.backgroundColor = [UIColor clearColor]; _typeLabel.backgroundColor = [UIColor clearColor];
_typeLabel.textAlignment = NSTextAlignmentLeft; _typeLabel.textAlignment = NSTextAlignmentLeft;
_typeLabel.font = TGSystemFontOfSize(12.0f); _typeLabel.font = TGBoldSystemFontOfSize(13);
_typeLabel.text = @"GIF"; _typeLabel.text = @"GIF";
[_typeLabel sizeToFit]; [_typeLabel sizeToFit];
[self addSubview:_typeLabel]; [self addSubview:_typeLabel];
@ -78,7 +78,9 @@ NSString *const TGMediaAssetsGifCellKind = @"TGMediaAssetsGifCellKind";
[super layoutSubviews]; [super layoutSubviews];
_shadowView.frame = (CGRect){ { 0, self.frame.size.height - _shadowView.frame.size.height }, {self.frame.size.width, _shadowView.frame.size.height } }; _shadowView.frame = (CGRect){ { 0, self.frame.size.height - _shadowView.frame.size.height }, {self.frame.size.width, _shadowView.frame.size.height } };
_typeLabel.frame = (CGRect){ { 5, _shadowView.frame.origin.y }, {self.frame.size.width - 5 - 4, _shadowView.frame.size.height } };
CGSize typeSize = _typeLabel.frame.size;
_typeLabel.frame = CGRectMake(self.frame.size.width - floor(typeSize.width) - 5.0, self.frame.size.height - floor(typeSize.height) - 4.0, typeSize.width, typeSize.height);
} }
@end @end

View File

@ -67,13 +67,12 @@ NSString *const TGMediaAssetsVideoCellKind = @"TGMediaAssetsVideoCellKind";
_iconView = [[UIImageView alloc] init]; _iconView = [[UIImageView alloc] init];
_iconView.contentMode = UIViewContentModeCenter; _iconView.contentMode = UIViewContentModeCenter;
[self addSubview:_iconView];
_durationLabel = [[UILabel alloc] init]; _durationLabel = [[UILabel alloc] init];
_durationLabel.textColor = [UIColor whiteColor]; _durationLabel.textColor = [UIColor whiteColor];
_durationLabel.backgroundColor = [UIColor clearColor]; _durationLabel.backgroundColor = [UIColor clearColor];
_durationLabel.textAlignment = NSTextAlignmentRight; _durationLabel.textAlignment = NSTextAlignmentRight;
_durationLabel.font = TGSystemFontOfSize(12.0f); _durationLabel.font = TGBoldSystemFontOfSize(13);
[_durationLabel sizeToFit]; [_durationLabel sizeToFit];
[self addSubview:_durationLabel]; [self addSubview:_durationLabel];
@ -113,6 +112,7 @@ NSString *const TGMediaAssetsVideoCellKind = @"TGMediaAssetsVideoCellKind";
durationString = [NSString stringWithFormat:@"%d:%02d", duration / 60, duration % 60]; durationString = [NSString stringWithFormat:@"%d:%02d", duration / 60, duration % 60];
_durationLabel.text = durationString; _durationLabel.text = durationString;
[_durationLabel sizeToFit];
if (asset.subtypes & TGMediaAssetSubtypeVideoTimelapse) if (asset.subtypes & TGMediaAssetSubtypeVideoTimelapse)
_iconView.image = TGComponentsImageNamed(@"ModernMediaItemTimelapseIcon"); _iconView.image = TGComponentsImageNamed(@"ModernMediaItemTimelapseIcon");
@ -235,7 +235,9 @@ NSString *const TGMediaAssetsVideoCellKind = @"TGMediaAssetsVideoCellKind";
self.checkButton.frame = (CGRect){ { self.frame.size.width - self.checkButton.frame.size.width - 2, 2 }, self.checkButton.frame.size }; self.checkButton.frame = (CGRect){ { self.frame.size.width - self.checkButton.frame.size.width - 2, 2 }, self.checkButton.frame.size };
_shadowView.frame = (CGRect){ { 0, self.frame.size.height - _shadowView.frame.size.height }, {self.frame.size.width, _shadowView.frame.size.height } }; _shadowView.frame = (CGRect){ { 0, self.frame.size.height - _shadowView.frame.size.height }, {self.frame.size.width, _shadowView.frame.size.height } };
_iconView.frame = CGRectMake(0, self.frame.size.height - 19, 19, 19); _iconView.frame = CGRectMake(0, self.frame.size.height - 19, 19, 19);
_durationLabel.frame = (CGRect){ { 5, _shadowView.frame.origin.y }, {self.frame.size.width - 5 - 4, _shadowView.frame.size.height } };
CGSize durationSize = _durationLabel.frame.size;
_durationLabel.frame = CGRectMake(self.frame.size.width - floor(durationSize.width) - 5.0, self.frame.size.height - floor(durationSize.height) - 4.0, durationSize.width, durationSize.height);
} }
@end @end

View File

@ -51,40 +51,49 @@
CGSize itemSize = TGPhotoThumbnailSizeForCurrentScreen(); CGSize itemSize = TGPhotoThumbnailSizeForCurrentScreen();
if ([UIScreen mainScreen].scale >= 2.0f - FLT_EPSILON) if ([UIScreen mainScreen].scale >= 2.0f - FLT_EPSILON)
{ {
if (widescreenWidth >= 736.0f - FLT_EPSILON) if (widescreenWidth >= 844.0f - FLT_EPSILON)
{ {
metrics->_normalItemSize = itemSize; metrics->_normalItemSize = itemSize;
metrics->_wideItemSize = itemSize; metrics->_wideItemSize = itemSize;
metrics->_normalEdgeInsets = UIEdgeInsetsMake(4.0f, 0.0f, 2.0f, 0.0f); metrics->_normalEdgeInsets = UIEdgeInsetsMake(2.0f, 0.0f, 2.0f, 0.0f);
metrics->_wideEdgeInsets = UIEdgeInsetsMake(4.0f, 2.0f, 1.0f, 2.0f); metrics->_wideEdgeInsets = UIEdgeInsetsMake(2.0f, 2.0f, 1.0f, 2.0f);
metrics->_normalLineSpacing = 1.0f; metrics->_normalLineSpacing = 2.0f;
metrics->_wideLineSpacing = 2.0f;
}
else if (widescreenWidth >= 736.0f - FLT_EPSILON)
{
metrics->_normalItemSize = itemSize;
metrics->_wideItemSize = itemSize;
metrics->_normalEdgeInsets = UIEdgeInsetsMake(2.0f, 0.0f, 2.0f, 0.0f);
metrics->_wideEdgeInsets = UIEdgeInsetsMake(2.0f, 2.0f, 1.0f, 2.0f);
metrics->_normalLineSpacing = 2.0f;
metrics->_wideLineSpacing = 2.0f; metrics->_wideLineSpacing = 2.0f;
} }
else if (widescreenWidth >= 667.0f - FLT_EPSILON) else if (widescreenWidth >= 667.0f - FLT_EPSILON)
{ {
metrics->_normalItemSize = itemSize; metrics->_normalItemSize = itemSize;
metrics->_wideItemSize = CGSizeMake(floor(itemSize.width), floor(itemSize.height)); metrics->_wideItemSize = CGSizeMake(floor(itemSize.width), floor(itemSize.height));
metrics->_normalEdgeInsets = UIEdgeInsetsMake(4.0f, 0.0f, 2.0f, 0.0f); metrics->_normalEdgeInsets = UIEdgeInsetsMake(2.0f, 0.0f, 2.0f, 0.0f);
metrics->_wideEdgeInsets = UIEdgeInsetsMake(4.0f, 2.0f, 1.0f, 2.0f); metrics->_wideEdgeInsets = UIEdgeInsetsMake(2.0f, 2.0f, 1.0f, 2.0f);
metrics->_normalLineSpacing = 1.0f; metrics->_normalLineSpacing = 2.0f;
metrics->_wideLineSpacing = 2.0f; metrics->_wideLineSpacing = 2.0f;
} }
else else
{ {
metrics->_normalItemSize = itemSize; metrics->_normalItemSize = itemSize;
metrics->_wideItemSize = CGSizeMake(floor(itemSize.width), floor(itemSize.height)); metrics->_wideItemSize = CGSizeMake(floor(itemSize.width), floor(itemSize.height));
metrics->_normalEdgeInsets = UIEdgeInsetsMake(4.0f, 0.0f, 2.0f, 0.0f); metrics->_normalEdgeInsets = UIEdgeInsetsMake(2.0f, 0.0f, 2.0f, 0.0f);
metrics->_wideEdgeInsets = UIEdgeInsetsMake(4.0f, 1.0f, 1.0f, 1.0f); metrics->_wideEdgeInsets = UIEdgeInsetsMake(2.0f, 1.0f, 1.0f, 1.0f);
metrics->_normalLineSpacing = 2.0f; metrics->_normalLineSpacing = 2.0f;
metrics->_wideLineSpacing = 3.0f; metrics->_wideLineSpacing = 2.0f;
} }
} }
else else
{ {
metrics->_normalItemSize = itemSize; metrics->_normalItemSize = itemSize;
metrics->_wideItemSize = CGSizeMake(floor(itemSize.width), floor(itemSize.height)); metrics->_wideItemSize = CGSizeMake(floor(itemSize.width), floor(itemSize.height));
metrics->_normalEdgeInsets = UIEdgeInsetsMake(4.0f, 0.0f, 2.0f, 0.0f); metrics->_normalEdgeInsets = UIEdgeInsetsMake(2.0f, 0.0f, 2.0f, 0.0f);
metrics->_wideEdgeInsets = UIEdgeInsetsMake(4.0f, 1.0f, 1.0f, 1.0f); metrics->_wideEdgeInsets = UIEdgeInsetsMake(2.0f, 1.0f, 1.0f, 1.0f);
metrics->_normalLineSpacing = 2.0f; metrics->_normalLineSpacing = 2.0f;
metrics->_wideLineSpacing = 2.0f; metrics->_wideLineSpacing = 2.0f;
} }

View File

@ -204,9 +204,23 @@ static id<TGNavigationBarMusicPlayerProvider> _musicPlayerProvider;
- (void)layoutSubviews - (void)layoutSubviews
{ {
[self updateLayout];
[super layoutSubviews]; [super layoutSubviews];
for (UIView *view in self.subviews) {
if (iosMajorVersion() >= 11) {
view.frame = CGRectOffset(view.frame, 0.0, 6.0);
}
}
[self updateLayout];
}
- (CGSize)sizeThatFits:(CGSize)size {
if (iosMajorVersion() < 11) {
return CGSizeMake(MAX(self.frame.size.width, size.width), 36.0 - 6.0);
} else {
return [super sizeThatFits:size];
}
} }
- (void)updateLayout - (void)updateLayout
@ -217,7 +231,13 @@ static id<TGNavigationBarMusicPlayerProvider> _musicPlayerProvider;
if (iosMajorVersion() >= 11 && self.superview.safeAreaInsets.top > FLT_EPSILON) if (iosMajorVersion() >= 11 && self.superview.safeAreaInsets.top > FLT_EPSILON)
backgroundOverflow = self.superview.safeAreaInsets.top; backgroundOverflow = self.superview.safeAreaInsets.top;
_backgroundContainerView.frame = CGRectMake(0, -backgroundOverflow, self.bounds.size.width, backgroundOverflow + self.bounds.size.height); CGFloat heightAddition = 0.0;
if (iosMajorVersion() < 11) {
backgroundOverflow = 20.0;
heightAddition = 6.0 + TGScreenPixel;
}
_backgroundContainerView.frame = CGRectMake(0, -backgroundOverflow, self.bounds.size.width, backgroundOverflow + self.bounds.size.height + heightAddition);
if (_barBackgroundView != nil) if (_barBackgroundView != nil)
_barBackgroundView.frame = _backgroundContainerView.bounds; _barBackgroundView.frame = _backgroundContainerView.bounds;
@ -298,6 +318,10 @@ static id<TGNavigationBarMusicPlayerProvider> _musicPlayerProvider;
- (void)setFrame:(CGRect)frame - (void)setFrame:(CGRect)frame
{ {
if (frame.size.height < 56.0) {
frame.size.height = 56.0;
}
[super setFrame:frame]; [super setFrame:frame];
if (_statusBarBackgroundView != nil && _statusBarBackgroundView.superview != nil) if (_statusBarBackgroundView != nil && _statusBarBackgroundView.superview != nil)

View File

@ -26,27 +26,31 @@ CGSize TGPhotoThumbnailSizeForCurrentScreen()
{ {
if (widescreenWidth >= 896.0f - FLT_EPSILON) if (widescreenWidth >= 896.0f - FLT_EPSILON)
{ {
return CGSizeMake(103.0f, 103.0f); return CGSizeMake(137.0f - TGScreenPixel, 137.0f - TGScreenPixel);
}
else if (widescreenWidth >= 844.0f - FLT_EPSILON)
{
return CGSizeMake(129.0f - TGScreenPixel, 129.0f - TGScreenPixel);
} }
else if (widescreenWidth >= 812.0f - FLT_EPSILON) else if (widescreenWidth >= 812.0f - FLT_EPSILON)
{ {
return CGSizeMake(93.0f, 93.0f); return CGSizeMake(124.0f - TGScreenPixel, 124.0f - TGScreenPixel);
} }
else if (widescreenWidth >= 736.0f - FLT_EPSILON) else if (widescreenWidth >= 736.0f - FLT_EPSILON)
{ {
return CGSizeMake(103.0f, 103.0f); return CGSizeMake(137.0f - TGScreenPixel, 137.0f - TGScreenPixel);
} }
else if (widescreenWidth >= 667.0f - FLT_EPSILON) else if (widescreenWidth >= 667.0f - FLT_EPSILON)
{ {
return CGSizeMake(93.0f, 93.5f); return CGSizeMake(124.0f - TGScreenPixel, 124.0f - TGScreenPixel);
} }
else else
{ {
return CGSizeMake(78.5f, 78.5f); return CGSizeMake(106.0f - TGScreenPixel, 106.0f - TGScreenPixel);
} }
} }
return CGSizeMake(78.5f, 78.5f); return CGSizeMake(106.0f, 106.0f);
} }
CGSize TGScaleToSize(CGSize size, CGSize maxSize) CGSize TGScaleToSize(CGSize size, CGSize maxSize)

View File

@ -347,7 +347,7 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f;
[_doneButton setTitle:TGLocalized(@"Common.Done") forState:UIControlStateNormal]; [_doneButton setTitle:TGLocalized(@"Common.Done") forState:UIControlStateNormal];
_doneButton.titleLabel.font = TGSystemFontOfSize(17.0); _doneButton.titleLabel.font = TGSystemFontOfSize(17.0);
[_doneButton sizeToFit]; [_doneButton sizeToFit];
[_wrapperView addSubview:_doneButton]; // [_wrapperView addSubview:_doneButton];
void (^settingsPressed)(void) = ^ void (^settingsPressed)(void) = ^
{ {

View File

@ -1026,7 +1026,7 @@ static id<LegacyComponentsContext> _defaultContext = nil;
- (CGFloat)navigationBarHeightForInterfaceOrientation:(UIInterfaceOrientation)orientation - (CGFloat)navigationBarHeightForInterfaceOrientation:(UIInterfaceOrientation)orientation
{ {
static CGFloat portraitHeight = 44.0f; static CGFloat portraitHeight = 56.0f;
static CGFloat landscapeHeight = 32.0f; static CGFloat landscapeHeight = 32.0f;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^ dispatch_once(&onceToken, ^
@ -1035,13 +1035,13 @@ static id<LegacyComponentsContext> _defaultContext = nil;
CGFloat widescreenWidth = MAX(screenSize.width, screenSize.height); CGFloat widescreenWidth = MAX(screenSize.width, screenSize.height);
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && ABS(widescreenWidth - 736) > FLT_EPSILON) if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && ABS(widescreenWidth - 736) > FLT_EPSILON)
{ {
portraitHeight = 44.0f; portraitHeight = 56.0f;
landscapeHeight = 32.0f; landscapeHeight = 56.0f;
} }
else else
{ {
portraitHeight = 44.0f; portraitHeight = 56.0f;
landscapeHeight = 44.0f; landscapeHeight = 56.0f;
} }
}); });
bool large = UIInterfaceOrientationIsPortrait(orientation) || self.alwaysUseTallNavigationBarHeight; bool large = UIInterfaceOrientationIsPortrait(orientation) || self.alwaysUseTallNavigationBarHeight;

View File

@ -870,12 +870,12 @@ private final class MediaPlayerContext {
var statusTimestamp = CACurrentMediaTime() var statusTimestamp = CACurrentMediaTime()
let playbackStatus: MediaPlayerPlaybackStatus let playbackStatus: MediaPlayerPlaybackStatus
var isPlaying = false
if case .playing = self.state {
isPlaying = true
}
if let bufferingProgress = bufferingProgress { if let bufferingProgress = bufferingProgress {
var whilePlaying = false playbackStatus = .buffering(initial: false, whilePlaying: isPlaying, progress: Float(bufferingProgress), display: true)
if case .playing = self.state {
whilePlaying = true
}
playbackStatus = .buffering(initial: false, whilePlaying: whilePlaying, progress: Float(bufferingProgress), display: true)
} else if !rate.isZero { } else if !rate.isZero {
if reportRate.isZero { if reportRate.isZero {
//playbackStatus = .buffering(initial: false, whilePlaying: true) //playbackStatus = .buffering(initial: false, whilePlaying: true)
@ -885,8 +885,13 @@ private final class MediaPlayerContext {
playbackStatus = .playing playbackStatus = .playing
} }
} else { } else {
playbackStatus = .paused if performActionAtEndNow && !self.stoppedAtEnd, case .loop = self.actionAtEnd, isPlaying {
playbackStatus = .playing
} else {
playbackStatus = .paused
}
} }
if self.lastStatusUpdateTimestamp == nil || self.lastStatusUpdateTimestamp! < statusTimestamp + 500 { if self.lastStatusUpdateTimestamp == nil || self.lastStatusUpdateTimestamp! < statusTimestamp + 500 {
lastStatusUpdateTimestamp = statusTimestamp lastStatusUpdateTimestamp = statusTimestamp
var reportTimestamp = timestamp var reportTimestamp = timestamp

View File

@ -636,7 +636,18 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} }
if let mediaReference = mediaReference, let peer = message.peers[message.id.peerId] { if let mediaReference = mediaReference, let peer = message.peers[message.id.peerId] {
legacyMediaEditor(context: strongSelf.context, peer: peer, media: mediaReference, initialCaption: message.text, presentStickers: { _ in return nil }, sendMessagesWithSignals: { [weak self] signals, _, _ in legacyMediaEditor(context: strongSelf.context, peer: peer, media: mediaReference, initialCaption: message.text, presentStickers: { [weak self] completion in
if let strongSelf = self {
let controller = DrawingStickersScreen(context: strongSelf.context, selectSticker: { fileReference, node, rect in
completion(fileReference.media, fileReference.media.isAnimatedSticker, node.view, rect)
return true
})
strongSelf.present(controller, in: .window(.root))
return controller
} else {
return nil
}
}, sendMessagesWithSignals: { [weak self] signals, _, _ in
if let strongSelf = self { if let strongSelf = self {
strongSelf.interfaceInteraction?.setupEditMessage(messageId, { _ in }) strongSelf.interfaceInteraction?.setupEditMessage(messageId, { _ in })
strongSelf.editMessageMediaWithLegacySignals(signals!) strongSelf.editMessageMediaWithLegacySignals(signals!)
@ -2329,7 +2340,18 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} }
if let mediaReference = mediaReference, let peer = message.peers[message.id.peerId] { if let mediaReference = mediaReference, let peer = message.peers[message.id.peerId] {
legacyMediaEditor(context: strongSelf.context, peer: peer, media: mediaReference, initialCaption: message.text, presentStickers: { _ in return nil }, sendMessagesWithSignals: { [weak self] signals, _, _ in legacyMediaEditor(context: strongSelf.context, peer: peer, media: mediaReference, initialCaption: message.text, presentStickers: { [weak self] completion in
if let strongSelf = self {
let controller = DrawingStickersScreen(context: strongSelf.context, selectSticker: { fileReference, node, rect in
completion(fileReference.media, fileReference.media.isAnimatedSticker, node.view, rect)
return true
})
strongSelf.present(controller, in: .window(.root))
return controller
} else {
return nil
}
}, sendMessagesWithSignals: { [weak self] signals, _, _ in
if let strongSelf = self { if let strongSelf = self {
strongSelf.interfaceInteraction?.setupEditMessage(messageId, { _ in }) strongSelf.interfaceInteraction?.setupEditMessage(messageId, { _ in })
strongSelf.editMessageMediaWithLegacySignals(signals!) strongSelf.editMessageMediaWithLegacySignals(signals!)

View File

@ -643,79 +643,12 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
} }
if data.canEdit && !isPinnedMessages { if data.canEdit && !isPinnedMessages {
var mediaReference: AnyMediaReference?
for media in message.media {
if let image = media as? TelegramMediaImage, let _ = largestImageRepresentation(image.representations) {
mediaReference = ImageMediaReference.standalone(media: image).abstract
break
} else if let file = media as? TelegramMediaFile {
mediaReference = FileMediaReference.standalone(media: file).abstract
break
}
}
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_MessageDialogEdit, icon: { theme in actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_MessageDialogEdit, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Edit"), color: theme.actionSheet.primaryTextColor) return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Edit"), color: theme.actionSheet.primaryTextColor)
}, action: { c, f in }, action: { c, f in
if let _ = mediaReference?.media as? TelegramMediaImage { interfaceInteraction.setupEditMessage(messages[0].id, { transition in
var updatedItems: [ContextMenuItem] = [] f(.custom(transition))
updatedItems.append(.action(ContextMenuActionItem(text: message.text.isEmpty ? chatPresentationInterfaceState.strings.Conversation_AddCaption : chatPresentationInterfaceState.strings.Conversation_EditCaption, icon: { theme in })
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Caption"), color: theme.actionSheet.primaryTextColor)
}, action: { _, f in
interfaceInteraction.setupEditMessage(messages[0].id, { transition in
f(.custom(transition))
})
})))
updatedItems.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_EditThisPhoto, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Draw"), color: theme.actionSheet.primaryTextColor)
}, action: { _, f in
controllerInteraction.editMessageMedia(messages[0].id, true)
f(.dismissWithoutContent)
})))
updatedItems.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ReplacePhoto, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Replace"), color: theme.actionSheet.primaryTextColor)
}, action: { _, f in
controllerInteraction.editMessageMedia(messages[0].id, false)
f(.dismissWithoutContent)
})))
updatedItems.append(.separator)
updatedItems.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.ChatList_Context_Back, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Back"), color: theme.contextMenu.primaryColor)
}, action: { c, _ in
c.setItems(contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState: chatPresentationInterfaceState, context: context, messages: messages, controllerInteraction: controllerInteraction, selectAll: selectAll, interfaceInteraction: interfaceInteraction))
})))
c.setItems(.single(updatedItems))
} else if let _ = mediaReference?.media as? TelegramMediaFile {
var updatedItems: [ContextMenuItem] = []
updatedItems.append(.action(ContextMenuActionItem(text: message.text.isEmpty ? chatPresentationInterfaceState.strings.Conversation_AddCaption : chatPresentationInterfaceState.strings.Conversation_EditCaption, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Caption"), color: theme.actionSheet.primaryTextColor)
}, action: { _, f in
interfaceInteraction.setupEditMessage(messages[0].id, { transition in
f(.custom(transition))
})
})))
updatedItems.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ReplaceFile, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Replace"), color: theme.actionSheet.primaryTextColor)
}, action: { _, f in
controllerInteraction.editMessageMedia(messages[0].id, false)
f(.dismissWithoutContent)
})))
updatedItems.append(.separator)
updatedItems.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.ChatList_Context_Back, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Back"), color: theme.contextMenu.primaryColor)
}, action: { c, _ in
c.setItems(contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState: chatPresentationInterfaceState, context: context, messages: messages, controllerInteraction: controllerInteraction, selectAll: selectAll, interfaceInteraction: interfaceInteraction))
})))
c.setItems(.single(updatedItems))
} else {
interfaceInteraction.setupEditMessage(messages[0].id, { transition in
f(.custom(transition))
})
}
}))) })))
} }
@ -830,7 +763,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
let presentationData = context.sharedContext.currentPresentationData.with { $0 } let presentationData = context.sharedContext.currentPresentationData.with { $0 }
var warnAboutPrivate = false var warnAboutPrivate = false
if case let .peer = chatPresentationInterfaceState.chatLocation { if case .peer = chatPresentationInterfaceState.chatLocation {
if channel.addressName == nil { if channel.addressName == nil {
warnAboutPrivate = true warnAboutPrivate = true
} }

View File

@ -16,6 +16,7 @@ import ActivityIndicator
import AnimationUI import AnimationUI
private let accessoryButtonFont = Font.medium(14.0) private let accessoryButtonFont = Font.medium(14.0)
private let counterFont = Font.with(size: 14.0, design: .regular, traits: [.monospacedNumbers])
private final class AccessoryItemIconButton: HighlightTrackingButton { private final class AccessoryItemIconButton: HighlightTrackingButton {
private let item: ChatTextInputAccessoryItem private let item: ChatTextInputAccessoryItem
@ -1193,11 +1194,11 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
let textCount = Int32(textInputNode.textView.text.count) let textCount = Int32(textInputNode.textView.text.count)
let counterColor: UIColor = textCount > inputTextMaxLength ? presentationInterfaceState.theme.chat.inputPanel.panelControlDestructiveColor : presentationInterfaceState.theme.chat.inputPanel.panelControlColor let counterColor: UIColor = textCount > inputTextMaxLength ? presentationInterfaceState.theme.chat.inputPanel.panelControlDestructiveColor : presentationInterfaceState.theme.chat.inputPanel.panelControlColor
let remainingCount = inputTextMaxLength - textCount let remainingCount = max(-999, inputTextMaxLength - textCount)
let counterText = remainingCount >= 5 ? "" : "\(inputTextMaxLength - textCount)" let counterText = remainingCount >= 5 ? "" : "\(remainingCount)"
self.counterTextNode.attributedText = NSAttributedString(string: counterText, font: Font.regular(14.0), textColor: counterColor) self.counterTextNode.attributedText = NSAttributedString(string: counterText, font: counterFont, textColor: counterColor)
} else { } else {
self.counterTextNode.attributedText = NSAttributedString(string: "", font: Font.regular(14.0), textColor: .black) self.counterTextNode.attributedText = NSAttributedString(string: "", font: counterFont, textColor: .black)
} }
let counterSize = self.counterTextNode.updateLayout(CGSize(width: 44.0, height: 44.0)) let counterSize = self.counterTextNode.updateLayout(CGSize(width: 44.0, height: 44.0))
@ -1481,11 +1482,11 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
let textCount = Int32(textInputNode.textView.text.count) let textCount = Int32(textInputNode.textView.text.count)
let counterColor: UIColor = textCount > inputTextMaxLength ? presentationInterfaceState.theme.chat.inputPanel.panelControlDestructiveColor : presentationInterfaceState.theme.chat.inputPanel.panelControlColor let counterColor: UIColor = textCount > inputTextMaxLength ? presentationInterfaceState.theme.chat.inputPanel.panelControlDestructiveColor : presentationInterfaceState.theme.chat.inputPanel.panelControlColor
let remainingCount = inputTextMaxLength - textCount let remainingCount = max(-999, inputTextMaxLength - textCount)
let counterText = remainingCount >= 5 ? "" : "\(inputTextMaxLength - textCount)" let counterText = remainingCount >= 5 ? "" : "\(remainingCount)"
self.counterTextNode.attributedText = NSAttributedString(string: counterText, font: Font.regular(14.0), textColor: counterColor) self.counterTextNode.attributedText = NSAttributedString(string: counterText, font: counterFont, textColor: counterColor)
} else { } else {
self.counterTextNode.attributedText = NSAttributedString(string: "", font: Font.regular(14.0), textColor: .black) self.counterTextNode.attributedText = NSAttributedString(string: "", font: counterFont, textColor: .black)
} }
if let (width, leftInset, rightInset, maxHeight, metrics, isSecondary) = self.validLayout { if let (width, leftInset, rightInset, maxHeight, metrics, isSecondary) = self.validLayout {