feat: 动态页图片、图片预览页无障碍适配

This commit is contained in:
orz12
2024-03-13 20:02:59 +08:00
parent ab2fb39952
commit d3c2a9d8f3
2 changed files with 147 additions and 139 deletions

View File

@@ -59,7 +59,9 @@ class _ContentState extends State<Content> {
(pictureItem.height != null && pictureItem.width != null
? pictureItem.height! / pictureItem.width!
: 1);
return GestureDetector(
return Semantics(
label: '图片1,共1张',
child: GestureDetector(
onTap: () {
showDialog(
useSafeArea: false,
@@ -92,7 +94,7 @@ class _ContentState extends State<Content> {
: const SizedBox(),
],
)),
);
));
},
),
),
@@ -106,7 +108,9 @@ class _ContentState extends State<Content> {
LayoutBuilder(
builder: (context, BoxConstraints box) {
double maxWidth = box.maxWidth.truncateToDouble();
return GestureDetector(
return Semantics(
label: '图片${i + 1},共$len张',
child: GestureDetector(
onTap: () {
showDialog(
useSafeArea: false,
@@ -123,7 +127,7 @@ class _ContentState extends State<Content> {
origAspectRatio:
pics[i].width!.toInt() / pics[i].height!.toInt(),
),
);
));
},
),
);
@@ -201,7 +205,7 @@ class _ContentState extends State<Content> {
if (hasPics) ...[
Text.rich(
picsNodes(),
semanticsLabel: '动态图片',
// semanticsLabel: '动态图片',
),
]
],

View File

@@ -135,14 +135,17 @@ class _ImagePreviewState extends State<ImagePreview>
),
body: Stack(
children: [
GestureDetector(
Semantics(
label: '双指缩放、长按保存、左右滑动切换图片',
child: GestureDetector(
onLongPress: () => onOpenMenu(),
child: ExtendedImageGesturePageView.builder(
controller: ExtendedPageController(
initialPage: _previewController.initialPage.value,
pageSpacing: 0,
),
onPageChanged: (int index) => _previewController.onChange(index),
onPageChanged: (int index) =>
_previewController.onChange(index),
canScrollPage: (GestureDetails? gestureDetails) =>
gestureDetails!.totalScale! <= 1.0,
itemCount: widget.imgList!.length,
@@ -234,6 +237,7 @@ class _ImagePreviewState extends State<ImagePreview>
},
),
),
),
Positioned(
left: 0,
right: 0,