mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Don't display app badge when app is inactive
This commit is contained in:
parent
ad86dcb7c4
commit
31300c3c16
@ -358,11 +358,23 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateContainers(layout rawLayout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
private var forceBadgeHidden = false
|
||||||
self.isUpdatingContainers = true
|
public func setForceBadgeHidden(_ hidden: Bool) {
|
||||||
|
guard hidden != self.forceBadgeHidden else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.forceBadgeHidden = hidden
|
||||||
|
if let layout = self.validLayout {
|
||||||
|
self.updateBadgeVisibility(layout: layout)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let badgeNode = self.badgeNode, let image = badgeNode.image {
|
private func updateBadgeVisibility(layout: ContainerViewLayout) {
|
||||||
let badgeIsHidden = !rawLayout.deviceMetrics.hasTopNotch || rawLayout.size.width > rawLayout.size.height
|
guard let badgeNode = self.badgeNode else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let badgeIsHidden = !layout.deviceMetrics.hasTopNotch || self.forceBadgeHidden || layout.size.width > layout.size.height
|
||||||
if badgeIsHidden != badgeNode.isHidden && !badgeIsHidden {
|
if badgeIsHidden != badgeNode.isHidden && !badgeIsHidden {
|
||||||
Queue.mainQueue().after(0.3) {
|
Queue.mainQueue().after(0.3) {
|
||||||
badgeNode.isHidden = badgeIsHidden
|
badgeNode.isHidden = badgeIsHidden
|
||||||
@ -370,6 +382,13 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
} else {
|
} else {
|
||||||
badgeNode.isHidden = badgeIsHidden
|
badgeNode.isHidden = badgeIsHidden
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateContainers(layout rawLayout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||||
|
self.isUpdatingContainers = true
|
||||||
|
|
||||||
|
if let badgeNode = self.badgeNode, let image = badgeNode.image {
|
||||||
|
self.updateBadgeVisibility(layout: rawLayout)
|
||||||
badgeNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((rawLayout.size.width - image.size.width) / 2.0), y: 6.0), size: image.size)
|
badgeNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((rawLayout.size.width - image.size.width) / 2.0), y: 6.0), size: image.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@ public final class TelegramRootController: NavigationController {
|
|||||||
private var presentationDataDisposable: Disposable?
|
private var presentationDataDisposable: Disposable?
|
||||||
private var presentationData: PresentationData
|
private var presentationData: PresentationData
|
||||||
|
|
||||||
|
private var applicationInFocusDisposable: Disposable?
|
||||||
|
|
||||||
public init(context: AccountContext) {
|
public init(context: AccountContext) {
|
||||||
self.context = context
|
self.context = context
|
||||||
|
|
||||||
@ -71,6 +73,15 @@ public final class TelegramRootController: NavigationController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
self.applicationInFocusDisposable = (context.sharedContext.applicationBindings.applicationIsActive
|
||||||
|
|> distinctUntilChanged
|
||||||
|
|> deliverOn(Queue.mainQueue())).start(next: { [weak self] value in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
strongSelf.setForceBadgeHidden(!value)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(coder aDecoder: NSCoder) {
|
required public init(coder aDecoder: NSCoder) {
|
||||||
@ -80,6 +91,7 @@ public final class TelegramRootController: NavigationController {
|
|||||||
deinit {
|
deinit {
|
||||||
self.permissionsDisposable?.dispose()
|
self.permissionsDisposable?.dispose()
|
||||||
self.presentationDataDisposable?.dispose()
|
self.presentationDataDisposable?.dispose()
|
||||||
|
self.applicationInFocusDisposable?.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func addRootControllers(showCallsTab: Bool) {
|
public func addRootControllers(showCallsTab: Bool) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user