Update Ghostgram features

This commit is contained in:
ichmagmaus 812
2026-03-07 18:15:32 +01:00
parent 1a3303b059
commit 24a7ec39d9
902 changed files with 148302 additions and 62355 deletions
@@ -1,5 +1,9 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
sgdeps = [
"//Swiftgram/SGSimpleSettings"
]
swift_library(
name = "TabBarComponent",
module_name = "TabBarComponent",
@@ -9,7 +13,7 @@ swift_library(
copts = [
"-warnings-as-errors",
],
deps = [
deps = sgdeps + [
"//submodules/Display",
"//submodules/TelegramPresentationData",
"//submodules/ComponentFlow",
@@ -1,3 +1,4 @@
import SGSimpleSettings
import Foundation
import UIKit
import Display
@@ -111,7 +112,7 @@ public final class NavigationSearchView: UIView {
transition.setFrame(view: self.backgroundView, frame: CGRect(origin: CGPoint(), size: backgroundSize))
let alphaTransition: ComponentTransition = transition.animation.isImmediate ? .immediate : .easeInOut(duration: 0.25)
self.backgroundView.update(size: backgroundSize, cornerRadius: backgroundSize.height * 0.5, isDark: params.theme.overallDarkAppearance, tintColor: .init(kind: .panel, color: UIColor(white: params.theme.overallDarkAppearance ? 0.0 : 1.0, alpha: 0.6)), isInteractive: true, transition: transition)
self.backgroundView.update(size: backgroundSize, cornerRadius: backgroundSize.height * 0.5, isDark: params.theme.overallDarkAppearance, tintColor: .init(kind: .panel), isInteractive: true, transition: transition)
if self.iconView.image == nil {
self.iconView.image = UIImage(bundleImageName: "Navigation/Search")?.withRenderingMode(.alwaysTemplate)
@@ -215,7 +216,7 @@ public final class NavigationSearchView: UIView {
}
close.background.frame = closeFrame.size.centered(in: previousBackgroundFrame)
close.background.update(size: close.background.bounds.size, cornerRadius: close.background.bounds.height * 0.5, isDark: params.theme.overallDarkAppearance, tintColor: .init(kind: .panel, color: UIColor(white: params.theme.overallDarkAppearance ? 0.0 : 1.0, alpha: 0.6)), isInteractive: true, transition: .immediate)
close.background.update(size: close.background.bounds.size, cornerRadius: close.background.bounds.height * 0.5, isDark: params.theme.overallDarkAppearance, tintColor: .init(kind: .panel), isInteractive: true, transition: .immediate)
ComponentTransition.immediate.setScale(view: close.background, scale: 0.001)
}
@@ -229,7 +230,7 @@ public final class NavigationSearchView: UIView {
transition.setFrame(view: close.icon, frame: image.size.centered(in: CGRect(origin: CGPoint(), size: closeFrame.size)))
}
close.background.update(size: closeFrame.size, cornerRadius: closeFrame.height * 0.5, isDark: params.theme.overallDarkAppearance, tintColor: .init(kind: .panel, color: UIColor(white: params.theme.overallDarkAppearance ? 0.0 : 1.0, alpha: 0.6)), isInteractive: true, transition: closeTransition)
close.background.update(size: closeFrame.size, cornerRadius: closeFrame.height * 0.5, isDark: params.theme.overallDarkAppearance, tintColor: .init(kind: .panel), isInteractive: true, transition: closeTransition)
} else {
if let close = self.close {
self.close = nil
@@ -237,7 +238,7 @@ public final class NavigationSearchView: UIView {
let closeFrame = CGSize(width: 48.0, height: 48.0).centered(in: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: params.size))
transition.setPosition(view: closeBackground, position: closeFrame.center)
transition.setBounds(view: closeBackground, bounds: CGRect(origin: CGPoint(), size: closeFrame.size))
closeBackground.update(size: closeFrame.size, cornerRadius: closeFrame.height * 0.5, isDark: params.theme.overallDarkAppearance, tintColor: .init(kind: .panel, color: UIColor(white: params.theme.overallDarkAppearance ? 0.0 : 1.0, alpha: 0.6)), isInteractive: true, transition: transition)
closeBackground.update(size: closeFrame.size, cornerRadius: closeFrame.height * 0.5, isDark: params.theme.overallDarkAppearance, tintColor: .init(kind: .panel), isInteractive: true, transition: transition)
transition.setScale(view: closeBackground, scale: 0.001, completion: { [weak closeBackground] _ in
closeBackground?.removeFromSuperview()
})
@@ -556,7 +557,28 @@ public final class TabBarComponent: Component {
let _ = alphaTransition
let innerInset: CGFloat = 4.0
let availableSize = CGSize(width: min(500.0, availableSize.width), height: availableSize.height)
var availableSize = CGSize(width: min(500.0, availableSize.width), height: availableSize.height)
if !(SGSimpleSettings.shared.wideTabBar || component.search?.isActive ?? false) {
let widthReducer: CGFloat
switch component.items.count {
case 1:
widthReducer = 1.75
case 2:
widthReducer = 1.5
case 3:
widthReducer = 1.25
case 4:
widthReducer = 1.0
default:
widthReducer = 1.0
}
availableSize.width = availableSize.width / widthReducer
if !SGSimpleSettings.shared.tabBarSearchEnabled {
availableSize.width -= 48.0
availableSize.width -= innerInset * 2.0
}
}
let previousComponent = self.component
self.component = component
@@ -564,7 +586,7 @@ public final class TabBarComponent: Component {
self.overrideUserInterfaceStyle = component.theme.overallDarkAppearance ? .dark : .light
let barHeight: CGFloat = 56.0 + innerInset * 2.0
let barHeight: CGFloat = (SGSimpleSettings.shared.showTabNames ? 56.0 : 40.0) + innerInset * 2.0
var availableItemsWidth: CGFloat = availableSize.width - innerInset * 2.0
if component.search != nil {
@@ -597,7 +619,7 @@ public final class TabBarComponent: Component {
isUnconstrained: true
)),
environment: {},
containerSize: CGSize(width: 200.0, height: 56.0)
containerSize: CGSize(width: 200.0, height: SGSimpleSettings.shared.showTabNames ? 56.0 : 40.0)
)
unboundItemWidths.append(itemSize.width)
@@ -626,7 +648,7 @@ public final class TabBarComponent: Component {
totalItemsWidth = total
}
let itemHeight: CGFloat = 56.0
let itemHeight: CGFloat = (SGSimpleSettings.shared.showTabNames ? 56.0 : 40.0)
let contentWidth: CGFloat = innerInset * 2.0 + totalItemsWidth
let tabsSize = CGSize(width: min(availableSize.width, contentWidth), height: itemHeight + innerInset * 2.0)
@@ -767,7 +789,7 @@ public final class TabBarComponent: Component {
} else if let selectionFrame {
lensSelection = (selectionFrame.minX - innerInset, selectionFrame.width + innerInset * 2.0)
} else {
lensSelection = (0.0, 56.0)
lensSelection = (0.0, (SGSimpleSettings.shared.showTabNames ? 56.0 : 40.0))
}
var lensSize: CGSize = tabsSize
@@ -1060,7 +1082,7 @@ private final class ItemComponent: Component {
containerSize: CGSize(width: availableSize.width, height: 100.0)
)
let titleFrame = CGRect(origin: CGPoint(x: floor((availableSize.width - titleSize.width) * 0.5), y: availableSize.height - 8.0 - titleSize.height), size: titleSize)
if let titleView = self.title.view {
if SGSimpleSettings.shared.showTabNames, let titleView = self.title.view {
if titleView.superview == nil {
self.contextContainerView.contentView.addSubview(titleView)
}