multiple runtime bugfixes for 1.5.5+65
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
|
||||
import '../model/account_data.dart';
|
||||
import '../api/errors/error_mapper.dart';
|
||||
import 'a11y/a11y_labels.dart';
|
||||
import 'app_progress_indicator.dart';
|
||||
import 'placeholder_view.dart';
|
||||
import 'user_avatar.dart';
|
||||
|
||||
class LargeProfilePictureView extends StatelessWidget {
|
||||
/// Full-screen avatar. Loads the bytes itself instead of handing the URL to an
|
||||
/// [ImageProvider]: Nextcloud and Spreed serve generated avatars as SVG, which
|
||||
/// no codec can decode ("Invalid image data") — those get an [SvgPicture]
|
||||
/// instead of the zoomable [PhotoView].
|
||||
class LargeProfilePictureView extends StatefulWidget {
|
||||
final String id;
|
||||
final bool isGroup;
|
||||
|
||||
@@ -15,24 +22,73 @@ class LargeProfilePictureView extends StatelessWidget {
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<LargeProfilePictureView> createState() =>
|
||||
_LargeProfilePictureViewState();
|
||||
}
|
||||
|
||||
class _LargeProfilePictureViewState extends State<LargeProfilePictureView> {
|
||||
late Future<AvatarPayload?> _payload;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_payload = loadAvatarPayload(
|
||||
id: widget.id,
|
||||
isGroup: widget.isGroup,
|
||||
size: 1024,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final label = isGroup ? A11yLabels.groupPicture : A11yLabels.profilePicture;
|
||||
final label = widget.isGroup
|
||||
? A11yLabels.groupPicture
|
||||
: A11yLabels.profilePicture;
|
||||
final background = Theme.of(context).colorScheme.surface;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(label)),
|
||||
body: Semantics(
|
||||
image: true,
|
||||
label: label,
|
||||
child: PhotoView(
|
||||
minScale: 0.5,
|
||||
maxScale: 3.0,
|
||||
imageProvider: Image.network(
|
||||
avatarUrl(id: id, isGroup: isGroup, size: 1024),
|
||||
headers: {'Authorization': AccountData().getBasicAuthHeader()},
|
||||
).image,
|
||||
backgroundDecoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
child: FutureBuilder<AvatarPayload?>(
|
||||
future: _payload,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return const Center(child: AppProgressIndicator.large());
|
||||
}
|
||||
final payload = snapshot.data;
|
||||
if (snapshot.hasError) {
|
||||
return PlaceholderView(
|
||||
icon: Icons.broken_image_outlined,
|
||||
text: errorToUserMessage(snapshot.error),
|
||||
);
|
||||
}
|
||||
// No avatar on the server — the same icon the small avatar shows.
|
||||
if (payload == null) {
|
||||
return PlaceholderView(
|
||||
icon: widget.isGroup ? Icons.group : Icons.person,
|
||||
text: 'Kein Bild hinterlegt.',
|
||||
);
|
||||
}
|
||||
if (payload.isSvg) {
|
||||
return ColoredBox(
|
||||
color: background,
|
||||
child: InteractiveViewer(
|
||||
minScale: 0.5,
|
||||
maxScale: 3,
|
||||
child: SvgPicture.memory(payload.bytes, fit: BoxFit.contain),
|
||||
),
|
||||
);
|
||||
}
|
||||
return PhotoView(
|
||||
minScale: 0.5,
|
||||
maxScale: 3.0,
|
||||
imageProvider: MemoryImage(payload.bytes),
|
||||
backgroundDecoration: BoxDecoration(color: background),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user