Files
Client/lib/widget/chat_background_picker_sheet.dart
T

31 lines
1.1 KiB
Dart

import 'dart:typed_data';
import 'package:flutter/material.dart';
import '../routing/app_routes.dart';
import 'details_bottom_sheet.dart';
import 'file_pick.dart';
/// Bottom sheet with "from gallery" and "take photo" actions for choosing a
/// chat background. Returns the picked image bytes **as-is** — cropping is a
/// separate, explicit step (see [cropChatBackgroundImage]) so the user isn't
/// forced through a cropper after every pick. Returns `null` if the user
/// cancelled everything.
Future<Uint8List?> showChatBackgroundPickerSheet(BuildContext context) async {
Uint8List? result;
await showDetailsBottomSheet(
context,
children: (sheetContext) =>
imageSourceTiles(sheetContext, onPicked: (bytes) => result = bytes),
);
return result;
}
/// Opens the free-form cropper on [bytes] and returns the cropped result, or
/// `null` if the user cancelled. Free aspect ratio since the background fills
/// the whole screen.
Future<Uint8List?> cropChatBackgroundImage(
BuildContext context,
Uint8List bytes,
) => AppRoutes.openAvatarCrop(context, imageBytes: bytes, aspectRatio: null);