Skip to content

Commit 1ef71d2

Browse files
committed
Various improvements
1 parent 1f041ea commit 1ef71d2

File tree

4 files changed

+78
-23
lines changed

4 files changed

+78
-23
lines changed

Telegram/Telegram-iOS/en.lproj/Localizable.strings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13221,3 +13221,5 @@ Sorry for the inconvenience.";
1322113221

1322213222
"Gift.Send.TitleTo" = "Gift to %@";
1322313223
"Gift.Send.SendShort" = "Send";
13224+
13225+
"Premium.EmojiStatus.Proceed" = "Unlock Emoji Statuses";

submodules/PremiumUI/Sources/PremiumDemoScreen.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,9 @@ private final class DemoSheetContent: CombinedComponent {
12761276
buttonText = strings.Premium_MessagePrivacy_Proceed
12771277
case .folderTags:
12781278
buttonText = strings.Premium_FolderTags_Proceed
1279+
case .emojiStatus:
1280+
buttonText = strings.Premium_EmojiStatus_Proceed
1281+
buttonAnimationName = "premium_unlock"
12791282
default:
12801283
buttonText = strings.Common_OK
12811284
}

submodules/UndoUI/Sources/UndoOverlayControllerNode.swift

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
3838
private var multiAvatarsSize: CGSize?
3939
private var iconImageSize: CGSize?
4040
private let iconCheckNode: RadialStatusNode?
41-
private let animationNode: AnimationNode?
41+
private var animationNode: AnimationNode?
4242
private var animatedStickerNode: AnimatedStickerNode?
4343
private var slotMachineNode: SlotMachineAnimationNode?
4444
private var stillStickerNode: TransformImageNode?
@@ -1625,6 +1625,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
16251625
}
16261626

