feat: avatar cropping
This commit is contained in:
parent
f043e191d2
commit
c0888d47be
5 changed files with 102 additions and 12 deletions
|
|
@ -161,10 +161,8 @@ class MessageContent extends StatelessWidget {
|
|||
case MessageTypes.Audio:
|
||||
if (PlatformInfos.isMobile ||
|
||||
PlatformInfos.isMacOS ||
|
||||
PlatformInfos.isWeb
|
||||
// Disabled until https://github.com/bleonard252/just_audio_mpv/issues/3
|
||||
// is fixed
|
||||
// || PlatformInfos.isLinux
|
||||
PlatformInfos.isWeb ||
|
||||
PlatformInfos.isLinux
|
||||
) {
|
||||
return AudioPlayerWidget(
|
||||
event,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
|
@ -15,6 +16,7 @@ import 'package:fluffychat/utils/platform_infos.dart';
|
|||
import 'package:fluffychat/widgets/adaptive_dialogs/show_modal_action_popup.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart';
|
||||
import 'package:fluffychat/widgets/avatar_crop_dialog.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import '../../widgets/matrix.dart';
|
||||
import 'settings_view.dart';
|
||||
|
|
@ -126,6 +128,8 @@ class SettingsController extends State<Settings> {
|
|||
return;
|
||||
}
|
||||
MatrixFile file;
|
||||
Uint8List bytes;
|
||||
String name;
|
||||
if (PlatformInfos.isMobile) {
|
||||
final result = await ImagePicker().pickImage(
|
||||
source: action == AvatarAction.camera
|
||||
|
|
@ -134,16 +138,25 @@ class SettingsController extends State<Settings> {
|
|||
imageQuality: 50,
|
||||
);
|
||||
if (result == null) return;
|
||||
file = MatrixFile(bytes: await result.readAsBytes(), name: result.path);
|
||||
bytes = await result.readAsBytes();
|
||||
name = result.path;
|
||||
} else {
|
||||
final result = await selectFiles(context, type: FileType.image);
|
||||
final pickedFile = result.firstOrNull;
|
||||
if (pickedFile == null) return;
|
||||
file = MatrixFile(
|
||||
bytes: await pickedFile.readAsBytes(),
|
||||
name: pickedFile.name,
|
||||
);
|
||||
bytes = await pickedFile.readAsBytes();
|
||||
name = pickedFile.name;
|
||||
}
|
||||
final cropped = await showDialog<Uint8List>(
|
||||
context: context,
|
||||
builder: (contect) => AvatarCropDialog(image: bytes),
|
||||
);
|
||||
if (cropped == null) return;
|
||||
bytes = cropped;
|
||||
file = MatrixFile(
|
||||
bytes: bytes,
|
||||
name: name,
|
||||
);
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => matrix.client.setAvatar(file),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue