Small adjustments

This commit is contained in:
Ali 2022-12-31 14:52:27 +04:00
parent 41cbce1cc9
commit b41aa0fd05
6 changed files with 51 additions and 42 deletions

View File

@ -8611,3 +8611,14 @@ Sorry for the inconvenience.";
"GroupMembers.MembersHiddenOff" = "Switch this on to hide the list of members in this group. Admins will remain visible.";
"StorageManagement.ClearCache" = "Clear Cache";
"ChatList.StorageHintTitle" = "Free up to %@";
"ChatList.StorageHintText" = "Clear storage space on your iPhone";
"StorageManagement.PeerShowDetails" = "Show Details";
"StorageManagement.PeerOpenProfile" = "Open Profile";
"StorageManagement.ContextSelect" = "Select";
"StorageManagement.ContextDeselect" = "Deselect";
"StorageManagement.OpenPhoto" = "Open Photo";
"StorageManagement.OpenVideo" = "Open Video";
"StorageManagement.OpenFile" = "Open File";

View File

@ -1341,7 +1341,7 @@ public final class ChatListNode: ListView {
}
let storageInfo: Signal<Double?, NoError>
if case .chatList(groupId: .root) = location, chatListFilter == nil {
if "".isEmpty, case .chatList(groupId: .root) = location, chatListFilter == nil {
let storageBox = context.account.postbox.mediaBox.storageBox
storageInfo = storageBox.totalSize()
|> take(1)

View File

@ -120,16 +120,16 @@ class ChatListStorageInfoItemNode: ListViewItemNode {
let themeUpdated = item.theme !== previousItem?.theme
//TODO:localize
let titleString = NSMutableAttributedString()
titleString.append(NSAttributedString(string: "Free up to ", font: titleFont, textColor: item.theme.rootController.navigationBar.primaryTextColor))
let sizeString = dataSizeString(Int64(item.sizeFraction), formatting: DataSizeStringFormatting(strings: item.strings, decimalSeparator: "."))
titleString.append(NSAttributedString(string: sizeString, font: titleFont, textColor: item.theme.rootController.navigationBar.accentTextColor))
let rawTitleString = item.strings.ChatList_StorageHintTitle(sizeString)
let titleString = NSMutableAttributedString(attributedString: NSAttributedString(string: rawTitleString.string, font: titleFont, textColor: item.theme.rootController.navigationBar.primaryTextColor))
if let range = rawTitleString.ranges.first {
titleString.addAttribute(.foregroundColor, value: item.theme.rootController.navigationBar.accentTextColor, range: range.range)
}
let titleLayout = makeTitleLayout(TextNodeLayoutArguments(attributedString: titleString, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - sideInset - rightInset, height: 100.0)))
//TODO:localize
let textLayout = makeTextLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: "Clear storage space on your iPhone", font: textFont, textColor: item.theme.rootController.navigationBar.secondaryTextColor), maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - sideInset - rightInset, height: 100.0)))
let textLayout = makeTextLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.strings.ChatList_StorageHintText, font: textFont, textColor: item.theme.rootController.navigationBar.secondaryTextColor), maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - sideInset - rightInset, height: 100.0)))
let layout = ListViewItemNodeLayout(contentSize: CGSize(width: params.width, height: height), insets: UIEdgeInsets())

View File

