forked from TelegramMessenger/Telegram-iOS
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
147 changed files
with
2,651 additions
and
1,822 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
7.3.1 | ||
7.3.1:981f82a470bad1349322b6f51c9c6ffa0aa291dab1014fac411543c12e661dff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ on: | |
|
||
jobs: | ||
build: | ||
runs-on: macos-14 | ||
runs-on: macos-15 | ||
|
||
steps: | ||
- uses: webfactory/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
|
||
jobs: | ||
build: | ||
runs-on: macos-14 | ||
runs-on: macos-15 | ||
|
||
steps: | ||
- uses: webfactory/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
Nicegram/NGData/Sources/Modern/Data/NicegramSettingsRepositoryImpl.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
Nicegram/NGData/Sources/Modern/Domain/GetGrayscaleSettingsUseCase.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Nicegram/NGData/Sources/Modern/Domain/NicegramSettingsRepository.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
24
Nicegram/NGData/Sources/Modern/NicegramSettingsModule.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
32
Nicegram/NGData/Sources/Modern/Presentation/GrayscaleLayer.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Nicegram/NGData/Sources/Modern/Presentation/NicegramSettings+PresentationHelpers.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.