This commit is contained in:
Ali
2023-07-14 20:49:24 +04:00
parent aab73d6aeb
commit f305edfb17
21 changed files with 377 additions and 184 deletions

View File

@@ -106,6 +106,8 @@ private extension StorageUsageScreenComponent.Category {
self = .avatars
case .misc:
self = .misc
case .stories:
self = .stories
}
}
}
@@ -264,6 +266,7 @@ final class StorageUsageScreenComponent: Component {
case stickers
case avatars
case misc
case stories
var color: UIColor {
switch self {
@@ -283,6 +286,8 @@ final class StorageUsageScreenComponent: Component {
return UIColor(rgb: 0xAF52DE)
case .misc:
return UIColor(rgb: 0xFF9500)
case .stories:
return UIColor(rgb: 0x3478F6)
}
}
@@ -304,6 +309,9 @@ final class StorageUsageScreenComponent: Component {
return strings.StorageManagement_SectionAvatars
case .misc:
return strings.StorageManagement_SectionMiscellaneous
case .stories:
//TODO:localize
return "Stories"
}
}
@@ -325,6 +333,8 @@ final class StorageUsageScreenComponent: Component {
return "Settings/Storage/ParticleAvatars"
case .misc:
return "Settings/Storage/ParticleOther"
case .stories:
return "Settings/Storage/ParticleOther"
}
}
}
@@ -1254,7 +1264,8 @@ final class StorageUsageScreenComponent: Component {
.music,
.stickers,
.avatars,
.misc
.misc,
.stories
]
var listCategories: [StorageCategoriesComponent.CategoryData] = []
@@ -1286,6 +1297,8 @@ final class StorageUsageScreenComponent: Component {
mappedCategory = .avatars
case .misc:
mappedCategory = .misc
case .stories:
mappedCategory = .stories
case .other:
continue
}
@@ -1773,7 +1786,7 @@ final class StorageUsageScreenComponent: Component {
contentHeight += 8.0
var keepContentHeight: CGFloat = 0.0
for i in 0 ..< 3 {
for i in 0 ..< 4 {
let item: ComponentView<Empty>
if let current = self.keepDurationItems[i] {
item = current
@@ -1795,6 +1808,11 @@ final class StorageUsageScreenComponent: Component {
iconName = "Settings/Menu/GroupChats"
title = environment.strings.Notifications_GroupChats
mappedCategory = .groups
case 3:
iconName = "Settings/Menu/Stories"
//TODO:localized
title = "Stories"
mappedCategory = .stories
default:
iconName = "Settings/Menu/Channels"
title = environment.strings.Notifications_Channels
@@ -1810,8 +1828,10 @@ final class StorageUsageScreenComponent: Component {
}
var subtitle: String?
if let cacheSettingsExceptionCount = self.cacheSettingsExceptionCount, let categoryCount = cacheSettingsExceptionCount[mappedCategory] {
subtitle = environment.strings.CacheEvictionMenu_CategoryExceptions(Int32(categoryCount))
if mappedCategory != .stories {
if let cacheSettingsExceptionCount = self.cacheSettingsExceptionCount, let categoryCount = cacheSettingsExceptionCount[mappedCategory] {
subtitle = environment.strings.CacheEvictionMenu_CategoryExceptions(Int32(categoryCount))
}
}
let itemSize = item.update(
@@ -1822,7 +1842,7 @@ final class StorageUsageScreenComponent: Component {
title: title,
subtitle: subtitle,
value: optionText,
hasNext: i != 3 - 1,
hasNext: i != 4 - 1,
action: { [weak self] sourceView in
guard let self else {
return
@@ -2869,6 +2889,8 @@ final class StorageUsageScreenComponent: Component {
mappedCategories.append(.avatars)
case .misc:
mappedCategories.append(.misc)
case .stories:
mappedCategories.append(.stories)
}
}
@@ -2918,6 +2940,8 @@ final class StorageUsageScreenComponent: Component {
mappedCategories.append(.avatars)
case .misc:
mappedCategories.append(.misc)
case .stories:
mappedCategories.append(.stories)
}
}
@@ -2947,6 +2971,8 @@ final class StorageUsageScreenComponent: Component {
mappedCategory = .avatars
case .misc:
mappedCategory = .misc
case .stories:
mappedCategory = .stories
}
if let value = contextStats.categories[mappedCategory] {
@@ -3149,12 +3175,23 @@ final class StorageUsageScreenComponent: Component {
var subItems: [ContextMenuItem] = []
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
var presetValues: [Int32] = [
Int32.max,
31 * 24 * 60 * 60,
7 * 24 * 60 * 60,
1 * 24 * 60 * 60
]
var presetValues: [Int32]
if case .stories = mappedCategory {
presetValues = [
7 * 24 * 60 * 60,
2 * 24 * 60 * 60,
1 * 24 * 60 * 60
]
} else {
presetValues = [
Int32.max,
31 * 24 * 60 * 60,
7 * 24 * 60 * 60,
1 * 24 * 60 * 60
]
}
if currentValue != 0 && !presetValues.contains(currentValue) {
presetValues.append(currentValue)
presetValues.sort(by: >)
@@ -3181,30 +3218,32 @@ final class StorageUsageScreenComponent: Component {
subItems.append(.separator)
if peerExceptions.isEmpty {
let exceptionsText = presentationData.strings.GroupInfo_Permissions_AddException
subItems.append(.action(ContextMenuActionItem(text: exceptionsText, icon: { theme in
if case .privateChats = mappedCategory {
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/AddUser"), color: theme.contextMenu.primaryColor)
} else {
return generateTintedImage(image: UIImage(bundleImageName: "Location/CreateGroupIcon"), color: theme.contextMenu.primaryColor)
}
}, action: { _, f in
f(.default)
if let exceptionsController = makeStorageUsageExceptionsScreen(mappedCategory) {
pushControllerImpl?(exceptionsController)
}
})))
} else {
subItems.append(.custom(MultiplePeerAvatarsContextItem(context: context, peers: peerExceptions.prefix(3).map { EnginePeer($0.peer.peer) }, totalCount: peerExceptions.count, action: { c, _ in
c.dismiss(completion: {
if mappedCategory != .stories {
if peerExceptions.isEmpty {
let exceptionsText = presentationData.strings.GroupInfo_Permissions_AddException
subItems.append(.action(ContextMenuActionItem(text: exceptionsText, icon: { theme in
if case .privateChats = mappedCategory {
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/AddUser"), color: theme.contextMenu.primaryColor)
} else {
return generateTintedImage(image: UIImage(bundleImageName: "Location/CreateGroupIcon"), color: theme.contextMenu.primaryColor)
}
}, action: { _, f in
f(.default)
})
if let exceptionsController = makeStorageUsageExceptionsScreen(mappedCategory) {
pushControllerImpl?(exceptionsController)
}
}), false))
if let exceptionsController = makeStorageUsageExceptionsScreen(mappedCategory) {
pushControllerImpl?(exceptionsController)
}
})))
} else {
subItems.append(.custom(MultiplePeerAvatarsContextItem(context: context, peers: peerExceptions.prefix(3).map { EnginePeer($0.peer.peer) }, totalCount: peerExceptions.count, action: { c, _ in
c.dismiss(completion: {
})
if let exceptionsController = makeStorageUsageExceptionsScreen(mappedCategory) {
pushControllerImpl?(exceptionsController)
}
}), false))
}
}
if let sourceLabelView = sourceView.labelView {