mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
no message
This commit is contained in:
@@ -26,10 +26,10 @@ private struct NotificationSoundSelectionState: Equatable {
|
||||
}
|
||||
|
||||
private enum NotificationSoundSelectionEntry: ItemListNodeEntry {
|
||||
case modernHeader
|
||||
case classicHeader
|
||||
case none(section: NotificationSoundSelectionSection, selected: Bool)
|
||||
case sound(section: NotificationSoundSelectionSection, index: Int32, sound: PeerMessageSound, selected: Bool)
|
||||
case modernHeader(PresentationTheme, String)
|
||||
case classicHeader(PresentationTheme, String)
|
||||
case none(section: NotificationSoundSelectionSection, theme: PresentationTheme, text: String, selected: Bool)
|
||||
case sound(section: NotificationSoundSelectionSection, index: Int32, theme: PresentationTheme, text: String, sound: PeerMessageSound, selected: Bool)
|
||||
|
||||
var section: ItemListSectionId {
|
||||
switch self {
|
||||
@@ -37,9 +37,9 @@ private enum NotificationSoundSelectionEntry: ItemListNodeEntry {
|
||||
return NotificationSoundSelectionSection.modern.rawValue
|
||||
case .classicHeader:
|
||||
return NotificationSoundSelectionSection.classic.rawValue
|
||||
case let .none(section, _):
|
||||
case let .none(section, _, _, _):
|
||||
return section.rawValue
|
||||
case let .sound(section, _, _, _):
|
||||
case let .sound(section, _, _, _, _, _):
|
||||
return section.rawValue
|
||||
}
|
||||
}
|
||||
@@ -50,14 +50,14 @@ private enum NotificationSoundSelectionEntry: ItemListNodeEntry {
|
||||
return 0
|
||||
case .classicHeader:
|
||||
return 1000
|
||||
case let .none(section, _):
|
||||
case let .none(section, _, _, _):
|
||||
switch section {
|
||||
case .modern:
|
||||
return 1
|
||||
case .classic:
|
||||
return 1001
|
||||
}
|
||||
case let .sound(section, index, _, _):
|
||||
case let .sound(section, index, _, _, _, _):
|
||||
switch section {
|
||||
case .modern:
|
||||
return 2 + index
|
||||
@@ -69,20 +69,26 @@ private enum NotificationSoundSelectionEntry: ItemListNodeEntry {
|
||||
|
||||
static func ==(lhs: NotificationSoundSelectionEntry, rhs: NotificationSoundSelectionEntry) -> Bool {
|
||||
switch lhs {
|
||||
case .modernHeader, .classicHeader:
|
||||
if lhs.stableId == rhs.stableId {
|
||||
case let .modernHeader(lhsTheme, lhsText):
|
||||
if case let .modernHeader(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .none(section, selected):
|
||||
if case .none(section, selected) = rhs {
|
||||
case let .classicHeader(lhsTheme, lhsText):
|
||||
if case let .classicHeader(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .sound(section, index, name, selected):
|
||||
if case .sound(section, index, name, selected) = rhs {
|
||||
case let .none(lhsSection, lhsTheme, lhsText, lhsSelected):
|
||||
if case let .none(rhsSection, rhsTheme, rhsText, rhsSelected) = rhs, lhsSection == rhsSection, lhsTheme === rhsTheme, lhsText == rhsText, lhsSelected == rhsSelected {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .sound(lhsSection, lhsIndex, lhsTheme, lhsText, lhsSound, lhsSelected):
|
||||
if case let .sound(rhsSection, rhsIndex, rhsTheme, rhsText, rhsSound, rhsSelected) = rhs, lhsSection == rhsSection, lhsIndex == rhsIndex, lhsTheme === rhsTheme, lhsText == rhsText, lhsSound == rhsSound, lhsSelected == rhsSelected {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@@ -96,36 +102,36 @@ private enum NotificationSoundSelectionEntry: ItemListNodeEntry {
|
||||
|
||||
func item(_ arguments: NotificationSoundSelectionArguments) -> ListViewItem {
|
||||
switch self {
|
||||
case .modernHeader:
|
||||
return ItemListSectionHeaderItem(text: "ALERT TONES", sectionId: self.section)
|
||||
case .classicHeader:
|
||||
return ItemListSectionHeaderItem(text: "ALERT TONES", sectionId: self.section)
|
||||
case let .none(_, selected):
|
||||
return ItemListCheckboxItem(title: localizedPeerNotificationSoundString(.none), checked: selected, zeroSeparatorInsets: true, sectionId: self.section, action: {
|
||||
case let.modernHeader(theme, text):
|
||||
return ItemListSectionHeaderItem(theme: theme, text: text, sectionId: self.section)
|
||||
case let .classicHeader(theme, text):
|
||||
return ItemListSectionHeaderItem(theme: theme, text: text, sectionId: self.section)
|
||||
case let .none(_, theme, text, selected):
|
||||
return ItemListCheckboxItem(theme: theme, title: text, checked: selected, zeroSeparatorInsets: true, sectionId: self.section, action: {
|
||||
arguments.selectSound(.none)
|
||||
})
|
||||
case let .sound(_, _, sound, selected):
|
||||
return ItemListCheckboxItem(title: localizedPeerNotificationSoundString(sound), checked: selected, zeroSeparatorInsets: false, sectionId: self.section, action: {
|
||||
case let .sound(_, _, theme, text, sound, selected):
|
||||
return ItemListCheckboxItem(theme: theme, title: text, checked: selected, zeroSeparatorInsets: false, sectionId: self.section, action: {
|
||||
arguments.selectSound(sound)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func notificationsAndSoundsEntries(state: NotificationSoundSelectionState) -> [NotificationSoundSelectionEntry] {
|
||||
private func notificationsAndSoundsEntries(presentationData: PresentationData, state: NotificationSoundSelectionState) -> [NotificationSoundSelectionEntry] {
|
||||
var entries: [NotificationSoundSelectionEntry] = []
|
||||
|
||||
entries.append(.modernHeader)
|
||||
entries.append(.none(section: .modern, selected: state.selectedSound == .none))
|
||||
entries.append(.modernHeader(presentationData.theme, presentationData.strings.Notifications_AlertTones))
|
||||
entries.append(.none(section: .modern, theme: presentationData.theme, text: "None", selected: state.selectedSound == .none))
|
||||
for i in 0 ..< 12 {
|
||||
let sound: PeerMessageSound = .bundledModern(id: Int32(i))
|
||||
entries.append(.sound(section: .modern, index: Int32(i), sound: sound, selected: sound == state.selectedSound))
|
||||
entries.append(.sound(section: .modern, index: Int32(i), theme: presentationData.theme, text: localizedPeerNotificationSoundString(strings: presentationData.strings, sound: sound), sound: sound, selected: sound == state.selectedSound))
|
||||
}
|
||||
|
||||
entries.append(.classicHeader)
|
||||
entries.append(.classicHeader(presentationData.theme, presentationData.strings.Notifications_ClassicTones))
|
||||
for i in 0 ..< 8 {
|
||||
let sound: PeerMessageSound = .bundledClassic(id: Int32(i))
|
||||
entries.append(.sound(section: .classic, index: Int32(i), sound: sound, selected: sound == state.selectedSound))
|
||||
entries.append(.sound(section: .classic, index: Int32(i), theme: presentationData.theme, text: localizedPeerNotificationSoundString(strings: presentationData.strings, sound: sound), sound: sound, selected: sound == state.selectedSound))
|
||||
}
|
||||
|
||||
return entries
|
||||
@@ -151,24 +157,24 @@ public func notificationSoundSelectionController(account: Account, isModal: Bool
|
||||
cancelImpl?()
|
||||
})
|
||||
|
||||
let leftNavigationButton = ItemListNavigationButton(title: "Cancel", style: .regular, enabled: true, action: {
|
||||
arguments.cancel()
|
||||
})
|
||||
|
||||
let rightNavigationButton = ItemListNavigationButton(title: "Done", style: .bold, enabled: true, action: {
|
||||
arguments.complete()
|
||||
})
|
||||
|
||||
let signal = statePromise.get()
|
||||
|> map { state -> (ItemListControllerState, (ItemListNodeState<NotificationSoundSelectionEntry>, NotificationSoundSelectionEntry.ItemGenerationArguments)) in
|
||||
let signal = combineLatest((account.applicationContext as! TelegramApplicationContext).presentationData, statePromise.get())
|
||||
|> map { presentationData, state -> (ItemListControllerState, (ItemListNodeState<NotificationSoundSelectionEntry>, NotificationSoundSelectionEntry.ItemGenerationArguments)) in
|
||||
|
||||
let controllerState = ItemListControllerState(title: .text("Text Tone"), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton)
|
||||
let listState = ItemListNodeState(entries: notificationsAndSoundsEntries(state: state), style: .blocks)
|
||||
let leftNavigationButton = ItemListNavigationButton(title: presentationData.strings.Common_Cancel, style: .regular, enabled: true, action: {
|
||||
arguments.cancel()
|
||||
})
|
||||
|
||||
let rightNavigationButton = ItemListNavigationButton(title: presentationData.strings.Common_Done, style: .bold, enabled: true, action: {
|
||||
arguments.complete()
|
||||
})
|
||||
|
||||
let controllerState = ItemListControllerState(theme: presentationData.theme, title: .text(presentationData.strings.Notifications_TextTone), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back))
|
||||
let listState = ItemListNodeState(entries: notificationsAndSoundsEntries(presentationData: presentationData, state: state), style: .blocks)
|
||||
|
||||
return (controllerState, (listState, arguments))
|
||||
}
|
||||
}
|
||||
|
||||
let controller = ItemListController(signal)
|
||||
let controller = ItemListController(account: account, state: signal)
|
||||
|
||||
let result = Promise<PeerMessageSound?>()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user