Merge branch 'master' into hotfix/search-localizations
This commit is contained in:
@@ -11,11 +11,6 @@ class MyApp extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new MaterialApp(
|
||||
|
||||
@@ -22,6 +22,9 @@ class CountryCodePicker extends StatefulWidget {
|
||||
final bool enabled;
|
||||
final TextOverflow textOverflow;
|
||||
|
||||
/// the size of the selection dialog
|
||||
final Size dialogSize;
|
||||
|
||||
/// used to customize the country list
|
||||
final List<String> customList;
|
||||
|
||||
@@ -74,7 +77,9 @@ class CountryCodePicker extends StatefulWidget {
|
||||
this.textOverflow = TextOverflow.ellipsis,
|
||||
this.comparator,
|
||||
this.customList,
|
||||
});
|
||||
this.dialogSize,
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -100,29 +105,29 @@ class CountryCodePicker extends StatefulWidget {
|
||||
elements = elements.where((c) => countryFilter.contains(c.code)).toList();
|
||||
}
|
||||
|
||||
return _CountryCodePickerState(elements);
|
||||
return CountryCodePickerState(elements);
|
||||
}
|
||||
}
|
||||
|
||||
class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
class CountryCodePickerState extends State<CountryCodePicker> {
|
||||
CountryCode selectedItem;
|
||||
List<CountryCode> elements = [];
|
||||
List<CountryCode> favoriteElements = [];
|
||||
|
||||
_CountryCodePickerState(this.elements);
|
||||
CountryCodePickerState(this.elements);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget _widget;
|
||||
if (widget.builder != null)
|
||||
_widget = InkWell(
|
||||
onTap: _showSelectionDialog,
|
||||
child: widget.builder(selectedItem),
|
||||
onTap: showCountryCodePickerDialog,
|
||||
child: widget.builder(selectedItem.localize(context)),
|
||||
);
|
||||
else {
|
||||
_widget = FlatButton(
|
||||
padding: widget.padding,
|
||||
onPressed: widget.enabled ? _showSelectionDialog : null,
|
||||
onPressed: widget.enabled ? showCountryCodePickerDialog : null,
|
||||
child: Flex(
|
||||
direction: Axis.horizontal,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -202,7 +207,7 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void _showSelectionDialog() {
|
||||
void showCountryCodePickerDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => SelectionDialog(
|
||||
@@ -214,6 +219,7 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
searchStyle: widget.searchStyle,
|
||||
showFlag: widget.showFlag || (widget.showFlagDialog == true),
|
||||
flagWidth: widget.flagWidth,
|
||||
size: widget.dialogSize,
|
||||
),
|
||||
).then((e) {
|
||||
if (e != null) {
|
||||
|
||||
@@ -10,6 +10,7 @@ class SelectionDialog extends StatefulWidget {
|
||||
final WidgetBuilder emptySearchBuilder;
|
||||
final bool showFlag;
|
||||
final double flagWidth;
|
||||
final Size size;
|
||||
|
||||
/// elements passed as favorite
|
||||
final List<CountryCode> favoriteElements;
|
||||
@@ -24,6 +25,7 @@ class SelectionDialog extends StatefulWidget {
|
||||
this.searchStyle,
|
||||
this.showFlag,
|
||||
this.flagWidth = 32,
|
||||
this.size,
|
||||
}) : assert(searchDecoration != null, 'searchDecoration must not be null!'),
|
||||
this.searchDecoration =
|
||||
searchDecoration.copyWith(prefixIcon: Icon(Icons.search)),
|
||||
@@ -64,8 +66,9 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
||||
),
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height * 0.7,
|
||||
width: widget.size?.width ?? MediaQuery.of(context).size.width,
|
||||
height:
|
||||
widget.size?.height ?? MediaQuery.of(context).size.height * 0.7,
|
||||
child: ListView(
|
||||
children: [
|
||||
widget.favoriteElements.isEmpty
|
||||
|
||||
Reference in New Issue
Block a user