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