mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-06-08 19:13:56 +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:
@@ -45,6 +45,7 @@ swift_library(
|
||||
"//submodules/GalleryData",
|
||||
"//submodules/SegmentedControlNode",
|
||||
"//submodules/TelegramUIPreferences",
|
||||
"//submodules/TelegramUI/Components/GlassBackgroundComponent",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
||||
@@ -24,22 +24,26 @@ import GalleryData
|
||||
import AnimatedTextComponent
|
||||
import TelegramUIPreferences
|
||||
import SegmentControlComponent
|
||||
import GlassBackgroundComponent
|
||||
|
||||
final class DataUsageScreenComponent: Component {
|
||||
typealias EnvironmentType = ViewControllerComponentContainer.Environment
|
||||
|
||||
let context: AccountContext
|
||||
let overNavigationContainer: UIView
|
||||
let statsSet: StatsSet
|
||||
let mediaAutoDownloadSettings: MediaAutoDownloadSettings
|
||||
let makeAutodownloadSettingsController: (Bool) -> ViewController
|
||||
|
||||
init(
|
||||
context: AccountContext,
|
||||
overNavigationContainer: UIView,
|
||||
statsSet: StatsSet,
|
||||
mediaAutoDownloadSettings: MediaAutoDownloadSettings,
|
||||
makeAutodownloadSettingsController: @escaping (Bool) -> ViewController
|
||||
) {
|
||||
self.context = context
|
||||
self.overNavigationContainer = overNavigationContainer
|
||||
self.statsSet = statsSet
|
||||
self.mediaAutoDownloadSettings = mediaAutoDownloadSettings
|
||||
self.makeAutodownloadSettingsController = makeAutodownloadSettingsController
|
||||
@@ -313,12 +317,9 @@ final class DataUsageScreenComponent: Component {
|
||||
private var mediaAutoDownloadSettings: MediaAutoDownloadSettings = .defaultSettings
|
||||
private var mediaAutoDownloadSettingsDisposable: Disposable?
|
||||
|
||||
private let navigationBackgroundView: BlurredBackgroundView
|
||||
private let navigationSeparatorLayer: SimpleLayer
|
||||
private let navigationSeparatorLayerContainer: SimpleLayer
|
||||
|
||||
private let headerView = ComponentView<Empty>()
|
||||
private let headerOffsetContainer: HeaderContainer
|
||||
private let headerContentContainer: HeaderContainer
|
||||
private let headerDescriptionView = ComponentView<Empty>()
|
||||
|
||||
private var doneLabel: ComponentView<Empty>?
|
||||
@@ -356,14 +357,7 @@ final class DataUsageScreenComponent: Component {
|
||||
|
||||
override init(frame: CGRect) {
|
||||
self.headerOffsetContainer = HeaderContainer()
|
||||
|
||||
self.navigationBackgroundView = BlurredBackgroundView(color: nil, enableBlur: true)
|
||||
self.navigationBackgroundView.alpha = 0.0
|
||||
|
||||
self.navigationSeparatorLayer = SimpleLayer()
|
||||
self.navigationSeparatorLayer.opacity = 1.0
|
||||
self.navigationSeparatorLayerContainer = SimpleLayer()
|
||||
self.navigationSeparatorLayerContainer.opacity = 0.0
|
||||
self.headerContentContainer = HeaderContainer()
|
||||
|
||||
self.scrollContainerView = UIView()
|
||||
|
||||
@@ -396,12 +390,7 @@ final class DataUsageScreenComponent: Component {
|
||||
|
||||
self.scrollContainerView.addSubview(self.autoDownloadSettingsContainerView)
|
||||
|
||||
self.addSubview(self.navigationBackgroundView)
|
||||
|
||||
self.navigationSeparatorLayerContainer.addSublayer(self.navigationSeparatorLayer)
|
||||
self.layer.addSublayer(self.navigationSeparatorLayerContainer)
|
||||
|
||||
self.addSubview(self.headerOffsetContainer)
|
||||
self.headerOffsetContainer.addSubview(self.headerContentContainer)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
@@ -447,41 +436,19 @@ final class DataUsageScreenComponent: Component {
|
||||
headerOffset = min(headerOffset, minOffset)
|
||||
|
||||
let animatedTransition = ComponentTransition(animation: .curve(duration: 0.2, curve: .easeInOut))
|
||||
let navigationBackgroundAlpha: CGFloat = abs(headerOffset - minOffset) < 4.0 ? 1.0 : 0.0
|
||||
|
||||
let navigationButtonAlpha: CGFloat = scrollBounds.minY >= navigationMetrics.navigationHeight ? 0.0 : 1.0
|
||||
|
||||
animatedTransition.setAlpha(view: self.navigationBackgroundView, alpha: navigationBackgroundAlpha)
|
||||
animatedTransition.setAlpha(layer: self.navigationSeparatorLayerContainer, alpha: navigationBackgroundAlpha)
|
||||
|
||||
/*let expansionDistance: CGFloat = 32.0
|
||||
var expansionDistanceFactor: CGFloat = abs(scrollBounds.maxY - self.scrollView.contentSize.height) / expansionDistance
|
||||
expansionDistanceFactor = max(0.0, min(1.0, expansionDistanceFactor))
|
||||
|
||||
transition.setAlpha(layer: self.navigationSeparatorLayer, alpha: expansionDistanceFactor)*/
|
||||
|
||||
/*var offsetFraction: CGFloat = abs(headerOffset - minOffset) / 60.0
|
||||
offsetFraction = min(1.0, max(0.0, offsetFraction))
|
||||
transition.setScale(view: headerView, scale: 1.0 * offsetFraction + 0.8 * (1.0 - offsetFraction))*/
|
||||
|
||||
transition.setBounds(view: self.headerOffsetContainer, bounds: CGRect(origin: CGPoint(x: 0.0, y: headerOffset), size: self.headerOffsetContainer.bounds.size))
|
||||
|
||||
let headerContentsAlpha: CGFloat
|
||||
let offsetFraction = abs(headerOffset - minOffset) / 60.0
|
||||
headerContentsAlpha = min(1.0, max(0.0, offsetFraction))
|
||||
|
||||
transition.setAlpha(view: self.headerContentContainer, alpha: headerContentsAlpha)
|
||||
|
||||
if let controller = self.controller?(), let backButtonNode = controller.navigationBar?.backButtonNode {
|
||||
backButtonNode.updateManualAlpha(alpha: navigationButtonAlpha, transition: animatedTransition.containedViewLayoutTransition)
|
||||
|
||||
/*if backButtonNode.alpha != navigationButtonAlpha {
|
||||
if backButtonNode.isHidden {
|
||||
backButtonNode.alpha = 0.0
|
||||
backButtonNode.isHidden = false
|
||||
}
|
||||
animatedTransition.setAlpha(layer: backButtonNode.layer, alpha: navigationButtonAlpha, completion: { [weak backButtonNode] completed in
|
||||
if let backButtonNode, completed {
|
||||
if navigationButtonAlpha.isZero {
|
||||
backButtonNode.isHidden = true
|
||||
}
|
||||
}
|
||||
})
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -539,17 +506,9 @@ final class DataUsageScreenComponent: Component {
|
||||
|
||||
self.navigationMetrics = (environment.navigationHeight, environment.statusBarHeight)
|
||||
|
||||
self.navigationSeparatorLayer.backgroundColor = environment.theme.rootController.navigationBar.separatorColor.cgColor
|
||||
|
||||
let navigationFrame = CGRect(origin: CGPoint(), size: CGSize(width: availableSize.width, height: environment.navigationHeight))
|
||||
self.navigationBackgroundView.updateColor(color: environment.theme.rootController.navigationBar.blurredBackgroundColor, transition: .immediate)
|
||||
self.navigationBackgroundView.update(size: navigationFrame.size, transition: transition.containedViewLayoutTransition)
|
||||
transition.setFrame(view: self.navigationBackgroundView, frame: navigationFrame)
|
||||
|
||||
let navigationSeparatorFrame = CGRect(origin: CGPoint(x: 0.0, y: navigationFrame.maxY), size: CGSize(width: availableSize.width, height: UIScreenPixel))
|
||||
|
||||
transition.setFrame(layer: self.navigationSeparatorLayerContainer, frame: navigationSeparatorFrame)
|
||||
transition.setFrame(layer: self.navigationSeparatorLayer, frame: CGRect(origin: CGPoint(), size: navigationSeparatorFrame.size))
|
||||
if self.headerOffsetContainer.superview == nil {
|
||||
component.overNavigationContainer.addSubview(self.headerOffsetContainer)
|
||||
}
|
||||
|
||||
self.backgroundColor = environment.theme.list.blocksBackgroundColor
|
||||
|
||||
@@ -709,7 +668,7 @@ final class DataUsageScreenComponent: Component {
|
||||
let pieChartFrame = CGRect(origin: CGPoint(x: 0.0, y: contentHeight), size: pieChartSize)
|
||||
if let pieChartComponentView = self.pieChartView.view {
|
||||
if pieChartComponentView.superview == nil {
|
||||
self.scrollView.addSubview(pieChartComponentView)
|
||||
self.headerContentContainer.addSubview(pieChartComponentView)
|
||||
}
|
||||
|
||||
pieChartTransition.setFrame(view: pieChartComponentView, frame: pieChartFrame)
|
||||
@@ -740,7 +699,7 @@ final class DataUsageScreenComponent: Component {
|
||||
if let doneLabelView = doneLabel.view {
|
||||
var animateIn = false
|
||||
if doneLabelView.superview == nil {
|
||||
self.scrollView.addSubview(doneLabelView)
|
||||
self.headerContentContainer.addSubview(doneLabelView)
|
||||
animateIn = true
|
||||
}
|
||||
doneLabelTransition.setFrame(view: doneLabelView, frame: doneLabelFrame)
|
||||
@@ -755,7 +714,7 @@ final class DataUsageScreenComponent: Component {
|
||||
if let doneSupLabelView = doneSupLabel.view {
|
||||
var animateIn = false
|
||||
if doneSupLabelView.superview == nil {
|
||||
self.scrollView.addSubview(doneSupLabelView)
|
||||
self.headerContentContainer.addSubview(doneSupLabelView)
|
||||
animateIn = true
|
||||
}
|
||||
doneLabelTransition.setFrame(view: doneSupLabelView, frame: doneSupLabelFrame)
|
||||
@@ -796,7 +755,7 @@ final class DataUsageScreenComponent: Component {
|
||||
let headerViewFrame = CGRect(origin: CGPoint(x: floor((availableSize.width - headerViewSize.width) / 2.0), y: contentHeight), size: headerViewSize)
|
||||
if let headerComponentView = self.headerView.view {
|
||||
if headerComponentView.superview == nil {
|
||||
self.scrollContainerView.addSubview(headerComponentView)
|
||||
self.headerOffsetContainer.addSubview(headerComponentView)
|
||||
}
|
||||
transition.setPosition(view: headerComponentView, position: headerViewFrame.center)
|
||||
headerComponentView.bounds = CGRect(origin: CGPoint(), size: headerViewFrame.size)
|
||||
@@ -838,7 +797,7 @@ final class DataUsageScreenComponent: Component {
|
||||
let headerDescriptionFrame = CGRect(origin: CGPoint(x: floor((availableSize.width - headerDescriptionSize.width) / 2.0), y: contentHeight), size: headerDescriptionSize)
|
||||
if let headerDescriptionComponentView = self.headerDescriptionView.view {
|
||||
if headerDescriptionComponentView.superview == nil {
|
||||
self.scrollContainerView.addSubview(headerDescriptionComponentView)
|
||||
self.headerContentContainer.addSubview(headerDescriptionComponentView)
|
||||
}
|
||||
transition.setPosition(view: headerDescriptionComponentView, position: headerDescriptionFrame.center)
|
||||
headerDescriptionComponentView.bounds = CGRect(origin: CGPoint(), size: headerDescriptionFrame.size)
|
||||
@@ -892,7 +851,7 @@ final class DataUsageScreenComponent: Component {
|
||||
)
|
||||
if let chartTotalLabelView = self.chartTotalLabel.view {
|
||||
if chartTotalLabelView.superview == nil {
|
||||
self.scrollContainerView.addSubview(chartTotalLabelView)
|
||||
self.headerContentContainer.addSubview(chartTotalLabelView)
|
||||
}
|
||||
|
||||
let chartAreaHeight: CGFloat
|
||||
@@ -926,7 +885,7 @@ final class DataUsageScreenComponent: Component {
|
||||
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(value: .modeChanged)))
|
||||
})),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: availableSize.width - sideInset * 2.0, height: 100.0)
|
||||
containerSize: CGSize(width: availableSize.width - (environment.safeInsets.left + 16.0 + 44.0 + 10.0) * 2.0, height: 100.0)
|
||||
)
|
||||
let segmentedControlFrame = CGRect(origin: CGPoint(x: floor((availableSize.width - segmentedSize.width) * 0.5), y: contentHeight), size: segmentedSize)
|
||||
if let segmentedControlComponentView = self.segmentedControlView.view {
|
||||
@@ -1252,6 +1211,8 @@ final class DataUsageScreenComponent: Component {
|
||||
public final class DataUsageScreen: ViewControllerComponentContainer {
|
||||
private let context: AccountContext
|
||||
|
||||
private let overNavigationContainer: UIView
|
||||
|
||||
private let readyValue = Promise<Bool>()
|
||||
override public var ready: Promise<Bool> {
|
||||
return self.readyValue
|
||||
@@ -1260,8 +1221,14 @@ public final class DataUsageScreen: ViewControllerComponentContainer {
|
||||
public init(context: AccountContext, stats: NetworkUsageStats, mediaAutoDownloadSettings: MediaAutoDownloadSettings, makeAutodownloadSettingsController: @escaping (Bool) -> ViewController) {
|
||||
self.context = context
|
||||
|
||||
self.overNavigationContainer = SparseContainerView()
|
||||
|
||||
//let componentReady = Promise<Bool>()
|
||||
super.init(context: context, component: DataUsageScreenComponent(context: context, statsSet: DataUsageScreenComponent.StatsSet(stats: stats), mediaAutoDownloadSettings: mediaAutoDownloadSettings, makeAutodownloadSettingsController: makeAutodownloadSettingsController), navigationBarAppearance: .transparent)
|
||||
super.init(context: context, component: DataUsageScreenComponent(context: context, overNavigationContainer: self.overNavigationContainer, statsSet: DataUsageScreenComponent.StatsSet(stats: stats), mediaAutoDownloadSettings: mediaAutoDownloadSettings, makeAutodownloadSettingsController: makeAutodownloadSettingsController), navigationBarAppearance: .default)
|
||||
|
||||
if let navigationBar = self.navigationBar {
|
||||
navigationBar.customOverBackgroundContentView.insertSubview(self.overNavigationContainer, at: 0)
|
||||
}
|
||||
|
||||
//self.readyValue.set(componentReady.get() |> timeout(0.3, queue: .mainQueue(), alternate: .single(true)))
|
||||
self.readyValue.set(.single(true))
|
||||
|
||||
+71
-58
@@ -24,6 +24,7 @@ import TelegramStringFormatting
|
||||
import GalleryData
|
||||
import AnimatedTextComponent
|
||||
import BottomButtonPanelComponent
|
||||
import GlassBackgroundComponent
|
||||
|
||||
#if DEBUG
|
||||
import os.signpost
|
||||
@@ -116,17 +117,20 @@ final class StorageUsageScreenComponent: Component {
|
||||
typealias EnvironmentType = ViewControllerComponentContainer.Environment
|
||||
|
||||
let context: AccountContext
|
||||
let overNavigationContainer: UIView
|
||||
let makeStorageUsageExceptionsScreen: (CacheStorageSettings.PeerStorageCategory) -> ViewController?
|
||||
let peer: EnginePeer?
|
||||
let ready: Promise<Bool>
|
||||
|
||||
init(
|
||||
context: AccountContext,
|
||||
overNavigationContainer: UIView,
|
||||
makeStorageUsageExceptionsScreen: @escaping (CacheStorageSettings.PeerStorageCategory) -> ViewController?,
|
||||
peer: EnginePeer?,
|
||||
ready: Promise<Bool>
|
||||
) {
|
||||
self.context = context
|
||||
self.overNavigationContainer = overNavigationContainer
|
||||
self.makeStorageUsageExceptionsScreen = makeStorageUsageExceptionsScreen
|
||||
self.peer = peer
|
||||
self.ready = ready
|
||||
@@ -740,9 +744,7 @@ final class StorageUsageScreenComponent: Component {
|
||||
|
||||
private var isOtherCategoryExpanded: Bool = false
|
||||
|
||||
private let navigationBackgroundView: BlurredBackgroundView
|
||||
private let navigationSeparatorLayer: SimpleLayer
|
||||
private let navigationSeparatorLayerContainer: SimpleLayer
|
||||
private let navigationRightButtonsBackground: GlassBackgroundView
|
||||
private let navigationEditButton = ComponentView<Empty>()
|
||||
private let navigationDoneButton = ComponentView<Empty>()
|
||||
|
||||
@@ -799,16 +801,7 @@ final class StorageUsageScreenComponent: Component {
|
||||
private var keepScreenActiveDisposable: Disposable?
|
||||
|
||||
override init(frame: CGRect) {
|
||||
self.headerOffsetContainer = UIView()
|
||||
self.headerOffsetContainer.isUserInteractionEnabled = false
|
||||
|
||||
self.navigationBackgroundView = BlurredBackgroundView(color: nil, enableBlur: true)
|
||||
self.navigationBackgroundView.alpha = 0.0
|
||||
|
||||
self.navigationSeparatorLayer = SimpleLayer()
|
||||
self.navigationSeparatorLayer.opacity = 0.0
|
||||
self.navigationSeparatorLayerContainer = SimpleLayer()
|
||||
self.navigationSeparatorLayerContainer.opacity = 0.0
|
||||
self.headerOffsetContainer = SparseContainerView()
|
||||
|
||||
self.scrollContainerView = UIView()
|
||||
|
||||
@@ -821,6 +814,8 @@ final class StorageUsageScreenComponent: Component {
|
||||
self.headerProgressBackgroundLayer = SimpleLayer()
|
||||
self.headerProgressForegroundLayer = SimpleLayer()
|
||||
|
||||
self.navigationRightButtonsBackground = GlassBackgroundView()
|
||||
|
||||
super.init(frame: frame)
|
||||
|
||||
self.scrollView.delaysContentTouches = true
|
||||
@@ -846,13 +841,6 @@ final class StorageUsageScreenComponent: Component {
|
||||
|
||||
self.scrollView.layer.addSublayer(self.headerProgressBackgroundLayer)
|
||||
self.scrollView.layer.addSublayer(self.headerProgressForegroundLayer)
|
||||
|
||||
self.addSubview(self.navigationBackgroundView)
|
||||
|
||||
self.navigationSeparatorLayerContainer.addSublayer(self.navigationSeparatorLayer)
|
||||
self.layer.addSublayer(self.navigationSeparatorLayerContainer)
|
||||
|
||||
self.addSubview(self.headerOffsetContainer)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
@@ -946,9 +934,6 @@ final class StorageUsageScreenComponent: Component {
|
||||
let animatedTransition = ComponentTransition(animation: .curve(duration: 0.18, curve: .easeInOut))
|
||||
let navigationBackgroundAlpha: CGFloat = abs(headerOffset - minOffset) < 4.0 ? 1.0 : 0.0
|
||||
|
||||
animatedTransition.setAlpha(view: self.navigationBackgroundView, alpha: navigationBackgroundAlpha)
|
||||
animatedTransition.setAlpha(layer: self.navigationSeparatorLayerContainer, alpha: navigationBackgroundAlpha)
|
||||
|
||||
var buttonsMasterAlpha: CGFloat = 1.0
|
||||
if let component = self.component, component.peer != nil {
|
||||
buttonsMasterAlpha = 0.0
|
||||
@@ -960,20 +945,12 @@ final class StorageUsageScreenComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
let isSelectingPeers = self.aggregatedData?.isSelectingPeers ?? false
|
||||
|
||||
if let navigationEditButtonView = self.navigationEditButton.view {
|
||||
animatedTransition.setAlpha(view: navigationEditButtonView, alpha: (isSelectingPeers ? 0.0 : 1.0) * buttonsMasterAlpha * navigationBackgroundAlpha)
|
||||
}
|
||||
if let navigationDoneButtonView = self.navigationDoneButton.view {
|
||||
animatedTransition.setAlpha(view: navigationDoneButtonView, alpha: (isSelectingPeers ? 1.0 : 0.0) * buttonsMasterAlpha * navigationBackgroundAlpha)
|
||||
}
|
||||
animatedTransition.setAlpha(view: self.navigationRightButtonsBackground, alpha: buttonsMasterAlpha * navigationBackgroundAlpha)
|
||||
|
||||
let expansionDistance: CGFloat = 32.0
|
||||
var expansionDistanceFactor: CGFloat = abs(scrollBounds.maxY - self.scrollView.contentSize.height) / expansionDistance
|
||||
expansionDistanceFactor = max(0.0, min(1.0, expansionDistanceFactor))
|
||||
|
||||
transition.setAlpha(layer: self.navigationSeparatorLayer, alpha: expansionDistanceFactor)
|
||||
if let panelContainerView = self.panelContainer.view as? StorageUsagePanelContainerComponent.View {
|
||||
panelContainerView.updateNavigationMergeFactor(value: 1.0 - expansionDistanceFactor, transition: transition)
|
||||
}
|
||||
@@ -983,6 +960,17 @@ final class StorageUsageScreenComponent: Component {
|
||||
transition.setScale(view: headerView, scale: 1.0 * offsetFraction + 0.8 * (1.0 - offsetFraction))
|
||||
|
||||
transition.setBounds(view: self.headerOffsetContainer, bounds: CGRect(origin: CGPoint(x: 0.0, y: headerOffset), size: self.headerOffsetContainer.bounds.size))
|
||||
|
||||
let headerContentsAlpha = offsetFraction
|
||||
if let chartAvatarNode = self.chartAvatarNode {
|
||||
transition.setAlpha(view: chartAvatarNode.view, alpha: headerContentsAlpha)
|
||||
}
|
||||
if let pieChartComponentView = self.pieChartView.view {
|
||||
transition.setAlpha(view: pieChartComponentView, alpha: headerContentsAlpha)
|
||||
}
|
||||
if let chartTotalLabelView = self.chartTotalLabel.view {
|
||||
transition.setAlpha(view: chartTotalLabelView, alpha: headerContentsAlpha)
|
||||
}
|
||||
}
|
||||
|
||||
let _ = self.panelContainer.updateEnvironment(
|
||||
@@ -1109,6 +1097,13 @@ final class StorageUsageScreenComponent: Component {
|
||||
self.reloadStats(firstTime: true, completion: {})
|
||||
}
|
||||
|
||||
if self.headerOffsetContainer.superview == nil {
|
||||
component.overNavigationContainer.addSubview(self.headerOffsetContainer)
|
||||
}
|
||||
if self.navigationRightButtonsBackground.superview == nil {
|
||||
component.overNavigationContainer.addSubview(self.navigationRightButtonsBackground)
|
||||
}
|
||||
|
||||
var wasLockedAtPanels = false
|
||||
if let panelContainerView = self.panelContainer.view, let navigationMetrics = self.navigationMetrics {
|
||||
if self.scrollView.bounds.minY > 0.0 && abs(self.scrollView.bounds.minY - (panelContainerView.frame.minY - navigationMetrics.navigationHeight)) <= UIScreenPixel {
|
||||
@@ -1147,22 +1142,11 @@ final class StorageUsageScreenComponent: Component {
|
||||
|
||||
self.navigationMetrics = (environment.navigationHeight, environment.statusBarHeight)
|
||||
|
||||
self.navigationSeparatorLayer.backgroundColor = environment.theme.rootController.navigationBar.separatorColor.cgColor
|
||||
|
||||
let navigationFrame = CGRect(origin: CGPoint(), size: CGSize(width: availableSize.width, height: environment.navigationHeight))
|
||||
self.navigationBackgroundView.updateColor(color: environment.theme.rootController.navigationBar.blurredBackgroundColor, transition: .immediate)
|
||||
self.navigationBackgroundView.update(size: navigationFrame.size, transition: transition.containedViewLayoutTransition)
|
||||
transition.setFrame(view: self.navigationBackgroundView, frame: navigationFrame)
|
||||
|
||||
let navigationSeparatorFrame = CGRect(origin: CGPoint(x: 0.0, y: navigationFrame.maxY), size: CGSize(width: availableSize.width, height: UIScreenPixel))
|
||||
|
||||
transition.setFrame(layer: self.navigationSeparatorLayerContainer, frame: navigationSeparatorFrame)
|
||||
transition.setFrame(layer: self.navigationSeparatorLayer, frame: CGRect(origin: CGPoint(), size: navigationSeparatorFrame.size))
|
||||
|
||||
let navigationEditButtonSize = self.navigationEditButton.update(
|
||||
transition: transition,
|
||||
component: AnyComponent(Button(
|
||||
content: AnyComponent(Text(text: environment.strings.Common_Edit, font: Font.regular(17.0), color: environment.theme.rootController.navigationBar.accentTextColor)),
|
||||
content: AnyComponent(Text(text: environment.strings.Common_Edit, font: Font.regular(17.0), color: environment.theme.chat.inputPanel.panelControlColor)),
|
||||
contentInsets: UIEdgeInsets(top: 0.0, left: 6.0, bottom: 0.0, right: 6.0),
|
||||
action: { [weak self] in
|
||||
guard let self else {
|
||||
return
|
||||
@@ -1172,21 +1156,22 @@ final class StorageUsageScreenComponent: Component {
|
||||
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
}
|
||||
}
|
||||
).minSize(CGSize(width: 16.0, height: environment.navigationHeight - environment.statusBarHeight))),
|
||||
).minSize(CGSize(width: 44.0, height: 44.0))),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: 150.0, height: environment.navigationHeight - environment.statusBarHeight)
|
||||
containerSize: CGSize(width: 150.0, height: 44.0)
|
||||
)
|
||||
if let navigationEditButtonView = self.navigationEditButton.view {
|
||||
if navigationEditButtonView.superview == nil {
|
||||
self.addSubview(navigationEditButtonView)
|
||||
self.navigationRightButtonsBackground.contentView.addSubview(navigationEditButtonView)
|
||||
}
|
||||
transition.setFrame(view: navigationEditButtonView, frame: CGRect(origin: CGPoint(x: availableSize.width - 12.0 - environment.safeInsets.right - navigationEditButtonSize.width, y: environment.statusBarHeight), size: navigationEditButtonSize))
|
||||
transition.setFrame(view: navigationEditButtonView, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: navigationEditButtonSize))
|
||||
}
|
||||
|
||||
let navigationDoneButtonSize = self.navigationDoneButton.update(
|
||||
transition: transition,
|
||||
component: AnyComponent(Button(
|
||||
content: AnyComponent(Text(text: environment.strings.Common_Done, font: Font.semibold(17.0), color: environment.theme.rootController.navigationBar.accentTextColor)),
|
||||
content: AnyComponent(Text(text: environment.strings.Common_Done, font: Font.semibold(17.0), color: environment.theme.chat.inputPanel.panelControlColor)),
|
||||
contentInsets: UIEdgeInsets(top: 0.0, left: 6.0, bottom: 0.0, right: 6.0),
|
||||
action: { [weak self] in
|
||||
guard let self, let aggregatedData = self.aggregatedData else {
|
||||
return
|
||||
@@ -1195,19 +1180,39 @@ final class StorageUsageScreenComponent: Component {
|
||||
aggregatedData.clearPeerSelection()
|
||||
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)))
|
||||
}
|
||||
).minSize(CGSize(width: 16.0, height: environment.navigationHeight - environment.statusBarHeight))),
|
||||
).minSize(CGSize(width: 44.0, height: 44.0))),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: 150.0, height: environment.navigationHeight - environment.statusBarHeight)
|
||||
containerSize: CGSize(width: 150.0, height: 44.0)
|
||||
)
|
||||
if let navigationDoneButtonView = self.navigationDoneButton.view {
|
||||
if navigationDoneButtonView.superview == nil {
|
||||
self.addSubview(navigationDoneButtonView)
|
||||
self.navigationRightButtonsBackground.contentView.addSubview(navigationDoneButtonView)
|
||||
}
|
||||
transition.setFrame(view: navigationDoneButtonView, frame: CGRect(origin: CGPoint(x: availableSize.width - 12.0 - environment.safeInsets.right - navigationDoneButtonSize.width, y: environment.statusBarHeight), size: navigationDoneButtonSize))
|
||||
transition.setFrame(view: navigationDoneButtonView, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: navigationDoneButtonSize))
|
||||
}
|
||||
|
||||
let navigationRightButtonMaxWidth: CGFloat = max(navigationEditButtonSize.width, navigationDoneButtonSize.width)
|
||||
|
||||
var rightButtonsWidth: CGFloat = 0.0
|
||||
let isSelectingPeers = self.aggregatedData?.isSelectingPeers ?? false
|
||||
if let navigationEditButtonView = self.navigationEditButton.view {
|
||||
if !isSelectingPeers {
|
||||
rightButtonsWidth += navigationEditButtonSize.width
|
||||
}
|
||||
transition.setAlpha(view: navigationEditButtonView, alpha: isSelectingPeers ? 0.0 : 1.0)
|
||||
}
|
||||
if let navigationDoneButtonView = self.navigationDoneButton.view {
|
||||
if isSelectingPeers {
|
||||
rightButtonsWidth += navigationDoneButtonSize.width
|
||||
}
|
||||
transition.setAlpha(view: navigationDoneButtonView, alpha: isSelectingPeers ? 1.0 : 0.0)
|
||||
}
|
||||
|
||||
let navigationRightButtonsBackgroundSize = CGSize(width: max(44.0, rightButtonsWidth), height: 44.0)
|
||||
self.navigationRightButtonsBackground.update(size: navigationRightButtonsBackgroundSize, cornerRadius: 44.0 * 0.5, isDark: environment.theme.overallDarkAppearance, tintColor: .init(kind: .panel, color: UIColor(white: environment.theme.overallDarkAppearance ? 0.0 : 1.0, alpha: 0.6)), isInteractive: true, transition: transition)
|
||||
let navigationRightButtonsBackgroundFrame = CGRect(origin: CGPoint(x: availableSize.width - environment.safeInsets.right - 16.0 - navigationRightButtonsBackgroundSize.width, y: environment.statusBarHeight + 2.0 + floor((environment.navigationHeight - environment.statusBarHeight - 44.0) * 0.5)), size: navigationRightButtonsBackgroundSize)
|
||||
transition.setFrame(view: self.navigationRightButtonsBackground, frame: navigationRightButtonsBackgroundFrame)
|
||||
|
||||
self.backgroundColor = environment.theme.list.blocksBackgroundColor
|
||||
|
||||
var contentHeight: CGFloat = 0.0
|
||||
@@ -1436,7 +1441,7 @@ final class StorageUsageScreenComponent: Component {
|
||||
let pieChartFrame = CGRect(origin: CGPoint(x: 0.0, y: contentHeight), size: pieChartSize)
|
||||
if let pieChartComponentView = self.pieChartView.view {
|
||||
if pieChartComponentView.superview == nil {
|
||||
self.scrollView.addSubview(pieChartComponentView)
|
||||
self.headerOffsetContainer.addSubview(pieChartComponentView)
|
||||
}
|
||||
|
||||
pieChartTransition.setFrame(view: pieChartComponentView, frame: pieChartFrame)
|
||||
@@ -1637,7 +1642,7 @@ final class StorageUsageScreenComponent: Component {
|
||||
} else {
|
||||
chartAvatarNode = AvatarNode(font: avatarPlaceholderFont(size: 17.0))
|
||||
self.chartAvatarNode = chartAvatarNode
|
||||
self.scrollContainerView.addSubview(chartAvatarNode.view)
|
||||
self.headerOffsetContainer.addSubview(chartAvatarNode.view)
|
||||
chartAvatarNode.frame = avatarFrame
|
||||
|
||||
if peer.id == component.context.account.peerId {
|
||||
@@ -1681,7 +1686,7 @@ final class StorageUsageScreenComponent: Component {
|
||||
)
|
||||
if let chartTotalLabelView = self.chartTotalLabel.view {
|
||||
if chartTotalLabelView.superview == nil {
|
||||
self.scrollContainerView.addSubview(chartTotalLabelView)
|
||||
self.headerOffsetContainer.addSubview(chartTotalLabelView)
|
||||
}
|
||||
let totalLabelFrame = CGRect(origin: CGPoint(x: pieChartFrame.minX + floor((pieChartFrame.width - chartTotalLabelSize.width) / 2.0), y: pieChartFrame.minY + floor((pieChartFrame.height - chartTotalLabelSize.height) / 2.0)), size: chartTotalLabelSize)
|
||||
transition.setFrame(view: chartTotalLabelView, frame: totalLabelFrame)
|
||||
@@ -3303,6 +3308,8 @@ final class StorageUsageScreenComponent: Component {
|
||||
public final class StorageUsageScreen: ViewControllerComponentContainer {
|
||||
private let context: AccountContext
|
||||
|
||||
private let overNavigationContainer: UIView
|
||||
|
||||
private let readyValue = Promise<Bool>()
|
||||
override public var ready: Promise<Bool> {
|
||||
return self.readyValue
|
||||
@@ -3313,13 +3320,19 @@ public final class StorageUsageScreen: ViewControllerComponentContainer {
|
||||
public init(context: AccountContext, makeStorageUsageExceptionsScreen: @escaping (CacheStorageSettings.PeerStorageCategory) -> ViewController?, peer: EnginePeer? = nil) {
|
||||
self.context = context
|
||||
|
||||
self.overNavigationContainer = SparseContainerView()
|
||||
|
||||
let componentReady = Promise<Bool>()
|
||||
super.init(context: context, component: StorageUsageScreenComponent(context: context, makeStorageUsageExceptionsScreen: makeStorageUsageExceptionsScreen, peer: peer, ready: componentReady), navigationBarAppearance: .transparent)
|
||||
super.init(context: context, component: StorageUsageScreenComponent(context: context, overNavigationContainer: self.overNavigationContainer, makeStorageUsageExceptionsScreen: makeStorageUsageExceptionsScreen, peer: peer, ready: componentReady), navigationBarAppearance: .default)
|
||||
|
||||
if peer != nil {
|
||||
self.navigationPresentation = .modal
|
||||
}
|
||||
|
||||
if let navigationBar = self.navigationBar {
|
||||
navigationBar.customOverBackgroundContentView.insertSubview(self.overNavigationContainer, at: 0)
|
||||
}
|
||||
|
||||
self.readyValue.set(componentReady.get() |> timeout(0.3, queue: .mainQueue(), alternate: .single(true)))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user