mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Various fixes
This commit is contained in:
parent
d83e420ab7
commit
0fae76effd
@ -50,7 +50,7 @@ private final class AvatarComponent: Component {
|
|||||||
self.component = component
|
self.component = component
|
||||||
self.state = state
|
self.state = state
|
||||||
|
|
||||||
let size = CGSize(width: 36.0, height: 36.0)
|
let size = CGSize(width: 32.0, height: 32.0)
|
||||||
|
|
||||||
self.avatarNode.frame = CGRect(origin: CGPoint(), size: size)
|
self.avatarNode.frame = CGRect(origin: CGPoint(), size: size)
|
||||||
self.avatarNode.setPeer(
|
self.avatarNode.setPeer(
|
||||||
@ -177,14 +177,14 @@ final class StoryPreviewComponent: Component {
|
|||||||
let cancelButtonSize = self.cancelButton.update(
|
let cancelButtonSize = self.cancelButton.update(
|
||||||
transition: transition,
|
transition: transition,
|
||||||
component: AnyComponent(BundleIconComponent(
|
component: AnyComponent(BundleIconComponent(
|
||||||
name: "Media Gallery/Close",
|
name: "Stories/Close",
|
||||||
tintColor: UIColor.white
|
tintColor: UIColor.white
|
||||||
)),
|
)),
|
||||||
environment: {},
|
environment: {},
|
||||||
containerSize: CGSize(width: 44.0, height: 44.0)
|
containerSize: CGSize(width: 44.0, height: 44.0)
|
||||||
)
|
)
|
||||||
let cancelButtonFrame = CGRect(
|
let cancelButtonFrame = CGRect(
|
||||||
origin: CGPoint(x: 17.0, y: 24.0),
|
origin: CGPoint(x: availableSize.width - 40.0, y: 19.0),
|
||||||
size: cancelButtonSize
|
size: cancelButtonSize
|
||||||
)
|
)
|
||||||
if let cancelButtonView = self.cancelButton.view {
|
if let cancelButtonView = self.cancelButton.view {
|
||||||
@ -203,10 +203,10 @@ final class StoryPreviewComponent: Component {
|
|||||||
peer: accountPeer
|
peer: accountPeer
|
||||||
)),
|
)),
|
||||||
environment: {},
|
environment: {},
|
||||||
containerSize: CGSize(width: 44.0, height: 44.0)
|
containerSize: CGSize(width: 32.0, height: 32.0)
|
||||||
)
|
)
|
||||||
let avatarFrame = CGRect(
|
let avatarFrame = CGRect(
|
||||||
origin: CGPoint(x: availableSize.width - avatarSize.width - 6.0, y: 14.0),
|
origin: CGPoint(x: 12.0, y: 18.0),
|
||||||
size: avatarSize
|
size: avatarSize
|
||||||
)
|
)
|
||||||
if let avatarView = self.avatar.view {
|
if let avatarView = self.avatar.view {
|
||||||
@ -222,14 +222,14 @@ final class StoryPreviewComponent: Component {
|
|||||||
transition: transition,
|
transition: transition,
|
||||||
component: AnyComponent(Text(
|
component: AnyComponent(Text(
|
||||||
text: "My story",
|
text: "My story",
|
||||||
font: Font.semibold(17.0),
|
font: Font.medium(14.0),
|
||||||
color: .white
|
color: .white
|
||||||
)),
|
)),
|
||||||
environment: {},
|
environment: {},
|
||||||
containerSize: CGSize(width: 180.0, height: 44.0)
|
containerSize: CGSize(width: 180.0, height: 44.0)
|
||||||
)
|
)
|
||||||
let titleFrame = CGRect(
|
let titleFrame = CGRect(
|
||||||
origin: CGPoint(x: floorToScreenPixels((availableSize.width - titleSize.width) / 2.0), y: 21.0),
|
origin: CGPoint(x: 53.0, y: floorToScreenPixels(33.0 - titleSize.height / 2.0)),
|
||||||
size: titleSize
|
size: titleSize
|
||||||
)
|
)
|
||||||
if let titleView = self.title.view {
|
if let titleView = self.title.view {
|
||||||
|
@ -449,7 +449,7 @@ final class StoryContentCaptionComponent: Component {
|
|||||||
self.dustNode = dustNode
|
self.dustNode = dustNode
|
||||||
self.scrollView.insertSubview(dustNode.view, aboveSubview: spoilerTextNode.textNode.view)
|
self.scrollView.insertSubview(dustNode.view, aboveSubview: spoilerTextNode.textNode.view)
|
||||||
}
|
}
|
||||||
dustNode.frame = textFrame.insetBy(dx: -3.0, dy: -3.0).offsetBy(dx: 0.0, dy: 3.0)
|
dustNode.frame = textFrame.insetBy(dx: -3.0, dy: -3.0).offsetBy(dx: 0.0, dy: 0.0)
|
||||||
dustNode.update(size: dustNode.frame.size, color: .white, textColor: .white, rects: textLayout.0.spoilers.map { $0.1.offsetBy(dx: 3.0, dy: 3.0).insetBy(dx: 1.0, dy: 1.0) }, wordRects: textLayout.0.spoilerWords.map { $0.1.offsetBy(dx: 3.0, dy: 3.0).insetBy(dx: 1.0, dy: 1.0) })
|
dustNode.update(size: dustNode.frame.size, color: .white, textColor: .white, rects: textLayout.0.spoilers.map { $0.1.offsetBy(dx: 3.0, dy: 3.0).insetBy(dx: 1.0, dy: 1.0) }, wordRects: textLayout.0.spoilerWords.map { $0.1.offsetBy(dx: 3.0, dy: 3.0).insetBy(dx: 1.0, dy: 1.0) })
|
||||||
} else if let spoilerTextNode = self.spoilerTextNode {
|
} else if let spoilerTextNode = self.spoilerTextNode {
|
||||||
self.spoilerTextNode = nil
|
self.spoilerTextNode = nil
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
import Foundation
|
|
||||||
import UIKit
|
|
||||||
import Display
|
|
||||||
import ComponentFlow
|
|
||||||
import AccountContext
|
|
||||||
import TelegramCore
|
|
||||||
import TelegramStringFormatting
|
|
||||||
|
|
||||||
final class StoryPositionInfoComponent: Component {
|
|
||||||
let context: AccountContext
|
|
||||||
let position: Int
|
|
||||||
let totalCount: Int
|
|
||||||
|
|
||||||
init(context: AccountContext, position: Int, totalCount: Int) {
|
|
||||||
self.context = context
|
|
||||||
self.position = position
|
|
||||||
self.totalCount = totalCount
|
|
||||||
}
|
|
||||||
|
|
||||||
static func ==(lhs: StoryPositionInfoComponent, rhs: StoryPositionInfoComponent) -> Bool {
|
|
||||||
if lhs.context !== rhs.context {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if lhs.position != rhs.position {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if lhs.totalCount != rhs.totalCount {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
final class View: UIView {
|
|
||||||
private let title = ComponentView<Empty>()
|
|
||||||
|
|
||||||
private var component: StoryPositionInfoComponent?
|
|
||||||
private weak var state: EmptyComponentState?
|
|
||||||
|
|
||||||
override init(frame: CGRect) {
|
|
||||||
super.init(frame: frame)
|
|
||||||
|
|
||||||
self.isUserInteractionEnabled = false
|
|
||||||
}
|
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
|
||||||
fatalError("init(coder:) has not been implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func update(component: StoryPositionInfoComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
|
||||||
self.component = component
|
|
||||||
self.state = state
|
|
||||||
|
|
||||||
let size = availableSize
|
|
||||||
|
|
||||||
let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 })
|
|
||||||
|
|
||||||
let position = max(0, min(component.position + 1, component.totalCount))
|
|
||||||
let title = presentationData.strings.Items_NOfM("\(position)", "\(component.totalCount)").string
|
|
||||||
let titleSize = self.title.update(
|
|
||||||
transition: .immediate,
|
|
||||||
component: AnyComponent(Text(text: title, font: Font.with(size: 17.0, weight: .semibold, traits: .monospacedNumbers), color: .white)),
|
|
||||||
environment: {},
|
|
||||||
containerSize: availableSize
|
|
||||||
)
|
|
||||||
|
|
||||||
let contentHeight: CGFloat = titleSize.height
|
|
||||||
let titleFrame = CGRect(origin: CGPoint(x: floor((availableSize.width - titleSize.width) * 0.5), y: floor((availableSize.height - contentHeight) * 0.5)), size: titleSize)
|
|
||||||
|
|
||||||
if let titleView = self.title.view {
|
|
||||||
if titleView.superview == nil {
|
|
||||||
titleView.isUserInteractionEnabled = false
|
|
||||||
self.addSubview(titleView)
|
|
||||||
}
|
|
||||||
transition.setFrame(view: titleView, frame: titleFrame)
|
|
||||||
}
|
|
||||||
|
|
||||||
return size
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeView() -> View {
|
|
||||||
return View(frame: CGRect())
|
|
||||||
}
|
|
||||||
|
|
||||||
func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
|
||||||
return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user