Skip to content

Commit fd868c7

Browse files
fix: 3723 - now always replaces decimal separator for number format (#3734)
* Revert "feat: 3585 - upgrade to flutter 3.7 (#3666)" This reverts commit ad46236. * fix: 3723 - now always replaces decimal separator for number format Impacted files: * `strings_helper.dart`: removed now useless methods * `text_input_formatters_helper.dart`: now works in all cases, regardless of the presence of group separator in the target language, given that we don't use group separators in our decimal number formats anyway * fix: 3723 - unrelated localization fix Impacted file: * `app_ar.arb`
1 parent 7b9793b commit fd868c7

3 files changed

Lines changed: 8 additions & 17 deletions

File tree

packages/smooth_app/lib/helpers/strings_helper.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ extension StringExtensions on String {
2424
return positions;
2525
}
2626

27-
bool get isASpaceCharacter => this == ' ' || isANarrowBreakSpaceCharacter;
28-
29-
bool get isANarrowBreakSpaceCharacter => this == ' ';
30-
3127
/// Removes a character by giving its position
3228
String removeCharacterAt(int position) {
3329
assert(position >= 0 && position < length);

packages/smooth_app/lib/helpers/text_input_formatters_helper.dart

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,20 @@ import 'package:smooth_app/helpers/strings_helper.dart';
99
/// This separator is based on [NumberFormat], so it can be "." or "," depending
1010
/// on the user's language.
1111
///
12-
/// Only languages with a space character (eg: French) as a group separator will
13-
/// have access to all features.
12+
/// It works if there are no group separator in the format, as it would be
13+
/// problematic with the `123,456.9` and both comma and dot.
1414
///
15-
/// Also, if a separator is already displayed, it will be move to the new
15+
/// Also, if a separator is already displayed, it will be moved to the new
1616
/// position
1717
class DecimalSeparatorRewriter extends TextInputFormatter {
1818
DecimalSeparatorRewriter(NumberFormat format)
1919
: _decimalSeparator = format.symbols.DECIMAL_SEP,
2020
_separatorToReplace = _findSeparatorToReplace(format);
2121

2222
final String _decimalSeparator;
23-
final String? _separatorToReplace;
24-
25-
static String? _findSeparatorToReplace(NumberFormat format) {
26-
if (!format.symbols.GROUP_SEP.isASpaceCharacter) {
27-
return null;
28-
}
23+
final String _separatorToReplace;
2924

25+
static String _findSeparatorToReplace(NumberFormat format) {
3026
switch (format.symbols.DECIMAL_SEP) {
3127
case '.':
3228
return ',';
@@ -107,10 +103,9 @@ class DecimalSeparatorRewriter extends TextInputFormatter {
107103
/// Replaces a "." by a "," or a "," by a "." only if
108104
/// the group separator is an empty character
109105
String replaceSeparator(String newTextValue) {
110-
if (_separatorToReplace != null &&
111-
newTextValue.contains(_separatorToReplace!)) {
106+
if (newTextValue.contains(_separatorToReplace)) {
112107
return newTextValue.replaceAll(
113-
_separatorToReplace!,
108+
_separatorToReplace,
114109
_decimalSeparator,
115110
);
116111
} else {

packages/smooth_app/lib/l10n/app_ar.arb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@
853853
"@are_you_sure": {
854854
"description": "Are you sure?"
855855
},
856-
"knowledge_panel_text_source": "تعرف أكثر من خلال {source_name}",
856+
"knowledge_panel_text_source": "تعرف أكثر من خلال {sourceName}",
857857
"@knowledge_panel_text_source": {
858858
"description": "Source field within a text knowledge panel.",
859859
"placeholders": {

0 commit comments

Comments
 (0)