mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 13:05:11 +00:00
refactor: Make file dialog adaptive and adjust design
This commit is contained in:
parent
3ef9854c1d
commit
d1ce1e3ba7
3 changed files with 26 additions and 40 deletions
|
@ -149,7 +149,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||
);
|
||||
}
|
||||
|
||||
await showDialog(
|
||||
await showAdaptiveDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (c) => SendFileDialog(
|
||||
|
@ -490,7 +490,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||
),
|
||||
);
|
||||
if (result == null || result.files.isEmpty) return;
|
||||
await showDialog(
|
||||
await showAdaptiveDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (c) => SendFileDialog(
|
||||
|
@ -508,7 +508,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||
}
|
||||
|
||||
void sendImageFromClipBoard(Uint8List? image) async {
|
||||
await showDialog(
|
||||
await showAdaptiveDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (c) => SendFileDialog(
|
||||
|
@ -533,7 +533,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||
);
|
||||
if (result == null || result.files.isEmpty) return;
|
||||
|
||||
await showDialog(
|
||||
await showAdaptiveDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (c) => SendFileDialog(
|
||||
|
@ -556,7 +556,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||
final file = await ImagePicker().pickImage(source: ImageSource.camera);
|
||||
if (file == null) return;
|
||||
final bytes = await file.readAsBytes();
|
||||
await showDialog(
|
||||
await showAdaptiveDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (c) => SendFileDialog(
|
||||
|
@ -580,7 +580,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||
);
|
||||
if (file == null) return;
|
||||
final bytes = await file.readAsBytes();
|
||||
await showDialog(
|
||||
await showAdaptiveDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (c) => SendFileDialog(
|
||||
|
@ -688,7 +688,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||
}
|
||||
|
||||
void sendLocationAction() async {
|
||||
await showDialog(
|
||||
await showAdaptiveDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (c) => SendLocationDialog(room: room),
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||
import 'package:fluffychat/utils/size_string.dart';
|
||||
import '../../utils/resize_image.dart';
|
||||
|
@ -84,29 +85,31 @@ class SendFileDialogState extends State<SendFileDialog> {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: Image.memory(
|
||||
widget.files.first.bytes,
|
||||
fit: BoxFit.contain,
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||
elevation:
|
||||
Theme.of(context).appBarTheme.scrolledUnderElevation ?? 4,
|
||||
shadowColor: Theme.of(context).appBarTheme.shadowColor,
|
||||
child: Image.memory(
|
||||
widget.files.first.bytes,
|
||||
fit: BoxFit.contain,
|
||||
height: 256,
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Checkbox(
|
||||
value: origImage,
|
||||
onChanged: (v) => setState(() => origImage = v ?? false),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () => setState(() => origImage = !origImage),
|
||||
child: Text('${L10n.of(context)!.sendOriginal} ($sizeString)'),
|
||||
),
|
||||
],
|
||||
SwitchListTile.adaptive(
|
||||
value: origImage,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onChanged: (v) => setState(() => origImage = v),
|
||||
title: Text(L10n.of(context)!.sendOriginal),
|
||||
subtitle: Text(sizeString),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
contentWidget = Text('$fileName ($sizeString)');
|
||||
}
|
||||
return AlertDialog(
|
||||
return AlertDialog.adaptive(
|
||||
title: Text(sendStr),
|
||||
content: contentWidget,
|
||||
actions: <Widget>[
|
||||
|
|
|
@ -9,7 +9,6 @@ import 'package:geolocator/geolocator.dart';
|
|||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pages/chat/events/map_bubble.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
|
||||
class SendLocationDialog extends StatefulWidget {
|
||||
final Room room;
|
||||
|
@ -111,23 +110,7 @@ class SendLocationDialogState extends State<SendLocationDialog> {
|
|||
],
|
||||
);
|
||||
}
|
||||
if (PlatformInfos.isCupertinoStyle) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text(L10n.of(context)!.shareLocation),
|
||||
content: contentWidget,
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: Navigator.of(context, rootNavigator: false).pop,
|
||||
child: Text(L10n.of(context)!.cancel),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
onPressed: isSending ? null : sendAction,
|
||||
child: Text(L10n.of(context)!.send),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return AlertDialog(
|
||||
return AlertDialog.adaptive(
|
||||
title: Text(L10n.of(context)!.shareLocation),
|
||||
content: contentWidget,
|
||||
actions: [
|
||||
|
|
Loading…
Reference in a new issue