From 2505585404453aabacdbc57f53619f5febc55c81 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Sat, 5 May 2018 11:33:03 +0200 Subject: [PATCH] Add textStyle and padding as widget parameters --- CHANGELOG.md | 6 +++++- README.md | 2 +- lib/celement.dart | 8 ++++++-- lib/country_code_picker.dart | 21 +++++++++++++++++---- lib/selection_dialog.dart | 5 ++++- pubspec.yaml | 2 +- 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db3d050..8531144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,4 +28,8 @@ Now onChanged has a full CElement as argument and not only a string. (issue #4) ## 0.2.1 -Added some documentation \ No newline at end of file +Added some documentation + +## 0.2.2 + +Added textStyle and padding as widget parameters \ No newline at end of file diff --git a/README.md b/README.md index 74612f9..ac3c2c9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Pub](https://img.shields.io/badge/Pub-0.2.1-orange.svg)](https://pub.dartlang.org/packages/country_code_picker) +[![Pub](https://img.shields.io/badge/Pub-0.2.2-orange.svg)](https://pub.dartlang.org/packages/country_code_picker) # country_code_picker diff --git a/lib/celement.dart b/lib/celement.dart index eca9bae..92ab3f5 100644 --- a/lib/celement.dart +++ b/lib/celement.dart @@ -18,10 +18,14 @@ class CElement { @override String toString() { - return defaultTargetPlatform == TargetPlatform.android ? "$flag $dialCode" : dialCode; + return defaultTargetPlatform == TargetPlatform.android + ? "$flag $dialCode" + : dialCode; } String toLongString() { - return defaultTargetPlatform == TargetPlatform.android ? "$flag $dialCode $name" : "$dialCode $name"; + return defaultTargetPlatform == TargetPlatform.android + ? "$flag $dialCode $name" + : "$dialCode $name"; } } diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index fc16dec..6dd6b60 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -5,12 +5,21 @@ import 'package:country_code_picker/country_codes.dart'; import 'package:country_code_picker/selection_dialog.dart'; import 'package:flutter/material.dart'; +export 'celement.dart'; + class CountryCodePicker extends StatefulWidget { final Function(CElement) onChanged; final String initialSelection; final List favorite; + final TextStyle textStyle; + final EdgeInsetsGeometry padding; - CountryCodePicker({this.onChanged, this.initialSelection, this.favorite}); + CountryCodePicker( + {this.onChanged, + this.initialSelection, + this.favorite, + this.textStyle, + this.padding}); @override State createState() { @@ -36,9 +45,13 @@ class _CountryCodePickerState extends State { _CountryCodePickerState(this.elements); @override - Widget build(BuildContext context) => new GestureDetector( - child: new Text("${selectedItem.toString()}"), - onTap: _showSelectionDialog, + Widget build(BuildContext context) => new FlatButton( + child: new Text( + "${selectedItem.toString()}", + style: widget.textStyle ?? Theme.of(context).textTheme.button, + ), + padding: widget.padding, + onPressed: _showSelectionDialog, ); @override diff --git a/lib/selection_dialog.dart b/lib/selection_dialog.dart index 3227f8c..8917d1d 100644 --- a/lib/selection_dialog.dart +++ b/lib/selection_dialog.dart @@ -60,7 +60,10 @@ class _SelectionDialogState extends State { s = s.toUpperCase(); setState(() { showedElements = widget.elements - .where((e) => e.code.contains(s) || e.dialCode.contains(s) || e.name.toUpperCase().contains(s)) + .where((e) => + e.code.contains(s) || + e.dialCode.contains(s) || + e.name.toUpperCase().contains(s)) .toList(); }); } diff --git a/pubspec.yaml b/pubspec.yaml index 195e9b4..0be31ab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: country_code_picker description: A flutter package for showing a country code selector. -version: 0.2.1 +version: 0.2.2 author: Salvatore-Giordano homepage: https://github.com/Salvatore-Giordano/CountryCodePicker