mirror of
https://github.com/openfoodfacts/smooth-app.git
synced 2025-08-26 11:16:45 +08:00
fix: 3723 - now always replaces decimal separator for number format (#3734)
* Revert "feat: 3585 - upgrade to flutter 3.7 (#3666)" This reverts commit ad46236bdf77afea18b12cc69b3ee64a6752ee73. * 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`
This commit is contained in:
@ -24,10 +24,6 @@ extension StringExtensions on String {
|
||||
return positions;
|
||||
}
|
||||
|
||||
bool get isASpaceCharacter => this == ' ' || isANarrowBreakSpaceCharacter;
|
||||
|
||||
bool get isANarrowBreakSpaceCharacter => this == ' ';
|
||||
|
||||
/// Removes a character by giving its position
|
||||
String removeCharacterAt(int position) {
|
||||
assert(position >= 0 && position < length);
|
||||
|
@ -9,10 +9,10 @@ import 'package:smooth_app/helpers/strings_helper.dart';
|
||||
/// This separator is based on [NumberFormat], so it can be "." or "," depending
|
||||
/// on the user's language.
|
||||
///
|
||||
/// Only languages with a space character (eg: French) as a group separator will
|
||||
/// have access to all features.
|
||||
/// It works if there are no group separator in the format, as it would be
|
||||
/// problematic with the `123,456.9` and both comma and dot.
|
||||
///
|
||||
/// Also, if a separator is already displayed, it will be move to the new
|
||||
/// Also, if a separator is already displayed, it will be moved to the new
|
||||
/// position
|
||||
class DecimalSeparatorRewriter extends TextInputFormatter {
|
||||
DecimalSeparatorRewriter(NumberFormat format)
|
||||
@ -20,13 +20,9 @@ class DecimalSeparatorRewriter extends TextInputFormatter {
|
||||
_separatorToReplace = _findSeparatorToReplace(format);
|
||||
|
||||
final String _decimalSeparator;
|
||||
final String? _separatorToReplace;
|
||||
|
||||
static String? _findSeparatorToReplace(NumberFormat format) {
|
||||
if (!format.symbols.GROUP_SEP.isASpaceCharacter) {
|
||||
return null;
|
||||
}
|
||||
final String _separatorToReplace;
|
||||
|
||||
static String _findSeparatorToReplace(NumberFormat format) {
|
||||
switch (format.symbols.DECIMAL_SEP) {
|
||||
case '.':
|
||||
return ',';
|
||||
@ -107,10 +103,9 @@ class DecimalSeparatorRewriter extends TextInputFormatter {
|
||||
/// Replaces a "." by a "," or a "," by a "." only if
|
||||
/// the group separator is an empty character
|
||||
String replaceSeparator(String newTextValue) {
|
||||
if (_separatorToReplace != null &&
|
||||
newTextValue.contains(_separatorToReplace!)) {
|
||||
if (newTextValue.contains(_separatorToReplace)) {
|
||||
return newTextValue.replaceAll(
|
||||
_separatorToReplace!,
|
||||
_separatorToReplace,
|
||||
_decimalSeparator,
|
||||
);
|
||||
} else {
|
||||
|
@ -853,7 +853,7 @@
|
||||
"@are_you_sure": {
|
||||
"description": "Are you sure?"
|
||||
},
|
||||
"knowledge_panel_text_source": "تعرف أكثر من خلال {source_name}",
|
||||
"knowledge_panel_text_source": "تعرف أكثر من خلال {sourceName}",
|
||||
"@knowledge_panel_text_source": {
|
||||
"description": "Source field within a text knowledge panel.",
|
||||
"placeholders": {
|
||||
|
Reference in New Issue
Block a user