@ -1947,10 +1947,11 @@ final class StorageUsageScreenComponent: Component {
return
}
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
var itemList: [ContextMenuItem] = []
//TODO:localize
itemList.append(.action(ContextMenuActionItem(
text: "Show Details",
text: presentationData.strings.StorageManagement_PeerShowDetails,
icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Info"), color: theme.contextMenu.primaryColor) },
action: { [weak self] c, _ in
c.dismiss(completion: { [weak self] in
@ -1962,7 +1963,7 @@ final class StorageUsageScreenComponent: Component {
})
))
itemList.append(.action(ContextMenuActionItem(
text: "Open Profile",
text: presentationData.strings.StorageManagement_PeerOpenProfile,
icon: { theme in
if case .user = peer {
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/User"), color: theme.contextMenu.primaryColor)
@ -1991,7 +1992,7 @@ final class StorageUsageScreenComponent: Component {
})
))
itemList.append(.action(ContextMenuActionItem(
text: "Select",
text: presentationData.strings.StorageManagement_ContextSelect,
icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Select"), color: theme.contextMenu.primaryColor) },
action: { [weak self] c, _ in
c.dismiss(completion: {
@ -2006,8 +2007,6 @@ final class StorageUsageScreenComponent: Component {
))
let items = ContextController.Items(content: .list(itemList))
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
let controller = ContextController(
account: component.context.account,
presentationData: presentationData,
@ -2468,6 +2467,20 @@ final class StorageUsageScreenComponent: Component {
let strings = presentationData.strings
var items: [ContextMenuItem] = []
items.append(.action(ContextMenuActionItem(
text: presentationData.strings.StorageManagement_OpenPhoto,
icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Expand"), color: theme.contextMenu.primaryColor) },
action: { [weak self] c, _ in
c.dismiss(completion: { [weak self] in
guard let self else {
return
}
self.openMessage(message: message)
})
})
))
items.append(.action(ContextMenuActionItem(text: strings.SharedMedia_ViewInChat, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/GoToMessage"), color: theme.contextMenu.primaryColor) }, action: { [weak self] c, f in
c.dismiss(completion: { [weak self] in
guard let self, let component = self.component, let controller = self.controller?(), let navigationController = controller.navigationController as? NavigationController else {
@ -2534,24 +2547,24 @@ final class StorageUsageScreenComponent: Component {
return
}
//TODO:localize
var openTitle: String = "Open"
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
var openTitle: String = presentationData.strings.Conversation_LinkDialogOpen
var isAudio: Bool = false
for media in message.media {
if let _ = media as? TelegramMediaImage {
openTitle = "Open Photo"
openTitle = presentationData.strings.StorageManagement_OpenPhoto
} else if let file = media as? TelegramMediaFile {
if file.isVideo {
openTitle = "Open Video"
openTitle = presentationData.strings.StorageManagement_OpenVideo
} else {
openTitle = "Open File"
openTitle = presentationData.strings.StorageManagement_OpenFile
}
isAudio = file.isMusic || file.isVoice
}
}
var itemList: [ContextMenuItem] = []
//TODO:localize
if !isAudio {
itemList.append(.action(ContextMenuActionItem(
text: openTitle,
@ -2566,8 +2579,9 @@ final class StorageUsageScreenComponent: Component {
})
))
}
itemList.append(.action(ContextMenuActionItem(
text: "View in Chat",
text: presentationData.strings.SharedMedia_ViewInChat,
icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/GoToMessage"), color: theme.contextMenu.primaryColor)
},
@ -2596,7 +2610,7 @@ final class StorageUsageScreenComponent: Component {
})
))
itemList.append(.action(ContextMenuActionItem(
text: "Select",
text: aggregatedData.selectionState.selectedMessages.contains(messageId) ? presentationData.strings.StorageManagement_ContextDeselect : presentationData.strings.StorageManagement_ContextSelect,
icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Select"), color: theme.contextMenu.primaryColor) },
action: { [weak self] c, _ in
c.dismiss(completion: {
@ -2611,8 +2625,6 @@ final class StorageUsageScreenComponent: Component {
))
let items = ContextController.Items(content: .list(itemList))
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
let controller = ContextController(
account: component.context.account,
presentationData: presentationData,

View File

@ -10,6 +10,7 @@ swift_library(
"-warnings-as-errors",
],
deps = [
"//submodules/Display"
],
visibility = [
"//visibility:public",

View File

@ -8,6 +8,7 @@
import Foundation
import QuartzCore
import UIKit
import Display
// MARK: - LottieBackgroundBehavior
@ -395,31 +396,15 @@ final public class AnimationView: AnimationViewBase {
}
}
private var workaroundDisplayLink: CADisplayLink?
private var workaroundDisplayLink: SharedDisplayLinkDriver.Link?
private var needsWorkaroundDisplayLink: Bool = false {
didSet {
if self.needsWorkaroundDisplayLink != oldValue {
if self.needsWorkaroundDisplayLink {
if workaroundDisplayLink == nil {
class WorkaroundDisplayLinkTarget {
private let f: () -> Void
init(_ f: @escaping () -> Void) {
self.f = f
}
@objc func update() {
self.f()
}
}
/*self.workaroundDisplayLink = CADisplayLink(target: WorkaroundDisplayLinkTarget { [weak self] in
if self.workaroundDisplayLink == nil {
self.workaroundDisplayLink = SharedDisplayLinkDriver.shared.add { [weak self] in
let _ = self?.realtimeAnimationProgress
}, selector: #selector(WorkaroundDisplayLinkTarget.update))
if #available(iOS 15.0, *) {
let maxFps = Float(UIScreen.main.maximumFramesPerSecond)
self.workaroundDisplayLink?.preferredFrameRateRange = CAFrameRateRange(minimum: maxFps, maximum: maxFps, preferred: maxFps)
}
self.workaroundDisplayLink?.add(to: .main, forMode: .common)*/
}
} else {
if let workaroundDisplayLink = self.workaroundDisplayLink {