This commit is contained in:
Ali 2020-01-14 18:08:46 +04:00
parent d6de8a7db1
commit 66358399e5
8 changed files with 48 additions and 12 deletions

View File

@ -5268,13 +5268,13 @@ Any member of this group will be able to see messages in the channel.";
"PollResults.Title" = "Poll Results";
"PollResults.Collapse" = "COLLAPSE";
"PollResults.ShowMore_1" = "Show %@ More Person";
"PollResults.ShowMore_any" = "Show %@ More People";
"PollResults.ShowMore_1" = "Show %@ More";
"PollResults.ShowMore_any" = "Show %@ More";
"Conversation.StopQuiz" = "Stop Quiz";
"Conversation.StopQuizConfirmationTitle" = "If you stop this quiz now, nobody will be able to submit answers. This action cannot be undone.";
"Conversation.StopQuizConfirmation" = "Stop Quiz";
"Forward.ErrorDisabledForChat" = "Sorry, you can't forward messages to this chat.";
"Forward.ErrorPublicPollDisabledInChannels" = "Sorry, you can't forward public poll to the channel.";
"Forward.ErrorPublicQuizDisabledInChannels" = "Sorry, you can't forward public quiz to the channel.";
"Forward.ErrorPublicPollDisabledInChannels" = "Sorry, public polls cant be forwarded to channels.";
"Forward.ErrorPublicQuizDisabledInChannels" = "Sorry, public polls cant be forwarded to channels.";

View File

