mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-07-25 08:50:51 +02:00
chore: migrate to new version + fixed several critical bugs
- Migrated project to latest Telegram iOS base (v12.3.2+) - Fixed circular dependency between GhostModeManager and MiscSettingsManager - Fixed multiple Bazel build configuration errors (select() default conditions) - Fixed duplicate type definitions in PeerInfoScreen - Fixed swiftmodule directory resolution in build scripts - Added Ghostgram Settings tab in main Settings menu with all 5 features - Cleared sensitive credentials from config.json (template-only now) - Excluded bazel-cache from version control
This commit is contained in:
@@ -34,6 +34,8 @@ swift_library(
|
||||
"//submodules/Components/ComponentDisplayAdapters",
|
||||
"//submodules/TelegramUI/Components/TextNodeWithEntities",
|
||||
"//submodules/TelegramUI/Components/ListItemComponentAdaptor",
|
||||
"//submodules/TelegramUI/Components/GlassBackgroundComponent",
|
||||
"//submodules/TelegramUI/Components/HorizontalTabsComponent",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
||||
@@ -281,11 +281,12 @@ open class ItemListController: ViewController, KeyShortcutResponder, Presentable
|
||||
self.presentationData = presentationData
|
||||
self.hideNavigationBarBackground = hideNavigationBarBackground
|
||||
|
||||
super.init(navigationBarPresentationData: NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: presentationData.theme, hideBackground: hideNavigationBarBackground, hideSeparator: hideNavigationBarBackground), strings: NavigationBarStrings(presentationStrings: presentationData.strings)))
|
||||
super.init(navigationBarPresentationData: NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: presentationData.theme, hideBackground: hideNavigationBarBackground, hideSeparator: hideNavigationBarBackground, style: .glass), strings: NavigationBarStrings(presentationStrings: presentationData.strings)))
|
||||
|
||||
self.isOpaqueWhenInOverlay = true
|
||||
self.blocksBackgroundWhenInOverlay = true
|
||||
self.automaticallyControlPresentationContextLayout = false
|
||||
self._hasGlassStyle = true
|
||||
|
||||
self.statusBar.statusBarStyle = presentationData.theme.rootController.statusBarStyle.style
|
||||
|
||||
@@ -326,13 +327,23 @@ open class ItemListController: ViewController, KeyShortcutResponder, Presentable
|
||||
Queue.mainQueue().async {
|
||||
if let strongSelf = self {
|
||||
let previousState = previousControllerState.swap(controllerState)
|
||||
let isFirstTime = previousState == nil
|
||||
if previousState?.title != controllerState.title {
|
||||
var previousHadContentNode = false
|
||||
switch previousState?.title {
|
||||
case .textWithTabs:
|
||||
previousHadContentNode = true
|
||||
default:
|
||||
break
|
||||
}
|
||||
switch controllerState.title {
|
||||
case let .text(text):
|
||||
strongSelf.title = text
|
||||
strongSelf.navigationItem.titleView = nil
|
||||
strongSelf.segmentedTitleView = nil
|
||||
strongSelf.navigationBar?.setContentNode(nil, animated: false)
|
||||
if previousHadContentNode {
|
||||
strongSelf.navigationBar?.setContentNode(nil, animated: false)
|
||||
}
|
||||
if strongSelf.isNodeLoaded {
|
||||
strongSelf.controllerNode.panRecognizer?.isEnabled = false
|
||||
}
|
||||
@@ -340,7 +351,9 @@ open class ItemListController: ViewController, KeyShortcutResponder, Presentable
|
||||
strongSelf.title = ""
|
||||
strongSelf.navigationItem.titleView = ItemListTextWithSubtitleTitleView(theme: controllerState.presentationData.theme, title: title, subtitle: subtitle)
|
||||
strongSelf.segmentedTitleView = nil
|
||||
strongSelf.navigationBar?.setContentNode(nil, animated: false)
|
||||
if previousHadContentNode {
|
||||
strongSelf.navigationBar?.setContentNode(nil, animated: false)
|
||||
}
|
||||
if strongSelf.isNodeLoaded {
|
||||
strongSelf.controllerNode.panRecognizer?.isEnabled = false
|
||||
}
|
||||
@@ -358,7 +371,9 @@ open class ItemListController: ViewController, KeyShortcutResponder, Presentable
|
||||
}
|
||||
}
|
||||
}
|
||||
strongSelf.navigationBar?.setContentNode(nil, animated: false)
|
||||
if previousHadContentNode {
|
||||
strongSelf.navigationBar?.setContentNode(nil, animated: false)
|
||||
}
|
||||
if strongSelf.isNodeLoaded {
|
||||
strongSelf.controllerNode.panRecognizer?.isEnabled = false
|
||||
}
|
||||
@@ -515,10 +530,10 @@ open class ItemListController: ViewController, KeyShortcutResponder, Presentable
|
||||
}
|
||||
}
|
||||
|
||||
if strongSelf.presentationData != controllerState.presentationData {
|
||||
if strongSelf.presentationData != controllerState.presentationData || isFirstTime {
|
||||
strongSelf.presentationData = controllerState.presentationData
|
||||
|
||||
strongSelf.navigationBar?.updatePresentationData(NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: strongSelf.presentationData.theme, hideBackground: strongSelf.hideNavigationBarBackground, hideSeparator: strongSelf.hideNavigationBarBackground), strings: NavigationBarStrings(presentationStrings: strongSelf.presentationData.strings)))
|
||||
strongSelf.navigationBar?.updatePresentationData(NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: strongSelf.presentationData.theme, hideBackground: strongSelf.hideNavigationBarBackground, hideSeparator: strongSelf.hideNavigationBarBackground, edgeEffectColor: state.0.style == .blocks ? strongSelf.presentationData.theme.list.blocksBackgroundColor : strongSelf.presentationData.theme.list.plainBackgroundColor, style: .glass), strings: NavigationBarStrings(presentationStrings: strongSelf.presentationData.strings)), transition: .immediate)
|
||||
strongSelf.statusBar.updateStatusBarStyle(strongSelf.presentationData.theme.rootController.statusBarStyle.style, animated: true)
|
||||
|
||||
strongSelf.segmentedTitleView?.theme = controllerState.presentationData.theme
|
||||
@@ -675,7 +690,8 @@ private final class ItemListTextWithSubtitleTitleView: UIView, NavigationBarTitl
|
||||
private let titleNode: ImmediateTextNode
|
||||
private let subtitleNode: ImmediateTextNode
|
||||
|
||||
private var validLayout: (CGSize, CGRect)?
|
||||
private var validLayout: CGSize?
|
||||
var requestUpdate: ((ContainedViewLayoutTransition) -> Void)?
|
||||
|
||||
init(theme: PresentationTheme, title: String, subtitle: String) {
|
||||
self.titleNode = ImmediateTextNode()
|
||||
@@ -705,21 +721,23 @@ private final class ItemListTextWithSubtitleTitleView: UIView, NavigationBarTitl
|
||||
func updateTheme(theme: PresentationTheme) {
|
||||
self.titleNode.attributedText = NSAttributedString(string: self.titleNode.attributedText?.string ?? "", font: Font.medium(17.0), textColor: theme.rootController.navigationBar.primaryTextColor)
|
||||
self.subtitleNode.attributedText = NSAttributedString(string: self.subtitleNode.attributedText?.string ?? "", font: Font.regular(13.0), textColor: theme.rootController.navigationBar.secondaryTextColor)
|
||||
if let (size, clearBounds) = self.validLayout {
|
||||
let _ = self.updateLayout(size: size, clearBounds: clearBounds, transition: .immediate)
|
||||
if let size = self.validLayout {
|
||||
let _ = self.updateLayout(availableSize: size, transition: .immediate)
|
||||
}
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
if let (size, clearBounds) = self.validLayout {
|
||||
let _ = self.updateLayout(size: size, clearBounds: clearBounds, transition: .immediate)
|
||||
if let size = self.validLayout {
|
||||
let _ = self.updateLayout(availableSize: size, transition: .immediate)
|
||||
}
|
||||
}
|
||||
|
||||
func updateLayout(size: CGSize, clearBounds: CGRect, transition: ContainedViewLayoutTransition) -> CGRect {
|
||||
self.validLayout = (size, clearBounds)
|
||||
func updateLayout(availableSize: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
let size = availableSize
|
||||
|
||||
self.validLayout = size
|
||||
|
||||
let titleSize = self.titleNode.updateLayout(size)
|
||||
let subtitleSize = self.subtitleNode.updateLayout(size)
|
||||
@@ -731,7 +749,7 @@ private final class ItemListTextWithSubtitleTitleView: UIView, NavigationBarTitl
|
||||
self.titleNode.frame = titleFrame
|
||||
self.subtitleNode.frame = subtitleFrame
|
||||
|
||||
return titleFrame
|
||||
return availableSize
|
||||
}
|
||||
|
||||
func animateLayoutTransition() {
|
||||
|
||||
@@ -910,11 +910,7 @@ open class ItemListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
|
||||
if let validLayout = self.validLayout {
|
||||
updatedNode.updateLayout(layout: validLayout.0, navigationBarHeight: validLayout.1, transition: .immediate)
|
||||
}
|
||||
if updatedNode.addedUnderNavigationBar {
|
||||
self.insertSubnode(updatedNode, belowSubnode: self.navigationBar)
|
||||
} else {
|
||||
self.addSubnode(updatedNode)
|
||||
}
|
||||
self.insertSubnode(updatedNode, belowSubnode: self.navigationBar)
|
||||
updatedNode.activate()
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -3,9 +3,12 @@ import UIKit
|
||||
import Display
|
||||
import TelegramPresentationData
|
||||
import ComponentFlow
|
||||
import TabSelectorComponent
|
||||
import GlassBackgroundComponent
|
||||
import HorizontalTabsComponent
|
||||
|
||||
public final class ItemListControllerSegmentedTitleView: UIView {
|
||||
private let backgroundContainer: GlassBackgroundContainerView
|
||||
private let backgroundView: GlassBackgroundView
|
||||
private let tabSelector = ComponentView<Empty>()
|
||||
|
||||
public var theme: PresentationTheme {
|
||||
@@ -42,7 +45,13 @@ public final class ItemListControllerSegmentedTitleView: UIView {
|
||||
self.segments = segments
|
||||
self.index = selectedIndex
|
||||
|
||||
self.backgroundContainer = GlassBackgroundContainerView()
|
||||
self.backgroundView = GlassBackgroundView()
|
||||
|
||||
super.init(frame: CGRect())
|
||||
|
||||
self.addSubview(self.backgroundContainer)
|
||||
self.backgroundContainer.contentView.addSubview(self.backgroundView)
|
||||
}
|
||||
|
||||
required public init?(coder aDecoder: NSCoder) {
|
||||
@@ -62,10 +71,19 @@ public final class ItemListControllerSegmentedTitleView: UIView {
|
||||
return
|
||||
}
|
||||
|
||||
let mappedItems = zip(0 ..< self.segments.count, self.segments).map { index, segment in
|
||||
return TabSelectorComponent.Item(
|
||||
let mappedItems: [HorizontalTabsComponent.Tab] = zip(0 ..< self.segments.count, self.segments).map { index, segment in
|
||||
return HorizontalTabsComponent.Tab(
|
||||
id: AnyHashable(index),
|
||||
title: segment
|
||||
content: .title(HorizontalTabsComponent.Tab.Title(text: segment, entities: [], enableAnimations: false)),
|
||||
badge: nil,
|
||||
action: { [weak self] in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.indexUpdated?(index)
|
||||
},
|
||||
contextAction: nil,
|
||||
deleteAction: nil
|
||||
)
|
||||
}
|
||||
|
||||
@@ -77,34 +95,32 @@ public final class ItemListControllerSegmentedTitleView: UIView {
|
||||
|
||||
let tabSelectorSize = self.tabSelector.update(
|
||||
transition: transition,
|
||||
component: AnyComponent(TabSelectorComponent(
|
||||
colors: TabSelectorComponent.Colors(
|
||||
foreground: self.theme.list.itemPrimaryTextColor.withMultipliedAlpha(0.8),
|
||||
selection: self.theme.list.itemPrimaryTextColor.withMultipliedAlpha(0.05)
|
||||
),
|
||||
component: AnyComponent(HorizontalTabsComponent(
|
||||
context: nil,
|
||||
theme: self.theme,
|
||||
customLayout: TabSelectorComponent.CustomLayout(
|
||||
font: Font.medium(15.0),
|
||||
spacing: 8.0
|
||||
),
|
||||
items: mappedItems,
|
||||
selectedId: AnyHashable(self.index),
|
||||
setSelectedId: { [weak self] id in
|
||||
guard let self, let index = id.base as? Int else {
|
||||
return
|
||||
}
|
||||
self.indexUpdated?(index)
|
||||
}
|
||||
tabs: mappedItems,
|
||||
selectedTab: AnyHashable(self.index),
|
||||
isEditing: false,
|
||||
layout: .fit
|
||||
)),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: size.width, height: 44.0)
|
||||
)
|
||||
|
||||
let tabSelectorFrame = CGRect(origin: CGPoint(x: floor((size.width - tabSelectorSize.width) / 2.0), y: floor((size.height - tabSelectorSize.height) / 2.0)), size: tabSelectorSize)
|
||||
if let tabSelectorView = self.tabSelector.view {
|
||||
|
||||
transition.setFrame(view: self.backgroundContainer, frame: tabSelectorFrame)
|
||||
self.backgroundContainer.update(size: tabSelectorFrame.size, isDark: self.theme.overallDarkAppearance, transition: transition)
|
||||
|
||||
transition.setFrame(view: self.backgroundView, frame: CGRect(origin: CGPoint(), size: tabSelectorFrame.size))
|
||||
self.backgroundView.update(size: tabSelectorFrame.size, cornerRadius: tabSelectorFrame.height * 0.5, isDark: theme.overallDarkAppearance, tintColor: .init(kind: .panel, color: UIColor(white: self.theme.overallDarkAppearance ? 0.0 : 1.0, alpha: 0.6)), transition: transition)
|
||||
|
||||
if let tabSelectorView = self.tabSelector.view as? HorizontalTabsComponent.View {
|
||||
if tabSelectorView.superview == nil {
|
||||
self.addSubview(tabSelectorView)
|
||||
self.backgroundView.contentView.addSubview(tabSelectorView)
|
||||
tabSelectorView.setOverlayContainerView(overlayContainerView: self)
|
||||
}
|
||||
transition.setFrame(view: tabSelectorView, frame: tabSelectorFrame)
|
||||
transition.setFrame(view: tabSelectorView, frame: CGRect(origin: CGPoint(), size: tabSelectorFrame.size))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,10 +63,10 @@ final class ItemListControllerTabsContentNode: NavigationBarContentNode {
|
||||
guard let (size, leftInset, rightInset) = self.validLayout else {
|
||||
return
|
||||
}
|
||||
self.updateLayout(size: size, leftInset: leftInset, rightInset: rightInset, transition: transition)
|
||||
let _ = self.updateLayout(size: size, leftInset: leftInset, rightInset: rightInset, transition: transition)
|
||||
}
|
||||
|
||||
override func updateLayout(size: CGSize, leftInset: CGFloat, rightInset: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||
override func updateLayout(size: CGSize, leftInset: CGFloat, rightInset: CGFloat, transition: ContainedViewLayoutTransition) -> CGSize {
|
||||
let isFirstTime = self.validLayout == nil
|
||||
self.validLayout = (size, leftInset, rightInset)
|
||||
|
||||
@@ -116,6 +116,8 @@ final class ItemListControllerTabsContentNode: NavigationBarContentNode {
|
||||
if isFirstTime {
|
||||
self.requestContainerLayout(.immediate)
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
override var height: CGFloat {
|
||||
|
||||
@@ -125,7 +125,7 @@ public class ItemListActionItemNode: ListViewItemNode, ItemListItemNode {
|
||||
|
||||
self.activateArea = AccessibilityAreaNode()
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
super.init(layerBacked: false)
|
||||
|
||||
self.addSubnode(self.titleNode)
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class ItemListActivityTextItemNode: ListViewItemNode {
|
||||
|
||||
self.activityIndicator = ActivityIndicator(type: ActivityIndicatorType.custom(.black, 16.0, 2.0, false))
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
super.init(layerBacked: false)
|
||||
|
||||
self.addSubnode(self.titleNode)
|
||||
self.addSubnode(self.activityIndicator)
|
||||
|
||||
@@ -168,7 +168,7 @@ public class ItemListCheckboxItemNode: ItemListRevealOptionsItemNode {
|
||||
|
||||
self.activateArea = AccessibilityAreaNode()
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false, rotated: false, seeThrough: false)
|
||||
super.init(layerBacked: false, rotated: false, seeThrough: false)
|
||||
|
||||
self.addSubnode(self.contentParentNode)
|
||||
self.contentParentNode.addSubnode(self.contentContainerNode)
|
||||
|
||||
@@ -254,7 +254,7 @@ public class ItemListDisclosureItemNode: ListViewItemNode, ItemListItemNode {
|
||||
|
||||
self.activateArea = AccessibilityAreaNode()
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
super.init(layerBacked: false)
|
||||
|
||||
self.addSubnode(self.titleNode.textNode)
|
||||
self.addSubnode(self.labelNode)
|
||||
|
||||
@@ -83,8 +83,8 @@ open class ItemListRevealOptionsItemNode: ListViewItemNode, ASGestureRecognizerD
|
||||
return !self.isDisplayingRevealedOptions
|
||||
}
|
||||
|
||||
override public init(layerBacked: Bool, dynamicBounce: Bool, rotated: Bool, seeThrough: Bool) {
|
||||
super.init(layerBacked: layerBacked, dynamicBounce: dynamicBounce, rotated: rotated, seeThrough: seeThrough)
|
||||
override public init(layerBacked: Bool, rotated: Bool, seeThrough: Bool) {
|
||||
super.init(layerBacked: layerBacked, rotated: rotated, seeThrough: seeThrough)
|
||||
}
|
||||
|
||||
open var controlsContainer: ASDisplayNode {
|
||||
|
||||
@@ -267,7 +267,7 @@ public class ItemListExpandableSwitchItemNode: ListViewItemNode, ItemListItemNod
|
||||
self.subItemContainer = ASDisplayNode()
|
||||
self.subItemContainer.clipsToBounds = true
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
super.init(layerBacked: false)
|
||||
|
||||
self.addSubnode(self.titleNode)
|
||||
self.addSubnode(self.titleValueNode)
|
||||
|
||||
@@ -181,7 +181,7 @@ public class InfoItemNode: ListViewItemNode {
|
||||
self.closeButton.hitTestSlop = UIEdgeInsets(top: -8.0, left: -8.0, bottom: -8.0, right: -8.0)
|
||||
self.closeButton.displaysAsynchronously = false
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
super.init(layerBacked: false)
|
||||
|
||||
self.addSubnode(self.badgeNode)
|
||||
self.addSubnode(self.labelNode)
|
||||
|
||||
@@ -152,7 +152,7 @@ public class ItemListMultilineInputItemNode: ListViewItemNode, ASEditableTextNod
|
||||
self.limitTextNode = TextNode()
|
||||
self.limitTextNode.displaysAsynchronously = false
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
super.init(layerBacked: false)
|
||||
|
||||
self.textClippingNode.addSubnode(self.textNode)
|
||||
self.addSubnode(self.textClippingNode)
|
||||
|
||||
@@ -127,7 +127,7 @@ public class ItemListMultilineTextItemNode: ListViewItemNode {
|
||||
|
||||
self.activateArea = AccessibilityAreaNode()
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
super.init(layerBacked: false)
|
||||
|
||||
self.addSubnode(self.textNode)
|
||||
self.addSubnode(self.activateArea)
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ItemListPlaceholderItemNode: ListViewItemNode, ItemListItemNode {
|
||||
self.textNode = TextNode()
|
||||
self.textNode.isUserInteractionEnabled = false
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
super.init(layerBacked: false)
|
||||
|
||||
self.addSubnode(self.textNode)
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class ItemListSectionHeaderItemNode: ListViewItemNode {
|
||||
self.activateArea = AccessibilityAreaNode()
|
||||
self.activateArea.accessibilityTraits = [.staticText, .header]
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
super.init(layerBacked: false)
|
||||
|
||||
self.addSubnode(self.titleNode)
|
||||
self.addSubnode(self.accessoryTextNode)
|
||||
|
||||
@@ -177,7 +177,7 @@ public class ItemListSingleLineInputItemNode: ListViewItemNode, UITextFieldDeleg
|
||||
self.labelNode = TextNode()
|
||||
self.labelNode.isUserInteractionEnabled = false
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
super.init(layerBacked: false)
|
||||
|
||||
self.addSubnode(self.titleNode.textNode)
|
||||
self.addSubnode(self.textNode)
|
||||
|
||||
@@ -207,7 +207,7 @@ public class ItemListSwitchItemNode: ListViewItemNode, ItemListItemNode {
|
||||
|
||||
self.activateArea = AccessibilityAreaNode()
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
super.init(layerBacked: false)
|
||||
|
||||
self.addSubnode(self.titleNode)
|
||||
self.addSubnode(self.switchNode)
|
||||
|
||||
@@ -132,7 +132,7 @@ public class ItemListTextItemNode: ListViewItemNode, ItemListItemNode {
|
||||
self.activateArea = AccessibilityAreaNode()
|
||||
self.activateArea.accessibilityTraits = .staticText
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
super.init(layerBacked: false)
|
||||
|
||||
self.addSubnode(self.textNode.textNode)
|
||||
self.addSubnode(self.activateArea)
|
||||
|
||||
@@ -134,7 +134,7 @@ public class ItemListTextWithLabelItemNode: ListViewItemNode {
|
||||
self.textNode.contentMode = .left
|
||||
self.textNode.contentsScale = UIScreen.main.scale
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
super.init(layerBacked: false)
|
||||
|
||||
self.isAccessibilityElement = true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user