16271627
func updateContent(_ content: UndoOverlayContent) {
1628+
let previousContent = self.content
16281629
self.content = content
16291630

16301631
var undoTextColor = self.presentationData.theme.list.itemAccentColor.withMultiplied(hue: 0.933, saturation: 0.61, brightness: 1.0)
@@ -1651,6 +1652,35 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
16511652
self.textNode.attributedText = NSAttributedString(string: text, font: Font.regular(14.0), textColor: .white)
16521653
self.renewWithCurrentContent()
16531654
case let .actionSucceeded(title, text, _, destructive):
1655+
if case .progress = previousContent {
1656+
self.remainingSeconds = 5.0
1657+
1658+
if let snapshotView = self.textNode.view.snapshotView(afterScreenUpdates: false) {
1659+
snapshotView.frame = self.textNode.frame
1660+
self.textNode.view.superview?.addSubview(snapshotView)
1661+
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.25, removeOnCompletion: false, completion: { _ in
1662+
snapshotView.removeFromSuperview()
1663+
})
1664+
self.textNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25)
1665+
}
1666+
1667+
self.animationNode = AnimationNode(animation: "anim_success", colors: ["info1.info1.stroke": self.animationBackgroundColor, "info2.info2.Fill": self.animationBackgroundColor], scale: 1.0)
1668+
self.animationNode.flatMap(self.panelWrapperNode.addSubnode)
1669+
1670+
if let iconNode = self.iconNode, let statusNode = self.statusNode {
1671+
iconNode.layer.animateScale(from: 1.0, to: 0.01, duration: 0.25, removeOnCompletion: false)
1672+
iconNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.25)
1673+
statusNode.layer.animateScale(from: 1.0, to: 0.01, duration: 0.25, removeOnCompletion: false)
1674+
statusNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.25)
1675+
}
1676+
1677+
self.animationNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.1)
1678+
Queue.mainQueue().justDispatch {
1679+
self.animationNode?.layer.animateScale(from: 0.01, to: 1.0, duration: 0.2)
1680+
self.animationNode?.play()
1681+
}
1682+
}
1683+
16541684
if destructive {
16551685
undoTextColor = UIColor(rgb: 0xff7b74)
16561686
}
@@ -1717,6 +1747,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
17171747
var leftInset: CGFloat = 50.0
17181748
if let iconImageSize = self.iconImageSize {
17191749
if case .progress = self.content {
1750+
} else if case .actionSucceeded = self.content {
17201751
} else {
17211752
leftInset = 9.0 + iconImageSize.width + 9.0
17221753
}
@@ -1857,6 +1888,8 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
18571888
var isProgress = false
18581889
if case .progress = self.content {
18591890
isProgress = true
1891+
} else if case .actionSucceeded = self.content {
1892+
isProgress = true
18601893
}
18611894

18621895
let iconFrame: CGRect

submodules/WebUI/Sources/WebAppController.swift

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
247247
Queue.mainQueue().justDispatch {
248248
if let backgroundColor = botAppSettings.backgroundColor {
249249
self.appBackgroundColor = UIColor(rgb: UInt32(bitPattern: backgroundColor))
250+
self.placeholderBackgroundColor = self.appBackgroundColor
250251
self.updateBackgroundColor(transition: .immediate)
251252
}
252253
if let headerColor = botAppSettings.headerColor {
@@ -482,7 +483,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
482483

483484
let foregroundColor: UIColor
484485
let shimmeringColor: UIColor
485-
if let backgroundColor = self.appBackgroundColor {
486+
if let backgroundColor = self.placeholderBackgroundColor {
486487
if backgroundColor.lightness > 0.705 {
487488
foregroundColor = backgroundColor.mixedWith(UIColor(rgb: 0x000000), alpha: 0.05)
488489
shimmeringColor = UIColor.white.withAlphaComponent(0.2)
@@ -1438,6 +1439,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
14381439
fileprivate var needDismissConfirmation = false
14391440

14401441
fileprivate var appBackgroundColor: UIColor?
1442+
fileprivate var placeholderBackgroundColor: UIColor?
14411443
fileprivate var headerColor: UIColor?
14421444
fileprivate var headerPrimaryTextColor: UIColor?
14431445
private var headerColorKey: String?
@@ -2280,10 +2282,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
22802282
},
22812283
completion: { [weak self] resultUrl, _ in
22822284
if let resultUrl, let self {
2283-
if let tooltip = self.fileDownloadTooltip {
2284-
tooltip.dismissWithCommitAction()
2285-
}
2286-
2285+
let tooltipContent: UndoOverlayContent = .actionSucceeded(title: fileName, text: isMedia ? "Saved to Photos" : "Saved to Files", cancel: nil, destructive: false)
22872286
if isMedia {
22882287
let saveToPhotos: (URL, Bool) -> Void = { url, isVideo in
22892288
var fileExtension = (resultUrl.absoluteString as NSString).pathExtension
@@ -2303,18 +2302,26 @@ public final class WebAppController: ViewController, AttachmentContainable {
23032302
}
23042303
let isVideo = fileName.lowercased().hasSuffix(".mp4") || fileName.lowercased().hasSuffix(".mov")
23052304
saveToPhotos(resultUrl, isVideo)
2306-
2307-
let tooltipController = UndoOverlayController(
2308-
presentationData: self.presentationData,
2309-
content: .actionSucceeded(title: fileName, text: isMedia ? "Saved to Photos" : "Saved to Files", cancel: nil, destructive: false),
2310-
elevatedLayout: false,
2311-
position: .top,
2312-
action: { _ in
2313-
return true
2314-
}
2315-
)
2316-
controller.present(tooltipController, in: .current)
2305+
2306+
if let tooltip = self.fileDownloadTooltip {
2307+
tooltip.content = tooltipContent
2308+
} else {
2309+
let tooltipController = UndoOverlayController(
2310+
presentationData: self.presentationData,
2311+
content: tooltipContent,
2312+
elevatedLayout: false,
2313+
position: .top,
2314+
action: { _ in
2315+
return true
2316+
}
2317+
)
2318+
controller.present(tooltipController, in: .current)
2319+
}
23172320
} else {
2321+
if let tooltip = self.fileDownloadTooltip {
2322+
tooltip.dismissWithCommitAction()
2323+
}
2324+
23182325
let tempFile = TempBox.shared.file(path: resultUrl.absoluteString, fileName: fileName)
23192326
let url = URL(fileURLWithPath: tempFile.path)
23202327
try? FileManager.default.copyItem(at: resultUrl, to: url)
@@ -2325,7 +2332,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
23252332
}
23262333
let tooltipController = UndoOverlayController(
23272334
presentationData: self.presentationData,
2328-
content: .actionSucceeded(title: fileName, text: isMedia ? "Saved to Photos" : "Saved to Files", cancel: nil, destructive: false),
2335+
content: tooltipContent,
23292336
elevatedLayout: false,
23302337
position: .top,
23312338
action: { _ in
@@ -2335,11 +2342,6 @@ public final class WebAppController: ViewController, AttachmentContainable {
23352342
controller.present(tooltipController, in: .current)
23362343
})
23372344
controller.present(pickerController, in: .window(.root))
2338-
//
2339-
// if let documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
2340-
// let targetUrl = documentsUrl.appendingPathComponent(fileName)
2341-
// try? FileManager.default.copyItem(at: resultUrl, to: targetUrl)
2342-
// }
23432345
}
23442346
}
23452347
}
@@ -2404,6 +2406,21 @@ public final class WebAppController: ViewController, AttachmentContainable {
24042406
if result {
24052407
let context = self.context
24062408
let botId = controller.botId
2409+
2410+
if !context.isPremium {
2411+
var replaceImpl: ((ViewController) -> Void)?
2412+
let demoController = context.sharedContext.makePremiumDemoController(context: context, subject: .emojiStatus, forceDark: false, action: {
2413+
let controller = context.sharedContext.makePremiumIntroController(context: context, source: .animatedEmoji, forceDark: false, dismissed: nil)
2414+
replaceImpl?(controller)
2415+
}, dismissed: nil)
2416+
replaceImpl = { [weak demoController] c in
2417+
demoController?.replace(with: c)
2418+
}
2419+
controller.parentController()?.push(demoController)
2420+
self.webView?.sendEvent(name: "emoji_status_access_requested", data: "{status: \"cancelled\"}")
2421+
return
2422+
}
2423+
24072424
let _ = (context.engine.peers.toggleBotEmojiStatusAccess(peerId: botId, enabled: true)
24082425
|> deliverOnMainQueue).startStandalone(completed: { [weak self] in
24092426
self?.webView?.sendEvent(name: "emoji_status_access_requested", data: "{status: \"allowed\"}")

0 commit comments

Comments
 (0)