mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Stories
This commit is contained in:
parent
37f281dd40
commit
295a29332d
@ -1264,36 +1264,18 @@ open class TextNode: ASDisplayNode {
|
||||
if didClipLinebreak {
|
||||
coreTextLine = originalLine
|
||||
additionalTrailingLine = (truncationToken, truncationTokenWidth)
|
||||
|
||||
/*let mergedLine = NSMutableAttributedString()
|
||||
mergedLine.append(attributedString.attributedSubstring(from: NSRange(location: lineRange.location, length: lineRange.length)))
|
||||
mergedLine.append(truncatedTokenString)
|
||||
|
||||
coreTextLine = CTLineCreateWithAttributedString(mergedLine)
|
||||
|
||||
let runs = (CTLineGetGlyphRuns(coreTextLine) as [AnyObject]) as! [CTRun]
|
||||
for run in runs {
|
||||
let runAttributes: NSDictionary = CTRunGetAttributes(run)
|
||||
if let _ = runAttributes["CTForegroundColorFromContext"] {
|
||||
brokenLineRange.length = CTRunGetStringRange(run).location - brokenLineRange.location
|
||||
break
|
||||
}
|
||||
}
|
||||
if brokenLineRange.location + brokenLineRange.length > lineRange.location + lineRange.length {
|
||||
brokenLineRange.location = lineRange.location
|
||||
brokenLineRange.length = lineRange.length
|
||||
}
|
||||
if brokenLineRange.location + brokenLineRange.length > attributedString.length {
|
||||
brokenLineRange.length = attributedString.length - brokenLineRange.location
|
||||
}
|
||||
effectiveLineRange = brokenLineRange*/
|
||||
|
||||
truncated = true
|
||||
} else {
|
||||
coreTextLine = originalLine
|
||||
}
|
||||
} else {
|
||||
coreTextLine = CTLineCreateTruncatedLine(originalLine, Double(lineConstrainedSize.width), truncationType, truncationToken) ?? truncationToken
|
||||
var availableLineConstrainedWidth = lineConstrainedSize.width
|
||||
if customTruncationToken != nil {
|
||||
availableLineConstrainedWidth -= truncationTokenWidth
|
||||
}
|
||||
|
||||
coreTextLine = CTLineCreateTruncatedLine(originalLine, Double(availableLineConstrainedWidth), truncationType, truncationToken) ?? truncationToken
|
||||
|
||||
let runs = (CTLineGetGlyphRuns(coreTextLine) as [AnyObject]) as! [CTRun]
|
||||
for run in runs {
|
||||
let runAttributes: NSDictionary = CTRunGetAttributes(run)
|
||||
@ -1302,9 +1284,6 @@ open class TextNode: ASDisplayNode {
|
||||
break
|
||||
}
|
||||
}
|
||||
if customTruncationToken != nil {
|
||||
assert(true)
|
||||
}
|
||||
effectiveLineRange = CFRange(location: effectiveLineRange.location, length: 0)
|
||||
for run in runs {
|
||||
let runRange = CTRunGetStringRange(run)
|
||||
|
@ -53,7 +53,7 @@ final class PeerInfoStoryGridScreenComponent: Component {
|
||||
private weak var state: EmptyComponentState?
|
||||
private var environment: EnvironmentType?
|
||||
|
||||
private var paneNode: PeerInfoStoryPaneNode?
|
||||
private(set) var paneNode: PeerInfoStoryPaneNode?
|
||||
private var paneStatusDisposable: Disposable?
|
||||
private(set) var paneStatusText: String?
|
||||
|
||||
@ -171,74 +171,6 @@ final class PeerInfoStoryGridScreenComponent: Component {
|
||||
self.environment?.controller()?.push(PeerInfoStoryGridScreen(context: component.context, peerId: component.peerId, scope: .archive))
|
||||
})))
|
||||
}
|
||||
|
||||
/*if photoCount != 0 && videoCount != 0 {
|
||||
items.append(.separator)
|
||||
|
||||
let showPhotos: Bool
|
||||
switch pane.contentType {
|
||||
case .photo, .photoOrVideo:
|
||||
showPhotos = true
|
||||
default:
|
||||
showPhotos = false
|
||||
}
|
||||
let showVideos: Bool
|
||||
switch pane.contentType {
|
||||
case .video, .photoOrVideo:
|
||||
showVideos = true
|
||||
default:
|
||||
showVideos = false
|
||||
}
|
||||
|
||||
items.append(.action(ContextMenuActionItem(text: strings.SharedMedia_ShowPhotos, icon: { theme in
|
||||
if !showPhotos {
|
||||
return nil
|
||||
}
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor)
|
||||
}, action: { [weak pane] _, a in
|
||||
a(.default)
|
||||
|
||||
guard let pane = pane else {
|
||||
return
|
||||
}
|
||||
let updatedContentType: PeerInfoVisualMediaPaneNode.ContentType
|
||||
switch pane.contentType {
|
||||
case .photoOrVideo:
|
||||
updatedContentType = .video
|
||||
case .photo:
|
||||
updatedContentType = .photo
|
||||
case .video:
|
||||
updatedContentType = .photoOrVideo
|
||||
default:
|
||||
updatedContentType = pane.contentType
|
||||
}
|
||||
pane.updateContentType(contentType: updatedContentType)
|
||||
})))
|
||||
items.append(.action(ContextMenuActionItem(text: strings.SharedMedia_ShowVideos, icon: { theme in
|
||||
if !showVideos {
|
||||
return nil
|
||||
}
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor)
|
||||
}, action: { [weak pane] _, a in
|
||||
a(.default)
|
||||
|
||||
guard let pane = pane else {
|
||||
return
|
||||
}
|
||||
let updatedContentType: PeerInfoVisualMediaPaneNode.ContentType
|
||||
switch pane.contentType {
|
||||
case .photoOrVideo:
|
||||
updatedContentType = .photo
|
||||
case .photo:
|
||||
updatedContentType = .photoOrVideo
|
||||
case .video:
|
||||
updatedContentType = .video
|
||||
default:
|
||||
updatedContentType = pane.contentType
|
||||
}
|
||||
pane.updateContentType(contentType: updatedContentType)
|
||||
})))
|
||||
}*/
|
||||
}
|
||||
|
||||
let contextController = ContextController(account: component.context.account, presentationData: presentationData, source: .reference(PeerInfoContextReferenceContentSource(controller: controller, sourceNode: source)), items: .single(ContextController.Items(content: .list(items))), gesture: nil)
|
||||
@ -554,8 +486,6 @@ public class PeerInfoStoryGridScreen: ViewControllerComponentContainer {
|
||||
}
|
||||
moreBarButton.addTarget(self, action: #selector(self.morePressed), forControlEvents: .touchUpInside)
|
||||
|
||||
self.navigationItem.setRightBarButton(moreBarButtonItem, animated: false)
|
||||
|
||||
self.titleView = ChatTitleView(
|
||||
context: context, theme:
|
||||
presentationData.theme,
|
||||
@ -594,6 +524,8 @@ public class PeerInfoStoryGridScreen: ViewControllerComponentContainer {
|
||||
title = nil
|
||||
}
|
||||
self.titleView?.titleContent = .custom(presentationData.strings.StoryList_TitleSaved, title, false)
|
||||
|
||||
self.navigationItem.setRightBarButton(self.moreBarButtonItem, animated: false)
|
||||
case .archive:
|
||||
guard let componentView = self.node.hostView.componentView as? PeerInfoStoryGridScreenComponent.View else {
|
||||
return
|
||||
@ -605,6 +537,19 @@ public class PeerInfoStoryGridScreen: ViewControllerComponentContainer {
|
||||
title = presentationData.strings.StoryList_TitleArchive
|
||||
}
|
||||
self.titleView?.titleContent = .custom(title, nil, false)
|
||||
|
||||
var hasMenu = false
|
||||
if componentView.selectedCount != 0 {
|
||||
hasMenu = true
|
||||
} else if let paneNode = componentView.paneNode, !paneNode.isEmpty {
|
||||
hasMenu = true
|
||||
}
|
||||
|
||||
if hasMenu {
|
||||
self.navigationItem.setRightBarButton(self.moreBarButtonItem, animated: false)
|
||||
} else {
|
||||
self.navigationItem.setRightBarButton(nil, animated: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,6 +171,13 @@ public extension StoryContainerScreen {
|
||||
|> take(1)
|
||||
|> mapToSignal { state -> Signal<StoryContentContextState, NoError> in
|
||||
if let slice = state.slice {
|
||||
#if DEBUG && true
|
||||
if "".isEmpty {
|
||||
return .single(state)
|
||||
|> delay(4.0, queue: .mainQueue())
|
||||
}
|
||||
#endif
|
||||
|
||||
return waitUntilStoryMediaPreloaded(context: context, peerId: slice.peer.id, storyItem: slice.item.storyItem)
|
||||
|> timeout(4.0, queue: .mainQueue(), alternate: .complete())
|
||||
|> map { _ -> StoryContentContextState in
|
||||
|
@ -374,6 +374,7 @@ public final class StoryPeerListComponent: Component {
|
||||
|
||||
self.scrollContainerView = UIView()
|
||||
self.scrollContainerView.clipsToBounds = true
|
||||
self.scrollContainerView.isExclusiveTouch = true
|
||||
|
||||
self.titleView = UIImageView()
|
||||
self.titleView.layer.anchorPoint = CGPoint(x: 0.0, y: 0.5)
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit ef358c48b05ccd59319a7ceded340b75baffa751
|
||||
Subproject commit ebc8452d3a0d0bc18822b4eb6ca61ec8fa7a70a5
|
Loading…
x
Reference in New Issue
Block a user