Skip to content

Commit

Permalink
1.8.9 (370)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis15yo committed Nov 12, 2024
1 parent 30301ed commit f2b6b13
Show file tree
Hide file tree
Showing 38 changed files with 876 additions and 35 deletions.
6 changes: 3 additions & 3 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Nicegram/NGData/Sources/NGSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,28 @@ public struct NGSettings {

@NGStorage(key: "feedPeer", defaultValue: [:])
public static var feedPeer: [Int64: PeerId]

@NGStorage(key: "hideBadgeCounters", defaultValue: false)
public static var hideBadgeCounters: Bool
}

public extension NGSettings {
struct ChatDisplaySettings: Codable {
public var enableGrayscale: Bool = false
}

@NGStorage(key: "chatDisplaySettings", defaultValue: ChatDisplaySettings())
static var chatDisplaySettings
}

public extension NGSettings {
struct ChatListDisplaySettings: Codable {
public var disableAnimations: Bool = false
public var enableGrayscale: Bool = false
}

@NGStorage(key: "chatListDisplaySettings", defaultValue: ChatListDisplaySettings())
static var chatListDisplaySettings
}

public struct NGWebSettings {
Expand Down
26 changes: 25 additions & 1 deletion Nicegram/NGUI/Sources/NicegramSettingsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ private enum EasyToggleType {
case showProfileId
case showRegDate
case hideReactions
case hideStories
case hideStories
case hideBadgeCounters
case enableAnimationsInChatList
case enableGrayscaleInChatList
case enableGrayscaleInChat
}


Expand Down Expand Up @@ -541,6 +545,14 @@ private enum NicegramSettingsControllerEntry: ItemListNodeEntry {
if value {
sendUserSettingsAnalytics(with: .hideStoriesOn)
}
case .hideBadgeCounters:
NGSettings.hideBadgeCounters = value
case .enableAnimationsInChatList:
NGSettings.chatListDisplaySettings.disableAnimations = !value
case .enableGrayscaleInChatList:
NGSettings.chatListDisplaySettings.enableGrayscale = value
case .enableGrayscaleInChat:
NGSettings.chatDisplaySettings.enableGrayscale = value
}
})
case let .unblockHeader(text):
Expand Down Expand Up @@ -731,6 +743,18 @@ private func nicegramSettingsControllerEntries(presentationData: PresentationDat

entries.append(.easyToggle(toggleIndex, .hideStories, l("NicegramSettings.HideStories"), NGSettings.hideStories))
toggleIndex += 1

entries.append(.easyToggle(toggleIndex, .hideBadgeCounters, l("NicegramSettings.HideBadgeCounters"), NGSettings.hideBadgeCounters))
toggleIndex += 1

entries.append(.easyToggle(toggleIndex, .enableAnimationsInChatList, l("NicegramSettings.EnableAnimationsInChatList"), !NGSettings.chatListDisplaySettings.disableAnimations))
toggleIndex += 1

entries.append(.easyToggle(toggleIndex, .enableGrayscaleInChatList, l("NicegramSettings.EnableGrayscaleInChatList"), NGSettings.chatListDisplaySettings.enableGrayscale))
toggleIndex += 1

entries.append(.easyToggle(toggleIndex, .enableGrayscaleInChat, l("NicegramSettings.EnableGrayscaleInChat"), NGSettings.chatDisplaySettings.enableGrayscale))
toggleIndex += 1

if let sharingSettings {
entries.append(
Expand Down
36 changes: 36 additions & 0 deletions Nicegram/NGUtils/Sources/GrayscaleApplier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import UIKit

public class GrayscaleApplier {

private var grayscaleLayer: CALayer?

public init() {}
}

public extension GrayscaleApplier {
func onLayoutUpdated(
apply: Bool,
frame: CGRect,
superlayer: CALayer?
) {
if apply {
let grayscaleLayer: CALayer
if let _grayscaleLayer = self.grayscaleLayer {
grayscaleLayer = _grayscaleLayer
} else {
grayscaleLayer = CALayer()
grayscaleLayer.compositingFilter = "colorBlendMode"
grayscaleLayer.backgroundColor = UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 1.0).cgColor

self.grayscaleLayer = grayscaleLayer

superlayer?.addSublayer(grayscaleLayer)
}

grayscaleLayer.frame = frame
} else {
self.grayscaleLayer?.removeFromSuperlayer()
self.grayscaleLayer = nil
}
}
}
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"location" : "[email protected]:mobyrix/nicegram-assistant-ios.git",
"state" : {
"branch" : "develop",
"revision" : "970f0835a1b64becc8d6fbe0e9a381f04d1e14bd"
"revision" : "0f8c6a99b60031394f19946fe6887d4e7a12f3b7"
}
},
{
Expand Down
Loading

0 comments on commit f2b6b13

Please sign in to comment.