@@ -60,6 +60,9 @@ class NewGutenbergViewController: PostGBKEditorViewController, PostEditor, Publi
6060
6161 // TODO: reimplemet
6262// internal private(set) var contentInfo: ContentInfo?
63+ private var areNavigationItemsEnabled = true
64+ private var isUndoButtonDisabled = true
65+ private var isRedoButtonDisabled = true
6366
6467 // MARK: - GutenbergKit
6568
@@ -154,28 +157,41 @@ class NewGutenbergViewController: PostGBKEditorViewController, PostEditor, Publi
154157
155158 private func gutenbergDidRequestToggleRedoButton( _ isDisabled: Bool ) {
156159 DispatchQueue . main. async {
157- UIView . animate ( withDuration: 0.2 ) {
158- self . navigationBarManager. redoButton. isUserInteractionEnabled = isDisabled ? false : true
159- self . navigationBarManager. redoButton. alpha = isDisabled ? 0.3 : 1.0
160- }
160+ self . isRedoButtonDisabled = isDisabled
161+ self . updateRedoButton ( )
161162 }
162163 }
163164
164165 private func gutenbergDidRequestToggleUndoButton( _ isDisabled: Bool ) {
165166 DispatchQueue . main. async {
166- UIView . animate ( withDuration: 0.2 ) {
167- self . navigationBarManager. undoButton. isUserInteractionEnabled = isDisabled ? false : true
168- self . navigationBarManager. undoButton. alpha = isDisabled ? 0.3 : 1.0
169- }
167+ self . isUndoButtonDisabled = isDisabled
168+ self . updateUndoButton ( )
170169 }
171170 }
172171
173172 private func setNavigationItemsEnabled( _ enabled: Bool ) {
173+ areNavigationItemsEnabled = enabled
174174 navigationBarManager. closeButton. isEnabled = enabled
175175 navigationBarManager. moreButton. isEnabled = enabled
176- navigationBarManager. publishButton. isEnabled = enabled
177- navigationBarManager. undoButton. isEnabled = enabled
178- navigationBarManager. redoButton. isEnabled = enabled
176+ navigationBarManager. publishButton. isEnabled = enabled && isPublishButtonEnabled
177+ updateUndoButton ( )
178+ updateRedoButton ( )
179+ }
180+
181+ private func updateUndoButton( ) {
182+ updateHistoryButton ( navigationBarManager. undoButton, isDisabled: isUndoButtonDisabled)
183+ }
184+
185+ private func updateRedoButton( ) {
186+ updateHistoryButton ( navigationBarManager. redoButton, isDisabled: isRedoButtonDisabled)
187+ }
188+
189+ private func updateHistoryButton( _ button: UIButton , isDisabled: Bool ) {
190+ let isEnabled = areNavigationItemsEnabled && !isDisabled
191+ UIView . animate ( withDuration: 0.2 ) {
192+ button. isEnabled = isEnabled
193+ button. alpha = isEnabled ? 1.0 : 0.3
194+ }
179195 }
180196
181197 private func performAutoSave( ) {
0 commit comments