|
3 | 3 | // in the LICENSE file.
|
4 | 4 |
|
5 | 5 | import 'package:camera/camera.dart' show CameraLensDirection, FlashMode;
|
| 6 | +import 'package:flutter/rendering.dart'; |
| 7 | + |
| 8 | +/// All text delegates. |
| 9 | +const List<CameraPickerTextDelegate> cameraPickerTextDelegates = |
| 10 | + <CameraPickerTextDelegate>[ |
| 11 | + CameraPickerTextDelegate(), |
| 12 | + EnglishCameraPickerTextDelegate(), |
| 13 | +]; |
| 14 | + |
| 15 | +/// Obtain the text delegate from the given locale. |
| 16 | +CameraPickerTextDelegate cameraPickerTextDelegateFromLocale(Locale? locale) { |
| 17 | + if (locale == null) { |
| 18 | + return const CameraPickerTextDelegate(); |
| 19 | + } |
| 20 | + final String languageCode = locale.languageCode.toLowerCase(); |
| 21 | + for (final CameraPickerTextDelegate delegate in cameraPickerTextDelegates) { |
| 22 | + if (delegate.languageCode == languageCode) { |
| 23 | + return delegate; |
| 24 | + } |
| 25 | + } |
| 26 | + return const CameraPickerTextDelegate(); |
| 27 | +} |
6 | 28 |
|
7 |
| -/// Text delegate that controls text in widgets, implemented with Chinese. |
8 |
| -/// 控制部件中的文字实现,中文。 |
| 29 | +/// Text delegate implemented with Chinese. |
| 30 | +/// 中文文字实现 |
9 | 31 | class CameraPickerTextDelegate {
|
| 32 | + const CameraPickerTextDelegate(); |
| 33 | + |
| 34 | + String get languageCode => 'zh'; |
| 35 | + |
10 | 36 | /// Confirm string for the confirm button.
|
11 | 37 | /// 确认按钮的字段
|
12 | 38 | String get confirm => '确认';
|
13 | 39 |
|
14 |
| - /// Tips string above the shooting button before shooting. |
| 40 | + /// Tips above the shooting button before shooting. |
15 | 41 | /// 拍摄前确认按钮上方的提示文字
|
16 | 42 | String get shootingTips => '轻触拍照';
|
17 | 43 |
|
| 44 | + /// Tips with recording above the shooting button before shooting. |
| 45 | + /// 拍摄前确认按钮上方的提示文字(带录像) |
| 46 | + String get shootingWithRecordingTips => '轻触拍照,长按摄像'; |
| 47 | + |
| 48 | + /// Tips with only recording above the shooting button before shooting. |
| 49 | + /// 拍摄前确认按钮上方的提示文字(仅录像) |
| 50 | + String get shootingOnlyRecordingTips => '长按摄像'; |
| 51 | + |
| 52 | + /// Tips with tap recording above the shooting button before shooting. |
| 53 | + /// 拍摄前确认按钮上方的提示文字(点击录像) |
| 54 | + String get shootingTapRecordingTips => '轻触摄像'; |
| 55 | + |
18 | 56 | /// Load failed string for item.
|
19 | 57 | /// 资源加载失败时的字段
|
20 | 58 | String get loadFailed => '加载失败';
|
@@ -77,37 +115,28 @@ class CameraPickerTextDelegate {
|
77 | 115 | }
|
78 | 116 | }
|
79 | 117 |
|
80 |
| -/// Default text delegate including recording implements with Chinese. |
81 |
| -/// 中文文字实现(包括摄像) |
82 |
| -class CameraPickerTextDelegateWithRecording extends CameraPickerTextDelegate { |
| 118 | +/// Text delegate implements with English. |
| 119 | +class EnglishCameraPickerTextDelegate extends CameraPickerTextDelegate { |
| 120 | + const EnglishCameraPickerTextDelegate(); |
| 121 | + |
83 | 122 | @override
|
84 |
| - String get shootingTips => '轻触拍照,长按摄像'; |
85 |
| -} |
| 123 | + String get languageCode => 'en'; |
86 | 124 |
|
87 |
| -/// Default text delegate including only recording implements with Chinese. |
88 |
| -/// 中文文字实现(仅摄像) |
89 |
| -class CameraPickerTextDelegateWithOnlyRecording |
90 |
| - extends CameraPickerTextDelegate { |
91 | 125 | @override
|
92 |
| - String get shootingTips => '长按摄像'; |
93 |
| -} |
| 126 | + String get confirm => 'Confirm'; |
94 | 127 |
|
95 |
| -/// Default text delegate including tap recording implements with Chinese. |
96 |
| -/// 中文文字实现(仅轻触摄像) |
97 |
| -class CameraPickerTextDelegateWithTapRecording |
98 |
| - extends CameraPickerTextDelegate { |
99 | 128 | @override
|
100 |
| - String get shootingTips => '轻触摄像'; |
101 |
| -} |
| 129 | + String get shootingTips => 'Tap to take photo.'; |
102 | 130 |
|
103 |
| -/// Default text delegate implements with English. |
104 |
| -/// 英文文字实现 |
105 |
| -class EnglishCameraPickerTextDelegate extends CameraPickerTextDelegate { |
106 | 131 | @override
|
107 |
| - String get confirm => 'Confirm'; |
| 132 | + String get shootingWithRecordingTips => |
| 133 | + 'Tap to take photo. Long press to record video.'; |
108 | 134 |
|
109 | 135 | @override
|
110 |
| - String get shootingTips => 'Tap to take photo.'; |
| 136 | + String get shootingOnlyRecordingTips => 'Long press to record video.'; |
| 137 | + |
| 138 | + @override |
| 139 | + String get shootingTapRecordingTips => 'Tap to record video.'; |
111 | 140 |
|
112 | 141 | @override
|
113 | 142 | String get loadFailed => 'Load failed';
|
@@ -148,27 +177,3 @@ class EnglishCameraPickerTextDelegate extends CameraPickerTextDelegate {
|
148 | 177 | String sSwitchCameraLensDirectionLabel(CameraLensDirection value) =>
|
149 | 178 | 'Switch to the ${sCameraLensDirectionLabel(value)} camera';
|
150 | 179 | }
|
151 |
| - |
152 |
| -/// Default text delegate including recording implements with English. |
153 |
| -/// 英文文字实现(包括摄像) |
154 |
| -class EnglishCameraPickerTextDelegateWithRecording |
155 |
| - extends EnglishCameraPickerTextDelegate { |
156 |
| - @override |
157 |
| - String get shootingTips => 'Tap to take photo. Long press to record video.'; |
158 |
| -} |
159 |
| - |
160 |
| -/// Default text delegate including only recording implements with English. |
161 |
| -/// 英文文字实现(仅摄像) |
162 |
| -class EnglishCameraPickerTextDelegateWithOnlyRecording |
163 |
| - extends EnglishCameraPickerTextDelegate { |
164 |
| - @override |
165 |
| - String get shootingTips => 'Long press to record video.'; |
166 |
| -} |
167 |
| - |
168 |
| -/// Default text delegate including tap recording implements with English. |
169 |
| -/// 英文文字实现(仅轻触摄像) |
170 |
| -class EnglishCameraPickerTextDelegateWithTapRecording |
171 |
| - extends EnglishCameraPickerTextDelegate { |
172 |
| - @override |
173 |
| - String get shootingTips => 'Tap to record video.'; |
174 |
| -} |
|
0 commit comments