This commit is contained in:
Kylmakalle
2025-12-19 22:45:26 +02:00
parent c382dd4fb1
commit 96a12a0d56
12 changed files with 177 additions and 4 deletions

View File

@@ -15,6 +15,7 @@ public func updateSGWebSettingsInteractivelly(context: AccountContext) {
SGLogger.shared.log("SGAPI", "New SGWebSettings for id \(context.account.peerId.id._internalGetInt64Value()): \(webSettings) ")
SGSimpleSettings.shared.canUseStealthMode = webSettings.global.storiesAvailable
SGSimpleSettings.shared.duckyAppIconAvailable = webSettings.global.duckyAppIconAvailable
SGSimpleSettings.shared.canUseNY = webSettings.global.nyAvailable
let _ = (context.account.postbox.transaction { transaction in
updateAppConfiguration(transaction: transaction, { configuration -> AppConfiguration in
var configuration = configuration

15
Swiftgram/SGNY/BUILD Normal file
View File

@@ -0,0 +1,15 @@
filegroup(
name = "SGNY",
srcs = glob([
"Sources/**/*.swift",
]),
visibility = [
"//visibility:public",
],
)
filegroup(
name = "SGNYAssets",
srcs = glob(["Images.xcassets/**"]),
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "SGSnowflake.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@@ -0,0 +1,66 @@
import Foundation
import UIKit
import AsyncDisplayKit
import Display
import SGSimpleSettings
class WallpaperNYNode: ASDisplayNode {
private var emitterLayer: CAEmitterLayer?
func updateLayout(size: CGSize) {
if self.emitterLayer == nil {
let particlesLayer = CAEmitterLayer()
self.emitterLayer = particlesLayer
self.layer.addSublayer(particlesLayer)
self.layer.masksToBounds = true
particlesLayer.backgroundColor = UIColor.clear.cgColor
particlesLayer.emitterShape = .circle
particlesLayer.emitterMode = .surface
particlesLayer.renderMode = .oldestLast
let cell1 = CAEmitterCell()
switch SGSimpleSettings.shared.nyStyle {
case SGSimpleSettings.NYStyle.lightning.rawValue:
// cell1.contents = generateTintedImage(image: UIImage(bundleImageName: "SwiftgramContextMenu"), color: .white)
cell1.contents = UIImage(bundleImageName: "SwiftgramContextMenu")?.cgImage
cell1.name = "lightning"
cell1.scale = 0.15
cell1.scaleRange = 0.25
default:
cell1.contents = UIImage(bundleImageName: "SGSnowflake")?.cgImage
cell1.name = "snow"
cell1.scale = 0.04
cell1.scaleRange = 0.15
}
cell1.birthRate = 202.0
cell1.lifetime = 70.0
cell1.velocity = 1.0
cell1.velocityRange = -1.5
cell1.xAcceleration = 0.33
cell1.yAcceleration = 1.0
cell1.emissionRange = .pi
cell1.spin = -28.6 * (.pi / 180.0)
cell1.spinRange = 57.2 * (.pi / 180.0)
cell1.color = UIColor.white.withAlphaComponent(0.58).cgColor
// cell1.alphaRange = -0.2
particlesLayer.emitterCells = [cell1]
}
if let emitterLayer = self.emitterLayer {
var emitterWidthK: CGFloat = 2.5
switch SGSimpleSettings.shared.nyStyle {
case SGSimpleSettings.NYStyle.lightning.rawValue:
emitterWidthK = 5.0
default:
break
}
emitterLayer.emitterPosition = CGPoint(x: size.width * 0.40, y: -size.height / 2.0)
emitterLayer.emitterSize = CGSize(width: size.width * emitterWidthK, height: size.height)
emitterLayer.frame = CGRect(x: 0.0, y: 0.0, width: size.width, height: size.height)
}
}
}

View File

@@ -27,6 +27,7 @@ import UndoUI
private enum SGControllerSection: Int32, SGItemListSection {
case search
case trending
case content
case tabs
case folders
@@ -103,6 +104,7 @@ private enum SGBoolSetting: String {
}
private enum SGOneFromManySetting: String {
case nyStyle
case bottomTabStyle
case downloadSpeedBoost
case allChatsTitleLengthOverride
@@ -143,6 +145,17 @@ private func SGControllerEntries(presentationData: PresentationData, callListSet
let id = SGItemListCounter()
entries.append(.searchInput(id: id.count, section: .search, title: NSAttributedString(string: "🔍"), text: state.searchQuery ?? "", placeholder: strings.Common_Search))
// if SGSimpleSettings.shared.canUseNY {
if "".isEmpty {
entries.append(.header(id: id.count, section: .trending, text: i18n("Settings.NY.Header", lang), badge: nil))
entries.append(.oneFromManySelector(id: id.count, section: .trending, settingName: .nyStyle, text: i18n("Settings.NY.Style", lang), value: i18n("Settings.NY.Style.\(SGSimpleSettings.shared.nyStyle)", lang), enabled: true))
entries.append(.notice(id: id.count, section: .trending, text: i18n("Settings.NY.Notice", lang)))
} else {
id.increment(3)
}
if appConfiguration.sgWebSettings.global.canEditSettings {
entries.append(.disclosure(id: id.count, section: .content, link: .contentSettings, text: i18n("Settings.ContentSettings", lang)))
} else {
@@ -648,6 +661,18 @@ public func sgSettingsController(context: AccountContext/*, focusOnItemTag: Int?
setAction(value.rawValue)
}))
}
case .nyStyle:
let setAction: (String) -> Void = { value in
SGSimpleSettings.shared.nyStyle = value
simplePromise.set(true)
}
for value in SGSimpleSettings.NYStyle.allCases {
items.append(ActionSheetButtonItem(title: i18n("Settings.NY.Style.\(value.rawValue)", presentationData.strings.baseLanguageCode), color: .accent, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
setAction(value.rawValue)
}))
}
}
actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [

View File

@@ -152,6 +152,8 @@ public class SGSimpleSettings {
case transcriptionBackend
case translationBackend
case customAppBadge
case canUseNY
case nyStyle
}
public enum DownloadSpeedBoostValues: String, CaseIterable {
@@ -212,6 +214,12 @@ public class SGSimpleSettings {
case silenced
case disabled
}
public enum NYStyle: String, CaseIterable {
case `default`
case snow
case lightning
}
public static let defaultValues: [String: Any] = [
Keys.hidePhoneInSettings.rawValue: true,
@@ -282,6 +290,8 @@ public class SGSimpleSettings {
Keys.transcriptionBackend.rawValue: TranscriptionBackend.default.rawValue,
Keys.translationBackend.rawValue: TranslationBackend.default.rawValue,
Keys.customAppBadge.rawValue: "",
Keys.canUseNY.rawValue: false,
Keys.nyStyle.rawValue: NYStyle.snow.rawValue,
]
public static let groupDefaultValues: [String: Any] = [
@@ -518,6 +528,12 @@ public class SGSimpleSettings {
@UserDefault(key: Keys.customAppBadge.rawValue)
public var customAppBadge: String
@UserDefault(key: Keys.canUseNY.rawValue)
public var canUseNY: Bool
@UserDefault(key: Keys.nyStyle.rawValue)
public var nyStyle: String
}
extension SGSimpleSettings {
@@ -540,6 +556,12 @@ extension SGSimpleSettings {
}
}
extension SGSimpleSettings {
public var isNYEnabled: Bool {
return /*canUseNY && */ NYStyle(rawValue: nyStyle) != .default
}
}
public func getSGDownloadPartSize(_ default: Int64, fileSize: Int64?) -> Int64 {
let currentDownloadSetting = SGSimpleSettings.shared.downloadSpeedBoost
// Increasing chunk size for small files make it worse in terms of overall download performance

View File

@@ -262,3 +262,10 @@
"AppBadge.Title" = "App Badge";
"AppBadge.Notice" = "Customize App Badge shown on screenshots";
"Settings.NY.Header" = "HOLIDAY EFFECTS";
"Settings.NY.Style" = "Style";
"Settings.NY.Style.default" = "Disabled";
"Settings.NY.Style.snow" = "Snow";
"Settings.NY.Style.lightning" = "Swiftgram";
"Settings.NY.Notice" = "Available for a limited time only!";

View File

@@ -5,7 +5,7 @@ public struct SGWebSettings: Codable, Equatable {
public let user: SGUserSettings
public static var defaultValue: SGWebSettings {
return SGWebSettings(global: SGGlobalSettings(ytPip: true, qrLogin: true, storiesAvailable: false, canViewMessages: true, canEditSettings: false, canShowTelescope: false, announcementsData: nil, regdateFormat: "month", botMonkeys: [], forceReasons: [], unforceReasons: [], paymentsEnabled: true, duckyAppIconAvailable: true, canGrant: false, proSupportUrl: nil), user: SGUserSettings(contentReasons: [], canSendTelescope: false, canBuyInBeta: true))
return SGWebSettings(global: SGGlobalSettings(ytPip: true, qrLogin: true, storiesAvailable: false, canViewMessages: true, canEditSettings: false, canShowTelescope: false, announcementsData: nil, regdateFormat: "month", botMonkeys: [], forceReasons: [], unforceReasons: [], paymentsEnabled: true, duckyAppIconAvailable: true, canGrant: false, proSupportUrl: nil, nyAvailable: false), user: SGUserSettings(contentReasons: [], canSendTelescope: false, canBuyInBeta: true))
}
}
@@ -25,6 +25,7 @@ public struct SGGlobalSettings: Codable, Equatable {
public let duckyAppIconAvailable: Bool
public let canGrant: Bool
public let proSupportUrl: String?
public let nyAvailable: Bool
}
public struct SGBotMonkeys: Codable, Equatable {

View File

@@ -357,7 +357,7 @@ objc_library(
],
)
SGRESOURCES = ["//Swiftgram/SGSettingsUI:SGUIAssets", "//Swiftgram/SGPayWall:SGPayWallAssets", "//Swiftgram/SGAppBadgeAssets:SGAppBadgeAssets"]
SGRESOURCES = ["//Swiftgram/SGSettingsUI:SGUIAssets", "//Swiftgram/SGPayWall:SGPayWallAssets", "//Swiftgram/SGAppBadgeAssets:SGAppBadgeAssets", "//Swiftgram/SGNY:SGNYAssets"]
swift_library(
name = "Lib",

View File

@@ -40,19 +40,27 @@ apple_resource_bundle(
],
)
sgdeps = [
"//Swiftgram/SGSimpleSettings:SGSimpleSettings",
]
sgsrcs = [
"//Swiftgram/SGNY:SGNY"
]
swift_library(
name = "WallpaperBackgroundNode",
module_name = "WallpaperBackgroundNode",
srcs = glob([
"Sources/**/*.swift",
]),
]) + sgsrcs,
copts = [
"-warnings-as-errors",
],
data = [
":WallpaperBackgroundNodeBundle",
],
deps = [
deps = sgdeps + [
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
"//submodules/Display:Display",
"//submodules/GradientBackground:GradientBackground",

View File

@@ -1,3 +1,4 @@
import SGSimpleSettings
import Foundation
import UIKit
import AsyncDisplayKit
@@ -959,6 +960,10 @@ public final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgrou
}
}
// MARK: Swiftgram
private var NYNode: WallpaperNYNode?
//
private var imageContentMode: UIView.ContentMode {
didSet {
self.contentNode.contentMode = self.imageContentMode
@@ -1597,7 +1602,9 @@ public final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgrou
if isFirstLayout && !self.frame.isEmpty {
self.updateScale()
/* MARK: Swiftgram */ if SGSimpleSettings.shared.isNYEnabled && self.NYNode == nil { let nYNode = WallpaperNYNode(); self.addSubnode(nYNode); self.NYNode = nYNode }
}
/* MARK: Swiftgram */ self.NYNode?.frame = CGRect(origin: CGPoint(), size: size); self.NYNode?.updateLayout(size: size)
}
private var isAnimating = false