Skip to content

Commit

Permalink
improve semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
cedvdb committed Feb 6, 2024
1 parent 159ea07 commit 2224c1c
Show file tree
Hide file tree
Showing 26 changed files with 98 additions and 95 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [9.0.3]
- improve semantics

## [9.0.2]
- reformat national number on country changed

Expand All @@ -6,7 +9,6 @@

## [9.0.0]

- Big Internal refactor in the hope of making contribution easier
- Various fixes for country selection UX
- Various fixes for input cursor issues
- Improve accessibility touches surfaces
Expand All @@ -20,6 +22,7 @@
- [Deprecated] : `shouldFormat`, it is now always ON by default
- [Deprecated] : `defaultCountry`, you should now use either `initialValue` or provide a controller with an initial value.
- [Deprecated] : `CountrySelectorNavigator.searchDelegate()` changed into `CountrySelectorNavigator.PageNavigator()`.
- Internal refactor in the hope of making contribution easier


## [8.1.1]
Expand Down
9 changes: 3 additions & 6 deletions l10n/en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
"invalidMobilePhoneNumber": "Invalid mobile phone number",
"invalidFixedLinePhoneNumber": "Invalid fixed line phone number",
"requiredPhoneNumber": "Required phone number",
"tapToSelectACountry": "Tap to select a country. Current selection: {countryName} {countryDialCode}",
"@tapToSelectACountry": {
"selectACountry": "Select a country. Current selection: {countryName}",
"@selectACountry": {
"description": "semantic description of the country button",
"placeholders": {
"countryName": {
"type": "String"
},
"countryDialCode": {
"type": "String"
}
}
},
"enterPhoneNumber": "Enter your phone number"
"phoneNumber": "Phone number"
}
5 changes: 4 additions & 1 deletion lib/src/country_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ class CountryButton extends StatelessWidget {
final countryName = countryLocalization.countryName(isoCode);
final countryDialCode = '+ ${countryLocalization.countryDialCode(isoCode)}';
return Semantics(
label: localization.tapToSelectACountry(countryName, countryDialCode),
// no need to put the dial code inside the semantics
// as it is a text inside the button, it will be added
// automatically
label: localization.selectACountry(countryName),
child: InkWell(
onTap: onTap,
child: Padding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ abstract class PhoneFieldLocalizationImpl {
/// semantic description of the country button
///
/// In en, this message translates to:
/// **'Tap to select a country. Current selection: {countryName} {countryDialCode}'**
String tapToSelectACountry(String countryName, String countryDialCode);
/// **'Select a country. Current selection: {countryName}'**
String selectACountry(String countryName);

/// No description provided for @enterPhoneNumber.
/// No description provided for @phoneNumber.
///
/// In en, this message translates to:
/// **'Enter your phone number'**
String get enterPhoneNumber;
/// **'Phone number'**
String get phoneNumber;
}

class _PhoneFieldLocalizationImplDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for Arabic (`ar`).
class PhoneFieldLocalizationImplAr extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplAr([super.locale = 'ar']);
PhoneFieldLocalizationImplAr([String locale = 'ar']) : super(locale);

@override
String get invalidPhoneNumber => 'رقم الهاتف غير صحيح';
Expand All @@ -20,10 +20,10 @@ class PhoneFieldLocalizationImplAr extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'رقم الهاتف مطلوب';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for Central Kurdish (`ckb`).
class PhoneFieldLocalizationImplCkb extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplCkb([super.locale = 'ckb']);
PhoneFieldLocalizationImplCkb([String locale = 'ckb']) : super(locale);

@override
String get invalidPhoneNumber => 'ژمارەی تەلەفۆنی نادروست';
Expand All @@ -21,10 +21,10 @@ class PhoneFieldLocalizationImplCkb extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'ژمارەی تەلەفۆنی پێویست';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for German (`de`).
class PhoneFieldLocalizationImplDe extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplDe([super.locale = 'de']);
PhoneFieldLocalizationImplDe([String locale = 'de']) : super(locale);

@override
String get invalidPhoneNumber => 'Ungültige Telefonnummer';
Expand All @@ -20,10 +20,10 @@ class PhoneFieldLocalizationImplDe extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'Telefonnummer erforderlich';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for Modern Greek (`el`).
class PhoneFieldLocalizationImplEl extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplEl([super.locale = 'el']);
PhoneFieldLocalizationImplEl([String locale = 'el']) : super(locale);

@override
String get invalidPhoneNumber => 'Μη έγκυρος αριθμός τηλεφώνου';
Expand All @@ -21,10 +21,10 @@ class PhoneFieldLocalizationImplEl extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'Απαιτούμενος αριθμός τηλεφώνου';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for English (`en`).
class PhoneFieldLocalizationImplEn extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplEn([super.locale = 'en']);
PhoneFieldLocalizationImplEn([String locale = 'en']) : super(locale);

@override
String get invalidPhoneNumber => 'Invalid phone number';
Expand All @@ -20,10 +20,10 @@ class PhoneFieldLocalizationImplEn extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'Required phone number';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for Spanish Castilian (`es`).
class PhoneFieldLocalizationImplEs extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplEs([super.locale = 'es']);
PhoneFieldLocalizationImplEs([String locale = 'es']) : super(locale);

@override
String get invalidPhoneNumber => 'Numero de telefono invalido';
Expand All @@ -20,10 +20,10 @@ class PhoneFieldLocalizationImplEs extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'Número de teléfono obligatorio';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for Persian (`fa`).
class PhoneFieldLocalizationImplFa extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplFa([super.locale = 'fa']);
PhoneFieldLocalizationImplFa([String locale = 'fa']) : super(locale);

@override
String get invalidPhoneNumber => 'شماره تلفن نامعتبر است';
Expand All @@ -20,10 +20,10 @@ class PhoneFieldLocalizationImplFa extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'شماره تلفن الزامی است';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for French (`fr`).
class PhoneFieldLocalizationImplFr extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplFr([super.locale = 'fr']);
PhoneFieldLocalizationImplFr([String locale = 'fr']) : super(locale);

@override
String get invalidPhoneNumber => 'Numéro de téléphone invalide';
Expand All @@ -21,10 +21,10 @@ class PhoneFieldLocalizationImplFr extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'Numéro de téléphone requis';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for Hindi (`hi`).
class PhoneFieldLocalizationImplHi extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplHi([super.locale = 'hi']);
PhoneFieldLocalizationImplHi([String locale = 'hi']) : super(locale);

@override
String get invalidPhoneNumber => 'अवैध फोन नंबर';
Expand All @@ -20,10 +20,10 @@ class PhoneFieldLocalizationImplHi extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'फ़ोन नंबर आवश्यक';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for Italian (`it`).
class PhoneFieldLocalizationImplIt extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplIt([super.locale = 'it']);
PhoneFieldLocalizationImplIt([String locale = 'it']) : super(locale);

@override
String get invalidPhoneNumber => 'Numero di telefono invalido';
Expand All @@ -20,10 +20,10 @@ class PhoneFieldLocalizationImplIt extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'Numero di telefono richiesto';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for Kurdish (`ku`).
class PhoneFieldLocalizationImplKu extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplKu([super.locale = 'ku']);
PhoneFieldLocalizationImplKu([String locale = 'ku']) : super(locale);

@override
String get invalidPhoneNumber => 'ژمارەی تەلەفۆنی نادروست';
Expand All @@ -21,10 +21,10 @@ class PhoneFieldLocalizationImplKu extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'ژمارەی تەلەفۆنی پێویست';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for Norwegian Bokmål (`nb`).
class PhoneFieldLocalizationImplNb extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplNb([super.locale = 'nb']);
PhoneFieldLocalizationImplNb([String locale = 'nb']) : super(locale);

@override
String get invalidPhoneNumber => 'Ugyldig telefonnummer';
Expand All @@ -20,10 +20,10 @@ class PhoneFieldLocalizationImplNb extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'Telefonnummer er påkrevd';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for Dutch Flemish (`nl`).
class PhoneFieldLocalizationImplNl extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplNl([super.locale = 'nl']);
PhoneFieldLocalizationImplNl([String locale = 'nl']) : super(locale);

@override
String get invalidPhoneNumber => 'Ongeldig telefoonnummer';
Expand All @@ -20,10 +20,10 @@ class PhoneFieldLocalizationImplNl extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'Telefoonnummer vereist';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'phone_field_localization_impl.dart';

/// The translations for Portuguese (`pt`).
class PhoneFieldLocalizationImplPt extends PhoneFieldLocalizationImpl {
PhoneFieldLocalizationImplPt([super.locale = 'pt']);
PhoneFieldLocalizationImplPt([String locale = 'pt']) : super(locale);

@override
String get invalidPhoneNumber => 'Número de telefone inválido';
Expand All @@ -20,10 +20,10 @@ class PhoneFieldLocalizationImplPt extends PhoneFieldLocalizationImpl {
String get requiredPhoneNumber => 'Número de telefone obrigatório';

@override
String tapToSelectACountry(String countryName, String countryDialCode) {
return 'Tap to select a country. Current selection: $countryName $countryDialCode';
String selectACountry(String countryName) {
return 'Select a country. Current selection: $countryName';
}

@override
String get enterPhoneNumber => 'Enter your phone number';
String get phoneNumber => 'Phone number';
}
Loading

0 comments on commit 2224c1c

Please sign in to comment.