Skip to content

Commit

Permalink
eliminate unnecessary coupling between AutoHearControl and NumberSuit…
Browse files Browse the repository at this point in the history
…eCommonPreferences, phetsims/number-pairs#22
  • Loading branch information
pixelzoom committed Dec 9, 2024
1 parent e9d5849 commit ce9807b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions js/common/view/AutoHearControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),
Expand All @@ -32,7 +32,7 @@ const MISSING_VOICE_WARNING_TEXT_OPTIONS: TextOptions = {
export default class AutoHearControl extends Node {

public constructor(
preferences: NumberSuiteCommonPreferences,
autoHearEnabledProperty: Property<boolean>,
speechSynthesisAnnouncer: NumberSuiteCommonSpeechSynthesisAnnouncer,
labelStringProperty: TReadOnlyProperty<string>,
descriptionStringProperty: TReadOnlyProperty<string>,
Expand All @@ -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( {
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit ce9807b

Please sign in to comment.