Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Commit

Permalink
feat: add various semantics labels (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel committed May 18, 2021
1 parent 119f5fb commit 2cd33ed
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 85 deletions.
36 changes: 36 additions & 0 deletions lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,41 @@
"shareRetakeConfirmationConfirmButtonText": "Yes, retake photo",
"@shareRetakeConfirmationConfirmButtonText": {
"description": "Confirm button text shown in the confirmation when user taps the retake button"
},
"shutterButtonLabelText": "Take photo",
"@shutterButtonLabelText": {
"description": "Semantic label for the shutter button used to take a photo"
},
"stickersNextButtonLabelText": "Create final photo",
"@stickersNextButtonLabelText": {
"description": "Semantic label for the next button used to proceed to the share page"
},
"dashButtonLabelText": "Add dash friend",
"@dashButtonLabelText": {
"description": "Semantic label for the dash character button"
},
"sparkyButtonLabelText": "Add sparky friend",
"@sparkyButtonLabelText": {
"description": "Semantic label for the sparky character button"
},
"dinoButtonLabelText": "Add dino friend",
"@dinoButtonLabelText": {
"description": "Semantic label for the dino character button"
},
"androidButtonLabelText": "Add android jetpack friend",
"@androidButtonLabelText": {
"description": "Semantic label for the android jetpack character button"
},
"addStickersButtonLabelText": "Add props",
"@addStickersButtonLabelText": {
"description": "Semantic label for the add props button"
},
"retakePhotoButtonLabelText": "Retake photo",
"@retakePhotoButtonLabelText": {
"description": "Semantic label for the retake photo button"
},
"clearAllStickersButtonLabelText": "Clear all props",
"@clearAllStickersButtonLabelText": {
"description": "Semantic label for the clear all stickers button"
}
}
9 changes: 6 additions & 3 deletions lib/photobooth/widgets/characters_caption.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ class CharactersCaption extends StatelessWidget {
@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return AppTooltip.custom(
visible: true,
message: l10n.charactersCaptionText,
return Semantics(
button: false,
child: AppTooltip.custom(
visible: true,
message: l10n.charactersCaptionText,
),
);
}
}
10 changes: 6 additions & 4 deletions lib/photobooth/widgets/photobooth_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:io_photobooth/assets.g.dart';
import 'package:io_photobooth/footer/footer.dart';
import 'package:io_photobooth/l10n/l10n.dart';
import 'package:io_photobooth/photobooth/photobooth.dart';
import 'package:photobooth_ui/photobooth_ui.dart';

