Various improvements

This commit is contained in:
Ilya Laktyushin
2023-12-20 14:20:11 +04:00
parent e6ba681c03
commit 7c435bf03e
6 changed files with 62 additions and 50 deletions

View File

@@ -127,17 +127,20 @@ private final class MediaToolsScreenComponent: Component {
let context: AccountContext
let mediaEditor: MediaEditor
let section: MediaToolsSection
let hiddenTools: [EditorToolKey]
let sectionUpdated: (MediaToolsSection) -> Void
init(
context: AccountContext,
mediaEditor: MediaEditor,
section: MediaToolsSection,
hiddenTools: [EditorToolKey],
sectionUpdated: @escaping (MediaToolsSection) -> Void
) {
self.context = context
self.mediaEditor = mediaEditor
self.section = section
self.hiddenTools = hiddenTools
self.sectionUpdated = sectionUpdated
}
@@ -148,6 +151,9 @@ private final class MediaToolsScreenComponent: Component {
if lhs.section != rhs.section {
return false
}
if lhs.hiddenTools != rhs.hiddenTools {
return false
}
return true
}
@@ -362,7 +368,6 @@ private final class MediaToolsScreenComponent: Component {
if availableSize.height < previewSize.height + 30.0 {
topInset = 0.0
controlsBottomInset = -75.0
// self.buttonsBackgroundView.backgroundColor = .black
} else {
self.buttonsBackgroundView.backgroundColor = .clear
}
@@ -658,6 +663,8 @@ private final class MediaToolsScreenComponent: Component {
// )
]
tools = tools.filter { !component.hiddenTools.contains($0.key) }
if !component.mediaEditor.sourceIsVideo {
tools.insert(AdjustmentTool(
key: .grain,
@@ -1044,6 +1051,7 @@ public final class MediaToolsScreen: ViewController {
context: self.context,
mediaEditor: controller.mediaEditor,
section: self.currentSection,
hiddenTools: controller.hiddenTools,
sectionUpdated: { [weak self] section in
if let self {
self.currentSection = section
@@ -1087,15 +1095,17 @@ public final class MediaToolsScreen: ViewController {
}
fileprivate let context: AccountContext
fileprivate let hiddenTools: [EditorToolKey]
fileprivate let mediaEditor: MediaEditor
public var dismissed: () -> Void = {}
private var initialValues: MediaEditorValues
public init(context: AccountContext, mediaEditor: MediaEditor) {
public init(context: AccountContext, mediaEditor: MediaEditor, hiddenTools: [EditorToolKey]) {
self.context = context
self.mediaEditor = mediaEditor
self.hiddenTools = hiddenTools
self.initialValues = mediaEditor.values.makeCopy()
super.init(navigationBarPresentationData: nil)