mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various Fixes
This commit is contained in:
parent
b3e5ac68b0
commit
2178de9f8a
@ -390,7 +390,7 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry {
|
||||
}
|
||||
)
|
||||
case let .includePeer(_, peer, isRevealed):
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(timeFormat: .regular, dateFormat: .monthFirst, dateSeparator: ".", decimalSeparator: ".", groupingSeparator: "."), nameDisplayOrder: .firstLast, context: arguments.context, peer: peer.chatMainPeer!, height: .peerList, aliasHandling: .threatSelfAsSaved, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: isRevealed), revealOptions: ItemListPeerItemRevealOptions(options: [ItemListPeerItemRevealOption(type: .destructive, title: presentationData.strings.Common_Delete, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context, peer: peer.chatMainPeer!, height: .peerList, aliasHandling: .threatSelfAsSaved, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: isRevealed), revealOptions: ItemListPeerItemRevealOptions(options: [ItemListPeerItemRevealOption(type: .destructive, title: presentationData.strings.Common_Delete, action: {
|
||||
arguments.deleteIncludePeer(peer.peerId)
|
||||
})]), switchValue: nil, enabled: true, selectable: false, sectionId: self.section, action: nil, setPeerIdWithRevealedOptions: { lhs, rhs in
|
||||
arguments.setItemIdWithRevealedOptions(lhs.flatMap { .peer($0) }, rhs.flatMap { .peer($0) })
|
||||
@ -398,7 +398,7 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry {
|
||||
arguments.deleteIncludePeer(id)
|
||||
})
|
||||
case let .excludePeer(_, peer, isRevealed):
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(timeFormat: .regular, dateFormat: .monthFirst, dateSeparator: ".", decimalSeparator: ".", groupingSeparator: "."), nameDisplayOrder: .firstLast, context: arguments.context, peer: peer.chatMainPeer!, height: .peerList, aliasHandling: .threatSelfAsSaved, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: isRevealed), revealOptions: ItemListPeerItemRevealOptions(options: [ItemListPeerItemRevealOption(type: .destructive, title: presentationData.strings.Common_Delete, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context, peer: peer.chatMainPeer!, height: .peerList, aliasHandling: .threatSelfAsSaved, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: isRevealed), revealOptions: ItemListPeerItemRevealOptions(options: [ItemListPeerItemRevealOption(type: .destructive, title: presentationData.strings.Common_Delete, action: {
|
||||
arguments.deleteExcludePeer(peer.peerId)
|
||||
})]), switchValue: nil, enabled: true, selectable: false, sectionId: self.section, action: nil, setPeerIdWithRevealedOptions: { lhs, rhs in
|
||||
arguments.setItemIdWithRevealedOptions(lhs.flatMap { .peer($0) }, rhs.flatMap { .peer($0) })
|
||||
|
@ -262,7 +262,7 @@ private enum InviteLinksListEntry: ItemListNodeEntry {
|
||||
case let .adminsHeader(_, text):
|
||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||
case let .admin(_, _, creator):
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(timeFormat: .regular, dateFormat: .monthFirst, dateSeparator: ".", decimalSeparator: ".", groupingSeparator: "."), nameDisplayOrder: .firstLast, context: arguments.context, peer: creator.peer.peer!, height: .peerList, aliasHandling: .standard, nameColor: .primary, nameStyle: .plain, presence: nil, text: .none, label: creator.count > 1 ? .disclosure("\(creator.count)") : .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: nil), revealOptions: nil, switchValue: nil, enabled: true, highlighted: false, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context, peer: creator.peer.peer!, height: .peerList, aliasHandling: .standard, nameColor: .primary, nameStyle: .plain, presence: nil, text: .none, label: creator.count > 1 ? .disclosure("\(creator.count)") : .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: nil), revealOptions: nil, switchValue: nil, enabled: true, highlighted: false, selectable: true, sectionId: self.section, action: {
|
||||
arguments.openAdmin(creator)
|
||||
}, setPeerIdWithRevealedOptions: { _, _ in }, removePeer: { _ in }, toggleUpdated: nil, contextAction: nil)
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ private enum ChannelDiscussionGroupSetupControllerEntry: ItemListNodeEntry {
|
||||
} else {
|
||||
text = strings.Channel_DiscussionGroup_PrivateChannel
|
||||
}
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(timeFormat: .regular, dateFormat: .monthFirst, dateSeparator: ".", decimalSeparator: ".", groupingSeparator: "."), nameDisplayOrder: nameOrder, context: arguments.context, peer: peer, aliasHandling: .standard, nameStyle: .plain, presence: nil, text: .text(text, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: nameOrder, context: arguments.context, peer: peer, aliasHandling: .standard, nameStyle: .plain, presence: nil, text: .text(text, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, selectable: true, sectionId: self.section, action: {
|
||||
arguments.selectGroup(peer.id)
|
||||
}, setPeerIdWithRevealedOptions: { _, _ in }, removePeer: { _ in })
|
||||
case let .groupsInfo(_, title):
|
||||
|
@ -187,7 +187,7 @@ private enum IntentsSettingsControllerEntry: ItemListNodeEntry {
|
||||
case let .accountHeader(theme, text):
|
||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||
case let .account(theme, peer, selected, _):
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(timeFormat: .regular, dateFormat: .dayFirst, dateSeparator: ".", decimalSeparator: ".", groupingSeparator: ""), nameDisplayOrder: .firstLast, context: arguments.context.sharedContext.makeTempAccountContext(account: arguments.context.account), peer: peer, height: .generic, aliasHandling: .standard, nameStyle: .plain, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: false), revealOptions: nil, switchValue: ItemListPeerItemSwitch(value: selected, style: .check), enabled: true, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context.sharedContext.makeTempAccountContext(account: arguments.context.account), peer: peer, height: .generic, aliasHandling: .standard, nameStyle: .plain, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: false), revealOptions: nil, switchValue: ItemListPeerItemSwitch(value: selected, style: .check), enabled: true, selectable: true, sectionId: self.section, action: {
|
||||
arguments.updateSettings { $0.withUpdatedAccount(peer.id) }
|
||||
}, setPeerIdWithRevealedOptions: { _, _ in}, removePeer: { _ in })
|
||||
return ItemListTextItem(presentationData: presentationData, text: .plain(""), sectionId: self.section)
|
||||
|
@ -144,7 +144,7 @@ private enum StatsEntry: ItemListNodeEntry {
|
||||
}
|
||||
|
||||
let text: String = presentationData.strings.Stats_MessageViews(views)
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(timeFormat: .military, dateFormat: .dayFirst, dateSeparator: ".", decimalSeparator: ",", groupingSeparator: ""), nameDisplayOrder: .firstLast, context: arguments.context, peer: message.peers[message.id.peerId]!, height: .generic, aliasHandling: .standard, nameColor: .primary, nameStyle: .plain, presence: nil, text: .text(text, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: nil), revealOptions: nil, switchValue: nil, enabled: true, highlighted: false, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context, peer: message.peers[message.id.peerId]!, height: .generic, aliasHandling: .standard, nameColor: .primary, nameStyle: .plain, presence: nil, text: .text(text, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: nil), revealOptions: nil, switchValue: nil, enabled: true, highlighted: false, selectable: true, sectionId: self.section, action: {
|
||||
arguments.openMessage(message.id)
|
||||
}, setPeerIdWithRevealedOptions: { _, _ in }, removePeer: { _ in }, toggleUpdated: nil, contextAction: nil)
|
||||
}
|
||||
|
@ -15,13 +15,24 @@ public struct PresentationDateTimeFormat: Equatable {
|
||||
public let timeFormat: PresentationTimeFormat
|
||||
public let dateFormat: PresentationDateFormat
|
||||
public let dateSeparator: String
|
||||
public let dateSuffix: String
|
||||
public let decimalSeparator: String
|
||||
public let groupingSeparator: String
|
||||
|
||||
public init(timeFormat: PresentationTimeFormat, dateFormat: PresentationDateFormat, dateSeparator: String, decimalSeparator: String, groupingSeparator: String) {
|
||||
public init() {
|
||||
self.timeFormat = .regular
|
||||
self.dateFormat = .monthFirst
|
||||
self.dateSeparator = "."
|
||||
self.dateSuffix = ""
|
||||
self.decimalSeparator = "."
|
||||
self.groupingSeparator = "."
|
||||
}
|
||||
|
||||
public init(timeFormat: PresentationTimeFormat, dateFormat: PresentationDateFormat, dateSeparator: String, dateSuffix: String, decimalSeparator: String, groupingSeparator: String) {
|
||||
self.timeFormat = timeFormat
|
||||
self.dateFormat = dateFormat
|
||||
self.dateSeparator = dateSeparator
|
||||
self.dateSuffix = dateSuffix
|
||||
self.decimalSeparator = decimalSeparator
|
||||
self.groupingSeparator = groupingSeparator
|
||||
}
|
||||
@ -145,9 +156,13 @@ private func currentDateTimeFormat() -> PresentationDateTimeFormat {
|
||||
|
||||
let dateFormat: PresentationDateFormat
|
||||
var dateSeparator = "/"
|
||||
var dateSuffix = ""
|
||||
if let dateString = DateFormatter.dateFormat(fromTemplate: "MdY", options: 0, locale: locale) {
|
||||
for separator in [".", "/", "-", "/"] {
|
||||
for separator in [". ", ".", "/", "-", "/"] {
|
||||
if dateString.contains(separator) {
|
||||
if separator == ". " {
|
||||
dateSuffix = "."
|
||||
}
|
||||
dateSeparator = separator
|
||||
break
|
||||
}
|
||||
@ -163,7 +178,7 @@ private func currentDateTimeFormat() -> PresentationDateTimeFormat {
|
||||
|
||||
let decimalSeparator = locale.decimalSeparator ?? "."
|
||||
let groupingSeparator = locale.groupingSeparator ?? ""
|
||||
return PresentationDateTimeFormat(timeFormat: timeFormat, dateFormat: dateFormat, dateSeparator: dateSeparator, decimalSeparator: decimalSeparator, groupingSeparator: groupingSeparator)
|
||||
return PresentationDateTimeFormat(timeFormat: timeFormat, dateFormat: dateFormat, dateSeparator: dateSeparator, dateSuffix: dateSuffix, decimalSeparator: decimalSeparator, groupingSeparator: groupingSeparator)
|
||||
}
|
||||
|
||||
private func currentPersonNameSortOrder() -> PresentationPersonNameOrder {
|
||||
|
@ -53,11 +53,12 @@ public func stringForMediumDate(timestamp: Int32, strings: PresentationStrings,
|
||||
|
||||
let dateString: String
|
||||
let separator = dateTimeFormat.dateSeparator
|
||||
let suffix = dateTimeFormat.dateSuffix
|
||||
switch dateTimeFormat.dateFormat {
|
||||
case .monthFirst:
|
||||
dateString = String(format: "%02d%@%02d%@%02d", month, separator, day, separator, year - 100)
|
||||
dateString = String(format: "%02d%@%02d%@%02d%@", month, separator, day, separator, year - 100, suffix)
|
||||
case .dayFirst:
|
||||
dateString = String(format: "%02d%@%02d%@%02d", day, separator, month, separator, year - 100)
|
||||
dateString = String(format: "%02d%@%02d%@%02d%@", day, separator, month, separator, year - 100, suffix)
|
||||
}
|
||||
|
||||
let timeString = stringForShortTimestamp(hours: Int32(timeinfo.tm_hour), minutes: Int32(timeinfo.tm_min), dateTimeFormat: dateTimeFormat)
|
||||
|
@ -6,21 +6,23 @@ import TelegramPresentationData
|
||||
|
||||
public func stringForTimestamp(day: Int32, month: Int32, year: Int32, dateTimeFormat: PresentationDateTimeFormat) -> String {
|
||||
let separator = dateTimeFormat.dateSeparator
|
||||
let suffix = dateTimeFormat.dateSuffix
|
||||
switch dateTimeFormat.dateFormat {
|
||||
case .monthFirst:
|
||||
return String(format: "%d%@%d%@%02d", month, separator, day, separator, year - 100)
|
||||
return String(format: "%02d%@%02d%@%02d%@", month, separator, day, separator, year - 100, suffix)
|
||||
case .dayFirst:
|
||||
return String(format: "%d%@%02d%@%02d", day, separator, month, separator, year - 100)
|
||||
return String(format: "%02d%@%02d%@%02d%@", day, separator, month, separator, year - 100, suffix)
|
||||
}
|
||||
}
|
||||
|
||||
public func stringForTimestamp(day: Int32, month: Int32, dateTimeFormat: PresentationDateTimeFormat) -> String {
|
||||
let separator = dateTimeFormat.dateSeparator
|
||||
let suffix = dateTimeFormat.dateSuffix
|
||||
switch dateTimeFormat.dateFormat {
|
||||
case .monthFirst:
|
||||
return String(format: "%d%@%d", month, separator, day)
|
||||
return String(format: "%02d%@%02d%@", month, separator, day, suffix)
|
||||
case .dayFirst:
|
||||
return String(format: "%d%@%02d", day, separator, month)
|
||||
return String(format: "%02d%@%02d%@", day, separator, month, suffix)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -838,7 +838,7 @@ final class ChatEmptyNode: ASDisplayNode {
|
||||
} else if let _ = interfaceState.peerNearbyData {
|
||||
contentType = .peerNearby
|
||||
} else if let peer = peer as? TelegramUser {
|
||||
if peer.isDeleted || peer.botInfo != nil || peer.flags.contains(.isSupport) {
|
||||
if peer.isDeleted || peer.botInfo != nil || peer.flags.contains(.isSupport) || peer.isScam || interfaceState.peerIsBlocked {
|
||||
contentType = .regular
|
||||
} else if case .clearedHistory = emptyType {
|
||||
contentType = .regular
|
||||
@ -854,8 +854,12 @@ final class ChatEmptyNode: ASDisplayNode {
|
||||
|
||||
var contentTransition = transition
|
||||
if self.content?.0 != contentType {
|
||||
var animateContentIn = false
|
||||
if let node = self.content?.1 {
|
||||
node.removeFromSupernode()
|
||||
if self.content?.0 != nil && contentType == .greeting && transition.isAnimated {
|
||||
animateContentIn = true
|
||||
}
|
||||
}
|
||||
let node: ASDisplayNode & ChatEmptyNodeContent
|
||||
switch contentType {
|
||||
@ -875,6 +879,11 @@ final class ChatEmptyNode: ASDisplayNode {
|
||||
self.content = (contentType, node)
|
||||
self.addSubnode(node)
|
||||
contentTransition = .immediate
|
||||
|
||||
if animateContentIn, case let .animated(duration, curve) = transition {
|
||||
node.layer.animateAlpha(from: 0.0, to: 1.0, duration: duration)
|
||||
node.layer.animateScale(from: 0.0, to: 1.0, duration: duration, timingFunction: curve.timingFunction)
|
||||
}
|
||||
}
|
||||
self.isUserInteractionEnabled = [.peerNearby, .greeting].contains(contentType)
|
||||
|
||||
|
@ -188,7 +188,7 @@ private enum PollResultsEntry: ItemListNodeEntry {
|
||||
let header = ItemListPeerItemHeader(theme: presentationData.theme, strings: presentationData.strings, text: optionText, additionalText: optionAdditionalText, actionTitle: optionExpanded ? presentationData.strings.PollResults_Collapse : presentationData.strings.MessagePoll_VotedCount(optionCount), id: Int64(optionId), action: optionExpanded ? {
|
||||
arguments.collapseOption(opaqueIdentifier)
|
||||
} : nil)
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(timeFormat: .regular, dateFormat: .dayFirst, dateSeparator: ".", decimalSeparator: ".", groupingSeparator: ""), nameDisplayOrder: .firstLast, context: arguments.context, peer: peer.peers[peer.peerId]!, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), switchValue: nil, enabled: true, selectable: shimmeringAlternation == nil, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context, peer: peer.peers[peer.peerId]!, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), switchValue: nil, enabled: true, selectable: shimmeringAlternation == nil, sectionId: self.section, action: {
|
||||
arguments.openPeer(peer)
|
||||
}, setPeerIdWithRevealedOptions: { _, _ in
|
||||
}, removePeer: { _ in
|
||||
|
Loading…
x
Reference in New Issue
Block a user