mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[web] autofill hints (flutter/engine#17887)
* adding autofill hints map from flutter values to the browser values, which will be used by the web engine: * removing unused reverse map * addressing reviewer comments * changing licences
This commit is contained in:
parent
6a3dc7a98e
commit
aee119fb36
@ -494,6 +494,7 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/text/ruler.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/text/unicode_range.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/text/word_break_properties.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/text/word_breaker.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/text_editing/autofill_hint.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/text_editing/input_type.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/text_editing/text_editing.dart
|
||||
FILE: ../../../flutter/lib/web_ui/lib/src/engine/util.dart
|
||||
|
||||
@ -115,6 +115,7 @@ part 'engine/text/ruler.dart';
|
||||
part 'engine/text/unicode_range.dart';
|
||||
part 'engine/text/word_break_properties.dart';
|
||||
part 'engine/text/word_breaker.dart';
|
||||
part 'engine/text_editing/autofill_hint.dart';
|
||||
part 'engine/text_editing/input_type.dart';
|
||||
part 'engine/text_editing/text_editing.dart';
|
||||
part 'engine/util.dart';
|
||||
|
||||
@ -0,0 +1,87 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.6
|
||||
part of engine;
|
||||
|
||||
/// Maps AutofillHints from the framework to the autofill hints that is used for
|
||||
/// browsers.
|
||||
/// See: https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/services/autofill.dart
|
||||
/// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
|
||||
class BrowserAutofillHints {
|
||||
static final BrowserAutofillHints _singletonInstance =
|
||||
BrowserAutofillHints._();
|
||||
|
||||
/// The [BrowserAutofillHints] singleton.
|
||||
static BrowserAutofillHints get instance => _singletonInstance;
|
||||
|
||||
final Map<String, String> _flutterToEngineMap;
|
||||
|
||||
BrowserAutofillHints._()
|
||||
: _flutterToEngineMap = {
|
||||
'birthday': 'bday',
|
||||
'birthdayDay': 'bday-day',
|
||||
'birthdayMonth': 'bday-month',
|
||||
'birthdayYear': 'bday-year',
|
||||
'countryCode': 'country',
|
||||
'countryName': 'country-name',
|
||||
'creditCardExpirationDate': 'cc-exp',
|
||||
'creditCardExpirationMonth': 'cc-exp-month',
|
||||
'creditCardExpirationYear': 'cc-exp-year',
|
||||
'creditCardFamilyName': 'cc-family-name',
|
||||
'creditCardGivenName': 'cc-given-name',
|
||||
'creditCardMiddleName': 'cc-additional-name',
|
||||
'creditCardName': 'cc-name',
|
||||
'creditCardNumber': 'cc-number',
|
||||
'creditCardSecurityCode': 'cc-csc',
|
||||
'creditCardType': 'cc-type',
|
||||
'email': 'email',
|
||||
'familyName': 'familyName',
|
||||
'fullStreetAddress': 'street-address',
|
||||
'gender': 'sex',
|
||||
'givenName': 'given-name',
|
||||
'impp': 'impp',
|
||||
'jobTitle': 'organization-title',
|
||||
'language': 'language',
|
||||
'middleName': 'middleName',
|
||||
'name': 'name',
|
||||
'namePrefix': 'honorific-prefix',
|
||||
'nameSuffix': 'honorific-suffix',
|
||||
'newPassword': 'new-password',
|
||||
'nickname': 'nickname',
|
||||
'oneTimeCode': 'one-time-code',
|
||||
'organizationName': 'organization',
|
||||
'password': 'current-password',
|
||||
'photo': 'photo',
|
||||
'postalCode': 'postal-code',
|
||||
'streetAddressLevel1': 'address-level1',
|
||||
'streetAddressLevel2': 'address-level2',
|
||||
'streetAddressLevel3': 'address-level3',
|
||||
'streetAddressLevel4': 'address-level4',
|
||||
'streetAddressLine1': 'address-line1',
|
||||
'streetAddressLine2': 'address-line2',
|
||||
'streetAddressLine3': 'address-line3',
|
||||
'telephoneNumber': 'tel',
|
||||
'telephoneNumberAreaCode': 'tel-area-code',
|
||||
'telephoneNumberCountryCode': 'tel-country-code',
|
||||
'telephoneNumberExtension': 'tel-extension',
|
||||
'telephoneNumberLocal': 'tel-local',
|
||||
'telephoneNumberLocalPrefix': 'tel-local-prefix',
|
||||
'telephoneNumberLocalSuffix': 'tel-local-suffix',
|
||||
'telephoneNumberNational': 'tel-national',
|
||||
'transactionAmount': 'transaction-amount',
|
||||
'transactionCurrency': 'transaction-currency',
|
||||
'url': 'url',
|
||||
'username': 'username',
|
||||
};
|
||||
|
||||
/// Converts the Flutter AutofillHint to the autofill hint value used by the
|
||||
/// browsers.
|
||||
/// See: https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/services/autofill.dart
|
||||
/// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
|
||||
String flutterToEngine(String flutterAutofillHint) {
|
||||
// Use the hints as it is.
|
||||
return _flutterToEngineMap[flutterAutofillHint] ?? flutterAutofillHint;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user