@ -416,7 +416,7 @@ public final class AvatarNode: ASDisplayNode {
if peerId.namespace == -1 {
colorIndex = -1
} else {
colorIndex = abs(Int(clamping: accountPeerId.id &+ peerId.id))
colorIndex = abs(Int(clamping: peerId.id))
}
} else {
colorIndex = -1
@ -582,6 +582,8 @@ public func drawPeerAvatarLetters(context: CGContext, size: CGSize, font: UIFont
context.drawLinearGradient(gradient, start: CGPoint(), end: CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions())
context.resetClip()
context.setBlendMode(.normal)
let string = letters.count == 0 ? "" : (letters[0] + (letters.count == 1 ? "" : letters[1]))
@ -597,7 +599,9 @@ public func drawPeerAvatarLetters(context: CGContext, size: CGSize, font: UIFont
context.scaleBy(x: 1.0, y: -1.0)
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
let textPosition = context.textPosition
context.translateBy(x: lineOrigin.x, y: lineOrigin.y)
CTLineDraw(line, context)
context.translateBy(x: -lineOrigin.x, y: -lineOrigin.y)
context.textPosition = textPosition
}

View File

@ -5,6 +5,8 @@ public class DirectionalPanGestureRecognizer: UIPanGestureRecognizer {
private var validatedGesture = false
private var firstLocation: CGPoint = CGPoint()
public var shouldBegin: ((CGPoint) -> Bool)?
override public init(target: Any?, action: Selector?) {
super.init(target: target, action: action)
@ -21,7 +23,13 @@ public class DirectionalPanGestureRecognizer: UIPanGestureRecognizer {
super.touchesBegan(touches, with: event)
let touch = touches.first!
self.firstLocation = touch.location(in: self.view)
let point = touch.location(in: self.view)
if let shouldBegin = self.shouldBegin, !shouldBegin(point) {
self.state = .failed
return
}
self.firstLocation = point
if let target = self.view?.hitTest(self.firstLocation, with: event) {
if target == self.view {

View File

@ -296,7 +296,13 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, editMediaO
})!
itemViews.append(locationItem)
if (peer is TelegramGroup || peer is TelegramChannel) && canSendMessagesToPeer(peer) && canSendPolls {
var peerSupportsPolls = false
if peer is TelegramGroup || peer is TelegramChannel {
peerSupportsPolls = true
} else if let user = peer as? TelegramUser, let _ = user.botInfo {
peerSupportsPolls = true
}
if peerSupportsPolls && canSendMessagesToPeer(peer) && canSendPolls {
let pollItem = TGMenuSheetButtonItemView(title: presentationData.strings.AttachmentMenu_Poll, type: TGMenuSheetButtonTypeDefault, fontSize: fontSize, action: { [weak controller] in
controller?.dismiss(animated: true)
openPoll()

View File

@ -229,7 +229,7 @@ private final class PollResultsOptionContext {
}
|> mapToSignal { inputPeer -> Signal<([RenderedPeer], Int, String?), NoError> in
if let inputPeer = inputPeer {
let signal = account.network.request(Api.functions.messages.getPollVotes(flags: 1 << 0, peer: inputPeer, id: messageId.id, option: Buffer(data: opaqueIdentifier), offset: nextOffset, limit: nextOffset == nil ? 10 : 50))
let signal = account.network.request(Api.functions.messages.getPollVotes(flags: 1 << 0, peer: inputPeer, id: messageId.id, option: Buffer(data: opaqueIdentifier), offset: nextOffset, limit: nextOffset == nil ? 15 : 50))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.messages.VotesList?, NoError> in
return .single(nil)

View File

@ -1351,7 +1351,7 @@ class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode {
if optionNode.frame.contains(point), case .tap = gesture {
if optionNode.isUserInteractionEnabled {
return .ignore
} else if let result = optionNode.currentResult, let item = self.item, let option = optionNode.option {
} else if let result = optionNode.currentResult, let item = self.item, let poll = self.poll, case .public = poll.publicity, let option = optionNode.option {
if !isEstimating {
item.controllerInteraction.openMessagePollResults(item.message.id, option.opaqueIdentifier)
return .ignore
@ -1543,6 +1543,7 @@ private final class MergedAvatarsNode: ASDisplayNode {
case let .letters(peerId, letters):
context.translateBy(x: currentX, y: 0.0)
drawPeerAvatarLetters(context: context, size: CGSize(width: mergedImageSize, height: mergedImageSize), font: avatarFont, letters: letters, peerId: peerId)
context.translateBy(x: -currentX, y: 0.0)
case let .image(reference):
if let image = parameters.images[parameters.peers[i].peerId] {
context.translateBy(x: imageRect.midX, y: imageRect.midY)

View File

@ -259,7 +259,18 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, UIGestu
panRecognizer.delegate = self
panRecognizer.delaysTouchesBegan = false
panRecognizer.cancelsTouchesInView = true
//self.view.addGestureRecognizer(panRecognizer)
panRecognizer.shouldBegin = { [weak self] point in
guard let strongSelf = self else {
return false
}
if strongSelf.controlsNode.bounds.contains(strongSelf.view.convert(point, to: strongSelf.controlsNode.view)) {
if strongSelf.controlsNode.frame.maxY <= strongSelf.historyNode.frame.minY {
return true
}
}
return false
}
self.view.addGestureRecognizer(panRecognizer)
}
func updatePresentationData(_ presentationData: PresentationData) {
@ -325,7 +336,9 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, UIGestu
if self.controlsNode.bounds.contains(self.view.convert(point, to: self.controlsNode.view)) {
let controlsHitTest = self.controlsNode.view.hitTest(self.view.convert(point, to: self.controlsNode.view), with: event)
if controlsHitTest == nil {
return self.historyNode.view
if self.controlsNode.frame.maxY > self.historyNode.frame.minY {
return self.historyNode.view
}
}
}

View File

@ -322,13 +322,17 @@ public func pollResultsController(context: AccountContext, messageId: MessageId,
var initialScrollToItem: ListViewScrollToItem?
if let focusOnOptionWithOpaqueIdentifier = focusOnOptionWithOpaqueIdentifier, previousWasEmptyValue == nil {
var isFirstOption = true
loop: for i in 0 ..< entries.count {
switch entries[i] {
case let .optionPeer(optionPeer):
if optionPeer.opaqueIdentifier == focusOnOptionWithOpaqueIdentifier {
initialScrollToItem = ListViewScrollToItem(index: i, position: .top(0.0), animated: false, curve: .Default(duration: nil), directionHint: .Down)
if !isFirstOption {
initialScrollToItem = ListViewScrollToItem(index: i, position: .top(0.0), animated: false, curve: .Default(duration: nil), directionHint: .Down)
}
break loop
}
isFirstOption = false
default:
break
}