import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';

import '../model/account_data.dart';
import 'a11y/a11y_labels.dart';
import 'user_avatar.dart';

class LargeProfilePictureView extends StatelessWidget {
  final String id;
  final bool isGroup;

  const LargeProfilePictureView({
    required this.id,
    this.isGroup = false,
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    final label = isGroup ? A11yLabels.groupPicture : A11yLabels.profilePicture;
    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,
          ),
        ),
      ),
    );
  }
}
