mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-30 01:11:46 +00:00
Improve storage usage selection
This commit is contained in:
parent
dc6e7b82c5
commit
2bdda2bc17
@ -8609,3 +8609,5 @@ Sorry for the inconvenience.";
|
|||||||
"GroupMembers.HideMembers" = "Hide Members";
|
"GroupMembers.HideMembers" = "Hide Members";
|
||||||
"GroupMembers.MembersHiddenOn" = "Switch this off to show the list of members in this group.";
|
"GroupMembers.MembersHiddenOn" = "Switch this off to show the list of members in this group.";
|
||||||
"GroupMembers.MembersHiddenOff" = "Switch this on to hide the list of members in this group. Admins will remain visible.";
|
"GroupMembers.MembersHiddenOff" = "Switch this on to hide the list of members in this group. Admins will remain visible.";
|
||||||
|
|
||||||
|
"StorageManagement.ClearCache" = "Clear Cache";
|
||||||
|
@ -40,6 +40,7 @@ final class StorageCategoriesComponent: Component {
|
|||||||
let strings: PresentationStrings
|
let strings: PresentationStrings
|
||||||
let categories: [CategoryData]
|
let categories: [CategoryData]
|
||||||
let isOtherExpanded: Bool
|
let isOtherExpanded: Bool
|
||||||
|
let displayAction: Bool
|
||||||
let toggleCategorySelection: (StorageUsageScreenComponent.Category) -> Void
|
let toggleCategorySelection: (StorageUsageScreenComponent.Category) -> Void
|
||||||
let toggleOtherExpanded: () -> Void
|
let toggleOtherExpanded: () -> Void
|
||||||
let clearAction: () -> Void
|
let clearAction: () -> Void
|
||||||
@ -49,6 +50,7 @@ final class StorageCategoriesComponent: Component {
|
|||||||
strings: PresentationStrings,
|
strings: PresentationStrings,
|
||||||
categories: [CategoryData],
|
categories: [CategoryData],
|
||||||
isOtherExpanded: Bool,
|
isOtherExpanded: Bool,
|
||||||
|
displayAction: Bool,
|
||||||
toggleCategorySelection: @escaping (StorageUsageScreenComponent.Category) -> Void,
|
toggleCategorySelection: @escaping (StorageUsageScreenComponent.Category) -> Void,
|
||||||
toggleOtherExpanded: @escaping () -> Void,
|
toggleOtherExpanded: @escaping () -> Void,
|
||||||
clearAction: @escaping () -> Void
|
clearAction: @escaping () -> Void
|
||||||
@ -57,6 +59,7 @@ final class StorageCategoriesComponent: Component {
|
|||||||
self.strings = strings
|
self.strings = strings
|
||||||
self.categories = categories
|
self.categories = categories
|
||||||
self.isOtherExpanded = isOtherExpanded
|
self.isOtherExpanded = isOtherExpanded
|
||||||
|
self.displayAction = displayAction
|
||||||
self.toggleCategorySelection = toggleCategorySelection
|
self.toggleCategorySelection = toggleCategorySelection
|
||||||
self.toggleOtherExpanded = toggleOtherExpanded
|
self.toggleOtherExpanded = toggleOtherExpanded
|
||||||
self.clearAction = clearAction
|
self.clearAction = clearAction
|
||||||
@ -75,6 +78,9 @@ final class StorageCategoriesComponent: Component {
|
|||||||
if lhs.isOtherExpanded != rhs.isOtherExpanded {
|
if lhs.isOtherExpanded != rhs.isOtherExpanded {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.displayAction != rhs.displayAction {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,59 +201,65 @@ final class StorageCategoriesComponent: Component {
|
|||||||
self.itemViews.removeValue(forKey: key)
|
self.itemViews.removeValue(forKey: key)
|
||||||
}
|
}
|
||||||
|
|
||||||
let clearTitle: String
|
if component.displayAction {
|
||||||
let label: String?
|
let clearTitle: String
|
||||||
if totalSelectedSize == 0 {
|
let label: String?
|
||||||
clearTitle = component.strings.StorageManagement_ClearSelected
|
if totalSelectedSize == 0 {
|
||||||
label = nil
|
clearTitle = component.strings.StorageManagement_ClearSelected
|
||||||
} else if hasDeselected {
|
label = nil
|
||||||
clearTitle = component.strings.StorageManagement_ClearSelected
|
} else if hasDeselected {
|
||||||
label = dataSizeString(totalSelectedSize, formatting: DataSizeStringFormatting(strings: component.strings, decimalSeparator: "."))
|
clearTitle = component.strings.StorageManagement_ClearSelected
|
||||||
} else {
|
label = dataSizeString(totalSelectedSize, formatting: DataSizeStringFormatting(strings: component.strings, decimalSeparator: "."))
|
||||||
clearTitle = component.strings.StorageManagement_ClearAll
|
} else {
|
||||||
label = dataSizeString(totalSelectedSize, formatting: DataSizeStringFormatting(strings: component.strings, decimalSeparator: "."))
|
clearTitle = component.strings.StorageManagement_ClearAll
|
||||||
}
|
label = dataSizeString(totalSelectedSize, formatting: DataSizeStringFormatting(strings: component.strings, decimalSeparator: "."))
|
||||||
|
}
|
||||||
contentHeight += 8.0
|
|
||||||
let buttonSize = self.button.update(
|
contentHeight += 8.0
|
||||||
transition: transition,
|
let buttonSize = self.button.update(
|
||||||
component: AnyComponent(SolidRoundedButtonComponent(
|
transition: transition,
|
||||||
title: clearTitle,
|
component: AnyComponent(SolidRoundedButtonComponent(
|
||||||
label: label,
|
title: clearTitle,
|
||||||
theme: SolidRoundedButtonComponent.Theme(
|
label: label,
|
||||||
backgroundColor: component.theme.list.itemCheckColors.fillColor,
|
theme: SolidRoundedButtonComponent.Theme(
|
||||||
backgroundColors: [],
|
backgroundColor: component.theme.list.itemCheckColors.fillColor,
|
||||||
foregroundColor: component.theme.list.itemCheckColors.foregroundColor
|
backgroundColors: [],
|
||||||
),
|
foregroundColor: component.theme.list.itemCheckColors.foregroundColor
|
||||||
font: .bold,
|
),
|
||||||
fontSize: 17.0,
|
font: .bold,
|
||||||
height: 50.0,
|
fontSize: 17.0,
|
||||||
cornerRadius: 10.0,
|
height: 50.0,
|
||||||
gloss: false,
|
cornerRadius: 10.0,
|
||||||
isEnabled: totalSelectedSize != 0,
|
gloss: false,
|
||||||
animationName: nil,
|
isEnabled: totalSelectedSize != 0,
|
||||||
iconPosition: .right,
|
animationName: nil,
|
||||||
iconSpacing: 4.0,
|
iconPosition: .right,
|
||||||
action: { [weak self] in
|
iconSpacing: 4.0,
|
||||||
guard let self, let component = self.component else {
|
action: { [weak self] in
|
||||||
return
|
guard let self, let component = self.component else {
|
||||||
}
|
return
|
||||||
component.clearAction()
|
}
|
||||||
}
|
component.clearAction()
|
||||||
)),
|
}
|
||||||
environment: {},
|
)),
|
||||||
containerSize: CGSize(width: availableSize.width - 16.0 * 2.0, height: 50.0)
|
environment: {},
|
||||||
)
|
containerSize: CGSize(width: availableSize.width - 16.0 * 2.0, height: 50.0)
|
||||||
let buttonFrame = CGRect(origin: CGPoint(x: 16.0, y: contentHeight), size: buttonSize)
|
)
|
||||||
if let buttonView = button.view {
|
let buttonFrame = CGRect(origin: CGPoint(x: 16.0, y: contentHeight), size: buttonSize)
|
||||||
if buttonView.superview == nil {
|
if let buttonView = self.button.view {
|
||||||
self.addSubview(buttonView)
|
if buttonView.superview == nil {
|
||||||
|
self.addSubview(buttonView)
|
||||||
|
}
|
||||||
|
transition.setFrame(view: buttonView, frame: buttonFrame)
|
||||||
|
}
|
||||||
|
contentHeight += buttonSize.height
|
||||||
|
|
||||||
|
contentHeight += 16.0
|
||||||
|
} else {
|
||||||
|
if let buttonView = self.button.view {
|
||||||
|
buttonView.removeFromSuperview()
|
||||||
}
|
}
|
||||||
transition.setFrame(view: buttonView, frame: buttonFrame)
|
|
||||||
}
|
}
|
||||||
contentHeight += buttonSize.height
|
|
||||||
|
|
||||||
contentHeight += 16.0
|
|
||||||
|
|
||||||
self.backgroundColor = component.theme.list.itemBlocksBackgroundColor
|
self.backgroundColor = component.theme.list.itemBlocksBackgroundColor
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user