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
ce911f3f9b
commit
fe9610eee9
@ -67,7 +67,7 @@
|
|||||||
|
|
||||||
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping inhibitSelection:(bool)inhibitSelection selectionLimit:(int)selectionLimit
|
+ (instancetype)controllerWithContext:(id<LegacyComponentsContext>)context assetGroup:(TGMediaAssetGroup *)assetGroup intent:(TGMediaAssetsControllerIntent)intent recipientName:(NSString *)recipientName saveEditedPhotos:(bool)saveEditedPhotos allowGrouping:(bool)allowGrouping inhibitSelection:(bool)inhibitSelection selectionLimit:(int)selectionLimit
|
||||||
{
|
{
|
||||||
if (intent != TGMediaAssetsControllerSendMediaIntent)
|
if (intent != TGMediaAssetsControllerSendMediaIntent && intent != TGMediaAssetsControllerSendFileIntent)
|
||||||
allowGrouping = false;
|
allowGrouping = false;
|
||||||
|
|
||||||
TGMediaAssetsController *assetsController = [[TGMediaAssetsController alloc] initWithContext:context intent:intent saveEditedPhotos:saveEditedPhotos allowGrouping:allowGrouping selectionLimit:selectionLimit];
|
TGMediaAssetsController *assetsController = [[TGMediaAssetsController alloc] initWithContext:context intent:intent saveEditedPhotos:saveEditedPhotos allowGrouping:allowGrouping selectionLimit:selectionLimit];
|
||||||
@ -735,6 +735,9 @@
|
|||||||
dict[@"fileName"] = assetData.fileName;
|
dict[@"fileName"] = assetData.fileName;
|
||||||
dict[@"mimeType"] = TGMimeTypeForFileUTI(assetData.fileUTI);
|
dict[@"mimeType"] = TGMimeTypeForFileUTI(assetData.fileUTI);
|
||||||
|
|
||||||
|
if (groupedId != nil)
|
||||||
|
dict[@"groupedId"] = groupedId;
|
||||||
|
|
||||||
id generatedItem = descriptionGenerator(dict, caption, entities, nil);
|
id generatedItem = descriptionGenerator(dict, caption, entities, nil);
|
||||||
return generatedItem;
|
return generatedItem;
|
||||||
}] catch:^SSignal *(id error)
|
}] catch:^SSignal *(id error)
|
||||||
@ -752,6 +755,9 @@
|
|||||||
dict[@"mimeType"] = TGMimeTypeForFileUTI(asset.uniformTypeIdentifier);
|
dict[@"mimeType"] = TGMimeTypeForFileUTI(asset.uniformTypeIdentifier);
|
||||||
dict[@"fileName"] = asset.fileName;
|
dict[@"fileName"] = asset.fileName;
|
||||||
|
|
||||||
|
if (groupedId != nil)
|
||||||
|
dict[@"groupedId"] = groupedId;
|
||||||
|
|
||||||
id generatedItem = descriptionGenerator(dict, caption, entities, nil);
|
id generatedItem = descriptionGenerator(dict, caption, entities, nil);
|
||||||
return generatedItem;
|
return generatedItem;
|
||||||
}];
|
}];
|
||||||
@ -971,6 +977,9 @@
|
|||||||
if (adjustments.paintingData.stickers.count > 0)
|
if (adjustments.paintingData.stickers.count > 0)
|
||||||
dict[@"stickers"] = adjustments.paintingData.stickers;
|
dict[@"stickers"] = adjustments.paintingData.stickers;
|
||||||
|
|
||||||
|
if (groupedId != nil)
|
||||||
|
dict[@"groupedId"] = groupedId;
|
||||||
|
|
||||||
id generatedItem = descriptionGenerator(dict, caption, entities, nil);
|
id generatedItem = descriptionGenerator(dict, caption, entities, nil);
|
||||||
return generatedItem;
|
return generatedItem;
|
||||||
}]];
|
}]];
|
||||||
|
@ -184,7 +184,7 @@ public func legacyAssetPickerItemGenerator() -> ((Any?, String?, [Any]?, String?
|
|||||||
name = customName
|
name = customName
|
||||||
}
|
}
|
||||||
|
|
||||||
result["item" as NSString] = LegacyAssetItemWrapper(item: .file(data: .asset(asset.backingAsset), thumbnail: thumbnail, mimeType: mimeType, name: name, caption: caption), timer: nil, groupedId: nil)
|
result["item" as NSString] = LegacyAssetItemWrapper(item: .file(data: .asset(asset.backingAsset), thumbnail: thumbnail, mimeType: mimeType, name: name, caption: caption), timer: nil, groupedId: (dict["groupedId"] as? NSNumber)?.int64Value)
|
||||||
} else {
|
} else {
|
||||||
result["item" as NSString] = LegacyAssetItemWrapper(item: .image(data: .asset(asset.backingAsset), thumbnail: thumbnail, caption: caption, stickers: []), timer: (dict["timer"] as? NSNumber)?.intValue, groupedId: (dict["groupedId"] as? NSNumber)?.int64Value)
|
result["item" as NSString] = LegacyAssetItemWrapper(item: .image(data: .asset(asset.backingAsset), thumbnail: thumbnail, caption: caption, stickers: []), timer: (dict["timer"] as? NSNumber)?.intValue, groupedId: (dict["groupedId"] as? NSNumber)?.int64Value)
|
||||||
}
|
}
|
||||||
|
@ -545,6 +545,27 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate {
|
|||||||
self.pinDisposable.set(nil)
|
self.pinDisposable.set(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func showAll(animated: Bool = true) {
|
||||||
|
guard let mapView = self.mapView else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var annotations: [MKAnnotation] = []
|
||||||
|
if let userAnnotation = self.userLocationAnnotation {
|
||||||
|
annotations.append(userAnnotation)
|
||||||
|
}
|
||||||
|
annotations.append(contentsOf: self.annotations)
|
||||||
|
|
||||||
|
var zoomRect: MKMapRect = MKMapRect()
|
||||||
|
for annotation in annotations {
|
||||||
|
let pointRegionRect = MKMapRect(region: MKCoordinateRegion(center: annotation.coordinate, latitudinalMeters: 100, longitudinalMeters: 100))
|
||||||
|
zoomRect = zoomRect.union(pointRegionRect)
|
||||||
|
}
|
||||||
|
|
||||||
|
let insets = UIEdgeInsets()
|
||||||
|
zoomRect = mapView.mapRectThatFits(zoomRect, edgePadding: insets)
|
||||||
|
mapView.setVisibleMapRect(zoomRect, animated: animated)
|
||||||
|
}
|
||||||
|
|
||||||
func updateLayout(size: CGSize) {
|
func updateLayout(size: CGSize) {
|
||||||
self.proximityDimView.frame = CGRect(origin: CGPoint(), size: size)
|
self.proximityDimView.frame = CGRect(origin: CGPoint(), size: size)
|
||||||
self.pickerAnnotationContainerView.frame = CGRect(x: 0.0, y: floorToScreenPixels((size.height - size.width) / 2.0), width: size.width, height: size.width)
|
self.pickerAnnotationContainerView.frame = CGRect(x: 0.0, y: floorToScreenPixels((size.height - size.width) / 2.0), width: size.width, height: size.width)
|
||||||
|
@ -29,6 +29,12 @@ public class LocationViewParams {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum LocationViewRightBarButton {
|
||||||
|
case none
|
||||||
|
case share
|
||||||
|
case showAll
|
||||||
|
}
|
||||||
|
|
||||||
class LocationViewInteraction {
|
class LocationViewInteraction {
|
||||||
let toggleMapModeSelection: () -> Void
|
let toggleMapModeSelection: () -> Void
|
||||||
let updateMapMode: (LocationMapMode) -> Void
|
let updateMapMode: (LocationMapMode) -> Void
|
||||||
@ -40,8 +46,9 @@ class LocationViewInteraction {
|
|||||||
let updateSendActionHighlight: (Bool) -> Void
|
let updateSendActionHighlight: (Bool) -> Void
|
||||||
let sendLiveLocation: (CLLocationCoordinate2D) -> Void
|
let sendLiveLocation: (CLLocationCoordinate2D) -> Void
|
||||||
let stopLiveLocation: () -> Void
|
let stopLiveLocation: () -> Void
|
||||||
|
let updateRightBarButton: (LocationViewRightBarButton) -> Void
|
||||||
|
|
||||||
init(toggleMapModeSelection: @escaping () -> Void, updateMapMode: @escaping (LocationMapMode) -> Void, goToUserLocation: @escaping () -> Void, goToCoordinate: @escaping (CLLocationCoordinate2D) -> Void, requestDirections: @escaping () -> Void, share: @escaping () -> Void, setupProximityNotification: @escaping (CLLocationCoordinate2D, Bool) -> Void, updateSendActionHighlight: @escaping (Bool) -> Void, sendLiveLocation: @escaping (CLLocationCoordinate2D) -> Void, stopLiveLocation: @escaping () -> Void) {
|
init(toggleMapModeSelection: @escaping () -> Void, updateMapMode: @escaping (LocationMapMode) -> Void, goToUserLocation: @escaping () -> Void, goToCoordinate: @escaping (CLLocationCoordinate2D) -> Void, requestDirections: @escaping () -> Void, share: @escaping () -> Void, setupProximityNotification: @escaping (CLLocationCoordinate2D, Bool) -> Void, updateSendActionHighlight: @escaping (Bool) -> Void, sendLiveLocation: @escaping (CLLocationCoordinate2D) -> Void, stopLiveLocation: @escaping () -> Void, updateRightBarButton: @escaping (LocationViewRightBarButton) -> Void) {
|
||||||
self.toggleMapModeSelection = toggleMapModeSelection
|
self.toggleMapModeSelection = toggleMapModeSelection
|
||||||
self.updateMapMode = updateMapMode
|
self.updateMapMode = updateMapMode
|
||||||
self.goToUserLocation = goToUserLocation
|
self.goToUserLocation = goToUserLocation
|
||||||
@ -52,6 +59,7 @@ class LocationViewInteraction {
|
|||||||
self.updateSendActionHighlight = updateSendActionHighlight
|
self.updateSendActionHighlight = updateSendActionHighlight
|
||||||
self.sendLiveLocation = sendLiveLocation
|
self.sendLiveLocation = sendLiveLocation
|
||||||
self.stopLiveLocation = stopLiveLocation
|
self.stopLiveLocation = stopLiveLocation
|
||||||
|
self.updateRightBarButton = updateRightBarButton
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +78,8 @@ public final class LocationViewController: ViewController {
|
|||||||
private var permissionDisposable: Disposable?
|
private var permissionDisposable: Disposable?
|
||||||
|
|
||||||
private var interaction: LocationViewInteraction?
|
private var interaction: LocationViewInteraction?
|
||||||
|
|
||||||
|
private var rightBarButtonAction: LocationViewRightBarButton = .none
|
||||||
|
|
||||||
public init(context: AccountContext, subject: Message, params: LocationViewParams) {
|
public init(context: AccountContext, subject: Message, params: LocationViewParams) {
|
||||||
self.context = context
|
self.context = context
|
||||||
@ -83,8 +93,6 @@ public final class LocationViewController: ViewController {
|
|||||||
|
|
||||||
self.title = self.presentationData.strings.Map_LocationTitle
|
self.title = self.presentationData.strings.Map_LocationTitle
|
||||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Close, style: .plain, target: self, action: #selector(self.cancelPressed))
|
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Close, style: .plain, target: self, action: #selector(self.cancelPressed))
|
||||||
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationShareIcon(self.presentationData.theme), style: .plain, target: self, action: #selector(self.sharePressed))
|
|
||||||
self.navigationItem.rightBarButtonItem?.accessibilityLabel = self.presentationData.strings.VoiceOver_MessageContextShare
|
|
||||||
|
|
||||||
self.presentationDataDisposable = (context.sharedContext.presentationData
|
self.presentationDataDisposable = (context.sharedContext.presentationData
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
|
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
|
||||||
@ -95,7 +103,7 @@ public final class LocationViewController: ViewController {
|
|||||||
|
|
||||||
strongSelf.navigationBar?.updatePresentationData(NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: strongSelf.presentationData.theme).withUpdatedSeparatorColor(.clear), strings: NavigationBarStrings(presentationStrings: strongSelf.presentationData.strings)))
|
strongSelf.navigationBar?.updatePresentationData(NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: strongSelf.presentationData.theme).withUpdatedSeparatorColor(.clear), strings: NavigationBarStrings(presentationStrings: strongSelf.presentationData.strings)))
|
||||||
|
|
||||||
strongSelf.navigationItem.rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationShareIcon(strongSelf.presentationData.theme), style: .plain, target: strongSelf, action: #selector(strongSelf.sharePressed))
|
strongSelf.updateRightBarButton()
|
||||||
|
|
||||||
if strongSelf.isNodeLoaded {
|
if strongSelf.isNodeLoaded {
|
||||||
strongSelf.controllerNode.updatePresentationData(presentationData)
|
strongSelf.controllerNode.updatePresentationData(presentationData)
|
||||||
@ -247,6 +255,15 @@ public final class LocationViewController: ViewController {
|
|||||||
}, stopLiveLocation: { [weak self] in
|
}, stopLiveLocation: { [weak self] in
|
||||||
params.stopLiveLocation()
|
params.stopLiveLocation()
|
||||||
self?.dismiss()
|
self?.dismiss()
|
||||||
|
}, updateRightBarButton: { [weak self] action in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if action != strongSelf.rightBarButtonAction {
|
||||||
|
strongSelf.rightBarButtonAction = action
|
||||||
|
strongSelf.updateRightBarButton()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.scrollToTop = { [weak self] in
|
self.scrollToTop = { [weak self] in
|
||||||
@ -280,6 +297,18 @@ public final class LocationViewController: ViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func updateRightBarButton() {
|
||||||
|
switch self.rightBarButtonAction {
|
||||||
|
case .none:
|
||||||
|
self.navigationItem.rightBarButtonItem = nil
|
||||||
|
case .share:
|
||||||
|
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationShareIcon(self.presentationData.theme), style: .plain, target: self, action: #selector(self.sharePressed))
|
||||||
|
self.navigationItem.rightBarButtonItem?.accessibilityLabel = self.presentationData.strings.VoiceOver_MessageContextShare
|
||||||
|
case .showAll:
|
||||||
|
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Map_LiveLocationShowAll, style: .plain, target: self, action: #selector(self.showAllPressed))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||||
super.containerLayoutUpdated(layout, transition: transition)
|
super.containerLayoutUpdated(layout, transition: transition)
|
||||||
|
|
||||||
@ -295,7 +324,7 @@ public final class LocationViewController: ViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc private func showAllPressed() {
|
@objc private func showAllPressed() {
|
||||||
self.dismiss()
|
self.controllerNode.showAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ private enum LocationViewEntry: Comparable, Identifiable {
|
|||||||
|
|
||||||
func item(account: Account, presentationData: PresentationData, interaction: LocationViewInteraction?) -> ListViewItem {
|
func item(account: Account, presentationData: PresentationData, interaction: LocationViewInteraction?) -> ListViewItem {
|
||||||
switch self {
|
switch self {
|
||||||
case let .info(theme, location, address, distance, time):
|
case let .info(_, location, address, distance, time):
|
||||||
let addressString: String?
|
let addressString: String?
|
||||||
if let address = address {
|
if let address = address {
|
||||||
addressString = address
|
addressString = address
|
||||||
@ -132,7 +132,7 @@ private enum LocationViewEntry: Comparable, Identifiable {
|
|||||||
}, getDirections: {
|
}, getDirections: {
|
||||||
interaction?.requestDirections()
|
interaction?.requestDirections()
|
||||||
})
|
})
|
||||||
case let .toggleLiveLocation(theme, title, subtitle, coordinate, beginTimstamp, timeout):
|
case let .toggleLiveLocation(_, title, subtitle, coordinate, beginTimstamp, timeout):
|
||||||
let beginTimeAndTimeout: (Double, Double)?
|
let beginTimeAndTimeout: (Double, Double)?
|
||||||
if let beginTimstamp = beginTimstamp, let timeout = timeout {
|
if let beginTimstamp = beginTimstamp, let timeout = timeout {
|
||||||
beginTimeAndTimeout = (beginTimstamp, timeout)
|
beginTimeAndTimeout = (beginTimstamp, timeout)
|
||||||
@ -403,6 +403,18 @@ final class LocationViewControllerNode: ViewControllerTracingNode {
|
|||||||
|
|
||||||
strongSelf.headerNode.mapNode.activeProximityRadius = state.proximityRadius
|
strongSelf.headerNode.mapNode.activeProximityRadius = state.proximityRadius
|
||||||
|
|
||||||
|
let rightBarButtonAction: LocationViewRightBarButton
|
||||||
|
if location.liveBroadcastingTimeout != nil {
|
||||||
|
if liveLocations.count > 1 {
|
||||||
|
rightBarButtonAction = .showAll
|
||||||
|
} else {
|
||||||
|
rightBarButtonAction = .none
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rightBarButtonAction = .share
|
||||||
|
}
|
||||||
|
strongSelf.interaction.updateRightBarButton(rightBarButtonAction)
|
||||||
|
|
||||||
if let (layout, navigationBarHeight) = strongSelf.validLayout {
|
if let (layout, navigationBarHeight) = strongSelf.validLayout {
|
||||||
var updateLayout = false
|
var updateLayout = false
|
||||||
let transition: ContainedViewLayoutTransition = .animated(duration: 0.45, curve: .spring)
|
let transition: ContainedViewLayoutTransition = .animated(duration: 0.45, curve: .spring)
|
||||||
@ -534,6 +546,10 @@ final class LocationViewControllerNode: ViewControllerTracingNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func showAll() {
|
||||||
|
self.headerNode.mapNode.showAll()
|
||||||
|
}
|
||||||
|
|
||||||
func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationHeight: CGFloat, transition: ContainedViewLayoutTransition) {
|
func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationHeight: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||||
let isFirstLayout = self.validLayout == nil
|
let isFirstLayout = self.validLayout == nil
|
||||||
self.validLayout = (layout, navigationHeight)
|
self.validLayout = (layout, navigationHeight)
|
||||||
|
@ -7171,6 +7171,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
let message: EnqueueMessage = .message(text: "", attributes: [], mediaReference: .standalone(media: file), replyToMessageId: replyMessageId, localGroupingKey: groupingKey)
|
let message: EnqueueMessage = .message(text: "", attributes: [], mediaReference: .standalone(media: file), replyToMessageId: replyMessageId, localGroupingKey: groupingKey)
|
||||||
messages.append(message)
|
messages.append(message)
|
||||||
}
|
}
|
||||||
|
if let _ = groupingKey, results.count % 10 == 0 {
|
||||||
|
groupingKey = arc4random64()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !messages.isEmpty {
|
if !messages.isEmpty {
|
||||||
|
@ -104,7 +104,7 @@ class ChatMessageFileBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
if case let .linear(_, bottom) = position {
|
if case let .linear(_, bottom) = position {
|
||||||
if case .Neighbour(_, _, .condensed) = bottom {
|
if case .Neighbour(_, _, .condensed) = bottom {
|
||||||
if selectedFile?.isMusic ?? false {
|
if selectedFile?.isMusic ?? false {
|
||||||
bottomInset -= 14.0
|
// bottomInset -= 14.0
|
||||||
} else {
|
} else {
|
||||||
bottomInset -= 10.0
|
bottomInset -= 10.0
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user