123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- import 'package:photo/src/entity/options.dart';
- import 'package:photo/src/provider/selected_provider.dart';
-
- abstract class I18nProvider {
- const I18nProvider._();
-
- String getTitleText(Options options);
-
- String getCancelText(Options options);
-
- String getSureText(Options options, int currentCount);
-
- String getPreviewText(Options options, SelectedProvider selectedProvider);
-
- String getSelectedOptionsText(Options options);
-
- String getFullImageText(Options options);
-
- String getMaxTipText(Options options);
-
- String getAllGalleryText(Options options);
-
- String loadingText() {
- return "Loading...";
- }
-
- I18NPermissionProvider getNotPermissionText([Options options]);
-
- static const I18nProvider chinese = CNProvider();
-
- static const I18nProvider english = ENProvider();
- }
-
- class CNProvider extends I18nProvider {
- const CNProvider() : super._();
-
- @override
- String getTitleText(Options options) {
- return "图片选择";
- }
-
- @override
- String getPreviewText(Options options, SelectedProvider selectedProvider) {
- return "预览(${selectedProvider.selectedCount})";
- }
-
- @override
- String getCancelText(Options options) {
- return "取消";
- }
-
- @override
- String getSureText(Options options, int currentCount) {
- return "确定($currentCount/${options.maxSelected})";
- }
-
- @override
- String getSelectedOptionsText(Options options) {
- return "选择";
- }
-
- @override
- String getFullImageText(Options options) {
- return "原图";
- }
-
- @override
- String getMaxTipText(Options options) {
- return "您已经选择了${options.maxSelected}张图片";
- }
-
- @override
- String getAllGalleryText(Options options) {
- return "全部图片";
- }
-
- @override
- String loadingText() {
- return "加载中...";
- }
-
- @override
- I18NPermissionProvider getNotPermissionText([Options options]) {
- return I18NPermissionProvider(
- cancelText: "取消", sureText: "去开启", titleText: "没有访问相册的权限");
- }
- }
-
- class ENProvider extends I18nProvider {
- const ENProvider() : super._();
-
- @override
- String getTitleText(Options options) {
- return "Image Picker";
- }
-
- @override
- String getPreviewText(Options options, SelectedProvider selectedProvider) {
- return "Preview (${selectedProvider.selectedCount})";
- }
-
- @override
- String getCancelText(Options options) {
- return "Cancel";
- }
-
- @override
- String getSureText(Options options, int currentCount) {
- return "Confirm ($currentCount/${options.maxSelected})";
- }
-
- @override
- String getSelectedOptionsText(Options options) {
- return "Selected";
- }
-
- @override
- String getFullImageText(Options options) {
- return "Full image";
- }
-
- @override
- String getMaxTipText(Options options) {
- return "Select ${options.maxSelected} pictures at most";
- }
-
- @override
- String getAllGalleryText(Options options) {
- return "All";
- }
-
- @override
- I18NPermissionProvider getNotPermissionText([Options options]) {
- return I18NPermissionProvider(
- cancelText: "Cancel",
- sureText: "Allow",
- titleText: "No permission to access gallery");
- }
- }
-
- abstract class I18NCustomProvider implements I18nProvider {
- final String maxTipText;
- final String previewText;
- final String selectedOptionsText;
- final String sureText;
- final String titleText;
- final I18NPermissionProvider notPermissionText;
-
- I18NCustomProvider(
- this.maxTipText,
- this.previewText,
- this.selectedOptionsText,
- this.sureText,
- this.titleText,
- this.notPermissionText);
-
- @override
- String getMaxTipText(Options options) {
- return maxTipText;
- }
-
- @override
- String getSelectedOptionsText(Options options) {
- return selectedOptionsText;
- }
-
- @override
- String getTitleText(Options options) {
- return titleText;
- }
-
- @override
- I18NPermissionProvider getNotPermissionText([Options options]) {
- return notPermissionText;
- }
- }
-
- class I18NPermissionProvider {
- final String titleText;
- final String sureText;
- final String cancelText;
-
- const I18NPermissionProvider(
- {this.titleText, this.sureText, this.cancelText});
- }
|