From ce9807bd51b48d7d9429ec511d3bc17320af5040 Mon Sep 17 00:00:00 2001 From: pixelzoom Date: Mon, 9 Dec 2024 14:26:37 -0700 Subject: [PATCH] eliminate unnecessary coupling between AutoHearControl and NumberSuiteCommonPreferences, https://github.com/phetsims/number-pairs/issues/22 --- js/common/view/AutoHearControl.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/js/common/view/AutoHearControl.ts b/js/common/view/AutoHearControl.ts index f608b62..3179419 100644 --- a/js/common/view/AutoHearControl.ts +++ b/js/common/view/AutoHearControl.ts @@ -20,9 +20,9 @@ import exclamationTriangleSolidShape from '../../../../sherpa/js/fontawesome-5/e import ToggleSwitch from '../../../../sun/js/ToggleSwitch.js'; import numberSuiteCommon from '../../numberSuiteCommon.js'; import NumberSuiteCommonStrings from '../../NumberSuiteCommonStrings.js'; -import NumberSuiteCommonPreferences from '../model/NumberSuiteCommonPreferences.js'; import NumberSuiteCommonConstants from '../NumberSuiteCommonConstants.js'; import NumberSuiteCommonSpeechSynthesisAnnouncer from './NumberSuiteCommonSpeechSynthesisAnnouncer.js'; +import Property from '../../../../axon/js/Property.js'; const MISSING_VOICE_WARNING_TEXT_OPTIONS: TextOptions = { font: new PhetFont( 14 ), @@ -32,7 +32,7 @@ const MISSING_VOICE_WARNING_TEXT_OPTIONS: TextOptions = { export default class AutoHearControl extends Node { public constructor( - preferences: NumberSuiteCommonPreferences, + autoHearEnabledProperty: Property, speechSynthesisAnnouncer: NumberSuiteCommonSpeechSynthesisAnnouncer, labelStringProperty: TReadOnlyProperty, descriptionStringProperty: TReadOnlyProperty, @@ -43,7 +43,7 @@ export default class AutoHearControl extends Node { visible: visible } ); - const toggleSwitch = new ToggleSwitch( preferences.autoHearEnabledProperty, false, true, + const toggleSwitch = new ToggleSwitch( autoHearEnabledProperty, false, true, PreferencesDialogConstants.TOGGLE_SWITCH_OPTIONS ); const control = new PreferencesControl( { @@ -78,10 +78,9 @@ export default class AutoHearControl extends Node { children: [ warningIcon, missingVoiceWarningMessage ], spacing: 14, align: 'center', - visibleProperty: new DerivedProperty( [ - preferences.autoHearEnabledProperty, - speechSynthesisAnnouncer.hasVoiceProperty - ], ( autoHearEnabled, hasVoice ) => autoHearEnabled && !hasVoice + visibleProperty: new DerivedProperty( + [ autoHearEnabledProperty, speechSynthesisAnnouncer.hasVoiceProperty ], + ( autoHearEnabled, hasVoice ) => autoHearEnabled && !hasVoice ) } ); this.addChild( missingVoiceWarningNode );