From 2335b1236b3d44ae4d5087ac2a0a12374f4acfdb Mon Sep 17 00:00:00 2001 From: chrisklus Date: Tue, 20 Dec 2022 13:20:16 -0700 Subject: [PATCH] Divide parts of number-play into number-suite-common, see https://github.com/phetsims/number-suite-common/issues/1 --- js/common/view/LocaleSwitch.ts | 64 ---------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 js/common/view/LocaleSwitch.ts diff --git a/js/common/view/LocaleSwitch.ts b/js/common/view/LocaleSwitch.ts deleted file mode 100644 index 3a0991f1..00000000 --- a/js/common/view/LocaleSwitch.ts +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021-2022, University of Colorado Boulder - -/** - * An ABSwitch for choosing the primary or secondary locale. - * - * @author Chris Klusendorf (PhET Interactive Simulations) - */ - -import BooleanProperty from '../../../../axon/js/BooleanProperty.js'; -import Dimension2 from '../../../../dot/js/Dimension2.js'; -import PhetFont from '../../../../scenery-phet/js/PhetFont.js'; -import { Text } from '../../../../scenery/js/imports.js'; -import ABSwitch from '../../../../sun/js/ABSwitch.js'; -import numberPlay from '../../numberPlay.js'; -import NumberPlayStrings from '../../NumberPlayStrings.js'; -import NumberPlayConstants from '../NumberPlayConstants.js'; -import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js'; -import IntentionalAny from '../../../../phet-core/js/types/IntentionalAny.js'; - -// constants -const AB_SWITCH_OPTIONS = { - centerOnSwitch: true, - spacing: 8, - toggleSwitchOptions: { - size: new Dimension2( 40, 20 ) - } -}; - -class LocaleSwitch extends ABSwitch { - - public constructor( isPrimaryLocaleProperty: BooleanProperty, showSecondLocaleProperty: TReadOnlyProperty, - secondLocaleStringsProperty: TReadOnlyProperty, maxWidth: number ) { - - // options for the switch text. calculate the maxWidth for each string as half of the available horizontal space - // without the ToggleSwitch or spacing. - const switchTextOptions = { - font: new PhetFont( 14 ), - maxWidth: ( maxWidth - AB_SWITCH_OPTIONS.toggleSwitchOptions.size.width - AB_SWITCH_OPTIONS.spacing * 2 ) * 0.5 - }; - - const secondLanguageStringKey = `${NumberPlayConstants.NUMBER_PLAY_STRING_KEY_PREFIX}language`; - const secondLanguageText = new Text( '', switchTextOptions ); - - secondLocaleStringsProperty.link( secondLocaleStrings => { - secondLanguageText.setText( secondLocaleStrings[ secondLanguageStringKey ] ); - } ); - - super( isPrimaryLocaleProperty, - true, new Text( NumberPlayStrings.languageStringProperty, switchTextOptions ), - false, secondLanguageText, - AB_SWITCH_OPTIONS - ); - - showSecondLocaleProperty.link( showSecondLocale => { - this.visible = showSecondLocale; - if ( !showSecondLocale ) { - isPrimaryLocaleProperty.value = true; - } - } ); - } -} - -numberPlay.register( 'LocaleSwitch', LocaleSwitch ); -export default LocaleSwitch; \ No newline at end of file