From 8898c017ccb6f54a9360b0b34afa089f4d396c0f Mon Sep 17 00:00:00 2001 From: kareem Date: Sun, 3 Dec 2023 00:22:00 +0200 Subject: [PATCH 01/16] first commit --- lib/country_code_picker.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index d962ff02..4af1a6f4 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -295,7 +295,7 @@ class CountryCodePickerState extends State { } void showCountryCodePickerDialog() async { - final item = await showDialog( + final item = await showModalBottomSheet( barrierColor: widget.barrierColor ?? Colors.grey.withOpacity(0.5), context: context, builder: (context) => Center( From d662af06d36b05e7a2d7e4ab690de7ef35d4866e Mon Sep 17 00:00:00 2001 From: kareem Date: Sun, 3 Dec 2023 01:49:03 +0200 Subject: [PATCH 02/16] second commit --- example/ios/Runner.xcodeproj/project.pbxproj | 3 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- example/lib/main.dart | 8 +- example/pubspec.yaml | 2 +- ios/Flutter/Generated.xcconfig | 4 +- ios/Flutter/flutter_export_environment.sh | 4 +- lib/country_code_picker.dart | 32 +++++- lib/src/selection_dialog.dart | 106 ++++++++++++------ 8 files changed, 110 insertions(+), 51 deletions(-) diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 0ff20a05..d773213b 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -127,7 +127,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -176,6 +176,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a3..a6b826db 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ runApp(const MyApp()); class MyApp extends StatefulWidget { - const MyApp({Key key}) : super(key: key); + const MyApp({Key? key}) : super(key: key); @override MyAppState createState() => MyAppState(); @@ -107,10 +107,10 @@ class MyAppState extends State { favorite: const ['+39', 'FR'], countryFilter: const ['IT', 'FR'], showFlagDialog: false, - comparator: (a, b) => b.name.compareTo(a.name), + comparator: (a, b) => b.name!.compareTo(a.name!), //Get the country information relevant to the initial selection onInit: (code) => debugPrint( - "on init ${code.name} ${code.dialCode} ${code.name}"), + "on init ${code?.name} ${code?.dialCode} ${code?.name}"), ), CountryCodePicker( onChanged: print, @@ -123,7 +123,7 @@ class MyAppState extends State { borderRadius: BorderRadius.circular(7), ), ), - const SizedBox( + SizedBox( width: 400, height: 60, child: CountryCodePicker( diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 1f4d287e..ae30eab7 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -11,7 +11,7 @@ version: 1.0.0+1 publish_to: none environment: - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: diff --git a/ios/Flutter/Generated.xcconfig b/ios/Flutter/Generated.xcconfig index 015ea0e5..053db87f 100644 --- a/ios/Flutter/Generated.xcconfig +++ b/ios/Flutter/Generated.xcconfig @@ -1,6 +1,6 @@ // This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/Users/bezzo/flutter -FLUTTER_APPLICATION_PATH=/Users/bezzo/Desktop/CountryCodePicker +FLUTTER_ROOT=/Users/kareem/Developer/flutter +FLUTTER_APPLICATION_PATH=/Users/kareem/Documents/KareemMacFolders/Flutter_Active_Projects/CountryCodePicker COCOAPODS_PARALLEL_CODE_SIGN=true FLUTTER_TARGET=lib/main.dart FLUTTER_BUILD_DIR=build diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh index 06333d0c..da94cffb 100755 --- a/ios/Flutter/flutter_export_environment.sh +++ b/ios/Flutter/flutter_export_environment.sh @@ -1,7 +1,7 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/bezzo/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/bezzo/Desktop/CountryCodePicker" +export "FLUTTER_ROOT=/Users/kareem/Developer/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/kareem/Documents/KareemMacFolders/Flutter_Active_Projects/CountryCodePicker" export "COCOAPODS_PARALLEL_CODE_SIGN=true" export "FLUTTER_TARGET=lib/main.dart" export "FLUTTER_BUILD_DIR=build" diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 4af1a6f4..62df828f 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -91,8 +91,10 @@ class CountryCodePicker extends StatefulWidget { final EdgeInsetsGeometry dialogItemPadding; final EdgeInsetsGeometry searchPadding; + String txtFieldHintTxt; - const CountryCodePicker({ + CountryCodePicker({ + this.txtFieldHintTxt="search", this.onChanged, this.onInit, this.initialSelection, @@ -295,12 +297,25 @@ class CountryCodePickerState extends State { } void showCountryCodePickerDialog() async { - final item = await showModalBottomSheet( - barrierColor: widget.barrierColor ?? Colors.grey.withOpacity(0.5), + final item = await + + + showModalBottomSheet( context: context, - builder: (context) => Center( - child: Dialog( + isScrollControlled: true, + backgroundColor: Colors.transparent, + builder: (context) => Container( + height: MediaQuery.of(context).size.height * 0.75, + decoration: new BoxDecoration( + color: Colors.white, + borderRadius: new BorderRadius.only( + topLeft: const Radius.circular(25.0), + topRight: const Radius.circular(25.0), + ), + ), + child: Center( child: SelectionDialog( + widget.txtFieldHintTxt, elements, favoriteElements, showCountryOnly: widget.showCountryOnly, @@ -325,6 +340,13 @@ class CountryCodePickerState extends State { ), ); + + + + + + + if (item != null) { setState(() { selectedItem = item; diff --git a/lib/src/selection_dialog.dart b/lib/src/selection_dialog.dart index 6f932fee..ffd4dd11 100644 --- a/lib/src/selection_dialog.dart +++ b/lib/src/selection_dialog.dart @@ -32,8 +32,10 @@ class SelectionDialog extends StatefulWidget { final EdgeInsetsGeometry dialogItemPadding; final EdgeInsetsGeometry searchPadding; + String? txtFieldHintTxt="search"; SelectionDialog( + this.txtFieldHintTxt, this.elements, this.favoriteElements, { Key? key, @@ -103,48 +105,82 @@ class _SelectionDialogState extends State { Padding( padding: widget.searchPadding, child: TextField( + + + + decoration: InputDecoration( + + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: Colors.green.withOpacity(0.5), // Change the border color as needed + width: 2.0, + ), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: Colors.green.withOpacity(0.5), // Change the border color as needed + width: 1.0, + ), + ), + + + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: Colors.green.withOpacity(0.5), // Change the border color as needed + width: 1.0, // Adjust the border width + ), + ), + hintText: widget.txtFieldHintTxt, + suffixIcon: Icon(Icons.search), + ), style: widget.searchStyle, - decoration: widget.searchDecoration, + //decoration: widget.searchDecoration, onChanged: _filterElements, ), ), Expanded( - child: ListView( - children: [ - widget.favoriteElements.isEmpty - ? const DecoratedBox(decoration: BoxDecoration()) - : Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ...widget.favoriteElements.map( - (f) => InkWell( - onTap: () { - _selectItem(f); - }, - child: Padding( - padding: widget.dialogItemPadding, - child: _buildOption(f), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: ListView( + children: [ + widget.favoriteElements.isEmpty + ? const DecoratedBox(decoration: BoxDecoration()) + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ...widget.favoriteElements.map( + (f) => InkWell( + onTap: () { + _selectItem(f); + }, + child: Padding( + padding: widget.dialogItemPadding, + child: _buildOption(f), + ) ) - ) - ), - const Divider(), - ], - ), - if (filteredElements.isEmpty) - _buildEmptySearchWidget(context) - else - ...filteredElements.map( - (e) => InkWell( - onTap: () { - _selectItem(e); - }, - child: Padding( - padding: widget.dialogItemPadding, - child: _buildOption(e), + ), + const Divider(), + ], + ), + if (filteredElements.isEmpty) + _buildEmptySearchWidget(context) + else + ...filteredElements.map( + (e) => InkWell( + onTap: () { + _selectItem(e); + }, + child: Padding( + padding: widget.dialogItemPadding, + child: _buildOption(e), + ) ) - ) - ), - ], + ), + ], + ), ), ), ], From f6a6272ba1e20eb09d1352ab6db813037298e767 Mon Sep 17 00:00:00 2001 From: kareem Date: Sun, 3 Dec 2023 12:55:11 +0200 Subject: [PATCH 03/16] search feature only common --- example/lib/main.dart | 53 ++--------------------------------- lib/country_code_picker.dart | 29 +++++++++++++++++-- lib/src/selection_dialog.dart | 23 ++++++++------- 3 files changed, 41 insertions(+), 64 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 8517ff08..512c3913 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -101,66 +101,19 @@ class MyAppState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ CountryCodePicker( + showFlag: true, onChanged: print, // Initial selection and favorite can be one of code ('IT') OR dial_code('+39') initialSelection: 'IT', favorite: const ['+39', 'FR'], countryFilter: const ['IT', 'FR'], - showFlagDialog: false, + showFlagDialog: true, comparator: (a, b) => b.name!.compareTo(a.name!), //Get the country information relevant to the initial selection onInit: (code) => debugPrint( "on init ${code?.name} ${code?.dialCode} ${code?.name}"), ), - CountryCodePicker( - onChanged: print, - // Initial selection and favorite can be one of code ('IT') OR dial_code('+39') - initialSelection: 'IT', - favorite: const ['+39', 'FR'], - countryFilter: const ['IT', 'FR'], - // flag can be styled with BoxDecoration's `borderRadius` and `shape` fields - flagDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(7), - ), - ), - SizedBox( - width: 400, - height: 60, - child: CountryCodePicker( - onChanged: print, - hideMainText: true, - showFlagMain: true, - showFlag: false, - initialSelection: 'TF', - hideSearch: true, - showCountryOnly: true, - showOnlyCountryWhenClosed: true, - alignLeft: true, - ), - ), - SizedBox( - width: 400, - height: 60, - child: CountryCodePicker( - onChanged: (element) => debugPrint(element.toLongString()), - initialSelection: 'TF', - showCountryOnly: true, - showOnlyCountryWhenClosed: true, - favorite: const ['+39', 'FR'], - ), - ), - SizedBox( - width: 100, - height: 60, - child: CountryCodePicker( - enabled: false, - onChanged: (c) => c.name, - initialSelection: 'TF', - showCountryOnly: true, - showOnlyCountryWhenClosed: true, - favorite: const ['+39', 'FR'], - ), - ), + ], ), ), diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 62df828f..1a7a2176 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -177,7 +177,32 @@ class CountryCodePickerState extends State { child: widget.builder!(selectedItem), ); } else { - internalWidget = TextButton( + internalWidget = SelectionDialog( + + widget.txtFieldHintTxt, + elements, + favoriteElements, + showCountryOnly: widget.showCountryOnly, + emptySearchBuilder: widget.emptySearchBuilder, + searchDecoration: widget.searchDecoration, + searchStyle: widget.searchStyle, + textStyle: widget.dialogTextStyle, + boxDecoration: widget.boxDecoration, + showFlag: widget.showFlagDialog ?? widget.showFlag, + flagWidth: widget.flagWidth, + size: widget.dialogSize, + backgroundColor: widget.dialogBackgroundColor, + barrierColor: widget.barrierColor, + hideSearch: widget.hideSearch, + hideCloseIcon: widget.hideCloseIcon, + closeIcon: widget.closeIcon, + flagDecoration: widget.flagDecoration, + dialogItemPadding: widget.dialogItemPadding, + searchPadding: widget.searchPadding, + ); + + + /*TextButton( onPressed: widget.enabled ? showCountryCodePickerDialog : null, child: Padding( padding: widget.padding, @@ -235,7 +260,7 @@ class CountryCodePickerState extends State { ], ), ), - ); + );*/ } return internalWidget; } diff --git a/lib/src/selection_dialog.dart b/lib/src/selection_dialog.dart index ffd4dd11..a125df0d 100644 --- a/lib/src/selection_dialog.dart +++ b/lib/src/selection_dialog.dart @@ -71,23 +71,20 @@ class _SelectionDialogState extends State { @override Widget build(BuildContext context) => Padding( - padding: const EdgeInsets.all(0.0), + padding: const EdgeInsets.all(20.0), child: Container( clipBehavior: Clip.hardEdge, width: widget.size?.width ?? MediaQuery.of(context).size.width, - height: - widget.size?.height ?? MediaQuery.of(context).size.height * 0.85, + height: widget.size?.height ?? MediaQuery.of(context).size.height * 0.70, decoration: widget.boxDecoration ?? BoxDecoration( color: widget.backgroundColor ?? Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(8.0)), - boxShadow: [ - BoxShadow( - color: widget.barrierColor ?? Colors.grey.withOpacity(1), - spreadRadius: 5, - blurRadius: 7, - offset: const Offset(0, 3), // changes position of shadow + borderRadius: const BorderRadius.all(Radius.circular(20.0)), + border: Border.all( + color: Colors.green.withOpacity(0.5), + width: 1, ), + boxShadow: [ ], ), child: Column( @@ -95,12 +92,14 @@ class _SelectionDialogState extends State { crossAxisAlignment: CrossAxisAlignment.end, children: [ if (!widget.hideCloseIcon) - IconButton( + /* IconButton( padding: const EdgeInsets.all(0), iconSize: 20, icon: widget.closeIcon!, onPressed: () => Navigator.pop(context), - ), + ),*/ + + SizedBox(height:25,) , if (!widget.hideSearch) Padding( padding: widget.searchPadding, From d493ede48c481e8cce64e97377406623a786bac0 Mon Sep 17 00:00:00 2001 From: kareem Date: Sun, 3 Dec 2023 13:09:07 +0200 Subject: [PATCH 04/16] 2 feature in same branch --- lib/country_code_picker.dart | 67 +++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 1a7a2176..e3a0a060 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -1,5 +1,6 @@ library country_code_picker; + import 'package:collection/collection.dart' show IterableExtension; import 'package:flutter/material.dart'; @@ -92,8 +93,10 @@ class CountryCodePicker extends StatefulWidget { final EdgeInsetsGeometry searchPadding; String txtFieldHintTxt; + bool clickableFilepicker; CountryCodePicker({ + this.clickableFilepicker=true, this.txtFieldHintTxt="search", this.onChanged, this.onInit, @@ -177,7 +180,69 @@ class CountryCodePickerState extends State { child: widget.builder!(selectedItem), ); } else { - internalWidget = SelectionDialog( + internalWidget = + + widget.clickableFilepicker? + TextButton( + onPressed: widget.enabled ? showCountryCodePickerDialog : null, + child: Padding( + padding: widget.padding, + child: Flex( + direction: Axis.horizontal, + mainAxisSize: MainAxisSize.min, + children: [ + if (widget.showFlagMain != null + ? widget.showFlagMain! + : widget.showFlag) + Flexible( + flex: widget.alignLeft ? 0 : 1, + fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, + child: Container( + clipBehavior: widget.flagDecoration == null + ? Clip.none + : Clip.hardEdge, + decoration: widget.flagDecoration, + margin: widget.alignLeft + ? const EdgeInsets.only(right: 16.0, left: 8.0) + : const EdgeInsets.only(right: 16.0), + child: Image.asset( + selectedItem!.flagUri!, + package: 'country_code_picker', + width: widget.flagWidth, + ), + ), + ), + if (!widget.hideMainText) + Flexible( + fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, + child: Text( + widget.showOnlyCountryWhenClosed + ? selectedItem!.toCountryStringOnly() + : selectedItem.toString(), + style: widget.textStyle ?? + Theme.of(context).textTheme.labelLarge, + overflow: widget.textOverflow, + ), + ), + if (widget.showDropDownButton) + Flexible( + flex: widget.alignLeft ? 0 : 1, + fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, + child: Padding( + padding: widget.alignLeft + ? const EdgeInsets.only(right: 16.0, left: 8.0) + : const EdgeInsets.only(right: 16.0), + child: Icon( + Icons.arrow_drop_down, + color: Colors.grey, + size: widget.flagWidth, + )), + ), + ], + ), + ), + ) : + SelectionDialog( widget.txtFieldHintTxt, elements, From ed2e29b796b030572ba519d0c399966f91de44f7 Mon Sep 17 00:00:00 2001 From: kareem Date: Sun, 3 Dec 2023 13:39:32 +0200 Subject: [PATCH 05/16] 2 feature in same branch --- example/lib/main.dart | 3 ++ lib/country_code_picker.dart | 55 +++++++++++++++++++---------------- lib/src/selection_dialog.dart | 36 ++++++++++++++++++----- 3 files changed, 62 insertions(+), 32 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 512c3913..054ee042 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -103,6 +103,9 @@ class MyAppState extends State { CountryCodePicker( showFlag: true, onChanged: print, + clickableFilepicker:false, + hideLineAbovFiled:true , + // Initial selection and favorite can be one of code ('IT') OR dial_code('+39') initialSelection: 'IT', favorite: const ['+39', 'FR'], diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index e3a0a060..81e92b8a 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -77,7 +77,7 @@ class CountryCodePicker extends StatefulWidget { final bool hideSearch; /// Set to true if you want to hide the close icon dialog - final bool hideCloseIcon; + final bool hideLineAbovFiled; /// Set to true if you want to show drop down button final bool showDropDownButton; @@ -126,7 +126,7 @@ class CountryCodePicker extends StatefulWidget { this.comparator, this.countryFilter, this.hideSearch = false, - this.hideCloseIcon = false, + this.hideLineAbovFiled = false, this.showDropDownButton = false, this.dialogSize, this.dialogBackgroundColor, @@ -259,7 +259,7 @@ class CountryCodePickerState extends State { backgroundColor: widget.dialogBackgroundColor, barrierColor: widget.barrierColor, hideSearch: widget.hideSearch, - hideCloseIcon: widget.hideCloseIcon, + hideLineAbovFiled: widget.hideLineAbovFiled, closeIcon: widget.closeIcon, flagDecoration: widget.flagDecoration, dialogItemPadding: widget.dialogItemPadding, @@ -395,7 +395,7 @@ class CountryCodePickerState extends State { isScrollControlled: true, backgroundColor: Colors.transparent, builder: (context) => Container( - height: MediaQuery.of(context).size.height * 0.75, + height: MediaQuery.of(context).size.height * 0.85, decoration: new BoxDecoration( color: Colors.white, borderRadius: new BorderRadius.only( @@ -404,27 +404,32 @@ class CountryCodePickerState extends State { ), ), child: Center( - child: SelectionDialog( - widget.txtFieldHintTxt, - elements, - favoriteElements, - showCountryOnly: widget.showCountryOnly, - emptySearchBuilder: widget.emptySearchBuilder, - searchDecoration: widget.searchDecoration, - searchStyle: widget.searchStyle, - textStyle: widget.dialogTextStyle, - boxDecoration: widget.boxDecoration, - showFlag: widget.showFlagDialog ?? widget.showFlag, - flagWidth: widget.flagWidth, - size: widget.dialogSize, - backgroundColor: widget.dialogBackgroundColor, - barrierColor: widget.barrierColor, - hideSearch: widget.hideSearch, - hideCloseIcon: widget.hideCloseIcon, - closeIcon: widget.closeIcon, - flagDecoration: widget.flagDecoration, - dialogItemPadding: widget.dialogItemPadding, - searchPadding: widget.searchPadding, + child: Column( + children: [ + + SelectionDialog( + widget.txtFieldHintTxt, + elements, + favoriteElements, + showCountryOnly: widget.showCountryOnly, + emptySearchBuilder: widget.emptySearchBuilder, + searchDecoration: widget.searchDecoration, + searchStyle: widget.searchStyle, + textStyle: widget.dialogTextStyle, + boxDecoration: widget.boxDecoration, + showFlag: widget.showFlagDialog ?? widget.showFlag, + flagWidth: widget.flagWidth, + size: widget.dialogSize, + backgroundColor: widget.dialogBackgroundColor, + barrierColor: widget.barrierColor, + hideSearch: widget.hideSearch, + hideLineAbovFiled: widget.hideLineAbovFiled, + closeIcon: widget.closeIcon, + flagDecoration: widget.flagDecoration, + dialogItemPadding: widget.dialogItemPadding, + searchPadding: widget.searchPadding, + ), + ], ), ), ), diff --git a/lib/src/selection_dialog.dart b/lib/src/selection_dialog.dart index a125df0d..baed2747 100644 --- a/lib/src/selection_dialog.dart +++ b/lib/src/selection_dialog.dart @@ -17,7 +17,7 @@ class SelectionDialog extends StatefulWidget { final Decoration? flagDecoration; final Size? size; final bool hideSearch; - final bool hideCloseIcon; + final bool hideLineAbovFiled; final Icon? closeIcon; /// Background color of SelectionDialog @@ -52,7 +52,7 @@ class SelectionDialog extends StatefulWidget { this.backgroundColor, this.barrierColor, this.hideSearch = false, - this.hideCloseIcon = false, + this.hideLineAbovFiled = false, this.closeIcon, this.dialogItemPadding = const EdgeInsets.symmetric(horizontal: 24, vertical: 8), this.searchPadding = const EdgeInsets.symmetric(horizontal: 24), @@ -80,10 +80,10 @@ class _SelectionDialogState extends State { BoxDecoration( color: widget.backgroundColor ?? Colors.white, borderRadius: const BorderRadius.all(Radius.circular(20.0)), - border: Border.all( + /*border: Border.all( color: Colors.green.withOpacity(0.5), width: 1, - ), + ),*/ boxShadow: [ ], ), @@ -91,7 +91,7 @@ class _SelectionDialogState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.end, children: [ - if (!widget.hideCloseIcon) + // if (!widget.hideCloseIcon) /* IconButton( padding: const EdgeInsets.all(0), iconSize: 20, @@ -99,6 +99,26 @@ class _SelectionDialogState extends State { onPressed: () => Navigator.pop(context), ),*/ + widget.hideLineAbovFiled? + SizedBox(): + Center( + child: Padding( + padding: const EdgeInsets.all(3.0), + child: Container( + decoration: BoxDecoration( + color: Colors.black, // Set line color + borderRadius: BorderRadius.all( + Radius.circular(20) + + ), + ), + height: 4.0, // Set line thickness + width: 100.0, // Set line length + ), + ), + ), + + SizedBox(height:25,) , if (!widget.hideSearch) Padding( @@ -112,7 +132,9 @@ class _SelectionDialogState extends State { focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: BorderSide( - color: Colors.green.withOpacity(0.5), // Change the border color as needed + color: + + Colors.green.withOpacity(0.5), // Change the border color as needed width: 2.0, ), ), @@ -197,7 +219,7 @@ class _SelectionDialogState extends State { Flexible( child: Container( margin: const EdgeInsets.only(right: 16.0), - decoration: widget.flagDecoration, + // decoration: widget.flagDecoration, clipBehavior: widget.flagDecoration == null ? Clip.none : Clip.hardEdge, child: Image.asset( From af997cce82e82ac31d7538055664a2e5e362ff63 Mon Sep 17 00:00:00 2001 From: kareem Date: Sun, 3 Dec 2023 13:48:19 +0200 Subject: [PATCH 06/16] height Feature --- lib/country_code_picker.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 81e92b8a..a75b95bb 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -93,10 +93,12 @@ class CountryCodePicker extends StatefulWidget { final EdgeInsetsGeometry searchPadding; String txtFieldHintTxt; - bool clickableFilepicker; - + bool clickableFilepicker + double height; CountryCodePicker({ this.clickableFilepicker=true, + this.height= 0.75, + this.txtFieldHintTxt="search", this.onChanged, this.onInit, @@ -395,7 +397,7 @@ class CountryCodePickerState extends State { isScrollControlled: true, backgroundColor: Colors.transparent, builder: (context) => Container( - height: MediaQuery.of(context).size.height * 0.85, + height: MediaQuery.of(context).size.height * widget.height, decoration: new BoxDecoration( color: Colors.white, borderRadius: new BorderRadius.only( From e1f4aa4d08475fc06ab15ea3fe16815865317c51 Mon Sep 17 00:00:00 2001 From: kareem Date: Sun, 3 Dec 2023 13:49:05 +0200 Subject: [PATCH 07/16] height Feature --- lib/country_code_picker.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index a75b95bb..8f5fa6e6 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -93,7 +93,7 @@ class CountryCodePicker extends StatefulWidget { final EdgeInsetsGeometry searchPadding; String txtFieldHintTxt; - bool clickableFilepicker + bool clickableFilepicker; double height; CountryCodePicker({ this.clickableFilepicker=true, From 1ba36780aa1de41d3610f7bfa898f447876bdb59 Mon Sep 17 00:00:00 2001 From: kareem Date: Sun, 3 Dec 2023 16:38:21 +0200 Subject: [PATCH 08/16] i think final --- example/lib/main.dart | 46 ++++++++++++++++++++------- lib/country_code_picker.dart | 60 +++++++++++++++++++---------------- lib/src/selection_dialog.dart | 4 ++- 3 files changed, 70 insertions(+), 40 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 054ee042..8dfcfe9e 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -101,20 +101,42 @@ class MyAppState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ CountryCodePicker( - showFlag: true, - onChanged: print, - clickableFilepicker:false, + withoutBottomSheetheight: 0.50 , + + showBottomSheetheight: 0.60, + + + flagDecoration:BoxDecoration( + + color: Colors.white.withOpacity(0.7), + shape: BoxShape.circle, // Make the container circular + border: Border.all(color: Colors.grey)), + + txtFieldHintTxt: "البحث", + clickableFilepicker:true, hideLineAbovFiled:true , - // Initial selection and favorite can be one of code ('IT') OR dial_code('+39') - initialSelection: 'IT', - favorite: const ['+39', 'FR'], - countryFilter: const ['IT', 'FR'], - showFlagDialog: true, - comparator: (a, b) => b.name!.compareTo(a.name!), - //Get the country information relevant to the initial selection - onInit: (code) => debugPrint( - "on init ${code?.name} ${code?.dialCode} ${code?.name}"), + + flagWidth: 25, + + textStyle:TextStyle(color: Colors.black , fontWeight: FontWeight.bold , fontSize: 13), + + + /*flagDecoration:BoxDecoration( + + color: Colors.white.withOpacity(0.7), + shape: BoxShape.circle, // Make the container circular + border: Border.all(color: Colors.grey), + + ),*/ + onChanged: (value) { + // Handle country code change + print(value); + }, + // Initial selection and favorite country + initialSelection: 'SA', + // Add Saudi Arabia to the favorites + favorite: ['+966', 'SA'], ), ], diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 8f5fa6e6..d542ddc3 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -94,10 +94,13 @@ class CountryCodePicker extends StatefulWidget { final EdgeInsetsGeometry searchPadding; String txtFieldHintTxt; bool clickableFilepicker; - double height; - CountryCodePicker({ + double showBottomSheetheight; + double withoutBottomSheetheight; + + CountryCodePicker({ this.clickableFilepicker=true, - this.height= 0.75, + this.showBottomSheetheight= 0.75, + this.withoutBottomSheetheight=0.70, this.txtFieldHintTxt="search", this.onChanged, @@ -245,28 +248,29 @@ class CountryCodePickerState extends State { ), ) : SelectionDialog( - - widget.txtFieldHintTxt, - elements, - favoriteElements, - showCountryOnly: widget.showCountryOnly, - emptySearchBuilder: widget.emptySearchBuilder, - searchDecoration: widget.searchDecoration, - searchStyle: widget.searchStyle, - textStyle: widget.dialogTextStyle, - boxDecoration: widget.boxDecoration, - showFlag: widget.showFlagDialog ?? widget.showFlag, - flagWidth: widget.flagWidth, - size: widget.dialogSize, - backgroundColor: widget.dialogBackgroundColor, - barrierColor: widget.barrierColor, - hideSearch: widget.hideSearch, - hideLineAbovFiled: widget.hideLineAbovFiled, - closeIcon: widget.closeIcon, - flagDecoration: widget.flagDecoration, - dialogItemPadding: widget.dialogItemPadding, - searchPadding: widget.searchPadding, - ); + widget.withoutBottomSheetheight, + + widget.txtFieldHintTxt, + elements, + favoriteElements, + showCountryOnly: widget.showCountryOnly, + emptySearchBuilder: widget.emptySearchBuilder, + searchDecoration: widget.searchDecoration, + searchStyle: widget.searchStyle, + textStyle: widget.dialogTextStyle, + boxDecoration: widget.boxDecoration, + showFlag: widget.showFlagDialog ?? widget.showFlag, + flagWidth: widget.flagWidth, + size: widget.dialogSize, + backgroundColor: widget.dialogBackgroundColor, + barrierColor: widget.barrierColor, + hideSearch: widget.hideSearch, + hideLineAbovFiled: widget.hideLineAbovFiled, + closeIcon: widget.closeIcon, + flagDecoration: widget.flagDecoration, + dialogItemPadding: widget.dialogItemPadding, + searchPadding: widget.searchPadding, + ); /*TextButton( @@ -397,7 +401,7 @@ class CountryCodePickerState extends State { isScrollControlled: true, backgroundColor: Colors.transparent, builder: (context) => Container( - height: MediaQuery.of(context).size.height * widget.height, + height: MediaQuery.of(context).size.height * widget.showBottomSheetheight, decoration: new BoxDecoration( color: Colors.white, borderRadius: new BorderRadius.only( @@ -410,6 +414,8 @@ class CountryCodePickerState extends State { children: [ SelectionDialog( + widget.withoutBottomSheetheight, + widget.txtFieldHintTxt, elements, favoriteElements, @@ -427,7 +433,7 @@ class CountryCodePickerState extends State { hideSearch: widget.hideSearch, hideLineAbovFiled: widget.hideLineAbovFiled, closeIcon: widget.closeIcon, - flagDecoration: widget.flagDecoration, + // flagDecoration: widget.flagDecoration, dialogItemPadding: widget.dialogItemPadding, searchPadding: widget.searchPadding, ), diff --git a/lib/src/selection_dialog.dart b/lib/src/selection_dialog.dart index baed2747..8c2adcde 100644 --- a/lib/src/selection_dialog.dart +++ b/lib/src/selection_dialog.dart @@ -33,8 +33,10 @@ class SelectionDialog extends StatefulWidget { final EdgeInsetsGeometry searchPadding; String? txtFieldHintTxt="search"; + double height =0.70; SelectionDialog( + this.height, this.txtFieldHintTxt, this.elements, this.favoriteElements, { @@ -75,7 +77,7 @@ class _SelectionDialogState extends State { child: Container( clipBehavior: Clip.hardEdge, width: widget.size?.width ?? MediaQuery.of(context).size.width, - height: widget.size?.height ?? MediaQuery.of(context).size.height * 0.70, + height: widget.size?.height ?? MediaQuery.of(context).size.height * widget.height, decoration: widget.boxDecoration ?? BoxDecoration( color: widget.backgroundColor ?? Colors.white, From e6b8ea07219c92f38487df9cbf6f5a6ca8c5e79f Mon Sep 17 00:00:00 2001 From: kareem Date: Sun, 3 Dec 2023 17:49:44 +0200 Subject: [PATCH 09/16] i think final2 --- example/lib/main.dart | 15 +++--- lib/country_code_picker.dart | 63 ++++++++++++++-------- lib/src/selection_dialog.dart | 99 +++++++++++++++++++++-------------- 3 files changed, 110 insertions(+), 67 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 8dfcfe9e..bf88745d 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -101,23 +101,26 @@ class MyAppState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ CountryCodePicker( - withoutBottomSheetheight: 0.50 , + withoutBottomSheetheight: 0.80 , - showBottomSheetheight: 0.60, + showBottomSheetheight: 0.80, + txtFieldHintTxt: "البحث", + clickableFilepicker:false, + hideLineAbovFiled:false , + textDirection: TextDirection.rtl, flagDecoration:BoxDecoration( + color: Colors.white.withOpacity(0.7), shape: BoxShape.circle, // Make the container circular border: Border.all(color: Colors.grey)), - txtFieldHintTxt: "البحث", - clickableFilepicker:true, - hideLineAbovFiled:true , - flagWidth: 25, + + textStyle:TextStyle(color: Colors.black , fontWeight: FontWeight.bold , fontSize: 13), diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index d542ddc3..27f26a4a 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -96,8 +96,15 @@ class CountryCodePicker extends StatefulWidget { bool clickableFilepicker; double showBottomSheetheight; double withoutBottomSheetheight; + TextDirection textDirection; + Color txtFieldColor; + + CountryCodePicker({ + this.txtFieldColor=Colors.red, + + this.textDirection=TextDirection.rtl, this.clickableFilepicker=true, this.showBottomSheetheight= 0.75, this.withoutBottomSheetheight=0.70, @@ -248,6 +255,10 @@ class CountryCodePickerState extends State { ), ) : SelectionDialog( + widget.txtFieldColor, + widget.clickableFilepicker, + widget.textDirection, + widget.withoutBottomSheetheight, widget.txtFieldHintTxt, @@ -413,29 +424,35 @@ class CountryCodePickerState extends State { child: Column( children: [ - SelectionDialog( - widget.withoutBottomSheetheight, - - widget.txtFieldHintTxt, - elements, - favoriteElements, - showCountryOnly: widget.showCountryOnly, - emptySearchBuilder: widget.emptySearchBuilder, - searchDecoration: widget.searchDecoration, - searchStyle: widget.searchStyle, - textStyle: widget.dialogTextStyle, - boxDecoration: widget.boxDecoration, - showFlag: widget.showFlagDialog ?? widget.showFlag, - flagWidth: widget.flagWidth, - size: widget.dialogSize, - backgroundColor: widget.dialogBackgroundColor, - barrierColor: widget.barrierColor, - hideSearch: widget.hideSearch, - hideLineAbovFiled: widget.hideLineAbovFiled, - closeIcon: widget.closeIcon, - // flagDecoration: widget.flagDecoration, - dialogItemPadding: widget.dialogItemPadding, - searchPadding: widget.searchPadding, + Expanded( + child: SelectionDialog( + widget.txtFieldColor, + widget.clickableFilepicker, + + widget.textDirection, + widget.withoutBottomSheetheight, + + widget.txtFieldHintTxt, + elements, + favoriteElements, + showCountryOnly: widget.showCountryOnly, + emptySearchBuilder: widget.emptySearchBuilder, + searchDecoration: widget.searchDecoration, + searchStyle: widget.searchStyle, + textStyle: widget.dialogTextStyle, + boxDecoration: widget.boxDecoration, + showFlag: widget.showFlagDialog ?? widget.showFlag, + flagWidth: widget.flagWidth, + size: widget.dialogSize, + backgroundColor: widget.dialogBackgroundColor, + barrierColor: widget.barrierColor, + hideSearch: widget.hideSearch, + hideLineAbovFiled: widget.hideLineAbovFiled, + closeIcon: widget.closeIcon, + // flagDecoration: widget.flagDecoration, + dialogItemPadding: widget.dialogItemPadding, + searchPadding: widget.searchPadding, + ), ), ], ), diff --git a/lib/src/selection_dialog.dart b/lib/src/selection_dialog.dart index 8c2adcde..18fac53e 100644 --- a/lib/src/selection_dialog.dart +++ b/lib/src/selection_dialog.dart @@ -34,8 +34,14 @@ class SelectionDialog extends StatefulWidget { final EdgeInsetsGeometry searchPadding; String? txtFieldHintTxt="search"; double height =0.70; + TextDirection textDirection; + bool clickableFilepicker; + Color txtFieldColor; SelectionDialog( + this.txtFieldColor, + this.clickableFilepicker, + this.textDirection, this.height, this.txtFieldHintTxt, this.elements, @@ -73,7 +79,7 @@ class _SelectionDialogState extends State { @override Widget build(BuildContext context) => Padding( - padding: const EdgeInsets.all(20.0), + padding: const EdgeInsets.all(5.0), child: Container( clipBehavior: Clip.hardEdge, width: widget.size?.width ?? MediaQuery.of(context).size.width, @@ -82,10 +88,10 @@ class _SelectionDialogState extends State { BoxDecoration( color: widget.backgroundColor ?? Colors.white, borderRadius: const BorderRadius.all(Radius.circular(20.0)), - /*border: Border.all( - color: Colors.green.withOpacity(0.5), + border: Border.all( + color: widget.txtFieldColor, width: 1, - ),*/ + ), boxShadow: [ ], ), @@ -101,6 +107,8 @@ class _SelectionDialogState extends State { onPressed: () => Navigator.pop(context), ),*/ + SizedBox(height:10,) , + widget.hideLineAbovFiled? SizedBox(): Center( @@ -111,7 +119,7 @@ class _SelectionDialogState extends State { color: Colors.black, // Set line color borderRadius: BorderRadius.all( Radius.circular(20) - + ), ), height: 4.0, // Set line thickness @@ -125,48 +133,52 @@ class _SelectionDialogState extends State { if (!widget.hideSearch) Padding( padding: widget.searchPadding, - child: TextField( + child: Directionality( + textDirection: widget.textDirection, + child: TextField( - decoration: InputDecoration( - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0), - borderSide: BorderSide( - color: + decoration: InputDecoration( - Colors.green.withOpacity(0.5), // Change the border color as needed - width: 2.0, + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: widget.txtFieldColor,// Change the border color as needed + width: 2.0, + ), ), - ), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0), - borderSide: BorderSide( - color: Colors.green.withOpacity(0.5), // Change the border color as needed - width: 1.0, + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: widget.txtFieldColor, // Change the border color as needed + width: 1.0, + ), ), - ), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0), - borderSide: BorderSide( - color: Colors.green.withOpacity(0.5), // Change the border color as needed - width: 1.0, // Adjust the border width + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: widget.txtFieldColor, // Change the border color as needed + width: 1.0, // Adjust the border width + ), ), + hintText: widget.txtFieldHintTxt, + suffixIcon: Icon(Icons.search), ), - hintText: widget.txtFieldHintTxt, - suffixIcon: Icon(Icons.search), + style: widget.searchStyle, + //decoration: widget.searchDecoration, + onChanged: _filterElements, ), - style: widget.searchStyle, - //decoration: widget.searchDecoration, - onChanged: _filterElements, ), ), + SizedBox(height:10,) , + Expanded( child: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(0.0), child: ListView( children: [ widget.favoriteElements.isEmpty @@ -177,7 +189,9 @@ class _SelectionDialogState extends State { ...widget.favoriteElements.map( (f) => InkWell( onTap: () { - _selectItem(f); + widget.clickableFilepicker? + _selectItem(f) : + debugPrint(""); }, child: Padding( padding: widget.dialogItemPadding, @@ -206,6 +220,7 @@ class _SelectionDialogState extends State { ), ), ), + ], ), ), @@ -222,12 +237,20 @@ class _SelectionDialogState extends State { child: Container( margin: const EdgeInsets.only(right: 16.0), // decoration: widget.flagDecoration, - clipBehavior: - widget.flagDecoration == null ? Clip.none : Clip.hardEdge, - child: Image.asset( - e.flagUri!, - package: 'country_code_picker', - width: widget.flagWidth, + /*clipBehavior: + widget.flagDecoration == null ? Clip.none : Clip.hardEdge,*/ + child: ClipRRect( + borderRadius: BorderRadius.circular(5.0), // Set the circular border radius + + child: Image.asset( + e.flagUri!, + package: 'country_code_picker', + width: 40, + + //widget.flagWidth, + fit: BoxFit.cover, // Adjust the BoxFit as needed + + ), ), ), ), From 001d414ef540c0adbeeac5347994e5c24f53dff7 Mon Sep 17 00:00:00 2001 From: kareem Date: Sun, 3 Dec 2023 18:11:58 +0200 Subject: [PATCH 10/16] i think final3 --- example/lib/main.dart | 6 ------ lib/country_code_picker.dart | 7 +++++++ lib/src/selection_dialog.dart | 20 ++++++++++++-------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index bf88745d..e7b2b897 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -109,7 +109,6 @@ class MyAppState extends State { hideLineAbovFiled:false , textDirection: TextDirection.rtl, - flagDecoration:BoxDecoration( @@ -117,11 +116,6 @@ class MyAppState extends State { shape: BoxShape.circle, // Make the container circular border: Border.all(color: Colors.grey)), - - - - - textStyle:TextStyle(color: Colors.black , fontWeight: FontWeight.bold , fontSize: 13), diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 27f26a4a..ec4dbae0 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -98,10 +98,14 @@ class CountryCodePicker extends StatefulWidget { double withoutBottomSheetheight; TextDirection textDirection; Color txtFieldColor; + Color containerBorderColor; + CountryCodePicker({ + this.containerBorderColor=Colors.red, + this.txtFieldColor=Colors.red, this.textDirection=TextDirection.rtl, @@ -255,6 +259,7 @@ class CountryCodePickerState extends State { ), ) : SelectionDialog( + widget.containerBorderColor, widget.txtFieldColor, widget.clickableFilepicker, widget.textDirection, @@ -426,6 +431,8 @@ class CountryCodePickerState extends State { Expanded( child: SelectionDialog( + widget.containerBorderColor, + widget.txtFieldColor, widget.clickableFilepicker, diff --git a/lib/src/selection_dialog.dart b/lib/src/selection_dialog.dart index 18fac53e..6484a9fd 100644 --- a/lib/src/selection_dialog.dart +++ b/lib/src/selection_dialog.dart @@ -36,10 +36,12 @@ class SelectionDialog extends StatefulWidget { double height =0.70; TextDirection textDirection; bool clickableFilepicker; - Color txtFieldColor; + Color txtFieldBorderColor; + Color containerBorderColor; SelectionDialog( - this.txtFieldColor, + this.containerBorderColor, + this.txtFieldBorderColor, this.clickableFilepicker, this.textDirection, this.height, @@ -89,7 +91,7 @@ class _SelectionDialogState extends State { color: widget.backgroundColor ?? Colors.white, borderRadius: const BorderRadius.all(Radius.circular(20.0)), border: Border.all( - color: widget.txtFieldColor, + color: widget.containerBorderColor, width: 1, ), boxShadow: [ @@ -145,14 +147,14 @@ class _SelectionDialogState extends State { focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: BorderSide( - color: widget.txtFieldColor,// Change the border color as needed + color: widget.txtFieldBorderColor,// Change the border color as needed width: 2.0, ), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: BorderSide( - color: widget.txtFieldColor, // Change the border color as needed + color: widget.txtFieldBorderColor, // Change the border color as needed width: 1.0, ), ), @@ -161,7 +163,7 @@ class _SelectionDialogState extends State { border: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: BorderSide( - color: widget.txtFieldColor, // Change the border color as needed + color: widget.txtFieldBorderColor, // Change the border color as needed width: 1.0, // Adjust the border width ), ), @@ -208,7 +210,9 @@ class _SelectionDialogState extends State { ...filteredElements.map( (e) => InkWell( onTap: () { - _selectItem(e); + widget.clickableFilepicker? + _selectItem(e) : + debugPrint(""); }, child: Padding( padding: widget.dialogItemPadding, @@ -261,7 +265,7 @@ class _SelectionDialogState extends State { ? e.toCountryStringOnly() : e.toLongString(), overflow: TextOverflow.fade, - style: widget.textStyle, + style: TextStyle(fontWeight: FontWeight.w700), ), ), ], From 3cd644a87fa44ca17e9a3d9246f8eb1f4388d230 Mon Sep 17 00:00:00 2001 From: kareem Date: Sun, 3 Dec 2023 21:22:37 +0200 Subject: [PATCH 11/16] i think final4 --- example/lib/main.dart | 3 ++- lib/country_code_picker.dart | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index e7b2b897..67cff32f 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -93,6 +93,7 @@ class MyAppState extends State { GlobalWidgetsLocalizations.delegate, ], home: Scaffold( + backgroundColor: Colors.red, appBar: AppBar( title: const Text('CountryPicker Example'), ), @@ -105,7 +106,7 @@ class MyAppState extends State { showBottomSheetheight: 0.80, txtFieldHintTxt: "البحث", - clickableFilepicker:false, + clickableFilepicker:true, hideLineAbovFiled:false , textDirection: TextDirection.rtl, diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index ec4dbae0..8f21440d 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -220,7 +220,7 @@ class CountryCodePickerState extends State { decoration: widget.flagDecoration, margin: widget.alignLeft ? const EdgeInsets.only(right: 16.0, left: 8.0) - : const EdgeInsets.only(right: 16.0), + : const EdgeInsets.only(right: 0.0), child: Image.asset( selectedItem!.flagUri!, package: 'country_code_picker', From 83327f868eb7ed7f29145b166a2172315a8b5f24 Mon Sep 17 00:00:00 2001 From: kareem Date: Mon, 4 Dec 2023 15:20:37 +0200 Subject: [PATCH 12/16] i think final5 --- example/lib/main.dart | 6 +++++- lib/src/selection_dialog.dart | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 67cff32f..65d71d00 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -104,9 +104,13 @@ class MyAppState extends State { CountryCodePicker( withoutBottomSheetheight: 0.80 , + boxDecoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + borderRadius: BorderRadius.circular(18), + ), showBottomSheetheight: 0.80, txtFieldHintTxt: "البحث", - clickableFilepicker:true, + clickableFilepicker:false, hideLineAbovFiled:false , textDirection: TextDirection.rtl, diff --git a/lib/src/selection_dialog.dart b/lib/src/selection_dialog.dart index 6484a9fd..533287a4 100644 --- a/lib/src/selection_dialog.dart +++ b/lib/src/selection_dialog.dart @@ -168,7 +168,7 @@ class _SelectionDialogState extends State { ), ), hintText: widget.txtFieldHintTxt, - suffixIcon: Icon(Icons.search), + suffixIcon: Icon(Icons.search , color: Colors.grey ,), ), style: widget.searchStyle, //decoration: widget.searchDecoration, From c1f102989c0f16cc6ed1b40549041e194a0ad7b7 Mon Sep 17 00:00:00 2001 From: kareem Date: Mon, 4 Dec 2023 16:06:40 +0200 Subject: [PATCH 13/16] i think final6 --- example/lib/main.dart | 10 ++++++++-- lib/country_code_picker.dart | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 65d71d00..f8517778 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -102,15 +102,21 @@ class MyAppState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ CountryCodePicker( + withoutBottomSheetheight: 0.80 , boxDecoration: BoxDecoration( color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(18), - ), + border: Border.all( + color: Colors.red, + + // Border color + width: 2.0, // Border width + ), ), showBottomSheetheight: 0.80, txtFieldHintTxt: "البحث", - clickableFilepicker:false, + clickableFilepicker:true, hideLineAbovFiled:false , textDirection: TextDirection.rtl, diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 8f21440d..d7ee37f2 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -419,7 +419,7 @@ class CountryCodePickerState extends State { builder: (context) => Container( height: MediaQuery.of(context).size.height * widget.showBottomSheetheight, decoration: new BoxDecoration( - color: Colors.white, + color: Theme.of(context).colorScheme.surface, borderRadius: new BorderRadius.only( topLeft: const Radius.circular(25.0), topRight: const Radius.circular(25.0), From a831646163d6276b67cb9c73710496a432cd7684 Mon Sep 17 00:00:00 2001 From: kareem Date: Mon, 4 Dec 2023 16:48:33 +0200 Subject: [PATCH 14/16] i think final7 --- example/lib/main.dart | 1 + lib/country_code_picker.dart | 8 ++++---- lib/src/country_code.dart | 2 ++ lib/src/selection_dialog.dart | 11 +++++++---- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index f8517778..26cd5818 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -103,6 +103,7 @@ class MyAppState extends State { children: [ CountryCodePicker( + showCodeOnly: false, withoutBottomSheetheight: 0.80 , boxDecoration: BoxDecoration( diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index d7ee37f2..3f196442 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -20,7 +20,7 @@ class CountryCodePicker extends StatefulWidget { final List favorite; final TextStyle? textStyle; final EdgeInsetsGeometry padding; - final bool showCountryOnly; + final bool showCodeOnly; final InputDecoration searchDecoration; final TextStyle? searchStyle; final TextStyle? dialogTextStyle; @@ -120,7 +120,7 @@ class CountryCodePicker extends StatefulWidget { this.favorite = const [], this.textStyle, this.padding = const EdgeInsets.all(8.0), - this.showCountryOnly = false, + this.showCodeOnly = false, this.searchDecoration = const InputDecoration(), this.searchStyle, this.dialogTextStyle, @@ -269,7 +269,7 @@ class CountryCodePickerState extends State { widget.txtFieldHintTxt, elements, favoriteElements, - showCountryOnly: widget.showCountryOnly, + showCodeOnly: widget.showCodeOnly, emptySearchBuilder: widget.emptySearchBuilder, searchDecoration: widget.searchDecoration, searchStyle: widget.searchStyle, @@ -442,7 +442,7 @@ class CountryCodePickerState extends State { widget.txtFieldHintTxt, elements, favoriteElements, - showCountryOnly: widget.showCountryOnly, + showCodeOnly: widget.showCodeOnly, emptySearchBuilder: widget.emptySearchBuilder, searchDecoration: widget.searchDecoration, searchStyle: widget.searchStyle, diff --git a/lib/src/country_code.dart b/lib/src/country_code.dart index b8a38634..67959ed8 100644 --- a/lib/src/country_code.dart +++ b/lib/src/country_code.dart @@ -64,6 +64,8 @@ class CountryCode { String toString() => "$dialCode"; String toLongString() => "$dialCode ${toCountryStringOnly()}"; + String codeOnlyString() => "$dialCode"; + String toCountryStringOnly() { return '$_cleanName'; diff --git a/lib/src/selection_dialog.dart b/lib/src/selection_dialog.dart index 533287a4..30e9f6ec 100644 --- a/lib/src/selection_dialog.dart +++ b/lib/src/selection_dialog.dart @@ -6,7 +6,7 @@ import 'country_localizations.dart'; /// selection dialog used for selection of the country code class SelectionDialog extends StatefulWidget { final List elements; - final bool? showCountryOnly; + final bool? showCodeOnly; final InputDecoration searchDecoration; final TextStyle? searchStyle; final TextStyle? textStyle; @@ -49,7 +49,7 @@ class SelectionDialog extends StatefulWidget { this.elements, this.favoriteElements, { Key? key, - this.showCountryOnly, + this.showCodeOnly, this.emptySearchBuilder, InputDecoration searchDecoration = const InputDecoration(), this.searchStyle, @@ -258,11 +258,14 @@ class _SelectionDialogState extends State { ), ), ), + + + Expanded( flex: 4, child: Text( - widget.showCountryOnly! - ? e.toCountryStringOnly() + widget.showCodeOnly! + ? e.codeOnlyString() : e.toLongString(), overflow: TextOverflow.fade, style: TextStyle(fontWeight: FontWeight.w700), From 57c89eae09229f1c5f10064941ffc9df7c077dcb Mon Sep 17 00:00:00 2001 From: kareem Date: Tue, 5 Dec 2023 01:12:46 +0200 Subject: [PATCH 15/16] update 101 --- lib/src/selection_dialog.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/selection_dialog.dart b/lib/src/selection_dialog.dart index 30e9f6ec..fc022f88 100644 --- a/lib/src/selection_dialog.dart +++ b/lib/src/selection_dialog.dart @@ -201,7 +201,7 @@ class _SelectionDialogState extends State { ) ) ), - const Divider(), + Divider(color: Theme.of(context).colorScheme.surface,thickness: 0.2,), ], ), if (filteredElements.isEmpty) From 409e6e1cc8847c19f1119882bbdda52f2beed83e Mon Sep 17 00:00:00 2001 From: kareem Date: Tue, 5 Dec 2023 03:56:23 +0200 Subject: [PATCH 16/16] update 102 --- lib/src/selection_dialog.dart | 86 ++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/lib/src/selection_dialog.dart b/lib/src/selection_dialog.dart index fc022f88..ae3150ad 100644 --- a/lib/src/selection_dialog.dart +++ b/lib/src/selection_dialog.dart @@ -178,49 +178,53 @@ class _SelectionDialogState extends State { ), SizedBox(height:10,) , - Expanded( - child: Padding( - padding: const EdgeInsets.all(0.0), - child: ListView( - children: [ - widget.favoriteElements.isEmpty - ? const DecoratedBox(decoration: BoxDecoration()) - : Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ...widget.favoriteElements.map( - (f) => InkWell( - onTap: () { - widget.clickableFilepicker? - _selectItem(f) : - debugPrint(""); - }, - child: Padding( - padding: widget.dialogItemPadding, - child: _buildOption(f), + Directionality( + textDirection: TextDirection.ltr, + + child: Expanded( + child: Padding( + padding: const EdgeInsets.all(0.0), + child: ListView( + children: [ + widget.favoriteElements.isEmpty + ? const DecoratedBox(decoration: BoxDecoration()) + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ...widget.favoriteElements.map( + (f) => InkWell( + onTap: () { + widget.clickableFilepicker? + _selectItem(f) : + debugPrint(""); + }, + child: Padding( + padding: widget.dialogItemPadding, + child: _buildOption(f), + ) ) - ) - ), - Divider(color: Theme.of(context).colorScheme.surface,thickness: 0.2,), - ], - ), - if (filteredElements.isEmpty) - _buildEmptySearchWidget(context) - else - ...filteredElements.map( - (e) => InkWell( - onTap: () { - widget.clickableFilepicker? - _selectItem(e) : - debugPrint(""); - }, - child: Padding( - padding: widget.dialogItemPadding, - child: _buildOption(e), + ), + Divider(color: Theme.of(context).colorScheme.surface,thickness: 0.2,), + ], + ), + if (filteredElements.isEmpty) + _buildEmptySearchWidget(context) + else + ...filteredElements.map( + (e) => InkWell( + onTap: () { + widget.clickableFilepicker? + _selectItem(e) : + debugPrint(""); + }, + child: Padding( + padding: widget.dialogItemPadding, + child: _buildOption(e), + ) ) - ) - ), - ], + ), + ], + ), ), ), ),