Skip to content

Commit

Permalink
1.8.9 (375)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis15yo committed Nov 20, 2024
1 parent 9776f20 commit 61be813
Show file tree
Hide file tree
Showing 40 changed files with 616 additions and 38 deletions.
12 changes: 6 additions & 6 deletions MODULE.bazel.lock

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

3 changes: 2 additions & 1 deletion Nicegram/NGData/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ swift_library(
"//Nicegram/NGRequests:NGRequests",
"//Nicegram/NGLogging:NGLogging",
"//Nicegram/NGEnv:NGEnv",
"//Nicegram/NGAppCache:NGAppCache"
"//Nicegram/NGAppCache:NGAppCache",
"@swiftpkg_nicegram_assistant_ios//:NGCore",
],
visibility = [
"//visibility:public",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import Combine
import NGCore

class NicegramSettingsRepositoryImpl {

private let repo = UDRepository<NicegramSettings, NicegramSettingsDto>(
key: "nicegramSettings",
defaultValue: NicegramSettings(
disableAnimationsInChatList: false,
grayscaleAll: false,
grayscaleInChat: false,
grayscaleInChatList: false,
trackDigitalFootprint: false
),
toDomain: \.toDomain,
toDto: \.toDto
)
}

extension NicegramSettingsRepositoryImpl: NicegramSettingsRepository {
func settings() -> NicegramSettings {
repo.get()
}

func settingsPublisher() -> AnyPublisher<NicegramSettings, Never> {
repo.publisher()
}

func update(_ block: (NicegramSettings) -> (NicegramSettings)) async {
await repo.update(block)
}
}

private struct NicegramSettingsDto: Codable {
let disableAnimationsInChatList: Bool
let grayscaleAll: Bool
let grayscaleInChat: Bool
let grayscaleInChatList: Bool
let trackDigitalFootprint: Bool

var toDomain: NicegramSettings {
NicegramSettings(disableAnimationsInChatList: disableAnimationsInChatList, grayscaleAll: grayscaleAll, grayscaleInChat: grayscaleInChat, grayscaleInChatList: grayscaleInChatList, trackDigitalFootprint: trackDigitalFootprint)
}
}

private extension NicegramSettings {
var toDto: NicegramSettingsDto {
NicegramSettingsDto(disableAnimationsInChatList: disableAnimationsInChatList, grayscaleAll: grayscaleAll, grayscaleInChat: grayscaleInChat, grayscaleInChatList: grayscaleInChatList, trackDigitalFootprint: trackDigitalFootprint)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Combine

public class GetGrayscaleSettingsUseCase {

// MARK: - Dependencies

private let nicegramSettingsRepository: NicegramSettingsRepository

// MARK: - Lifecycle

init(nicegramSettingsRepository: NicegramSettingsRepository) {
self.nicegramSettingsRepository = nicegramSettingsRepository
}
}

public extension GetGrayscaleSettingsUseCase {
func grayscaleAllPublisher() -> AnyPublisher<Bool, Never> {
adjustedSetting(\.grayscaleAll)
}

func grayscaleInChatPublisher() -> AnyPublisher<Bool, Never> {
adjustedSetting(\.grayscaleInChat)
}

func grayscaleInChatListPublisher() -> AnyPublisher<Bool, Never> {
adjustedSetting(\.grayscaleInChatList)
}
}

private extension GetGrayscaleSettingsUseCase {
func adjustedSetting<T>(_ setting: @escaping (NicegramSettings) -> T) -> AnyPublisher<T, Never> {
nicegramSettingsRepository
.settingsPublisher()
.map { settings in
var result = settings
if result.grayscaleAll {
result.grayscaleInChat = false
result.grayscaleInChatList = false
}
return result
}
.map(setting)
.eraseToAnyPublisher()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Combine
import NGCore

public struct NicegramSettings: Withable {
public var disableAnimationsInChatList: Bool
public var grayscaleAll: Bool
public var grayscaleInChat: Bool
public var grayscaleInChatList: Bool
public var trackDigitalFootprint: Bool
}

public protocol NicegramSettingsRepository {
func settings() -> NicegramSettings
func settingsPublisher() -> AnyPublisher<NicegramSettings, Never>
func update(_: (NicegramSettings) -> (NicegramSettings)) async
}
24 changes: 24 additions & 0 deletions Nicegram/NGData/Sources/Modern/NicegramSettingsModule.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Factory

public final class NicegramSettingsModule: SharedContainer {
public static var shared = NicegramSettingsModule()
public var manager = ContainerManager()
}

extension NicegramSettingsModule {
public var getGrayscaleSettingsUseCase: Factory<GetGrayscaleSettingsUseCase> {
self { [self] in
GetGrayscaleSettingsUseCase(
nicegramSettingsRepository: nicegramSettingsRepository()
)
}
}
}

extension NicegramSettingsModule {
public var nicegramSettingsRepository: Factory<NicegramSettingsRepository> {
self {
NicegramSettingsRepositoryImpl()
}.cached
}
}
32 changes: 32 additions & 0 deletions Nicegram/NGData/Sources/Modern/Presentation/GrayscaleLayer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Combine
import UIKit

public class GrayscaleLayer: CALayer {
private var cancellables = Set<AnyCancellable>()

public init(
enablePublisher: AnyPublisher<Bool, Never>
) {
super.init()

self.isHidden = true
self.backgroundColor = UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 1.0).cgColor
self.compositingFilter = "colorBlendMode"

enablePublisher
.removeDuplicates()
.receive(on: DispatchQueue.main)
.sink { [weak self] enable in
self?.isHidden = !enable
}
.store(in: &cancellables)
}

public override init(layer: Any) {
super.init(layer: layer)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
private let nicegramSettingsRepository = NicegramSettingsModule.shared.nicegramSettingsRepository()

public func getNicegramSettings() -> NicegramSettings {
nicegramSettingsRepository.settings()
}

public func updateNicegramSettings(_ modifier: @escaping (inout NicegramSettings) -> Void) {
Task {
await nicegramSettingsRepository.update {
var result = $0
modifier(&result)
return result
}
}
}
36 changes: 35 additions & 1 deletion Nicegram/NGUI/Sources/NicegramSettingsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ private enum EasyToggleType {
case hideBadgeCounters
case hideUnreadCounters
case hideMentionNotification
case enableAnimationsInChatList
case enableGrayscaleAll
case enableGrayscaleInChatList
case enableGrayscaleInChat
}


Expand Down Expand Up @@ -551,6 +555,22 @@ private enum NicegramSettingsControllerEntry: ItemListNodeEntry {
case .hideMentionNotification:
NGSettings.hideMentionNotification = value
showRestartRequiredAlert(with: arguments, presentationData: presentationData)
case .enableAnimationsInChatList:
updateNicegramSettings {
$0.disableAnimationsInChatList = !value
}
case .enableGrayscaleAll:
updateNicegramSettings {
$0.grayscaleAll = value
}
case .enableGrayscaleInChatList:
updateNicegramSettings {
$0.grayscaleInChatList = value
}
case .enableGrayscaleInChat:
updateNicegramSettings {
$0.grayscaleInChat = value
}
}
})
case let .unblockHeader(text):
Expand Down Expand Up @@ -644,6 +664,8 @@ private enum NicegramSettingsControllerEntry: ItemListNodeEntry {
// MARK: Entries list

private func nicegramSettingsControllerEntries(presentationData: PresentationData, experimentalSettings: ExperimentalUISettings, showCalls: Bool, pinnedChats: [PinnedChat], sharingSettings: SharingSettings?, context: AccountContext) -> [NicegramSettingsControllerEntry] {
let nicegramSettings = getNicegramSettings()

var entries: [NicegramSettingsControllerEntry] = []

if !hideUnblock {
Expand Down Expand Up @@ -771,7 +793,19 @@ private func nicegramSettingsControllerEntries(presentationData: PresentationDat
)
)
toggleIndex += 1


entries.append(.easyToggle(toggleIndex, .enableAnimationsInChatList, l("NicegramSettings.EnableAnimationsInChatList"), !nicegramSettings.disableAnimationsInChatList))
toggleIndex += 1

entries.append(.easyToggle(toggleIndex, .enableGrayscaleAll, l("NicegramSettings.EnableGrayscaleAll"), nicegramSettings.grayscaleAll))
toggleIndex += 1

entries.append(.easyToggle(toggleIndex, .enableGrayscaleInChatList, l("NicegramSettings.EnableGrayscaleInChatList"), nicegramSettings.grayscaleInChatList))
toggleIndex += 1

entries.append(.easyToggle(toggleIndex, .enableGrayscaleInChat, l("NicegramSettings.EnableGrayscaleInChat"), nicegramSettings.grayscaleInChat))
toggleIndex += 1

if let sharingSettings {
entries.append(
.shareBotsData(
Expand Down
10 changes: 5 additions & 5 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
"kind" : "remoteSourceControl",
"location" : "[email protected]:mobyrix/nicegram-assistant-ios.git",
"state" : {
"branch" : "develop",
"revision" : "0f8c6a99b60031394f19946fe6887d4e7a12f3b7"
"branch" : "feat/new-onboarding",
"revision" : "46671ac5edb2acc67c8bb098d5e09accd566f915"
}
},
{
Expand All @@ -123,7 +123,7 @@
"location" : "[email protected]:mobyrix/nicegram-wallet-ios.git",
"state" : {
"branch" : "develop",
"revision" : "6417219110dae50a9dd129c61795dc469ceb12d0"
"revision" : "bacbf786664979e1b99783b81a0abaf8ad4735cf"
}
},
{
Expand Down Expand Up @@ -338,8 +338,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/trustwallet/wallet-core.git",
"state" : {
"revision" : "3772536bd3de5cf3a8b412f598823fc6ea5285fe",
"version" : "4.1.17"
"revision" : "e34e9ba2ed6e571e2b0531a5cfe1495cea5258f7",
"version" : "4.1.19"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription
let package = Package(
name: "nicegram-package",
dependencies: [
.package(url: "[email protected]:mobyrix/nicegram-assistant-ios.git", branch: "develop"),
.package(url: "[email protected]:mobyrix/nicegram-assistant-ios.git", branch: "feat/new-onboarding"),
.package(url: "[email protected]:mobyrix/nicegram-wallet-ios.git", branch: "develop")
]
)
4 changes: 4 additions & 0 deletions Telegram/Telegram-iOS/ar.lproj/NiceLocalizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@
"NicegramSettings.HideBadgeCounters" = "إخفاء عدادات الشارات";
"NicegramSettings.HideUnreadCounters" = "إخفاء عدادات الغير مقروءة";
"NicegramSettings.HideMentionNotification" = "إخفاء إشعارات الإشارة";
"NicegramSettings.EnableAnimationsInChatList" = "الرسوم المتحركة في قائمة الدردشة";
"NicegramSettings.EnableGrayscaleAll" = "الشاشة كاملة بالأبيض والأسود";
"NicegramSettings.EnableGrayscaleInChatList" = "الرمادي في قائمة الدردشة";
"NicegramSettings.EnableGrayscaleInChat" = "الرمادي في الدردشة";

/*Registration Date*/
"NiceFeatures.RegDate.OlderThan" = "أقدم من";
Expand Down
4 changes: 4 additions & 0 deletions Telegram/Telegram-iOS/de.lproj/NiceLocalizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@
"NicegramSettings.HideBadgeCounters" = "Ausblenden der Abzeichenzähler";
"NicegramSettings.HideUnreadCounters" = "Ungelesene Zähler verbergen";
"NicegramSettings.HideMentionNotification" = "Erwähnungsbenachrichtigungen verbergen";
"NicegramSettings.EnableAnimationsInChatList" = "Animationen in der Chatliste";
"NicegramSettings.EnableGrayscaleAll" = "Vollbild-Graustufen";
"NicegramSettings.EnableGrayscaleInChatList" = "Graustufen in der Chatliste";
"NicegramSettings.EnableGrayscaleInChat" = "Graustufen im Chat";

/*Registration Date*/
"NiceFeatures.RegDate.OlderThan" = "Älter als";
Expand Down
4 changes: 4 additions & 0 deletions Telegram/Telegram-iOS/en.lproj/NiceLocalizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@
"NicegramSettings.HideBadgeCounters" = "Hide Badge counters";
"NicegramSettings.HideUnreadCounters" = "Hide Unread counters";
"NicegramSettings.HideMentionNotification" = "Hide Mention notification";
"NicegramSettings.EnableAnimationsInChatList" = "Animations in chat list";
"NicegramSettings.EnableGrayscaleAll" = "Full-Screen Grayscale";
"NicegramSettings.EnableGrayscaleInChatList" = "Grayscale in chat list";
"NicegramSettings.EnableGrayscaleInChat" = "Grayscale in chat";

/*Registration Date*/
"NiceFeatures.RegDate.OlderThan" = "Older than";
Expand Down
4 changes: 4 additions & 0 deletions Telegram/Telegram-iOS/es.lproj/NiceLocalizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@
"NicegramSettings.HideBadgeCounters" = "Ocultar contadores de insignias";
"NicegramSettings.HideUnreadCounters" = "Ocultar contadores de no leídos";
"NicegramSettings.HideMentionNotification" = "Ocultar notificación de mención";
"NicegramSettings.EnableAnimationsInChatList" = "Animaciones en la lista de chat";
"NicegramSettings.EnableGrayscaleAll" = "Escala de grises en pantalla completa";
"NicegramSettings.EnableGrayscaleInChatList" = "Escala de grises en la lista de chat";
"NicegramSettings.EnableGrayscaleInChat" = "Escala de grises en el chat";

/*Registration Date*/
"NiceFeatures.RegDate.OlderThan" = "Mayor que";
Expand Down
4 changes: 4 additions & 0 deletions Telegram/Telegram-iOS/fr.lproj/NiceLocalizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@
"NicegramSettings.HideBadgeCounters" = "Masquer les compteurs de badges";
"NicegramSettings.HideUnreadCounters" = "Masquer les compteurs de non-lus";
"NicegramSettings.HideMentionNotification" = "Masquer la notification de mention";
"NicegramSettings.EnableAnimationsInChatList" = "Animations dans la liste de chat";
"NicegramSettings.EnableGrayscaleAll" = "Écran complet en niveaux de gris";
"NicegramSettings.EnableGrayscaleInChatList" = "Niveaux de gris dans la liste de chat";
"NicegramSettings.EnableGrayscaleInChat" = "Gris dans le chat";

/*Registration Date*/
"NiceFeatures.RegDate.OlderThan" = "Plus vieux que";
Expand Down
Loading

0 comments on commit 61be813

Please sign in to comment.