Skip to content

Commit 6e7137e

Browse files
authored
Merge branch 'flet-dev:main' into geolocator
2 parents b6b9b75 + fb7ee1a commit 6e7137e

File tree

12 files changed

+429
-41
lines changed

12 files changed

+429
-41
lines changed

.appveyor.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ skip_commits:
1111
environment:
1212
python_stack: python 3.10
1313
GITHUB_TOKEN:
14-
secure: doX0dwjWhBmT56aJqR9NCbtMFJpDpdYxPCIB4vQoHfSR+nTa+pLCo6Yv5qWpD/90
15-
DOCKER_REGISTRY_USER:
16-
secure: NJVK0u9M6ZhmQKUeR6Gnxg==
17-
DOCKER_REGISTRY_PASS:
18-
secure: V9nRzVDlIGS0a+dhkC2/vw==
14+
secure: 9SKIwc3VSfYJ5IChvNR74hQprJ0DRmcV9pPX+8KyE6IXIdfMsX6ikeUmMhJGRu3ztkZaF45jmU7Xn/6tauXQXhDBxK1N8kFHFSAnq6LjUXyhS0TZKX/H+jDozBeVbCXp
1915

2016
matrix:
2117
- job_name: Build Flet package for Flutter
@@ -84,9 +80,6 @@ environment:
8480

8581
matrix:
8682
fast_finish: true
87-
allow_failures:
88-
- job_name: Build Flet for iOS
89-
- job_name: Build Flet Studio for iOS
9083

9184
stack: $python_stack
9285

@@ -131,6 +124,8 @@ for:
131124
dart pub publish --force || exit 1
132125
cd $APPVEYOR_BUILD_FOLDER
133126
127+
sleep 10
128+
134129
cd packages/flet_audio
135130
dart pub publish --force || exit 1
136131
cd $APPVEYOR_BUILD_FOLDER
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import 'package:flet/src/utils/autofill.dart';
2+
import 'package:flutter/material.dart';
3+
4+
import '../models/control.dart';
5+
import 'create_control.dart';
6+
import 'error.dart';
7+
8+
class AutofillGroupControl extends StatelessWidget {
9+
final Control? parent;
10+
final Control control;
11+
final List<Control> children;
12+
final bool parentDisabled;
13+
final bool? parentAdaptive;
14+
15+
const AutofillGroupControl(
16+
{super.key,
17+
required this.parent,
18+
required this.control,
19+
required this.children,
20+
required this.parentDisabled,
21+
this.parentAdaptive});
22+
23+
@override
24+
Widget build(BuildContext context) {
25+
debugPrint("AutofillGroup build: ${control.id}");
26+
27+
var contentCtrls =
28+
children.where((c) => c.name == "content" && c.isVisible);
29+
bool disabled = control.isDisabled || parentDisabled;
30+
31+
if (contentCtrls.isEmpty) {
32+
return const ErrorControl("AutofillGroup control has no content.");
33+
}
34+
35+
return AutofillGroup(
36+
onDisposeAction: parseAutofillContextAction(
37+
control.attrString("disposeAction"), AutofillContextAction.commit)!,
38+
child: createControl(control, contentCtrls.first.id, disabled,
39+
parentAdaptive: parentAdaptive));
40+
}
41+
}

