diff --git a/README.md b/README.md index f5b73030..c1bb0635 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,9 @@ Just add the `CountryLocalizations.delegate` in the list of your app delegates Locale("ur"), Locale("uz"), Locale("vi"), - Locale("zh") + Locale("zh"), + Locale("zh-CN"), + Locale("zh-TW") ], localizationsDelegates: [ CountryLocalizations.delegate, @@ -137,32 +139,32 @@ Just add the `CountryLocalizations.delegate` in the list of your app delegates Here is a list of properties available to customize your widget: -| Name | Type | Description | -|-----|-----|------| -|onChanged| ValueChanged | callback invoked when the selection changes | -|onInit| ValueChanged | callback invoked during initialization of the widget | -|initialSelection| String | used to set the initial selected value | -|favorite| List | used to populate the favorite country list | -|textStyle| TextStyle | TextStyle applied to the widget button | -|padding| EdgeInsetsGeometry | the padding applied to the button | -|showCountryOnly| bool | true if you want to see only the countries in the selection dialog | -|searchDecoration| InputDecoration | decoration applied to the TextField search widget | -|searchStyle| TextStyle | style applied to the TextField search widget text | -|emptySearchBuilder| WidgetBuilder | use this to customize the widget used when the search returns 0 elements | -|builder| Function(CountryCode) | use this to build a custom widget instead of the default FlatButton | -|enabled| bool | set to false to disable the widget | -|textOverflow| TextOverflow | the button text overflow behaviour | -|dialogSize| Size | the size of the selection dialog | -|countryFilter| List | uses a list of strings to filter a sublist of countries | -|showOnlyCountryWhenClosed| bool | if true it'll show only the country | -|alignLeft| bool | aligns the flag and the Text to the left | -|showFlag| bool | shows the flag everywhere | -|showFlagMain| bool | shows the flag only when closed | -|showFlagDialog| bool | shows the flag only in dialog | -|flagWidth| double | the width of the flags | -|flagDecoration| Decoration | used for styling the flags | -|comparator| Comparator | use this to sort the countries in the selection dialog | -|hideSearch| bool | if true the search feature will be disabled | +| Name | Type | Description | +| ------------------------- | ------------------------- | ------------------------------------------------------------------------ | +| onChanged | ValueChanged | callback invoked when the selection changes | +| onInit | ValueChanged | callback invoked during initialization of the widget | +| initialSelection | String | used to set the initial selected value | +| favorite | List | used to populate the favorite country list | +| textStyle | TextStyle | TextStyle applied to the widget button | +| padding | EdgeInsetsGeometry | the padding applied to the button | +| showCountryOnly | bool | true if you want to see only the countries in the selection dialog | +| searchDecoration | InputDecoration | decoration applied to the TextField search widget | +| searchStyle | TextStyle | style applied to the TextField search widget text | +| emptySearchBuilder | WidgetBuilder | use this to customize the widget used when the search returns 0 elements | +| builder | Function(CountryCode) | use this to build a custom widget instead of the default FlatButton | +| enabled | bool | set to false to disable the widget | +| textOverflow | TextOverflow | the button text overflow behaviour | +| dialogSize | Size | the size of the selection dialog | +| countryFilter | List | uses a list of strings to filter a sublist of countries | +| showOnlyCountryWhenClosed | bool | if true it'll show only the country | +| alignLeft | bool | aligns the flag and the Text to the left | +| showFlag | bool | shows the flag everywhere | +| showFlagMain | bool | shows the flag only when closed | +| showFlagDialog | bool | shows the flag only in dialog | +| flagWidth | double | the width of the flags | +| flagDecoration | Decoration | used for styling the flags | +| comparator | Comparator | use this to sort the countries in the selection dialog | +| hideSearch | bool | if true the search feature will be disabled | ## Contributions diff --git a/example/lib/main.dart b/example/lib/main.dart index d0c2b136..a034f9dd 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -84,7 +84,9 @@ class _MyAppState extends State { Locale("ur"), Locale("uz"), Locale("vi"), - Locale("zh") + Locale("zh"), + Locale("zh", "CN"), + Locale("zh", "TW") ], localizationsDelegates: [ CountryLocalizations.delegate, diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index c979e12b..be9b20cf 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -4,7 +4,6 @@ import 'package:collection/collection.dart' show IterableExtension; import 'package:country_code_picker/country_code.dart'; import 'package:country_code_picker/country_codes.dart'; import 'package:country_code_picker/selection_dialog.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; import 'package:universal_platform/universal_platform.dart'; @@ -43,6 +42,8 @@ class CountryCodePicker extends StatefulWidget { /// Background color of selection dialog final Color? dialogBackgroundColor; + final Color? dialogBorderColor; + /// used to customize the country list final List? countryFilter; @@ -116,6 +117,7 @@ class CountryCodePicker extends StatefulWidget { this.showDropDownButton = false, this.dialogSize, this.dialogBackgroundColor, + this.dialogBorderColor, this.closeIcon = const Icon(Icons.close), this.countryList = codes, Key? key, @@ -199,8 +201,8 @@ class CountryCodePickerState extends State { widget.showOnlyCountryWhenClosed ? selectedItem!.toCountryStringOnly() : selectedItem.toString(), - style: - widget.textStyle ?? Theme.of(context).textTheme.button, + style: widget.textStyle ?? + Theme.of(context).textTheme.bodyMedium, overflow: widget.textOverflow, ), ), @@ -285,7 +287,6 @@ class CountryCodePickerState extends State { if (!UniversalPlatform.isAndroid && !UniversalPlatform.isIOS) { showDialog( barrierColor: widget.barrierColor ?? Colors.grey.withOpacity(0.5), - // backgroundColor: widget.backgroundColor ?? Colors.transparent, context: context, builder: (context) => Center( child: Container( @@ -306,6 +307,7 @@ class CountryCodePickerState extends State { flagWidth: widget.flagWidth, size: widget.dialogSize, backgroundColor: widget.dialogBackgroundColor, + borderColor: widget.dialogBorderColor, barrierColor: widget.barrierColor, hideSearch: widget.hideSearch, closeIcon: widget.closeIcon, diff --git a/lib/country_localizations.dart b/lib/country_localizations.dart index 3020f78e..373c3c2a 100644 --- a/lib/country_localizations.dart +++ b/lib/country_localizations.dart @@ -15,14 +15,15 @@ class CountryLocalizations { ); } - static const LocalizationsDelegate delegate = + static const _CountryLocalizationsDelegate delegate = _CountryLocalizationsDelegate(); late Map _localizedStrings; Future load() async { - String jsonString = await rootBundle.loadString( - 'packages/country_code_picker/i18n/${locale.languageCode}.json'); + String fileName = delegate.resolveLocale(locale); + String jsonString = await rootBundle + .loadString('packages/country_code_picker/i18n/$fileName.json'); Map jsonMap = json.decode(jsonString); _localizedStrings = jsonMap.map((key, value) { @@ -43,78 +44,22 @@ class _CountryLocalizationsDelegate @override bool isSupported(Locale locale) { - return [ - "af", - "am", - "ar", - "az", - "be", - "bg", - "bn", - "bs", - "ca", - "cs", - "da", - "de", - "el", - "en", - "es", - "et", - "fa", - "fi", - "fr", - "gl", - "ha", - "he", - "hi", - "hr", - "hu", - "hy", - "id", - "is", - "it", - "ja", - "ka", - "kk", - "km", - "ko", - "ku", - "ky", - "lt", - "lv", - "mk", - "ml", - "mn", - "ms", - "nb", - "nl", - "nn", - "no", - "pl", - "ps", - "pt", - "ro", - "ru", - "sd", - "sk", - "sl", - "so", - "sq", - "sr", - "sv", - "ta", - "tg", - "th", - "tk", - "tr", - "tt", - "uk", - "ug", - "ur", - "uz", - "vi", - "zh", - ].contains(locale.languageCode); + final codeWithCountry = '${locale.languageCode}' + + (locale.countryCode == null ? '' : '-${locale.countryCode}'); + return supportedLocales.contains(codeWithCountry) || + supportedLocales.contains(locale.languageCode); + } + + String resolveLocale(Locale locale) { + final codeWithCountry = '${locale.languageCode}' + + (locale.countryCode == null ? '' : '-${locale.countryCode}'); + if (supportedLocales.contains(codeWithCountry)) { + return codeWithCountry; + } + if (supportedLocales.contains(locale.languageCode)) { + return locale.languageCode; + } + return "en"; } @override @@ -126,4 +71,79 @@ class _CountryLocalizationsDelegate @override bool shouldReload(_CountryLocalizationsDelegate old) => false; + + static const supportedLocales = [ + "af", + "am", + "ar", + "az", + "be", + "bg", + "bn", + "bs", + "ca", + "cs", + "da", + "de", + "el", + "en", + "es", + "et", + "fa", + "fi", + "fr", + "gl", + "ha", + "he", + "hi", + "hr", + "hu", + "hy", + "id", + "is", + "it", + "ja", + "ka", + "kk", + "km", + "ko", + "ku", + "ky", + "lt", + "lv", + "mk", + "ml", + "mn", + "ms", + "nb", + "nl", + "nn", + "no", + "pl", + "ps", + "pt", + "ro", + "ru", + "sd", + "sk", + "sl", + "so", + "sq", + "sr", + "sv", + "ta", + "tg", + "th", + "tk", + "tr", + "tt", + "uk", + "ug", + "ur", + "uz", + "vi", + "zh", + "zh-CN", + "zh-TW", + ]; } diff --git a/lib/i18n/zh-CN.json b/lib/i18n/zh-CN.json new file mode 100644 index 00000000..93abba2a --- /dev/null +++ b/lib/i18n/zh-CN.json @@ -0,0 +1,252 @@ +{ + "AD": "安道尔", + "AE": "阿联酋", + "AF": "阿富汗", + "AG": "安提瓜和巴布达", + "AI": "安圭拉", + "AL": "阿尔巴尼亚", + "AM": "亚美尼亚", + "AO": "安哥拉", + "AQ": "南极洲", + "AR": "阿根廷", + "AS": "美属萨摩亚", + "AT": "奥地利", + "AU": "澳大利亚", + "AW": "阿鲁巴", + "AX": "奥兰", + "AZ": "阿塞拜疆", + "BA": "波黑", + "BB": "巴巴多斯", + "BD": "孟加拉国", + "BE": "比利时", + "BF": "布基纳法索", + "BG": "保加利亚", + "BH": "巴林", + "BI": "布隆迪", + "BJ": "贝宁", + "BL": "圣巴泰勒米", + "BM": "百慕大", + "BN": "文莱", + "BO": "玻利维亚", + "BQ": "荷兰加勒比区", + "BR": "巴西", + "BS": "巴哈马", + "BT": "不丹", + "BV": "布韦岛", + "BW": "博茨瓦纳", + "BY": "白俄罗斯", + "BZ": "伯利兹", + "CA": "加拿大", + "CC": "科科斯(基林)群岛", + "CD": "刚果(金)", + "CF": "中非", + "CG": "刚果(布)", + "CH": "瑞士", + "CI": "科特迪瓦", + "CK": "库克群岛", + "CL": "智利", + "CM": "喀麦隆", + "CN": "中国", + "CO": "哥伦比亚", + "CR": "哥斯达黎加", + "CU": "古巴", + "CV": "佛得角", + "CW": "库拉索", + "CX": "圣诞岛", + "CY": "塞浦路斯", + "CZ": "捷克", + "DE": "德国", + "DJ": "吉布提", + "DK": "丹麦", + "DM": "多米尼克", + "DO": "多米尼加", + "DZ": "阿尔及利亚", + "EC": "厄瓜多尔", + "EE": "爱沙尼亚", + "EG": "埃及", + "EH": "阿拉伯撒哈拉民主共和国", + "ER": "厄立特里亚", + "ES": "西班牙", + "ET": "埃塞俄比亚", + "FI": "芬兰", + "FJ": "斐济", + "FK": "福克兰群岛", + "FM": "密克罗尼西亚联邦", + "FO": "法罗群岛", + "FR": "法国", + "GA": "加蓬", + "GB": "英国", + "GD": "格林纳达", + "GE": "格鲁吉亚", + "GF": "法属圭亚那", + "GG": "根西", + "GH": "加纳", + "GI": "直布罗陀", + "GL": "格陵兰", + "GM": "冈比亚", + "GN": "几内亚", + "GP": "瓜德罗普", + "GQ": "赤道几内亚", + "GR": "希腊", + "GS": "南乔治亚和南桑威奇群岛", + "GT": "危地马拉", + "GU": "关岛", + "GW": "几内亚比绍", + "GY": "圭亚那", + "HK": "香港", + "HM": "赫德岛和麦克唐纳群岛", + "HN": "洪都拉斯", + "HR": "克罗地亚", + "HT": "海地", + "HU": "匈牙利", + "ID": "印尼", + "IE": "爱尔兰", + "IL": "以色列", + "IM": "马恩岛", + "IN": "印度", + "IO": "英属印度洋领地", + "IQ": "伊拉克", + "IR": "伊朗", + "IS": "冰岛", + "IT": "意大利", + "JE": "泽西", + "JM": "牙买加", + "JO": "约旦", + "JP": "日本", + "KE": "肯尼亚", + "KG": "吉尔吉斯斯坦", + "KH": "柬埔寨", + "KI": "基里巴斯", + "KM": "科摩罗", + "KN": "圣基茨和尼维斯", + "KP": "朝鲜", + "KR": "韩国", + "KW": "科威特", + "KY": "开曼群岛", + "KZ": "哈萨克斯坦", + "LA": "老挝", + "LB": "黎巴嫩", + "LC": "圣卢西亚", + "LI": "列支敦士登", + "LK": "斯里兰卡", + "LR": "利比里亚", + "LS": "莱索托", + "LT": "立陶宛", + "LU": "卢森堡", + "LV": "拉脱维亚", + "LY": "利比亚", + "MA": "摩洛哥", + "MC": "摩纳哥", + "MD": "摩尔多瓦", + "ME": "黑山", + "MF": "法属圣马丁", + "MG": "马达加斯加", + "MH": "马绍尔群岛", + "MK": "北马其顿", + "ML": "马里", + "MM": "缅甸", + "MN": "蒙古", + "MO": "澳门", + "MP": "北马里亚纳群岛", + "MQ": "马提尼克", + "MR": "毛里塔尼亚", + "MS": "蒙特塞拉特", + "MT": "马耳他", + "MU": "毛里求斯", + "MV": "马尔代夫", + "MW": "马拉维", + "MX": "墨西哥", + "MY": "马来西亚", + "MZ": "莫桑比克", + "NA": "纳米比亚", + "NC": "新喀里多尼亚", + "NE": "尼日尔", + "NF": "诺福克岛", + "NG": "尼日利亚", + "NI": "尼加拉瓜", + "NL": "荷兰", + "NO": "挪威", + "NP": "尼泊尔", + "NR": "瑙鲁", + "NU": "纽埃", + "NZ": "新西兰", + "OM": "阿曼", + "PA": "巴拿马", + "PE": "秘鲁", + "PF": "法属波利尼西亚", + "PG": "巴布亚新几内亚", + "PH": "菲律宾", + "PK": "巴基斯坦", + "PL": "波兰", + "PM": "圣皮埃尔和密克隆", + "PN": "皮特凯恩群岛", + "PR": "波多黎各", + "PS": "巴勒斯坦", + "PT": "葡萄牙", + "PW": "帕劳", + "PY": "巴拉圭", + "QA": "卡塔尔", + "RE": "留尼汪", + "RO": "罗马尼亚", + "RS": "塞尔维亚", + "RU": "俄罗斯", + "RW": "卢旺达", + "SA": "沙特阿拉伯", + "SB": "所罗门群岛", + "SC": "塞舌尔", + "SD": "苏丹", + "SE": "瑞典", + "SG": "新加坡", + "SH": "圣赫勒拿、阿森松和特里斯坦-达库尼亚", + "SI": "斯洛文尼亚", + "SJ": "斯瓦尔巴和扬马延", + "SK": "斯洛伐克", + "SL": "塞拉利昂", + "SM": "圣马力诺", + "SN": "塞内加尔", + "SO": "索马里", + "SR": "苏里南", + "SS": "南苏丹", + "ST": "圣多美和普林西比", + "SV": "萨尔瓦多", + "SX": "荷属圣马丁", + "SY": "叙利亚", + "SZ": "斯威士兰", + "TC": "特克斯和凯科斯群岛", + "TD": "乍得", + "TF": "法属南部领地", + "TG": "多哥", + "TH": "泰国", + "TJ": "塔吉克斯坦", + "TK": "托克劳", + "TL": "东帝汶", + "TM": "土库曼斯坦", + "TN": "突尼斯", + "TO": "汤加", + "TR": "土耳其", + "TT": "特立尼达和多巴哥", + "TV": "图瓦卢", + "TW": "中国台湾省", + "TZ": "坦桑尼亚", + "UA": "乌克兰", + "UG": "乌干达", + "UM": "美国本土外小岛屿", + "US": "美国", + "UY": "乌拉圭", + "UZ": "乌兹别克斯坦", + "VA": "梵蒂冈", + "VC": "圣文森特和格林纳丁斯", + "VE": "委内瑞拉", + "VG": "英属维尔京群岛", + "VI": "美属维尔京群岛", + "VN": "越南", + "VU": "瓦努阿图", + "WF": "瓦利斯和富图纳", + "WS": "萨摩亚", + "XK": "科索沃", + "YE": "也门", + "YT": "马约特", + "ZA": "南非", + "ZM": "赞比亚", + "ZW": "津巴布韦" +} \ No newline at end of file diff --git a/lib/i18n/zh-TW.json b/lib/i18n/zh-TW.json new file mode 100644 index 00000000..5d347144 --- /dev/null +++ b/lib/i18n/zh-TW.json @@ -0,0 +1,252 @@ +{ + "AD": "安道爾", + "AE": "阿拉伯聯合大公國", + "AF": "阿富汗", + "AG": "安地卡及巴布達", + "AI": "安圭拉", + "AL": "阿爾巴尼亞", + "AM": "亞美尼亞", + "AO": "安哥拉", + "AQ": "南極洲", + "AR": "阿根廷", + "AS": "美屬薩摩亞", + "AT": "奧地利", + "AU": "澳大利亞", + "AW": "阿魯巴", + "AX": "奧蘭", + "AZ": "亞塞拜然", + "BA": "波士尼亞與赫塞哥維納", + "BB": "巴貝多", + "BD": "孟加拉", + "BE": "比利時", + "BF": "布吉納法索", + "BG": "保加利亞", + "BH": "巴林", + "BI": "蒲隆地", + "BJ": "貝南", + "BL": "聖巴泰勒米", + "BM": "百慕達", + "BN": "汶萊", + "BO": "玻利維亞", + "BQ": "荷蘭加勒比區", + "BR": "巴西", + "BS": "巴哈馬", + "BT": "不丹", + "BV": "布威島", + "BW": "波札那", + "BY": "白俄羅斯", + "BZ": "貝里斯", + "CA": "加拿大", + "CC": "科科斯(基林)群島", + "CD": "民主剛果", + "CF": "中非共和國", + "CG": "剛果共和國", + "CH": "瑞士", + "CI": "象牙海岸", + "CK": "庫克群島", + "CL": "智利", + "CM": "喀麥隆", + "CN": "中國", + "CO": "哥倫比亞", + "CR": "哥斯大黎加", + "CU": "古巴", + "CV": "維德角", + "CW": "古拉索", + "CX": "聖誕島", + "CY": "賽普勒斯", + "CZ": "捷克", + "DE": "德國", + "DJ": "吉布提", + "DK": "丹麥", + "DM": "多米尼克", + "DO": "多明尼加", + "DZ": "阿爾及利亞", + "EC": "厄瓜多爾", + "EE": "愛沙尼亞", + "EG": "埃及", + "EH": "西撒哈拉", + "ER": "厄利垂亞", + "ES": "西班牙", + "ET": "衣索比亞", + "FI": "芬蘭", + "FJ": "斐濟", + "FK": "福克蘭群島", + "FM": "密克羅尼西亞聯邦", + "FO": "法羅群島", + "FR": "法國", + "GA": "加彭", + "GB": "英國", + "GD": "格瑞那達", + "GE": "喬治亞", + "GF": "法屬圭亞那", + "GG": "耿西", + "GH": "迦納", + "GI": "直布羅陀", + "GL": "格陵蘭", + "GM": "甘比亞", + "GN": "幾內亞", + "GP": "瓜地洛普", + "GQ": "赤道幾內亞", + "GR": "希臘", + "GS": "南喬治亞與南桑威奇", + "GT": "瓜地馬拉", + "GU": "關島", + "GW": "幾內亞比索", + "GY": "蓋亞那", + "HK": "香港", + "HM": "赫德島和麥克唐納群島", + "HN": "洪都拉斯", + "HR": "克羅埃西亞", + "HT": "海地", + "HU": "匈牙利", + "ID": "印度尼西亞", + "IE": "愛爾蘭", + "IL": "以色列", + "IM": "曼島", + "IN": "印度", + "IO": "英屬印度洋領地", + "IQ": "伊拉克", + "IR": "伊朗", + "IS": "冰島", + "IT": "義大利", + "JE": "澤西", + "JM": "牙買加", + "JO": "約旦", + "JP": "日本", + "KE": "肯亞", + "KG": "吉爾吉斯", + "KH": "柬埔寨", + "KI": "吉里巴斯", + "KM": "葛摩", + "KN": "聖克里斯多福及尼維斯", + "KP": "朝鮮", + "KR": "大韓民國", + "KW": "科威特", + "KY": "開曼群島", + "KZ": "哈薩克", + "LA": "寮國", + "LB": "黎巴嫩", + "LC": "聖露西亞", + "LI": "列支敦斯登", + "LK": "斯里蘭卡", + "LR": "賴比瑞亞", + "LS": "賴索托", + "LT": "立陶宛", + "LU": "盧森堡", + "LV": "拉脫維亞", + "LY": "利比亞", + "MA": "摩洛哥", + "MC": "摩納哥", + "MD": "摩爾多瓦", + "ME": "蒙特內哥羅", + "MF": "法屬聖馬丁", + "MG": "馬達加斯加", + "MH": "馬紹爾群島", + "MK": "北馬其頓", + "ML": "馬利", + "MM": "緬甸", + "MN": "蒙古", + "MO": "澳門", + "MP": "北馬里亞納群島", + "MQ": "馬丁尼克", + "MR": "茅利塔尼亞", + "MS": "蒙哲臘", + "MT": "馬爾他", + "MU": "模里西斯", + "MV": "馬爾地夫", + "MW": "馬拉威", + "MX": "墨西哥", + "MY": "馬來西亞", + "MZ": "莫三比克", + "NA": "納米比亞", + "NC": "新喀里多尼亞", + "NE": "尼日爾", + "NF": "諾福克島", + "NG": "奈及利亞", + "NI": "尼加拉瓜", + "NL": "荷蘭", + "NO": "挪威", + "NP": "尼泊爾", + "NR": "諾魯", + "NU": "紐埃", + "NZ": "紐西蘭", + "OM": "阿曼", + "PA": "巴拿馬", + "PE": "秘魯", + "PF": "法屬玻里尼西亞", + "PG": "巴布亞紐幾內亞", + "PH": "菲律賓", + "PK": "巴基斯坦", + "PL": "波蘭", + "PM": "聖皮耶與密克隆", + "PN": "皮特肯群島", + "PR": "波多黎各", + "PS": "巴勒斯坦", + "PT": "葡萄牙", + "PW": "帛琉", + "PY": "巴拉圭", + "QA": "卡達", + "RE": "留尼旺", + "RO": "羅馬尼亞", + "RS": "塞爾維亞", + "RU": "俄羅斯", + "RW": "盧安達", + "SA": "沙烏地阿拉伯", + "SB": "索羅門群島", + "SC": "塞席爾", + "SD": "蘇丹", + "SE": "瑞典", + "SG": "新加坡", + "SH": "聖赫勒拿、亞森欣與垂斯坦昆哈", + "SI": "斯洛維尼亞", + "SJ": "斯瓦巴和揚馬延", + "SK": "斯洛伐克", + "SL": "獅子山", + "SM": "聖馬利諾", + "SN": "塞內加爾", + "SO": "索馬里", + "SR": "蘇利南", + "SS": "南蘇丹", + "ST": "聖多美普林西比", + "SV": "薩爾瓦多", + "SX": "荷屬聖馬丁", + "SY": "敘利亞", + "SZ": "史瓦帝尼", + "TC": "土克凱可群島", + "TD": "查德", + "TF": "法屬南部和南極領地", + "TG": "多哥", + "TH": "泰國", + "TJ": "塔吉克", + "TK": "托克勞", + "TL": "東帝汶", + "TM": "土庫曼斯坦", + "TN": "突尼西亞", + "TO": "東加", + "TR": "土耳其", + "TT": "千里達及托巴哥", + "TV": "吐瓦魯", + "TW": "臺灣", + "TZ": "坦尚尼亞", + "UA": "烏克蘭", + "UG": "烏干達", + "UM": "美國本土外小島嶼", + "US": "美國", + "UY": "烏拉圭", + "UZ": "烏茲別克", + "VA": "梵蒂岡", + "VC": "聖文森及格瑞那丁", + "VE": "委內瑞拉", + "VG": "英屬維京群島", + "VI": "美屬維京群島", + "VN": "越南", + "VU": "萬那杜", + "WF": "瓦利斯和富圖納", + "WS": "薩摩亞", + "XK": "科索沃", + "YE": "葉門", + "YT": "馬約特", + "ZA": "南非", + "ZM": "尚比亞", + "ZW": "辛巴威" +} diff --git a/lib/i18n/zh.json b/lib/i18n/zh.json index 93abba2a..5d347144 100644 --- a/lib/i18n/zh.json +++ b/lib/i18n/zh.json @@ -1,252 +1,252 @@ { - "AD": "安道尔", - "AE": "阿联酋", + "AD": "安道爾", + "AE": "阿拉伯聯合大公國", "AF": "阿富汗", - "AG": "安提瓜和巴布达", + "AG": "安地卡及巴布達", "AI": "安圭拉", - "AL": "阿尔巴尼亚", - "AM": "亚美尼亚", + "AL": "阿爾巴尼亞", + "AM": "亞美尼亞", "AO": "安哥拉", - "AQ": "南极洲", + "AQ": "南極洲", "AR": "阿根廷", - "AS": "美属萨摩亚", - "AT": "奥地利", - "AU": "澳大利亚", - "AW": "阿鲁巴", - "AX": "奥兰", - "AZ": "阿塞拜疆", - "BA": "波黑", - "BB": "巴巴多斯", - "BD": "孟加拉国", - "BE": "比利时", - "BF": "布基纳法索", - "BG": "保加利亚", + "AS": "美屬薩摩亞", + "AT": "奧地利", + "AU": "澳大利亞", + "AW": "阿魯巴", + "AX": "奧蘭", + "AZ": "亞塞拜然", + "BA": "波士尼亞與赫塞哥維納", + "BB": "巴貝多", + "BD": "孟加拉", + "BE": "比利時", + "BF": "布吉納法索", + "BG": "保加利亞", "BH": "巴林", - "BI": "布隆迪", - "BJ": "贝宁", - "BL": "圣巴泰勒米", - "BM": "百慕大", - "BN": "文莱", - "BO": "玻利维亚", - "BQ": "荷兰加勒比区", + "BI": "蒲隆地", + "BJ": "貝南", + "BL": "聖巴泰勒米", + "BM": "百慕達", + "BN": "汶萊", + "BO": "玻利維亞", + "BQ": "荷蘭加勒比區", "BR": "巴西", - "BS": "巴哈马", + "BS": "巴哈馬", "BT": "不丹", - "BV": "布韦岛", - "BW": "博茨瓦纳", - "BY": "白俄罗斯", - "BZ": "伯利兹", + "BV": "布威島", + "BW": "波札那", + "BY": "白俄羅斯", + "BZ": "貝里斯", "CA": "加拿大", - "CC": "科科斯(基林)群岛", - "CD": "刚果(金)", - "CF": "中非", - "CG": "刚果(布)", + "CC": "科科斯(基林)群島", + "CD": "民主剛果", + "CF": "中非共和國", + "CG": "剛果共和國", "CH": "瑞士", - "CI": "科特迪瓦", - "CK": "库克群岛", + "CI": "象牙海岸", + "CK": "庫克群島", "CL": "智利", - "CM": "喀麦隆", - "CN": "中国", - "CO": "哥伦比亚", - "CR": "哥斯达黎加", + "CM": "喀麥隆", + "CN": "中國", + "CO": "哥倫比亞", + "CR": "哥斯大黎加", "CU": "古巴", - "CV": "佛得角", - "CW": "库拉索", - "CX": "圣诞岛", - "CY": "塞浦路斯", + "CV": "維德角", + "CW": "古拉索", + "CX": "聖誕島", + "CY": "賽普勒斯", "CZ": "捷克", - "DE": "德国", + "DE": "德國", "DJ": "吉布提", - "DK": "丹麦", + "DK": "丹麥", "DM": "多米尼克", - "DO": "多米尼加", - "DZ": "阿尔及利亚", - "EC": "厄瓜多尔", - "EE": "爱沙尼亚", + "DO": "多明尼加", + "DZ": "阿爾及利亞", + "EC": "厄瓜多爾", + "EE": "愛沙尼亞", "EG": "埃及", - "EH": "阿拉伯撒哈拉民主共和国", - "ER": "厄立特里亚", + "EH": "西撒哈拉", + "ER": "厄利垂亞", "ES": "西班牙", - "ET": "埃塞俄比亚", - "FI": "芬兰", - "FJ": "斐济", - "FK": "福克兰群岛", - "FM": "密克罗尼西亚联邦", - "FO": "法罗群岛", - "FR": "法国", - "GA": "加蓬", - "GB": "英国", - "GD": "格林纳达", - "GE": "格鲁吉亚", - "GF": "法属圭亚那", - "GG": "根西", - "GH": "加纳", - "GI": "直布罗陀", - "GL": "格陵兰", - "GM": "冈比亚", - "GN": "几内亚", - "GP": "瓜德罗普", - "GQ": "赤道几内亚", - "GR": "希腊", - "GS": "南乔治亚和南桑威奇群岛", - "GT": "危地马拉", - "GU": "关岛", - "GW": "几内亚比绍", - "GY": "圭亚那", + "ET": "衣索比亞", + "FI": "芬蘭", + "FJ": "斐濟", + "FK": "福克蘭群島", + "FM": "密克羅尼西亞聯邦", + "FO": "法羅群島", + "FR": "法國", + "GA": "加彭", + "GB": "英國", + "GD": "格瑞那達", + "GE": "喬治亞", + "GF": "法屬圭亞那", + "GG": "耿西", + "GH": "迦納", + "GI": "直布羅陀", + "GL": "格陵蘭", + "GM": "甘比亞", + "GN": "幾內亞", + "GP": "瓜地洛普", + "GQ": "赤道幾內亞", + "GR": "希臘", + "GS": "南喬治亞與南桑威奇", + "GT": "瓜地馬拉", + "GU": "關島", + "GW": "幾內亞比索", + "GY": "蓋亞那", "HK": "香港", - "HM": "赫德岛和麦克唐纳群岛", + "HM": "赫德島和麥克唐納群島", "HN": "洪都拉斯", - "HR": "克罗地亚", + "HR": "克羅埃西亞", "HT": "海地", "HU": "匈牙利", - "ID": "印尼", - "IE": "爱尔兰", + "ID": "印度尼西亞", + "IE": "愛爾蘭", "IL": "以色列", - "IM": "马恩岛", + "IM": "曼島", "IN": "印度", - "IO": "英属印度洋领地", + "IO": "英屬印度洋領地", "IQ": "伊拉克", "IR": "伊朗", - "IS": "冰岛", - "IT": "意大利", - "JE": "泽西", - "JM": "牙买加", - "JO": "约旦", + "IS": "冰島", + "IT": "義大利", + "JE": "澤西", + "JM": "牙買加", + "JO": "約旦", "JP": "日本", - "KE": "肯尼亚", - "KG": "吉尔吉斯斯坦", + "KE": "肯亞", + "KG": "吉爾吉斯", "KH": "柬埔寨", - "KI": "基里巴斯", - "KM": "科摩罗", - "KN": "圣基茨和尼维斯", - "KP": "朝鲜", - "KR": "韩国", + "KI": "吉里巴斯", + "KM": "葛摩", + "KN": "聖克里斯多福及尼維斯", + "KP": "朝鮮", + "KR": "大韓民國", "KW": "科威特", - "KY": "开曼群岛", - "KZ": "哈萨克斯坦", - "LA": "老挝", + "KY": "開曼群島", + "KZ": "哈薩克", + "LA": "寮國", "LB": "黎巴嫩", - "LC": "圣卢西亚", - "LI": "列支敦士登", - "LK": "斯里兰卡", - "LR": "利比里亚", - "LS": "莱索托", + "LC": "聖露西亞", + "LI": "列支敦斯登", + "LK": "斯里蘭卡", + "LR": "賴比瑞亞", + "LS": "賴索托", "LT": "立陶宛", - "LU": "卢森堡", - "LV": "拉脱维亚", - "LY": "利比亚", + "LU": "盧森堡", + "LV": "拉脫維亞", + "LY": "利比亞", "MA": "摩洛哥", - "MC": "摩纳哥", - "MD": "摩尔多瓦", - "ME": "黑山", - "MF": "法属圣马丁", - "MG": "马达加斯加", - "MH": "马绍尔群岛", - "MK": "北马其顿", - "ML": "马里", - "MM": "缅甸", + "MC": "摩納哥", + "MD": "摩爾多瓦", + "ME": "蒙特內哥羅", + "MF": "法屬聖馬丁", + "MG": "馬達加斯加", + "MH": "馬紹爾群島", + "MK": "北馬其頓", + "ML": "馬利", + "MM": "緬甸", "MN": "蒙古", - "MO": "澳门", - "MP": "北马里亚纳群岛", - "MQ": "马提尼克", - "MR": "毛里塔尼亚", - "MS": "蒙特塞拉特", - "MT": "马耳他", - "MU": "毛里求斯", - "MV": "马尔代夫", - "MW": "马拉维", + "MO": "澳門", + "MP": "北馬里亞納群島", + "MQ": "馬丁尼克", + "MR": "茅利塔尼亞", + "MS": "蒙哲臘", + "MT": "馬爾他", + "MU": "模里西斯", + "MV": "馬爾地夫", + "MW": "馬拉威", "MX": "墨西哥", - "MY": "马来西亚", - "MZ": "莫桑比克", - "NA": "纳米比亚", - "NC": "新喀里多尼亚", - "NE": "尼日尔", - "NF": "诺福克岛", - "NG": "尼日利亚", + "MY": "馬來西亞", + "MZ": "莫三比克", + "NA": "納米比亞", + "NC": "新喀里多尼亞", + "NE": "尼日爾", + "NF": "諾福克島", + "NG": "奈及利亞", "NI": "尼加拉瓜", - "NL": "荷兰", + "NL": "荷蘭", "NO": "挪威", - "NP": "尼泊尔", - "NR": "瑙鲁", - "NU": "纽埃", - "NZ": "新西兰", + "NP": "尼泊爾", + "NR": "諾魯", + "NU": "紐埃", + "NZ": "紐西蘭", "OM": "阿曼", - "PA": "巴拿马", - "PE": "秘鲁", - "PF": "法属波利尼西亚", - "PG": "巴布亚新几内亚", - "PH": "菲律宾", + "PA": "巴拿馬", + "PE": "秘魯", + "PF": "法屬玻里尼西亞", + "PG": "巴布亞紐幾內亞", + "PH": "菲律賓", "PK": "巴基斯坦", - "PL": "波兰", - "PM": "圣皮埃尔和密克隆", - "PN": "皮特凯恩群岛", + "PL": "波蘭", + "PM": "聖皮耶與密克隆", + "PN": "皮特肯群島", "PR": "波多黎各", "PS": "巴勒斯坦", "PT": "葡萄牙", - "PW": "帕劳", + "PW": "帛琉", "PY": "巴拉圭", - "QA": "卡塔尔", - "RE": "留尼汪", - "RO": "罗马尼亚", - "RS": "塞尔维亚", - "RU": "俄罗斯", - "RW": "卢旺达", - "SA": "沙特阿拉伯", - "SB": "所罗门群岛", - "SC": "塞舌尔", - "SD": "苏丹", + "QA": "卡達", + "RE": "留尼旺", + "RO": "羅馬尼亞", + "RS": "塞爾維亞", + "RU": "俄羅斯", + "RW": "盧安達", + "SA": "沙烏地阿拉伯", + "SB": "索羅門群島", + "SC": "塞席爾", + "SD": "蘇丹", "SE": "瑞典", "SG": "新加坡", - "SH": "圣赫勒拿、阿森松和特里斯坦-达库尼亚", - "SI": "斯洛文尼亚", - "SJ": "斯瓦尔巴和扬马延", + "SH": "聖赫勒拿、亞森欣與垂斯坦昆哈", + "SI": "斯洛維尼亞", + "SJ": "斯瓦巴和揚馬延", "SK": "斯洛伐克", - "SL": "塞拉利昂", - "SM": "圣马力诺", - "SN": "塞内加尔", - "SO": "索马里", - "SR": "苏里南", - "SS": "南苏丹", - "ST": "圣多美和普林西比", - "SV": "萨尔瓦多", - "SX": "荷属圣马丁", - "SY": "叙利亚", - "SZ": "斯威士兰", - "TC": "特克斯和凯科斯群岛", - "TD": "乍得", - "TF": "法属南部领地", + "SL": "獅子山", + "SM": "聖馬利諾", + "SN": "塞內加爾", + "SO": "索馬里", + "SR": "蘇利南", + "SS": "南蘇丹", + "ST": "聖多美普林西比", + "SV": "薩爾瓦多", + "SX": "荷屬聖馬丁", + "SY": "敘利亞", + "SZ": "史瓦帝尼", + "TC": "土克凱可群島", + "TD": "查德", + "TF": "法屬南部和南極領地", "TG": "多哥", - "TH": "泰国", - "TJ": "塔吉克斯坦", - "TK": "托克劳", - "TL": "东帝汶", - "TM": "土库曼斯坦", - "TN": "突尼斯", - "TO": "汤加", + "TH": "泰國", + "TJ": "塔吉克", + "TK": "托克勞", + "TL": "東帝汶", + "TM": "土庫曼斯坦", + "TN": "突尼西亞", + "TO": "東加", "TR": "土耳其", - "TT": "特立尼达和多巴哥", - "TV": "图瓦卢", - "TW": "中国台湾省", - "TZ": "坦桑尼亚", - "UA": "乌克兰", - "UG": "乌干达", - "UM": "美国本土外小岛屿", - "US": "美国", - "UY": "乌拉圭", - "UZ": "乌兹别克斯坦", - "VA": "梵蒂冈", - "VC": "圣文森特和格林纳丁斯", - "VE": "委内瑞拉", - "VG": "英属维尔京群岛", - "VI": "美属维尔京群岛", + "TT": "千里達及托巴哥", + "TV": "吐瓦魯", + "TW": "臺灣", + "TZ": "坦尚尼亞", + "UA": "烏克蘭", + "UG": "烏干達", + "UM": "美國本土外小島嶼", + "US": "美國", + "UY": "烏拉圭", + "UZ": "烏茲別克", + "VA": "梵蒂岡", + "VC": "聖文森及格瑞那丁", + "VE": "委內瑞拉", + "VG": "英屬維京群島", + "VI": "美屬維京群島", "VN": "越南", - "VU": "瓦努阿图", - "WF": "瓦利斯和富图纳", - "WS": "萨摩亚", + "VU": "萬那杜", + "WF": "瓦利斯和富圖納", + "WS": "薩摩亞", "XK": "科索沃", - "YE": "也门", - "YT": "马约特", + "YE": "葉門", + "YT": "馬約特", "ZA": "南非", - "ZM": "赞比亚", - "ZW": "津巴布韦" -} \ No newline at end of file + "ZM": "尚比亞", + "ZW": "辛巴威" +} diff --git a/lib/selection_dialog.dart b/lib/selection_dialog.dart index 176d0ee2..58e41c04 100644 --- a/lib/selection_dialog.dart +++ b/lib/selection_dialog.dart @@ -24,6 +24,8 @@ class SelectionDialog extends StatefulWidget { /// Boxshaow color of SelectionDialog that matches CountryCodePicker barrier color final Color? barrierColor; + final Color? borderColor; + /// elements passed as favorite final List favoriteElements; @@ -43,6 +45,7 @@ class SelectionDialog extends StatefulWidget { this.size, this.backgroundColor, this.barrierColor, + this.borderColor, this.hideSearch = false, this.closeIcon, }) : this.searchDecoration = searchDecoration.prefixIcon == null @@ -69,15 +72,11 @@ class _SelectionDialogState extends State { decoration: widget.boxDecoration ?? BoxDecoration( color: widget.backgroundColor ?? Colors.white, + border: Border.all( + width: 3.0, + color: widget.borderColor ?? Colors.transparent, + ), borderRadius: BorderRadius.all(Radius.circular(8.0)), - boxShadow: [ - BoxShadow( - color: widget.barrierColor ?? Colors.grey.withOpacity(1), - spreadRadius: 5, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], ), child: Column( mainAxisSize: MainAxisSize.min, diff --git a/pubspec.yaml b/pubspec.yaml index b0c5ab80..54ff07a3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: country_code_picker -description: A flutter package for showing a country code selector. In addition it gives the possibility to select a list of favorites countries, as well as to search using a simple searchbox +description: A flutter package for showing a country code selector. In addition it gives the possibility to select a list of favorites countries, as well as to search using a simple searchbox version: 2.0.2 homepage: https://github.com/imtoori/CountryCodePicker @@ -87,3 +87,5 @@ flutter: - packages/country_code_picker/i18n/uk.json - packages/country_code_picker/i18n/uz.json - packages/country_code_picker/i18n/zh.json + - packages/country_code_picker/i18n/zh-CN.json + - packages/country_code_picker/i18n/zh-TW.json