No Description

i18n_provider.dart 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. import 'package:photo/src/entity/options.dart';
  2. import 'package:photo/src/provider/selected_provider.dart';
  3. abstract class I18nProvider {
  4. const I18nProvider._();
  5. String getTitleText(Options options);
  6. String getCancelText(Options options);
  7. String getSureText(Options options, int currentCount);
  8. String getPreviewText(Options options, SelectedProvider selectedProvider);
  9. String getSelectedOptionsText(Options options);
  10. String getFullImageText(Options options);
  11. String getMaxTipText(Options options);
  12. String getAllGalleryText(Options options);
  13. String loadingText() {
  14. return "Loading...";
  15. }
  16. I18NPermissionProvider getNotPermissionText([Options options]);
  17. static const I18nProvider chinese = CNProvider();
  18. static const I18nProvider english = ENProvider();
  19. }
  20. class CNProvider extends I18nProvider {
  21. const CNProvider() : super._();
  22. @override
  23. String getTitleText(Options options) {
  24. return "图片选择";
  25. }
  26. @override
  27. String getPreviewText(Options options, SelectedProvider selectedProvider) {
  28. return "预览(${selectedProvider.selectedCount})";
  29. }
  30. @override
  31. String getCancelText(Options options) {
  32. return "取消";
  33. }
  34. @override
  35. String getSureText(Options options, int currentCount) {
  36. return "确定($currentCount/${options.maxSelected})";
  37. }
  38. @override
  39. String getSelectedOptionsText(Options options) {
  40. return "选择";
  41. }
  42. @override
  43. String getFullImageText(Options options) {
  44. return "原图";
  45. }
  46. @override
  47. String getMaxTipText(Options options) {
  48. return "您已经选择了${options.maxSelected}张图片";
  49. }
  50. @override
  51. String getAllGalleryText(Options options) {
  52. return "全部图片";
  53. }
  54. @override
  55. String loadingText() {
  56. return "加载中...";
  57. }
  58. @override
  59. I18NPermissionProvider getNotPermissionText([Options options]) {
  60. return I18NPermissionProvider(
  61. cancelText: "取消", sureText: "去开启", titleText: "没有访问相册的权限");
  62. }
  63. }
  64. class ENProvider extends I18nProvider {
  65. const ENProvider() : super._();
  66. @override
  67. String getTitleText(Options options) {
  68. return "Image Picker";
  69. }
  70. @override
  71. String getPreviewText(Options options, SelectedProvider selectedProvider) {
  72. return "Preview (${selectedProvider.selectedCount})";
  73. }
  74. @override
  75. String getCancelText(Options options) {
  76. return "Cancel";
  77. }
  78. @override
  79. String getSureText(Options options, int currentCount) {
  80. return "Confirm ($currentCount/${options.maxSelected})";
  81. }
  82. @override
  83. String getSelectedOptionsText(Options options) {
  84. return "Selected";
  85. }
  86. @override
  87. String getFullImageText(Options options) {
  88. return "Full image";
  89. }
  90. @override
  91. String getMaxTipText(Options options) {
  92. return "Select ${options.maxSelected} pictures at most";
  93. }
  94. @override
  95. String getAllGalleryText(Options options) {
  96. return "All";
  97. }
  98. @override
  99. I18NPermissionProvider getNotPermissionText([Options options]) {
  100. return I18NPermissionProvider(
  101. cancelText: "Cancel",
  102. sureText: "Allow",
  103. titleText: "No permission to access gallery");
  104. }
  105. }
  106. abstract class I18NCustomProvider implements I18nProvider {
  107. final String maxTipText;
  108. final String previewText;
  109. final String selectedOptionsText;
  110. final String sureText;
  111. final String titleText;
  112. final I18NPermissionProvider notPermissionText;
  113. I18NCustomProvider(
  114. this.maxTipText,
  115. this.previewText,
  116. this.selectedOptionsText,
  117. this.sureText,
  118. this.titleText,
  119. this.notPermissionText);
  120. @override
  121. String getMaxTipText(Options options) {
  122. return maxTipText;
  123. }
  124. @override
  125. String getSelectedOptionsText(Options options) {
  126. return selectedOptionsText;
  127. }
  128. @override
  129. String getTitleText(Options options) {
  130. return titleText;
  131. }
  132. @override
  133. I18NPermissionProvider getNotPermissionText([Options options]) {
  134. return notPermissionText;
  135. }
  136. }
  137. class I18NPermissionProvider {
  138. final String titleText;
  139. final String sureText;
  140. final String cancelText;
  141. const I18NPermissionProvider(
  142. {this.titleText, this.sureText, this.cancelText});
  143. }