Add ALT image tags more pervasively

merge-requests/67/merge
Hank Grabowski 2024-12-20 08:47:49 -05:00
rodzic 0b66b3806f
commit 9dad9e2847
4 zmienionych plików z 54 dodań i 30 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../globals.dart';
import '../riverpod_controllers/settings_services.dart';
import 'login_aware_cached_network_image.dart';
@ -44,10 +45,34 @@ class _ImageControlState extends ConsumerState<ImageControl> {
if (shown && widget.imageUrl.isNotEmpty) {
_shownImageUrls.add(widget.imageUrl);
image = LoginAwareCachedNetworkImage(
imageUrl: widget.imageUrl,
width: widget.width,
image = SizedBox(
height: widget.height,
width: widget.width,
child: Stack(
children: [
LoginAwareCachedNetworkImage(
imageUrl: widget.imageUrl,
width: widget.width,
height: widget.height,
),
if (widget.altText.isNotEmpty)
Positioned(
bottom: 5.0,
left: 5.0,
child: ElevatedButton(
onPressed: () async => await showInfoDialog(
context,
widget.altText,
),
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context)
.scaffoldBackgroundColor
.withValues(alpha: 0.7)),
child: const Text('ALT'),
),
),
],
),
);
} else {
final icon = widget.iconOverride ??

Wyświetl plik

@ -28,6 +28,29 @@ const processingSleep = Duration(milliseconds: 1);
const apiCallTimeout = Duration(seconds: 90);
const oauthTimeout = Duration(seconds: 30);
Future<void> showInfoDialog(BuildContext context, String text) async {
await showDialog<bool>(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return AlertDialog(
content: Text(
text,
softWrap: true,
),
actions: <Widget>[
ElevatedButton(
child: const Text('Dismiss'),
onPressed: () {
Navigator.pop(context, true); // showDialog() returns true
},
),
],
);
},
);
}
Future<bool?> showConfirmDialog(BuildContext context, String caption) {
return showDialog<bool>(
context: context,

Wyświetl plik

@ -208,8 +208,7 @@ class _GalleryScreenBody extends ConsumerWidget {
bottom: 5.0,
left: 5.0,
child: ElevatedButton(
onPressed: () async =>
await showImageCaption(
onPressed: () async => await showInfoDialog(
context,
image.description,
),
@ -244,27 +243,4 @@ class _GalleryScreenBody extends ConsumerWidget {
);
});
}
Future<void> showImageCaption(BuildContext context, String text) async {
await showDialog<bool>(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return AlertDialog(
content: Text(
text,
softWrap: true,
),
actions: <Widget>[
ElevatedButton(
child: const Text('Dismiss'),
onPressed: () {
Navigator.pop(context, true); // showDialog() returns true
},
),
],
);
},
);
}
}

Wyświetl plik

@ -187,10 +187,10 @@ class _MediaViewerScreenState extends ConsumerState<MediaViewerScreen> {
),
if (currentAttachment.description.isNotEmpty)
Positioned(
bottom: 5.0,
bottom: 20.0,
left: 5.0,
child: ElevatedButton(
onPressed: () async => await showConfirmDialog(
onPressed: () async => await showInfoDialog(
context,
currentAttachment.description,
),