@@ -198,11 +198,13 @@ class CameraPickerState extends State<CameraPicker>
198
198
return pickerConfig.minimumRecordingDuration;
199
199
}
200
200
201
+ /// Whether the controller is recording a video.
202
+ bool get isRecordingVideo => innerController? .value.isRecordingVideo ?? false ;
203
+
201
204
/// Whether the capture button is displaying.
202
205
bool get shouldCaptureButtonDisplay =>
203
- isCaptureButtonTapDown &&
204
- (innerController? .value.isRecordingVideo ?? false ) &&
205
- isRecordingRestricted;
206
+ (isCaptureButtonTapDown || MediaQuery .accessibleNavigationOf (context)) &&
207
+ isRecordingVideo;
206
208
207
209
/// Whether the camera preview should be rotated.
208
210
bool get isCameraRotated => pickerConfig.cameraQuarterTurns % 4 != 0 ;
@@ -236,6 +238,25 @@ class CameraPickerState extends State<CameraPicker>
236
238
/// The calculated capture actions section height.
237
239
double ? lastCaptureActionsEffectiveHeight;
238
240
241
+ /// Determine the label for the shooting button.
242
+ String get textShootingButtonLabel {
243
+ final String label;
244
+ if (pickerConfig.enableRecording) {
245
+ if (pickerConfig.onlyEnableRecording) {
246
+ if (pickerConfig.enableTapRecording) {
247
+ label = textDelegate.shootingTapRecordingTips;
248
+ } else {
249
+ label = textDelegate.shootingOnlyRecordingTips;
250
+ }
251
+ } else {
252
+ label = textDelegate.shootingWithRecordingTips;
253
+ }
254
+ } else {
255
+ label = textDelegate.shootingTips;
256
+ }
257
+ return label;
258
+ }
259
+
239
260
@override
240
261
void initState () {
241
262
super .initState ();
@@ -878,7 +899,7 @@ class CameraPickerState extends State<CameraPicker>
878
899
BoxConstraints constraints,
879
900
) {
880
901
lastShootingButtonPressedPosition ?? = event.position;
881
- if (innerController ? .value. isRecordingVideo == true ) {
902
+ if (isRecordingVideo) {
882
903
// First calculate relative offset.
883
904
final Offset offset = event.position - lastShootingButtonPressedPosition! ;
884
905
// Then turn negative,
@@ -987,7 +1008,7 @@ class CameraPickerState extends State<CameraPicker>
987
1008
/// 将被取消,并且状态会重置。
988
1009
void recordDetectionCancel (PointerUpEvent event) {
989
1010
recordDetectTimer? .cancel ();
990
- if (innerController ? .value. isRecordingVideo == true ) {
1011
+ if (isRecordingVideo) {
991
1012
stopRecordingVideo ();
992
1013
}
993
1014
}
@@ -1164,7 +1185,7 @@ class CameraPickerState extends State<CameraPicker>
1164
1185
return null ;
1165
1186
}
1166
1187
if (enableTapRecording) {
1167
- if (innerController ? .value. isRecordingVideo ?? false ) {
1188
+ if (isRecordingVideo) {
1168
1189
return textDelegate.sActionStopRecordingHint;
1169
1190
}
1170
1191
return textDelegate.sActionRecordHint;
@@ -1297,28 +1318,14 @@ class CameraPickerState extends State<CameraPicker>
1297
1318
/// Text widget for shooting tips.
1298
1319
/// 拍摄的提示文字
1299
1320
Widget buildCaptureTips (CameraController ? controller) {
1300
- final String tips;
1301
- if (pickerConfig.enableRecording) {
1302
- if (pickerConfig.onlyEnableRecording) {
1303
- if (pickerConfig.enableTapRecording) {
1304
- tips = textDelegate.shootingTapRecordingTips;
1305
- } else {
1306
- tips = textDelegate.shootingOnlyRecordingTips;
1307
- }
1308
- } else {
1309
- tips = textDelegate.shootingWithRecordingTips;
1310
- }
1311
- } else {
1312
- tips = textDelegate.shootingTips;
1313
- }
1314
1321
return AnimatedOpacity (
1315
1322
duration: recordDetectDuration,
1316
1323
opacity: controller? .value.isRecordingVideo ?? false ? 0 : 1 ,
1317
1324
child: Container (
1318
1325
height: 48.0 ,
1319
1326
alignment: Alignment .center,
1320
1327
child: Text (
1321
- tips ,
1328
+ textShootingButtonLabel ,
1322
1329
style: const TextStyle (fontSize: 15 ),
1323
1330
textAlign: TextAlign .center,
1324
1331
),
@@ -1419,14 +1426,19 @@ class CameraPickerState extends State<CameraPicker>
1419
1426
/// The shooting button.
1420
1427
/// 拍照按钮
1421
1428
Widget buildCaptureButton (BuildContext context, BoxConstraints constraints) {
1422
- if (! isCaptureButtonTapDown &&
1423
- (innerController? .value.isRecordingVideo ?? false )) {
1429
+ final showProgressIndicator =
1430
+ isCaptureButtonTapDown || MediaQuery .accessibleNavigationOf (context);
1431
+
1432
+ if (! showProgressIndicator && isRecordingVideo) {
1424
1433
return const SizedBox .shrink ();
1425
1434
}
1426
1435
const size = Size .square (82.0 );
1427
1436
return MergeSemantics (
1428
1437
child: Semantics (
1429
- label: textDelegate.sActionShootingButtonTooltip,
1438
+ label: isRecordingVideo
1439
+ ? textDelegate.sActionStopRecordingHint
1440
+ : textShootingButtonLabel,
1441
+ button: true ,
1430
1442
onTap: onTap,
1431
1443
onTapHint: onTapHint,
1432
1444
onLongPress: onLongPress,
@@ -1478,10 +1490,10 @@ class CameraPickerState extends State<CameraPicker>
1478
1490
if (shouldCaptureButtonDisplay)
1479
1491
RotatedBox (
1480
1492
quarterTurns:
1481
- ! enableScaledPreview ? cameraQuarterTurns : 0 ,
1493
+ enableScaledPreview ? 0 : cameraQuarterTurns ,
1482
1494
child: CameraProgressButton (
1483
1495
isAnimating:
1484
- isCaptureButtonTapDown && isShootingButtonAnimate,
1496
+ showProgressIndicator && isShootingButtonAnimate,
1485
1497
duration: pickerConfig.maximumRecordingDuration! ,
1486
1498
size: size,
1487
1499
ringsColor: theme.indicatorColor,
0 commit comments