@@ -573,23 +573,7 @@ class SettingsViewController: NSViewController {
573573 }
574574
575575 private func showHideTodoModeSettings( animated: Bool ) {
576- let show = Defaults . todo. userEnabled
577-
578- if show {
579- todoView. isHidden = false
580- todoViewHeightConstraint. isActive = false
581- animateChanges ( animated: animated) {
582- todoView. animator ( ) . alphaValue = 1
583- }
584- } else {
585- animateChanges ( animated: animated) {
586- todoView. isHidden = true
587- todoViewHeightConstraint. isActive = true
588- }
589- DispatchQueue . main. async {
590- self . todoView. alphaValue = 0
591- }
592- }
576+ setVisibility ( shown: Defaults . todo. userEnabled, ofView: todoView, withConstraint: todoViewHeightConstraint, animated: animated)
593577 }
594578
595579 func initializeToggles( ) {
@@ -633,12 +617,28 @@ class SettingsViewController: NSViewController {
633617 setToggleStatesForCycleSizeCheckboxes ( )
634618 }
635619
636- animateChanges ( animated: animated) {
637- cycleSizesView. isHidden = !showOptionsView
638- cycleSizesViewHeightConstraint. isActive = !showOptionsView
639- }
620+ setVisibility ( shown: showOptionsView, ofView: cycleSizesView, withConstraint: cycleSizesViewHeightConstraint, animated: animated)
640621 }
641622
623+ private func setVisibility( shown: Bool , ofView view: NSView , withConstraint constraint: NSLayoutConstraint , animated: Bool ) {
624+
625+ if shown {
626+ view. isHidden = false
627+ constraint. isActive = false
628+ animateChanges ( animated: animated) {
629+ view. animator ( ) . alphaValue = 1
630+ }
631+ } else {
632+ animateChanges ( animated: animated) {
633+ view. isHidden = true
634+ constraint. isActive = true
635+ }
636+ DispatchQueue . main. async {
637+ view. alphaValue = 0
638+ }
639+ }
640+ }
641+
642642 private func animateChanges( animated: Bool , block: ( ) -> Void ) {
643643 if animated {
644644 view. layoutSubtreeIfNeeded ( )
0 commit comments