Merge branch 'master' of github.com:imtoori/CountryCodePicker
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:country_code_picker/country_code.dart';
|
|||||||
import 'package:country_code_picker/country_codes.dart';
|
import 'package:country_code_picker/country_codes.dart';
|
||||||
import 'package:country_code_picker/selection_dialog.dart';
|
import 'package:country_code_picker/selection_dialog.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
||||||
|
|
||||||
export 'country_code.dart';
|
export 'country_code.dart';
|
||||||
|
|
||||||
@@ -226,9 +227,11 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showCountryCodePickerDialog() {
|
void showCountryCodePickerDialog() {
|
||||||
showDialog(
|
showMaterialModalBottomSheet(
|
||||||
|
barrierColor: Colors.grey.withOpacity(0.5),
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => SelectionDialog(
|
builder: (context, scrollController) => SelectionDialog(
|
||||||
elements,
|
elements,
|
||||||
favoriteElements,
|
favoriteElements,
|
||||||
showCountryOnly: widget.showCountryOnly,
|
showCountryOnly: widget.showCountryOnly,
|
||||||
|
|||||||
@@ -44,70 +44,90 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
List<CountryCode> filteredElements;
|
List<CountryCode> filteredElements;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => SimpleDialog(
|
Widget build(BuildContext context) => Padding(
|
||||||
titlePadding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
title: Column(
|
child: Container(
|
||||||
mainAxisSize: MainAxisSize.min,
|
width: widget.size?.width ?? MediaQuery.of(context).size.width,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
height:
|
||||||
children: <Widget>[
|
widget.size?.height ?? MediaQuery.of(context).size.height * 0.85,
|
||||||
IconButton(
|
decoration: BoxDecoration(
|
||||||
padding: const EdgeInsets.all(0),
|
color: Colors.white,
|
||||||
iconSize: 20,
|
borderRadius: BorderRadius.all(Radius.circular(25.0)),
|
||||||
icon: Icon(
|
boxShadow: [
|
||||||
Icons.close,
|
BoxShadow(
|
||||||
|
color: Colors.grey.withOpacity(1),
|
||||||
|
spreadRadius: 5,
|
||||||
|
blurRadius: 7,
|
||||||
|
offset: Offset(0, 3), // changes position of shadow
|
||||||
),
|
),
|
||||||
onPressed: () => Navigator.pop(context),
|
],
|
||||||
),
|
),
|
||||||
if (!widget.hideSearch)
|
child: Column(
|
||||||
Padding(
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
children: [
|
||||||
child: TextField(
|
Column(
|
||||||
style: widget.searchStyle,
|
mainAxisSize: MainAxisSize.min,
|
||||||
decoration: widget.searchDecoration,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
onChanged: _filterElements,
|
children: <Widget>[
|
||||||
|
IconButton(
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
iconSize: 20,
|
||||||
|
icon: Icon(
|
||||||
|
Icons.close,
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
if (!widget.hideSearch)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
child: TextField(
|
||||||
|
style: widget.searchStyle,
|
||||||
|
decoration: widget.searchDecoration,
|
||||||
|
onChanged: _filterElements,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
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
|
||||||
|
? const DecoratedBox(decoration: BoxDecoration())
|
||||||
|
: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
...widget.favoriteElements.map(
|
||||||
|
(f) => SimpleDialogOption(
|
||||||
|
child: _buildOption(f),
|
||||||
|
onPressed: () {
|
||||||
|
_selectItem(f);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (filteredElements.isEmpty)
|
||||||
|
_buildEmptySearchWidget(context)
|
||||||
|
else
|
||||||
|
...filteredElements.map(
|
||||||
|
(e) => SimpleDialogOption(
|
||||||
|
key: Key(e.toLongString()),
|
||||||
|
child: _buildOption(e),
|
||||||
|
onPressed: () {
|
||||||
|
_selectItem(e);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
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
|
|
||||||
? const DecoratedBox(decoration: BoxDecoration())
|
|
||||||
: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
...widget.favoriteElements.map(
|
|
||||||
(f) => SimpleDialogOption(
|
|
||||||
child: _buildOption(f),
|
|
||||||
onPressed: () {
|
|
||||||
_selectItem(f);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Divider(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (filteredElements.isEmpty)
|
|
||||||
_buildEmptySearchWidget(context)
|
|
||||||
else
|
|
||||||
...filteredElements.map(
|
|
||||||
(e) => SimpleDialogOption(
|
|
||||||
key: Key(e.toLongString()),
|
|
||||||
child: _buildOption(e),
|
|
||||||
onPressed: () {
|
|
||||||
_selectItem(e);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _buildOption(CountryCode e) {
|
Widget _buildOption(CountryCode e) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ environment:
|
|||||||
sdk: ">=2.2.2 <3.0.0"
|
sdk: ">=2.2.2 <3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
|
modal_bottom_sheet: ^0.2.0+1
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user