mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit '31046394008a309ae13cc1419fc6bce0781c0d0a'
This commit is contained in:
commit
e640af68dc
@ -6092,6 +6092,8 @@ Sorry for the inconvenience.";
|
||||
"Conversation.AlsoClearCacheTitle" = "You can use \"clear cache\" to remove unnecessary media — and re-downloaded files if you need them again.";
|
||||
"Conversation.DeleteAllMessagesInChat" = "Are you sure you want to delete all messages in %@?";
|
||||
|
||||
"InviteLinks.InviteLinkExpired" = "This invite link has expired.";
|
||||
|
||||
"Conversation.AutoremoveTimerSetUserYou" = "You set messages to automatically delete after %1$@";
|
||||
"Conversation.AutoremoveTimerSetUser" = "%1$@ set messages to automatically delete after %2$@";
|
||||
"Conversation.AutoremoveTimerRemovedUserYou" = "You disabled the auto-delete timer";
|
||||
|
@ -273,7 +273,7 @@ public final class DatePickerNode: ASDisplayNode {
|
||||
struct State {
|
||||
let minDate: Date
|
||||
let maxDate: Date
|
||||
let date: Date
|
||||
let date: Date?
|
||||
|
||||
let displayingMonthSelection: Bool
|
||||
let selectedMonth: Date
|
||||
@ -349,7 +349,7 @@ public final class DatePickerNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
public var date: Date {
|
||||
public var date: Date? {
|
||||
get {
|
||||
return self.state.date
|
||||
}
|
||||
@ -370,10 +370,10 @@ public final class DatePickerNode: ASDisplayNode {
|
||||
public init(theme: DatePickerTheme, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat) {
|
||||
self.theme = theme
|
||||
self.strings = strings
|
||||
self.state = State(minDate: telegramReleaseDate, maxDate: upperLimitDate, date: Date(), displayingMonthSelection: false, selectedMonth: monthForDate(Date()))
|
||||
self.state = State(minDate: telegramReleaseDate, maxDate: upperLimitDate, date: nil, displayingMonthSelection: false, selectedMonth: monthForDate(Date()))
|
||||
|
||||
self.timeTitleNode = ImmediateTextNode()
|
||||
self.timeTitleNode.attributedText = NSAttributedString(string: "Time", font: Font.regular(17.0), textColor: theme.textColor)
|
||||
self.timeTitleNode.attributedText = NSAttributedString(string: strings.InviteLink_Create_TimeLimitExpiryTime, font: Font.regular(17.0), textColor: theme.textColor)
|
||||
|
||||
self.timePickerNode = TimePickerNode(theme: theme, dateTimeFormat: dateTimeFormat, date: self.state.date)
|
||||
|
||||
@ -390,7 +390,7 @@ public final class DatePickerNode: ASDisplayNode {
|
||||
self.pickerBackgroundNode.isUserInteractionEnabled = false
|
||||
|
||||
var monthChangedImpl: ((Date) -> Void)?
|
||||
self.pickerNode = MonthPickerNode(theme: theme, strings: strings, date: self.state.date, yearRange: yearRange(for: self.state), valueChanged: { date in
|
||||
self.pickerNode = MonthPickerNode(theme: theme, strings: strings, date: self.state.date ?? monthForDate(Date()), yearRange: yearRange(for: self.state), valueChanged: { date in
|
||||
monthChangedImpl?(date)
|
||||
})
|
||||
self.pickerNode.minimumDate = self.state.minDate
|
||||
@ -503,7 +503,7 @@ public final class DatePickerNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
}
|
||||
self.pickerNode.date = self.state.date
|
||||
self.pickerNode.date = self.state.date ?? self.state.selectedMonth
|
||||
self.timePickerNode.date = self.state.date
|
||||
|
||||
if let size = self.validLayout {
|
||||
@ -571,13 +571,23 @@ public final class DatePickerNode: ASDisplayNode {
|
||||
let location = recognizer.location(in: monthNode.view)
|
||||
if let day = monthNode.dateAtPoint(location) {
|
||||
let monthComponents = calendar.dateComponents([.month, .year], from: monthNode.month)
|
||||
var currentComponents = calendar.dateComponents([.hour, .minute, .day, .month, .year], from: self.date)
|
||||
|
||||
currentComponents.year = monthComponents.year
|
||||
currentComponents.month = monthComponents.month
|
||||
currentComponents.day = Int(day)
|
||||
|
||||
if let date = calendar.date(from: currentComponents), date >= self.minimumDate && date < self.maximumDate {
|
||||
var dateComponents: DateComponents
|
||||
if let date = self.date {
|
||||
dateComponents = calendar.dateComponents([.hour, .minute, .day, .month, .year], from: date)
|
||||
dateComponents.year = monthComponents.year
|
||||
dateComponents.month = monthComponents.month
|
||||
dateComponents.day = Int(day)
|
||||
} else {
|
||||
dateComponents = DateComponents()
|
||||
dateComponents.year = monthComponents.year
|
||||
dateComponents.month = monthComponents.month
|
||||
dateComponents.day = Int(day)
|
||||
dateComponents.hour = 11
|
||||
dateComponents.minute = 0
|
||||
}
|
||||
|
||||
if let date = calendar.date(from: dateComponents), date >= self.minimumDate && date < self.maximumDate {
|
||||
let updatedState = State(minDate: self.state.minDate, maxDate: self.state.maxDate, date: date, displayingMonthSelection: self.state.displayingMonthSelection, selectedMonth: monthNode.month)
|
||||
self.updateState(updatedState, animated: false)
|
||||
|
||||
@ -999,10 +1009,10 @@ private final class TimePickerNode: ASDisplayNode {
|
||||
private let inputNode: TimeInputNode
|
||||
private let amPMSelectorNode: SegmentedControlNode
|
||||
|
||||
var date: Date {
|
||||
var date: Date? {
|
||||
didSet {
|
||||
if let size = self.validLayout {
|
||||
self.updateLayout(size: size)
|
||||
let _ = self.updateLayout(size: size)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1013,7 +1023,7 @@ private final class TimePickerNode: ASDisplayNode {
|
||||
|
||||
private var validLayout: CGSize?
|
||||
|
||||
init(theme: DatePickerTheme, dateTimeFormat: PresentationDateTimeFormat, date: Date) {
|
||||
init(theme: DatePickerTheme, dateTimeFormat: PresentationDateTimeFormat, date: Date?) {
|
||||
self.theme = theme
|
||||
self.dateTimeFormat = dateTimeFormat
|
||||
self.date = date
|
||||
@ -1026,9 +1036,15 @@ private final class TimePickerNode: ASDisplayNode {
|
||||
self.colonNode = ImmediateTextNode()
|
||||
self.inputNode = TimeInputNode()
|
||||
|
||||
let hours = calendar.component(.hour, from: date)
|
||||
let isPM: Bool
|
||||
if let date = date {
|
||||
let hours = calendar.component(.hour, from: date)
|
||||
isPM = hours > 12
|
||||
} else {
|
||||
isPM = true
|
||||
}
|
||||
|
||||
self.amPMSelectorNode = SegmentedControlNode(theme: theme.segmentedControlTheme, items: [SegmentedControlItem(title: "AM"), SegmentedControlItem(title: "PM")], selectedIndex: hours > 12 ? 1 : 0)
|
||||
self.amPMSelectorNode = SegmentedControlNode(theme: theme.segmentedControlTheme, items: [SegmentedControlItem(title: "AM"), SegmentedControlItem(title: "PM")], selectedIndex: isPM ? 1 : 0)
|
||||
|
||||
super.init()
|
||||
|
||||
@ -1039,8 +1055,11 @@ private final class TimePickerNode: ASDisplayNode {
|
||||
self.addSubnode(self.amPMSelectorNode)
|
||||
|
||||
self.amPMSelectorNode.selectedIndexChanged = { index in
|
||||
guard let date = self.date else {
|
||||
return
|
||||
}
|
||||
let hours = calendar.component(.hour, from: date)
|
||||
var components = calendar.dateComponents([.year, .month, .day, .hour, .minute], from: self.date)
|
||||
var components = calendar.dateComponents([.year, .month, .day, .hour, .minute], from: date)
|
||||
if index == 0 && hours >= 12 {
|
||||
components.hour = hours - 12
|
||||
} else if index == 1 && hours < 12 {
|
||||
@ -1067,8 +1086,15 @@ private final class TimePickerNode: ASDisplayNode {
|
||||
|
||||
var contentSize = CGSize()
|
||||
|
||||
let hours = Int32(calendar.component(.hour, from: self.date))
|
||||
let minutes = Int32(calendar.component(.hour, from: self.date))
|
||||
let hours: Int32
|
||||
let minutes: Int32
|
||||
if let date = self.date {
|
||||
hours = Int32(calendar.component(.hour, from: date))
|
||||
minutes = Int32(calendar.component(.hour, from: date))
|
||||
} else {
|
||||
hours = 11
|
||||
minutes = 0
|
||||
}
|
||||
let string = stringForShortTimestamp(hours: hours, minutes: minutes, dateTimeFormat: self.dateTimeFormat).replacingOccurrences(of: " AM", with: "").replacingOccurrences(of: " PM", with: "")
|
||||
|
||||
self.textNode.attributedText = NSAttributedString(string: string, font: Font.with(size: 21.0, design: .regular, weight: .regular, traits: [.monospacedNumbers]), textColor: self.theme.textColor)
|
||||
|
@ -289,7 +289,7 @@ private func inviteLinkEditControllerEntries(invite: ExportedInvitation?, state:
|
||||
}
|
||||
entries.append(.timeExpiryDate(presentationData.theme, time, state.pickingTimeLimit))
|
||||
if state.pickingTimeLimit {
|
||||
entries.append(.timeCustomPicker(presentationData.theme, presentationData.dateTimeFormat, time ?? currentTime))
|
||||
entries.append(.timeCustomPicker(presentationData.theme, presentationData.dateTimeFormat, time))
|
||||
}
|
||||
entries.append(.timeInfo(presentationData.theme, presentationData.strings.InviteLink_Create_TimeLimitInfo))
|
||||
|
||||
|
@ -53,7 +53,7 @@ private enum InviteLinkInviteEntryId: Hashable {
|
||||
|
||||
private enum InviteLinkInviteEntry: Comparable, Identifiable {
|
||||
case header(PresentationTheme, String, String)
|
||||
case mainLink(PresentationTheme, ExportedInvitation)
|
||||
case mainLink(PresentationTheme, ExportedInvitation?)
|
||||
case manage(PresentationTheme, String, Bool)
|
||||
|
||||
var stableId: InviteLinkInviteEntryId {
|
||||
@ -122,9 +122,13 @@ private enum InviteLinkInviteEntry: Comparable, Identifiable {
|
||||
return InviteLinkInviteHeaderItem(theme: theme, title: title, text: text)
|
||||
case let .mainLink(_, invite):
|
||||
return ItemListPermanentInviteLinkItem(context: interaction.context, presentationData: ItemListPresentationData(presentationData), invite: invite, count: 0, peers: [], displayButton: true, displayImporters: false, buttonColor: nil, sectionId: 0, style: .plain, copyAction: {
|
||||
interaction.copyLink(invite)
|
||||
if let invite = invite {
|
||||
interaction.copyLink(invite)
|
||||
}
|
||||
}, shareAction: {
|
||||
interaction.shareLink(invite)
|
||||
if let invite = invite {
|
||||
interaction.shareLink(invite)
|
||||
}
|
||||
}, contextAction: { node in
|
||||
interaction.mainLinkContextAction(invite, node, nil)
|
||||
}, viewAction: {
|
||||
@ -319,6 +323,8 @@ public final class InviteLinkInviteController: ViewController {
|
||||
self.backgroundColor = nil
|
||||
self.isOpaque = false
|
||||
|
||||
let mainInvitePromise = ValuePromise<ExportedInvitation?>(nil)
|
||||
|
||||
self.interaction = InviteLinkInviteInteraction(context: context, mainLinkContextAction: { [weak self] invite, node, gesture in
|
||||
guard let node = node as? ContextExtractedContentContainingNode else {
|
||||
return
|
||||
@ -385,7 +391,10 @@ public final class InviteLinkInviteController: ViewController {
|
||||
dismissAction()
|
||||
|
||||
if let invite = invite {
|
||||
let _ = (revokePeerExportedInvitation(account: context.account, peerId: peerId, link: invite.link) |> deliverOnMainQueue).start(completed: {
|
||||
let _ = (revokePeerExportedInvitation(account: context.account, peerId: peerId, link: invite.link) |> deliverOnMainQueue).start(next: { result in
|
||||
if let result = result, case let .replace(_, invite) = result {
|
||||
mainInvitePromise.set(invite)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -418,8 +427,8 @@ public final class InviteLinkInviteController: ViewController {
|
||||
|
||||
let peerView = context.account.postbox.peerView(id: peerId)
|
||||
let invites: Signal<PeerExportedInvitationsState, NoError> = .single(PeerExportedInvitationsState())
|
||||
self.disposable = (combineLatest(self.presentationDataPromise.get(), peerView, invites)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] presentationData, view, invites in
|
||||
self.disposable = (combineLatest(self.presentationDataPromise.get(), peerView, mainInvitePromise.get(), invites)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] presentationData, view, interactiveMainInvite, invites in
|
||||
if let strongSelf = self {
|
||||
var entries: [InviteLinkInviteEntry] = []
|
||||
|
||||
@ -432,17 +441,17 @@ public final class InviteLinkInviteController: ViewController {
|
||||
entries.append(.header(presentationData.theme, presentationData.strings.InviteLink_InviteLink, helpText))
|
||||
|
||||
let mainInvite: ExportedInvitation?
|
||||
if let cachedData = view.cachedData as? CachedGroupData, let invite = cachedData.exportedInvitation {
|
||||
if let invite = interactiveMainInvite {
|
||||
mainInvite = invite
|
||||
} else if let cachedData = view.cachedData as? CachedGroupData, let invite = cachedData.exportedInvitation {
|
||||
mainInvite = invite
|
||||
} else if let cachedData = view.cachedData as? CachedChannelData, let invite = cachedData.exportedInvitation {
|
||||
mainInvite = invite
|
||||
} else {
|
||||
mainInvite = nil
|
||||
}
|
||||
if let mainInvite = mainInvite {
|
||||
entries.append(.mainLink(presentationData.theme, mainInvite))
|
||||
}
|
||||
|
||||
entries.append(.mainLink(presentationData.theme, mainInvite))
|
||||
entries.append(.manage(presentationData.theme, presentationData.strings.InviteLink_Manage, true))
|
||||
|
||||
let previousEntries = previousEntries.swap(entries)
|
||||
@ -459,11 +468,6 @@ public final class InviteLinkInviteController: ViewController {
|
||||
strongSelf.updateFloatingHeaderOffset(offset: offset, transition: transition)
|
||||
}
|
||||
}
|
||||
self.listNode.visibleBottomContentOffsetChanged = { [weak self] offset in
|
||||
if case let .known(value) = offset, value < 40.0 {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
self.addSubnode(self.dimNode)
|
||||
self.addSubnode(self.contentNode)
|
||||
|
@ -223,7 +223,7 @@ public class ItemListDatePickerItemNode: ListViewItemNode, ItemListItemNode {
|
||||
}
|
||||
|
||||
datePickerNode.minimumDate = Date()
|
||||
datePickerNode.date = item.date.flatMap { Date(timeIntervalSince1970: TimeInterval($0)) } ?? Date()
|
||||
datePickerNode.date = item.date.flatMap { Date(timeIntervalSince1970: TimeInterval($0)) }
|
||||
|
||||
let datePickerSize = CGSize(width: width, height: contentSize.height)
|
||||
datePickerNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((params.width - datePickerSize.width) / 2.0), y: 0.0), size: datePickerSize)
|
||||
|
@ -87,7 +87,7 @@ public final class JoinLinkPreviewController: ViewController {
|
||||
strongSelf.navigateToPeer(peerId, ChatPeekTimeout(deadline: deadline, linkData: strongSelf.link))
|
||||
strongSelf.dismiss()
|
||||
case .invalidHash:
|
||||
strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.GroupInfo_InvitationLinkDoesNotExist, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||
strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.InviteLinks_InviteLinkExpired, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||
strongSelf.dismiss()
|
||||
}
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ public func channelPermissionsController(context: AccountContext, peerId origina
|
||||
let controller = PermissionController(context: context, splashScreen: true)
|
||||
controller.navigationPresentation = .modal
|
||||
controller.setState(.custom(icon: .animation("BroadcastGroup"), title: presentationData.strings.BroadcastGroups_IntroTitle, subtitle: nil, text: presentationData.strings.BroadcastGroups_IntroText, buttonTitle: presentationData.strings.BroadcastGroups_Convert, secondaryButtonTitle: presentationData.strings.BroadcastGroups_Cancel, footerText: nil), animated: false)
|
||||
controller.proceed = { result in
|
||||
controller.proceed = { [weak controller] result in
|
||||
let attributedTitle = NSAttributedString(string: presentationData.strings.BroadcastGroups_ConfirmationAlert_Title, font: Font.medium(17.0), textColor: presentationData.theme.actionSheet.primaryTextColor, paragraphAlignment: .center)
|
||||
let body = MarkdownAttributeSet(font: Font.regular(13.0), textColor: presentationData.theme.actionSheet.primaryTextColor)
|
||||
let bold = MarkdownAttributeSet(font: Font.semibold(13.0), textColor: presentationData.theme.actionSheet.primaryTextColor)
|
||||
@ -778,7 +778,7 @@ public func channelPermissionsController(context: AccountContext, peerId origina
|
||||
dismissToChatController?()
|
||||
})
|
||||
})])
|
||||
presentControllerImpl?(alertController, nil)
|
||||
controller?.present(alertController, in: .window(.root))
|
||||
}
|
||||
pushControllerImpl?(controller)
|
||||
}, openChannelExample: {
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -7089,7 +7089,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
let controller = PermissionController(context: context, splashScreen: true)
|
||||
controller.navigationPresentation = .modal
|
||||
controller.setState(.custom(icon: .animation("BroadcastGroup"), title: presentationData.strings.BroadcastGroups_IntroTitle, subtitle: nil, text: presentationData.strings.BroadcastGroups_IntroText, buttonTitle: presentationData.strings.BroadcastGroups_Convert, secondaryButtonTitle: presentationData.strings.BroadcastGroups_Cancel, footerText: nil), animated: false)
|
||||
controller.proceed = { result in
|
||||
controller.proceed = { [weak controller] result in
|
||||
let attributedTitle = NSAttributedString(string: presentationData.strings.BroadcastGroups_ConfirmationAlert_Title, font: Font.medium(17.0), textColor: presentationData.theme.actionSheet.primaryTextColor, paragraphAlignment: .center)
|
||||
let body = MarkdownAttributeSet(font: Font.regular(13.0), textColor: presentationData.theme.actionSheet.primaryTextColor)
|
||||
let bold = MarkdownAttributeSet(font: Font.semibold(13.0), textColor: presentationData.theme.actionSheet.primaryTextColor)
|
||||
@ -7108,7 +7108,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
strongSelf.present(UndoOverlayController(presentationData: presentationData, content: .gigagroupConversion(text: presentationData.strings.BroadcastGroups_Success(presentationStringsFormattedNumber(participantsLimit, presentationData.dateTimeFormat.decimalSeparator)).0), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||
})
|
||||
})])
|
||||
strongSelf.present(alertController, in: .window(.root))
|
||||
controller?.present(alertController, in: .window(.root))
|
||||
}
|
||||
strongSelf.push(controller)
|
||||
})])
|
||||
|
Loading…
x
Reference in New Issue
Block a user