packages/flet/lib/src/controls/create_control.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import '../utils/transforms.dart';
1717
import 'alert_dialog.dart';
1818
import 'animated_switcher.dart';
1919
import 'auto_complete.dart';
20+
import 'autofill_group.dart';
2021
import 'badge.dart';
2122
import 'banner.dart';
2223
import 'barchart.dart';
@@ -803,6 +804,14 @@ Widget createWidget(
803804
parentDisabled: parentDisabled,
804805
parentAdaptive: parentAdaptive,
805806
backend: backend);
807+
case "autofillgroup":
808+
return AutofillGroupControl(
809+
key: key,
810+
parent: parent,
811+
control: controlView.control,
812+
children: controlView.children,
813+
parentDisabled: parentDisabled,
814+
parentAdaptive: parentAdaptive);
806815
case "cupertinoradio":
807816
return CupertinoRadioControl(
808817
key: key,

packages/flet/lib/src/controls/expansion_panel.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class _ExpansionPanelListControlState extends State<ExpansionPanelListControl>
8181
var isExpanded = panelView.control.attrBool("expanded", false)!;
8282
var canTapHeader =
8383
panelView.control.attrBool("canTapHeader", false)!;
84-
var bgColor = widget.control.attrColor("bgColor", context);
84+
var bgColor = panelView.control.attrColor("bgColor", context);
8585

8686
return ExpansionPanel(
8787
backgroundColor: bgColor,

packages/flet/lib/src/controls/radio_group.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ class RadioGroupControl extends StatelessWidget {
2828
bool disabled = control.isDisabled || parentDisabled;
2929

3030
if (contentCtrls.isEmpty) {
31-
return const ErrorControl(
32-
"RadioGroup control does not have any content.");
31+
return const ErrorControl("RadioGroup control has no content.");
3332
}
3433

3534
return createControl(control, contentCtrls.first.id, disabled,

packages/flet/lib/src/controls/textfield.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
33

44
import '../flet_control_backend.dart';
55
import '../models/control.dart';
6+
import '../utils/autofill.dart';
67
import '../utils/borders.dart';
78
import '../utils/form_field.dart';
89
import '../utils/text.dart';
@@ -264,6 +265,7 @@ class _TextFieldControlState extends State<TextFieldControl>
264265
obscureText: password && !_revealPassword,
265266
controller: _controller,
266267
focusNode: focusNode,
268+
autofillHints: parseAutofillHints(widget.control, "autofillHints"),
267269
onChanged: (String value) {
268270
//debugPrint(value);
269271
_value = value;
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
import 'dart:convert';
2+
3+
import 'package:flutter/material.dart';
4+
5+
import '../models/control.dart';
6+
7+
List<String>? parseAutofillHints(Control control, String propName) {
8+
var v = control.attrString(propName, null);
9+
if (v == null) {
10+
return null;
11+
}
12+
13+
final j1 = json.decode(v);
14+
return autofillHintsFromJson(j1);
15+
}
16+
17+
List<String> autofillHintsFromJson(dynamic json) {
18+
List<String> hints = [];
19+
if (json is List) {
20+
hints = json
21+
.map((e) => autofillHintFromString(e.toString()))
22+
.whereType<String>()
23+
.toList();
24+
} else if (json is String) {
25+
hints = [autofillHintFromString(json)].whereType<String>().toList();
26+
}
27+
28+
return hints;
29+
}
30+
31+
String? autofillHintFromString(String? hint, [String? defaultAutoFillHint]) {
32+
switch (hint?.toLowerCase()) {
33+
case 'addresscity':
34+
return AutofillHints.addressCity;
35+
case 'addresscityandstate':
36+
return AutofillHints.addressCityAndState;
37+
case 'addressstate':
38+
return AutofillHints.addressState;
39+
case 'birthday':
40+
return AutofillHints.birthday;
41+
case 'birthdayday':
42+
return AutofillHints.birthdayDay;
43+
case 'birthdayMonth':
44+
return AutofillHints.birthdayMonth;
45+
case 'birthdayyear':
46+
return AutofillHints.birthdayYear;
47+
case 'countrycode':
48+
return AutofillHints.countryCode;
49+
case 'countryname':
50+
return AutofillHints.countryName;
51+
case 'creditcardexpirationdate':
52+
return AutofillHints.creditCardExpirationDate;
53+
case 'creditcardexpirationday':
54+
return AutofillHints.creditCardExpirationDay;
55+
case 'creditcardexpirationmonth':
56+
return AutofillHints.creditCardExpirationMonth;
57+
case 'creditcardexpirationyear':
58+
return AutofillHints.creditCardExpirationYear;
59+
case 'creditcardfamilyname':
60+
return AutofillHints.creditCardFamilyName;
61+
case 'creditcardgivenname':
62+
return AutofillHints.creditCardGivenName;
63+
case 'creditcardmiddlename':
64+
return AutofillHints.creditCardMiddleName;
65+
case 'creditcardname':
66+
return AutofillHints.creditCardName;
67+
case 'creditcardnumber':
68+
return AutofillHints.creditCardNumber;
69+
case 'creditcardsecuritycode':
70+
return AutofillHints.creditCardSecurityCode;
71+
case 'creditcardtype':
72+
return AutofillHints.creditCardType;
73+
case 'email':
74+
return AutofillHints.email;
75+
case 'familyname':
76+
return AutofillHints.familyName;
77+
case 'fullstreetaddress':
78+
return AutofillHints.fullStreetAddress;
79+
case 'gender':
80+
return AutofillHints.gender;
81+
case 'givenname':
82+
return AutofillHints.givenName;
83+
case 'impp':
84+
return AutofillHints.impp;
85+
case 'jobtitle':
86+
return AutofillHints.jobTitle;
87+
case 'language':
88+
return AutofillHints.language;
89+
case 'location':
90+
return AutofillHints.location;
91+
case 'middleinitial':
92+
return AutofillHints.middleInitial;
93+
case 'middlename':
94+
return AutofillHints.middleName;
95+
case 'name':
96+
return AutofillHints.name;
97+
case 'nameprefix':
98+
return AutofillHints.namePrefix;
99+
case 'namesuffix':
100+
return AutofillHints.nameSuffix;
101+
case 'newpassword':
102+
return AutofillHints.newPassword;
103+
case 'newusername':
104+
return AutofillHints.newUsername;
105+
case 'nickname':
106+
return AutofillHints.nickname;
107+
case 'onetimecode':
108+
return AutofillHints.oneTimeCode;
109+
case 'organizationname':
110+
return AutofillHints.organizationName;
111+
case 'password':
112+
return AutofillHints.password;
113+
case 'photo':
114+
return AutofillHints.photo;
115+
case 'postaladdress':
116+
return AutofillHints.postalAddress;
117+
case 'postaladdressextended':
118+
return AutofillHints.postalAddressExtended;
119+
case 'postaladdressextendedpostalcode':
120+
return AutofillHints.postalAddressExtendedPostalCode;
121+
case 'postalcode':
122+
return AutofillHints.postalCode;
123+
case 'streetaddresslevel1':
124+
return AutofillHints.streetAddressLevel1;
125+
case 'streetaddresslevel2':
126+
return AutofillHints.streetAddressLevel2;
127+
case 'streetaddresslevel3':
128+
return AutofillHints.streetAddressLevel3;
129+
case 'streetaddresslevel4':
130+
return AutofillHints.streetAddressLevel4;
131+
case 'streetaddressline1':
132+
return AutofillHints.streetAddressLine1;
133+
case 'streetaddressline2':
134+
return AutofillHints.streetAddressLine2;
135+
case 'streetaddressline3':
136+
return AutofillHints.streetAddressLine3;
137+
case 'sublocality':
138+
return AutofillHints.sublocality;
139+
case 'telephonenumber':
140+
return AutofillHints.telephoneNumber;
141+
case 'telephonenumberareacode':
142+
return AutofillHints.telephoneNumberAreaCode;
143+
case 'telephonenumbercountrycode':
144+
return AutofillHints.telephoneNumberCountryCode;
145+
case 'telephonenumberdevice':
146+
return AutofillHints.telephoneNumberDevice;
147+
case 'telephonenumberextension':
148+
return AutofillHints.telephoneNumberExtension;
149+
case 'telephonenumberlocal':
150+
return AutofillHints.telephoneNumberLocal;
151+
case 'telephonenumberlocalprefix':
152+
return AutofillHints.telephoneNumberLocalPrefix;
153+
case 'telephonenumberlocalsuffix':
154+
return AutofillHints.telephoneNumberLocalSuffix;
155+
case 'telephonenumbernational':
156+
return AutofillHints.telephoneNumberNational;
157+
case 'transactionamount':
158+
return AutofillHints.transactionAmount;
159+
case 'transactioncurrency':
160+
return AutofillHints.transactionCurrency;
161+
case 'url':
162+
return AutofillHints.url;
163+
case 'username':
164+
return AutofillHints.username;
165+
default:
166+
return defaultAutoFillHint;
167+
}
168+
}
169+
170+
AutofillContextAction? parseAutofillContextAction(String? action,
171+
[AutofillContextAction? defaultAction]) {
172+
switch (action?.toLowerCase()) {
173+
case 'commit':
174+
return AutofillContextAction.commit;
175+
case 'cancel':
176+
return AutofillContextAction.cancel;
177+
default:
178+
return defaultAction;
179+
}
180+
}

0 commit comments

Comments
 (0)