mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-01 04:08:07 +00:00
Various fixes
This commit is contained in:
parent
785e92c565
commit
22449d49e2
@ -666,6 +666,7 @@ private final class DemoSheetContent: CombinedComponent {
|
|||||||
let background = Child(GradientBackgroundComponent.self)
|
let background = Child(GradientBackgroundComponent.self)
|
||||||
let pager = Child(DemoPagerComponent.self)
|
let pager = Child(DemoPagerComponent.self)
|
||||||
let button = Child(SolidRoundedButtonComponent.self)
|
let button = Child(SolidRoundedButtonComponent.self)
|
||||||
|
let measureText = Child(MultilineTextComponent.self)
|
||||||
|
|
||||||
return { context in
|
return { context in
|
||||||
let environment = context.environment[ViewControllerComponentContainer.Environment.self].value
|
let environment = context.environment[ViewControllerComponentContainer.Environment.self].value
|
||||||
@ -1003,6 +1004,8 @@ private final class DemoSheetContent: CombinedComponent {
|
|||||||
.cornerRadius(15.0)
|
.cornerRadius(15.0)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var measuredTextHeight: CGFloat?
|
||||||
|
|
||||||
let buttonText: String
|
let buttonText: String
|
||||||
var buttonAnimationName: String?
|
var buttonAnimationName: String?
|
||||||
if state.isPremium == true {
|
if state.isPremium == true {
|
||||||
@ -1014,6 +1017,7 @@ private final class DemoSheetContent: CombinedComponent {
|
|||||||
case let .gift(price):
|
case let .gift(price):
|
||||||
buttonText = strings.Premium_Gift_GiftSubscription(price ?? "–").string
|
buttonText = strings.Premium_Gift_GiftSubscription(price ?? "–").string
|
||||||
case .other:
|
case .other:
|
||||||
|
var text: String
|
||||||
switch component.subject {
|
switch component.subject {
|
||||||
case .fasterDownload:
|
case .fasterDownload:
|
||||||
buttonText = strings.Premium_FasterSpeed_Proceed
|
buttonText = strings.Premium_FasterSpeed_Proceed
|
||||||
@ -1041,6 +1045,67 @@ private final class DemoSheetContent: CombinedComponent {
|
|||||||
default:
|
default:
|
||||||
buttonText = strings.Common_OK
|
buttonText = strings.Common_OK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch component.subject {
|
||||||
|
case .moreUpload:
|
||||||
|
text = strings.Premium_UploadSizeInfo
|
||||||
|
case .fasterDownload:
|
||||||
|
text = strings.Premium_FasterSpeedStandaloneInfo
|
||||||
|
case .voiceToText:
|
||||||
|
text = strings.Premium_VoiceToTextStandaloneInfo
|
||||||
|
case .noAds:
|
||||||
|
text = strings.Premium_NoAdsStandaloneInfo
|
||||||
|
case .uniqueReactions:
|
||||||
|
text = strings.Premium_InfiniteReactionsInfo
|
||||||
|
case .premiumStickers:
|
||||||
|
text = strings.Premium_StickersInfo
|
||||||
|
case .emojiStatus:
|
||||||
|
text = strings.Premium_EmojiStatusInfo
|
||||||
|
case .advancedChatManagement:
|
||||||
|
text = strings.Premium_ChatManagementStandaloneInfo
|
||||||
|
case .profileBadge:
|
||||||
|
text = strings.Premium_BadgeInfo
|
||||||
|
case .animatedUserpics:
|
||||||
|
text = strings.Premium_AvatarInfo
|
||||||
|
case .appIcons:
|
||||||
|
text = strings.Premium_AppIconStandaloneInfo
|
||||||
|
case .animatedEmoji:
|
||||||
|
text = strings.Premium_AnimatedEmojiStandaloneInfo
|
||||||
|
case .translation:
|
||||||
|
text = strings.Premium_TranslationStandaloneInfo
|
||||||
|
case .doubleLimits:
|
||||||
|
text = ""
|
||||||
|
case .stories:
|
||||||
|
text = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
let textSideInset: CGFloat = 24.0
|
||||||
|
|
||||||
|
let textColor = UIColor.black
|
||||||
|
let textFont = Font.regular(17.0)
|
||||||
|
let boldTextFont = Font.semibold(17.0)
|
||||||
|
let markdownAttributes = MarkdownAttributes(
|
||||||
|
body: MarkdownAttributeSet(font: textFont, textColor: textColor),
|
||||||
|
bold: MarkdownAttributeSet(font: boldTextFont, textColor: textColor),
|
||||||
|
link: MarkdownAttributeSet(font: textFont, textColor: textColor),
|
||||||
|
linkAttribute: { _ in
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
)
|
||||||
|
let measureText = measureText.update(
|
||||||
|
component: MultilineTextComponent(
|
||||||
|
text: .markdown(text: text, attributes: markdownAttributes),
|
||||||
|
horizontalAlignment: .center,
|
||||||
|
maximumNumberOfLines: 0,
|
||||||
|
lineSpacing: 0.0
|
||||||
|
),
|
||||||
|
availableSize: CGSize(width: context.availableSize.width - textSideInset * 2.0, height: context.availableSize.height),
|
||||||
|
transition: .immediate
|
||||||
|
)
|
||||||
|
context.add(measureText
|
||||||
|
.position(CGPoint(x: 0.0, y: 1000.0))
|
||||||
|
)
|
||||||
|
measuredTextHeight = measureText.size.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1079,7 +1144,11 @@ private final class DemoSheetContent: CombinedComponent {
|
|||||||
transition: context.transition
|
transition: context.transition
|
||||||
)
|
)
|
||||||
|
|
||||||
var contentHeight: CGFloat = context.availableSize.width + 146.0
|
var contentHeight: CGFloat = context.availableSize.width
|
||||||
|
if let measuredTextHeight {
|
||||||
|
contentHeight += measuredTextHeight + 66.0
|
||||||
|
} else {
|
||||||
|
contentHeight += 146.0
|
||||||
if case .other = component.source {
|
if case .other = component.source {
|
||||||
contentHeight -= 40.0
|
contentHeight -= 40.0
|
||||||
|
|
||||||
@ -1087,6 +1156,7 @@ private final class DemoSheetContent: CombinedComponent {
|
|||||||
contentHeight += 20.0
|
contentHeight += 20.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let buttonFrame = CGRect(origin: CGPoint(x: sideInset, y: contentHeight + 20.0), size: button.size)
|
let buttonFrame = CGRect(origin: CGPoint(x: sideInset, y: contentHeight + 20.0), size: button.size)
|
||||||
context.add(button
|
context.add(button
|
||||||
@ -1166,6 +1236,7 @@ private final class DemoSheetComponent: CombinedComponent {
|
|||||||
}
|
}
|
||||||
)),
|
)),
|
||||||
backgroundColor: .color(environment.theme.actionSheet.opaqueItemBackgroundColor),
|
backgroundColor: .color(environment.theme.actionSheet.opaqueItemBackgroundColor),
|
||||||
|
followContentSizeChanges: context.component.source == .other,
|
||||||
animateOut: animateOut
|
animateOut: animateOut
|
||||||
),
|
),
|
||||||
environment: {
|
environment: {
|
||||||
|
|||||||
@ -817,7 +817,7 @@ public class PremiumLimitsListScreen: ViewController {
|
|||||||
additionalInset = 20.0
|
additionalInset = 20.0
|
||||||
}
|
}
|
||||||
|
|
||||||
return layout.size.height - layout.size.width - 178.0 - panelHeight + additionalInset
|
return layout.size.height - layout.size.width - 181.0 - panelHeight + additionalInset
|
||||||
} else {
|
} else {
|
||||||
return 210.0
|
return 210.0
|
||||||
}
|
}
|
||||||
|
|||||||
@ -184,6 +184,7 @@ private struct PeerNameColorScreenState: Equatable {
|
|||||||
var updatedNameColor: PeerNameColor?
|
var updatedNameColor: PeerNameColor?
|
||||||
var updatedBackgroundEmojiId: Int64?
|
var updatedBackgroundEmojiId: Int64?
|
||||||
var inProgress: Bool = false
|
var inProgress: Bool = false
|
||||||
|
var needsBoosts: Bool = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private func peerNameColorScreenEntries(
|
private func peerNameColorScreenEntries(
|
||||||
@ -253,7 +254,11 @@ private func peerNameColorScreenEntries(
|
|||||||
colors: nameColors,
|
colors: nameColors,
|
||||||
currentColor: nameColor
|
currentColor: nameColor
|
||||||
))
|
))
|
||||||
|
if case .channel = peer {
|
||||||
|
entries.append(.colorDescription(presentationData.strings.NameColor_ChatPreview_Description_Channel))
|
||||||
|
} else {
|
||||||
entries.append(.colorDescription(presentationData.strings.NameColor_ChatPreview_Description_Account))
|
entries.append(.colorDescription(presentationData.strings.NameColor_ChatPreview_Description_Account))
|
||||||
|
}
|
||||||
|
|
||||||
if let emojiContent {
|
if let emojiContent {
|
||||||
entries.append(.backgroundEmojiHeader(presentationData.strings.NameColor_BackgroundEmoji_Title, backgroundEmojiId != nil ? presentationData.strings.NameColor_BackgroundEmoji_Remove : nil))
|
entries.append(.backgroundEmojiHeader(presentationData.strings.NameColor_BackgroundEmoji_Title, backgroundEmojiId != nil ? presentationData.strings.NameColor_BackgroundEmoji_Remove : nil))
|
||||||
@ -561,6 +566,10 @@ public func PeerNameColorScreen(
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
let state = stateValue.with({ $0 })
|
let state = stateValue.with({ $0 })
|
||||||
|
if case .channel = subject, state.needsBoosts {
|
||||||
|
f()
|
||||||
|
return true
|
||||||
|
}
|
||||||
var hasChanges = false
|
var hasChanges = false
|
||||||
if state.updatedNameColor != nil || state.updatedBackgroundEmojiId != nil {
|
if state.updatedNameColor != nil || state.updatedBackgroundEmojiId != nil {
|
||||||
hasChanges = true
|
hasChanges = true
|
||||||
@ -624,6 +633,12 @@ public func PeerNameColorScreen(
|
|||||||
|> deliverOnMainQueue).startStandalone(next: {
|
|> deliverOnMainQueue).startStandalone(next: {
|
||||||
}, error: { error in
|
}, error: { error in
|
||||||
if case .channelBoostRequired = error {
|
if case .channelBoostRequired = error {
|
||||||
|
updateState { state in
|
||||||
|
var updatedState = state
|
||||||
|
updatedState.needsBoosts = true
|
||||||
|
return updatedState
|
||||||
|
}
|
||||||
|
|
||||||
let _ = combineLatest(
|
let _ = combineLatest(
|
||||||
queue: Queue.mainQueue(),
|
queue: Queue.mainQueue(),
|
||||||
context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)),
|
context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user