diff --git a/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift b/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift index 3d94f3615c..4143af93ad 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift @@ -226,25 +226,23 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo self.paneContainerNode.interaction = interaction self.paneContainerNode.currentPaneUpdated = { [weak self] key, transitionFraction, transition in - if let strongSelf = self { - var filterKey: ChatListSearchFilter? - if let key = key { - switch key { - case .chats: - filterKey = .chats - case .media: - filterKey = .media - case .links: - filterKey = .links - case .files: - filterKey = .files - case .music: - filterKey = .music - case .voice: - filterKey = .voice - } + if let strongSelf = self, let key = key { + var filterKey: ChatListSearchFilter + switch key { + case .chats: + filterKey = .chats + case .media: + filterKey = .media + case .links: + filterKey = .links + case .files: + filterKey = .files + case .music: + filterKey = .music + case .voice: + filterKey = .voice } - strongSelf.selectedFilterKey = filterKey.flatMap { .filter($0.id) } + strongSelf.selectedFilterKey = .filter(filterKey.id) strongSelf.selectedFilterKeyPromise.set(.single(strongSelf.selectedFilterKey)) strongSelf.transitionFraction = transitionFraction diff --git a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift index b9142810d9..414d9441b5 100644 --- a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift @@ -694,7 +694,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { if !content.enableSound { isPaused = false } - } else { + } else if strongSelf.actionAtEnd == .stop { strongSelf.updateControlsVisibility(true) strongSelf.controlsTimer?.invalidate() strongSelf.controlsTimer = nil diff --git a/submodules/LegacyComponents/Sources/TGMediaAssetsGifCell.m b/submodules/LegacyComponents/Sources/TGMediaAssetsGifCell.m index 819953cfe1..ca3015a6e4 100644 --- a/submodules/LegacyComponents/Sources/TGMediaAssetsGifCell.m +++ b/submodules/LegacyComponents/Sources/TGMediaAssetsGifCell.m @@ -59,7 +59,7 @@ NSString *const TGMediaAssetsGifCellKind = @"TGMediaAssetsGifCellKind"; _typeLabel.textColor = [UIColor whiteColor]; _typeLabel.backgroundColor = [UIColor clearColor]; _typeLabel.textAlignment = NSTextAlignmentLeft; - _typeLabel.font = TGSystemFontOfSize(12.0f); + _typeLabel.font = TGBoldSystemFontOfSize(13); _typeLabel.text = @"GIF"; [_typeLabel sizeToFit]; [self addSubview:_typeLabel]; @@ -78,7 +78,9 @@ NSString *const TGMediaAssetsGifCellKind = @"TGMediaAssetsGifCellKind"; [super layoutSubviews]; _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 diff --git a/submodules/LegacyComponents/Sources/TGMediaAssetsVideoCell.m b/submodules/LegacyComponents/Sources/TGMediaAssetsVideoCell.m index e88099df21..69a26f9b7b 100644 --- a/submodules/LegacyComponents/Sources/TGMediaAssetsVideoCell.m +++ b/submodules/LegacyComponents/Sources/TGMediaAssetsVideoCell.m @@ -67,13 +67,12 @@ NSString *const TGMediaAssetsVideoCellKind = @"TGMediaAssetsVideoCellKind"; _iconView = [[UIImageView alloc] init]; _iconView.contentMode = UIViewContentModeCenter; - [self addSubview:_iconView]; _durationLabel = [[UILabel alloc] init]; _durationLabel.textColor = [UIColor whiteColor]; _durationLabel.backgroundColor = [UIColor clearColor]; _durationLabel.textAlignment = NSTextAlignmentRight; - _durationLabel.font = TGSystemFontOfSize(12.0f); + _durationLabel.font = TGBoldSystemFontOfSize(13); [_durationLabel sizeToFit]; [self addSubview:_durationLabel]; @@ -113,6 +112,7 @@ NSString *const TGMediaAssetsVideoCellKind = @"TGMediaAssetsVideoCellKind"; durationString = [NSString stringWithFormat:@"%d:%02d", duration / 60, duration % 60]; _durationLabel.text = durationString; + [_durationLabel sizeToFit]; if (asset.subtypes & TGMediaAssetSubtypeVideoTimelapse) _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 }; _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); - _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 diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerLayoutMetrics.m b/submodules/LegacyComponents/Sources/TGMediaPickerLayoutMetrics.m index a180be82f1..14eef45878 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerLayoutMetrics.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerLayoutMetrics.m @@ -51,40 +51,49 @@ CGSize itemSize = TGPhotoThumbnailSizeForCurrentScreen(); if ([UIScreen mainScreen].scale >= 2.0f - FLT_EPSILON) { - if (widescreenWidth >= 736.0f - FLT_EPSILON) + if (widescreenWidth >= 844.0f - FLT_EPSILON) { metrics->_normalItemSize = itemSize; metrics->_wideItemSize = itemSize; - metrics->_normalEdgeInsets = UIEdgeInsetsMake(4.0f, 0.0f, 2.0f, 0.0f); - metrics->_wideEdgeInsets = UIEdgeInsetsMake(4.0f, 2.0f, 1.0f, 2.0f); - metrics->_normalLineSpacing = 1.0f; + 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; + } + 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; } else if (widescreenWidth >= 667.0f - FLT_EPSILON) { metrics->_normalItemSize = itemSize; metrics->_wideItemSize = CGSizeMake(floor(itemSize.width), floor(itemSize.height)); - metrics->_normalEdgeInsets = UIEdgeInsetsMake(4.0f, 0.0f, 2.0f, 0.0f); - metrics->_wideEdgeInsets = UIEdgeInsetsMake(4.0f, 2.0f, 1.0f, 2.0f); - metrics->_normalLineSpacing = 1.0f; + 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; } else { metrics->_normalItemSize = itemSize; metrics->_wideItemSize = CGSizeMake(floor(itemSize.width), floor(itemSize.height)); - metrics->_normalEdgeInsets = UIEdgeInsetsMake(4.0f, 0.0f, 2.0f, 0.0f); - metrics->_wideEdgeInsets = UIEdgeInsetsMake(4.0f, 1.0f, 1.0f, 1.0f); + metrics->_normalEdgeInsets = UIEdgeInsetsMake(2.0f, 0.0f, 2.0f, 0.0f); + metrics->_wideEdgeInsets = UIEdgeInsetsMake(2.0f, 1.0f, 1.0f, 1.0f); metrics->_normalLineSpacing = 2.0f; - metrics->_wideLineSpacing = 3.0f; + metrics->_wideLineSpacing = 2.0f; } } else { metrics->_normalItemSize = itemSize; metrics->_wideItemSize = CGSizeMake(floor(itemSize.width), floor(itemSize.height)); - metrics->_normalEdgeInsets = UIEdgeInsetsMake(4.0f, 0.0f, 2.0f, 0.0f); - metrics->_wideEdgeInsets = UIEdgeInsetsMake(4.0f, 1.0f, 1.0f, 1.0f); + metrics->_normalEdgeInsets = UIEdgeInsetsMake(2.0f, 0.0f, 2.0f, 0.0f); + metrics->_wideEdgeInsets = UIEdgeInsetsMake(2.0f, 1.0f, 1.0f, 1.0f); metrics->_normalLineSpacing = 2.0f; metrics->_wideLineSpacing = 2.0f; } diff --git a/submodules/LegacyComponents/Sources/TGNavigationBar.m b/submodules/LegacyComponents/Sources/TGNavigationBar.m index 9db9f3ba8f..57a2ba7d6c 100644 --- a/submodules/LegacyComponents/Sources/TGNavigationBar.m +++ b/submodules/LegacyComponents/Sources/TGNavigationBar.m @@ -204,9 +204,23 @@ static id _musicPlayerProvider; - (void)layoutSubviews { - [self updateLayout]; - [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 @@ -217,7 +231,13 @@ static id _musicPlayerProvider; if (iosMajorVersion() >= 11 && self.superview.safeAreaInsets.top > FLT_EPSILON) 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) _barBackgroundView.frame = _backgroundContainerView.bounds; @@ -298,6 +318,10 @@ static id _musicPlayerProvider; - (void)setFrame:(CGRect)frame { + if (frame.size.height < 56.0) { + frame.size.height = 56.0; + } + [super setFrame:frame]; if (_statusBarBackgroundView != nil && _statusBarBackgroundView.superview != nil) diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorUtils.m b/submodules/LegacyComponents/Sources/TGPhotoEditorUtils.m index c2a2882fe3..43490ea095 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorUtils.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorUtils.m @@ -26,27 +26,31 @@ CGSize TGPhotoThumbnailSizeForCurrentScreen() { 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) { - return CGSizeMake(93.0f, 93.0f); + return CGSizeMake(124.0f - TGScreenPixel, 124.0f - TGScreenPixel); } 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) { - return CGSizeMake(93.0f, 93.5f); + return CGSizeMake(124.0f - TGScreenPixel, 124.0f - TGScreenPixel); } 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) diff --git a/submodules/LegacyComponents/Sources/TGPhotoPaintController.m b/submodules/LegacyComponents/Sources/TGPhotoPaintController.m index 06583aa272..f90dad60c1 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoPaintController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoPaintController.m @@ -347,7 +347,7 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f; [_doneButton setTitle:TGLocalized(@"Common.Done") forState:UIControlStateNormal]; _doneButton.titleLabel.font = TGSystemFontOfSize(17.0); [_doneButton sizeToFit]; - [_wrapperView addSubview:_doneButton]; +// [_wrapperView addSubview:_doneButton]; void (^settingsPressed)(void) = ^ { diff --git a/submodules/LegacyComponents/Sources/TGViewController.mm b/submodules/LegacyComponents/Sources/TGViewController.mm index 1ae75b6b6d..d8dd2aad62 100644 --- a/submodules/LegacyComponents/Sources/TGViewController.mm +++ b/submodules/LegacyComponents/Sources/TGViewController.mm @@ -1026,7 +1026,7 @@ static id _defaultContext = nil; - (CGFloat)navigationBarHeightForInterfaceOrientation:(UIInterfaceOrientation)orientation { - static CGFloat portraitHeight = 44.0f; + static CGFloat portraitHeight = 56.0f; static CGFloat landscapeHeight = 32.0f; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^ @@ -1035,13 +1035,13 @@ static id _defaultContext = nil; CGFloat widescreenWidth = MAX(screenSize.width, screenSize.height); if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && ABS(widescreenWidth - 736) > FLT_EPSILON) { - portraitHeight = 44.0f; - landscapeHeight = 32.0f; + portraitHeight = 56.0f; + landscapeHeight = 56.0f; } else { - portraitHeight = 44.0f; - landscapeHeight = 44.0f; + portraitHeight = 56.0f; + landscapeHeight = 56.0f; } }); bool large = UIInterfaceOrientationIsPortrait(orientation) || self.alwaysUseTallNavigationBarHeight; diff --git a/submodules/MediaPlayer/Sources/MediaPlayer.swift b/submodules/MediaPlayer/Sources/MediaPlayer.swift index 1ac1ab6327..750330d180 100644 --- a/submodules/MediaPlayer/Sources/MediaPlayer.swift +++ b/submodules/MediaPlayer/Sources/MediaPlayer.swift @@ -870,12 +870,12 @@ private final class MediaPlayerContext { var statusTimestamp = CACurrentMediaTime() let playbackStatus: MediaPlayerPlaybackStatus + var isPlaying = false + if case .playing = self.state { + isPlaying = true + } if let bufferingProgress = bufferingProgress { - var whilePlaying = false - if case .playing = self.state { - whilePlaying = true - } - playbackStatus = .buffering(initial: false, whilePlaying: whilePlaying, progress: Float(bufferingProgress), display: true) + playbackStatus = .buffering(initial: false, whilePlaying: isPlaying, progress: Float(bufferingProgress), display: true) } else if !rate.isZero { if reportRate.isZero { //playbackStatus = .buffering(initial: false, whilePlaying: true) @@ -885,8 +885,13 @@ private final class MediaPlayerContext { playbackStatus = .playing } } 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 { lastStatusUpdateTimestamp = statusTimestamp var reportTimestamp = timestamp diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index d889eb5590..83f2b82b5a 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -636,7 +636,18 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } 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 { strongSelf.interfaceInteraction?.setupEditMessage(messageId, { _ in }) 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] { - 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 { strongSelf.interfaceInteraction?.setupEditMessage(messageId, { _ in }) strongSelf.editMessageMediaWithLegacySignals(signals!) diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift index 45cfcd0805..960b5ba8a3 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift @@ -643,79 +643,12 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState } 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 return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Edit"), color: theme.actionSheet.primaryTextColor) }, action: { c, f in - if let _ = mediaReference?.media as? TelegramMediaImage { - 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_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)) - }) - } + interfaceInteraction.setupEditMessage(messages[0].id, { transition in + f(.custom(transition)) + }) }))) } @@ -830,7 +763,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState let presentationData = context.sharedContext.currentPresentationData.with { $0 } var warnAboutPrivate = false - if case let .peer = chatPresentationInterfaceState.chatLocation { + if case .peer = chatPresentationInterfaceState.chatLocation { if channel.addressName == nil { warnAboutPrivate = true } diff --git a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift index 4c2a78ae56..093531fe10 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift @@ -16,6 +16,7 @@ import ActivityIndicator import AnimationUI 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 let item: ChatTextInputAccessoryItem @@ -1193,11 +1194,11 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { let textCount = Int32(textInputNode.textView.text.count) let counterColor: UIColor = textCount > inputTextMaxLength ? presentationInterfaceState.theme.chat.inputPanel.panelControlDestructiveColor : presentationInterfaceState.theme.chat.inputPanel.panelControlColor - let remainingCount = inputTextMaxLength - textCount - let counterText = remainingCount >= 5 ? "" : "\(inputTextMaxLength - textCount)" - self.counterTextNode.attributedText = NSAttributedString(string: counterText, font: Font.regular(14.0), textColor: counterColor) + let remainingCount = max(-999, inputTextMaxLength - textCount) + let counterText = remainingCount >= 5 ? "" : "\(remainingCount)" + self.counterTextNode.attributedText = NSAttributedString(string: counterText, font: counterFont, textColor: counterColor) } 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)) @@ -1481,11 +1482,11 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { let textCount = Int32(textInputNode.textView.text.count) let counterColor: UIColor = textCount > inputTextMaxLength ? presentationInterfaceState.theme.chat.inputPanel.panelControlDestructiveColor : presentationInterfaceState.theme.chat.inputPanel.panelControlColor - let remainingCount = inputTextMaxLength - textCount - let counterText = remainingCount >= 5 ? "" : "\(inputTextMaxLength - textCount)" - self.counterTextNode.attributedText = NSAttributedString(string: counterText, font: Font.regular(14.0), textColor: counterColor) + let remainingCount = max(-999, inputTextMaxLength - textCount) + let counterText = remainingCount >= 5 ? "" : "\(remainingCount)" + self.counterTextNode.attributedText = NSAttributedString(string: counterText, font: counterFont, textColor: counterColor) } 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 {