Expand All @@ -21,12 +22,13 @@ class PhotoboothPreview extends StatelessWidget {

@override
Widget build(BuildContext context) {
final l10n = context.l10n;
final state = context.watch<PhotoboothBloc>().state;
final children = <Widget>[
CharacterIconButton(
key: const Key('photoboothView_dash_characterIconButton'),
icon: const AssetImage('assets/icons/dash_icon.png'),
label: 'Dash',
label: l10n.dashButtonLabelText,
isSelected: state.isDashSelected,
onPressed: () {
trackEvent(
Expand All @@ -42,7 +44,7 @@ class PhotoboothPreview extends StatelessWidget {
CharacterIconButton(
key: const Key('photoboothView_sparky_characterIconButton'),
icon: const AssetImage('assets/icons/sparky_icon.png'),
label: 'Sparky',
label: l10n.sparkyButtonLabelText,
isSelected: state.isSparkySelected,
onPressed: () {
trackEvent(
Expand All @@ -58,7 +60,7 @@ class PhotoboothPreview extends StatelessWidget {
CharacterIconButton(
key: const Key('photoboothView_android_characterIconButton'),
icon: const AssetImage('assets/icons/android_icon.png'),
label: 'Android Jetpack',
label: l10n.androidButtonLabelText,
isSelected: state.isAndroidSelected,
onPressed: () {
trackEvent(
Expand All @@ -74,7 +76,7 @@ class PhotoboothPreview extends StatelessWidget {
CharacterIconButton(
key: const Key('photoboothView_dino_characterIconButton'),
icon: const AssetImage('assets/icons/dino_icon.png'),
label: 'Dino',
label: l10n.dinoButtonLabelText,
isSelected: state.isDinoSelected,
onPressed: () {
trackEvent(
Expand Down
27 changes: 17 additions & 10 deletions lib/photobooth/widgets/shutter_button.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:io_photobooth/l10n/l10n.dart';
import 'package:just_audio/just_audio.dart';
import 'package:photobooth_ui/photobooth_ui.dart';
import 'package:very_good_analysis/very_good_analysis.dart';
Expand Down Expand Up @@ -122,16 +123,22 @@ class CameraButton extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Material(
clipBehavior: Clip.hardEdge,
shape: const CircleBorder(),
color: PhotoboothColors.transparent,
child: InkWell(
onTap: onPressed,
child: Image.asset(
'assets/icons/camera_button_icon.png',
height: 100,
width: 100,
final l10n = context.l10n;
return Semantics(
focusable: true,
button: true,
label: l10n.shutterButtonLabelText,
child: Material(
clipBehavior: Clip.hardEdge,
shape: const CircleBorder(),
color: PhotoboothColors.transparent,
child: InkWell(
onTap: onPressed,
child: Image.asset(
'assets/icons/camera_button_icon.png',
height: 100,
width: 100,
),
),
),
);
Expand Down
42 changes: 25 additions & 17 deletions lib/share/view/share_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,32 @@ class _ShareRetakeButton extends StatelessWidget {
return Positioned(
left: 15,
top: 15,
child: AppTooltipButton(
key: const Key('sharePage_retake_appTooltipButton'),
onPressed: () async {
final confirmed = await showAppModal(
context: context,
landscapeChild: const _ConfirmationDialogContent(),
portraitChild: const _ConfirmationBottomSheet(),
);
if (confirmed) {
context.read<PhotoboothBloc>().add(const PhotoClearAllTapped());
unawaited(
Navigator.of(context).pushReplacement(PhotoboothPage.route()),
child: Semantics(
focusable: true,
button: true,
label: l10n.retakePhotoButtonLabelText,
child: AppTooltipButton(
key: const Key('sharePage_retake_appTooltipButton'),
onPressed: () async {
final confirmed = await showAppModal(
context: context,
landscapeChild: const _ConfirmationDialogContent(),
portraitChild: const _ConfirmationBottomSheet(),
);
}
},
verticalOffset: 50,
message: l10n.retakeButtonTooltip,
child: Image.asset('assets/icons/retake_button_icon.png', height: 100),
if (confirmed) {
context.read<PhotoboothBloc>().add(const PhotoClearAllTapped());
unawaited(
Navigator.of(context).pushReplacement(PhotoboothPage.route()),
);
}
},
verticalOffset: 50,
message: l10n.retakeButtonTooltip,
child: Image.asset(
'assets/icons/retake_button_icon.png',
height: 100,
),
),
),
);
}
Expand Down
113 changes: 67 additions & 46 deletions lib/stickers/view/stickers_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,24 +175,29 @@ class _RetakeButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return AppTooltipButton(
key: const Key('stickersPage_retake_appTooltipButton'),
onPressed: () async {
final confirmed = await showAppModal(
context: context,
landscapeChild: const _RetakeConfirmationDialogContent(),
portraitChild: const _RetakeConfirmationBottomSheet(),
);
if (confirmed) {
context.read<PhotoboothBloc>().add(const PhotoClearAllTapped());
unawaited(
Navigator.of(context).pushReplacement(PhotoboothPage.route()),
return Semantics(
focusable: true,
button: true,
label: l10n.retakePhotoButtonLabelText,
child: AppTooltipButton(
key: const Key('stickersPage_retake_appTooltipButton'),
onPressed: () async {
final confirmed = await showAppModal(
context: context,
landscapeChild: const _RetakeConfirmationDialogContent(),
portraitChild: const _RetakeConfirmationBottomSheet(),
);
}
},
verticalOffset: 50,
message: l10n.retakeButtonTooltip,
child: Image.asset('assets/icons/retake_button_icon.png', height: 100),
if (confirmed) {
context.read<PhotoboothBloc>().add(const PhotoClearAllTapped());
unawaited(
Navigator.of(context).pushReplacement(PhotoboothPage.route()),
);
}
},
verticalOffset: 50,
message: l10n.retakeButtonTooltip,
child: Image.asset('assets/icons/retake_button_icon.png', height: 100),
),
);
}
}
Expand All @@ -202,25 +207,33 @@ class _NextButton extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Material(
clipBehavior: Clip.hardEdge,
shape: const CircleBorder(),
color: PhotoboothColors.transparent,
child: InkWell(
key: const Key('stickersPage_next_inkWell'),
onTap: () async {
final confirmed = await showAppModal(
context: context,
landscapeChild: const _NextConfirmationDialogContent(),
portraitChild: const _NextConfirmationBottomSheet(),
);
if (confirmed) {
unawaited(Navigator.of(context).pushReplacement(SharePage.route()));
}
},
child: Image.asset(
'assets/icons/go_next_button_icon.png',
height: 100,
final l10n = context.l10n;
return Semantics(
focusable: true,
button: true,
label: l10n.stickersNextButtonLabelText,
child: Material(
clipBehavior: Clip.hardEdge,
shape: const CircleBorder(),
color: PhotoboothColors.transparent,
child: InkWell(
key: const Key('stickersPage_next_inkWell'),
onTap: () async {
final confirmed = await showAppModal(
context: context,
landscapeChild: const _NextConfirmationDialogContent(),
portraitChild: const _NextConfirmationBottomSheet(),
);
if (confirmed) {
unawaited(
Navigator.of(context).pushReplacement(SharePage.route()),
);
}
},
child: Image.asset(
'assets/icons/go_next_button_icon.png',
height: 100,
),
),
),
);
Expand Down Expand Up @@ -434,16 +447,24 @@ class _OpenStickersButtonState extends State<OpenStickersButton> {
@override
Widget build(BuildContext context) {
final l10n = context.l10n;
final child = AppTooltipButton(
key: const Key('stickersView_openStickersButton_appTooltipButton'),
onPressed: () {
widget.onPressed();
if (_isAnimating) setState(() => _isAnimating = false);
},
message: l10n.openStickersTooltip,
verticalOffset: 50,
mode: TooltipMode.normal,
child: Image.asset('assets/icons/stickers_button_icon.png', height: 100),
final child = Semantics(
focusable: true,
button: true,
label: l10n.addStickersButtonLabelText,
child: AppTooltipButton(
key: const Key('stickersView_openStickersButton_appTooltipButton'),
onPressed: () {
widget.onPressed();
if (_isAnimating) setState(() => _isAnimating = false);
},
message: l10n.openStickersTooltip,
verticalOffset: 50,
mode: TooltipMode.normal,
child: Image.asset(
'assets/icons/stickers_button_icon.png',
height: 100,
),
),
);
return _isAnimating ? AnimatedPulse(child: child) : child;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ class ClearStickersButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return AppTooltipButton(
onPressed: onPressed,
message: l10n.clearStickersButtonTooltip,
verticalOffset: 50,
child: Image.asset('assets/icons/delete_icon.png', height: 100),
return Semantics(
focusable: true,
button: true,
label: l10n.clearAllStickersButtonLabelText,
child: AppTooltipButton(
onPressed: onPressed,
message: l10n.clearStickersButtonTooltip,
verticalOffset: 50,
child: Image.asset('assets/icons/delete_icon.png', height: 100),
),
);
}
}

0 comments on commit 2cd33ed

Please sign in to comment.