mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 09:35:12 +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,
|
context: context,
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
builder: (c) => SendFileDialog(
|
builder: (c) => SendFileDialog(
|
||||||
|
@ -490,7 +490,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (result == null || result.files.isEmpty) return;
|
if (result == null || result.files.isEmpty) return;
|
||||||
await showDialog(
|
await showAdaptiveDialog(
|
||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
builder: (c) => SendFileDialog(
|
builder: (c) => SendFileDialog(
|
||||||
|
@ -508,7 +508,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendImageFromClipBoard(Uint8List? image) async {
|
void sendImageFromClipBoard(Uint8List? image) async {
|
||||||
await showDialog(
|
await showAdaptiveDialog(
|
||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
builder: (c) => SendFileDialog(
|
builder: (c) => SendFileDialog(
|
||||||
|
@ -533,7 +533,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
||||||
);
|
);
|
||||||
if (result == null || result.files.isEmpty) return;
|
if (result == null || result.files.isEmpty) return;
|
||||||
|
|
||||||
await showDialog(
|
await showAdaptiveDialog(
|
||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
builder: (c) => SendFileDialog(
|
builder: (c) => SendFileDialog(
|
||||||
|
@ -556,7 +556,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
||||||
final file = await ImagePicker().pickImage(source: ImageSource.camera);
|
final file = await ImagePicker().pickImage(source: ImageSource.camera);
|
||||||
if (file == null) return;
|
if (file == null) return;
|
||||||
final bytes = await file.readAsBytes();
|
final bytes = await file.readAsBytes();
|
||||||
await showDialog(
|
await showAdaptiveDialog(
|
||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
builder: (c) => SendFileDialog(
|
builder: (c) => SendFileDialog(
|
||||||
|
@ -580,7 +580,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
||||||
);
|
);
|
||||||
if (file == null) return;
|
if (file == null) return;
|
||||||
final bytes = await file.readAsBytes();
|
final bytes = await file.readAsBytes();
|
||||||
await showDialog(
|
await showAdaptiveDialog(
|
||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
builder: (c) => SendFileDialog(
|
builder: (c) => SendFileDialog(
|
||||||
|
@ -688,7 +688,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendLocationAction() async {
|
void sendLocationAction() async {
|
||||||
await showDialog(
|
await showAdaptiveDialog(
|
||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
builder: (c) => SendLocationDialog(room: room),
|
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:future_loading_dialog/future_loading_dialog.dart';
|
||||||
import 'package:matrix/matrix.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/localized_exception_extension.dart';
|
||||||
import 'package:fluffychat/utils/size_string.dart';
|
import 'package:fluffychat/utils/size_string.dart';
|
||||||
import '../../utils/resize_image.dart';
|
import '../../utils/resize_image.dart';
|
||||||
|
@ -84,29 +85,31 @@ class SendFileDialogState extends State<SendFileDialog> {
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Flexible(
|
Flexible(
|
||||||
|
child: Material(
|
||||||
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||||
|
elevation:
|
||||||
|
Theme.of(context).appBarTheme.scrolledUnderElevation ?? 4,
|
||||||
|
shadowColor: Theme.of(context).appBarTheme.shadowColor,
|
||||||
child: Image.memory(
|
child: Image.memory(
|
||||||
widget.files.first.bytes,
|
widget.files.first.bytes,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
|
height: 256,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Row(
|
),
|
||||||
children: <Widget>[
|
SwitchListTile.adaptive(
|
||||||
Checkbox(
|
|
||||||
value: origImage,
|
value: origImage,
|
||||||
onChanged: (v) => setState(() => origImage = v ?? false),
|
contentPadding: EdgeInsets.zero,
|
||||||
),
|
onChanged: (v) => setState(() => origImage = v),
|
||||||
InkWell(
|
title: Text(L10n.of(context)!.sendOriginal),
|
||||||
onTap: () => setState(() => origImage = !origImage),
|
subtitle: Text(sizeString),
|
||||||
child: Text('${L10n.of(context)!.sendOriginal} ($sizeString)'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
contentWidget = Text('$fileName ($sizeString)');
|
contentWidget = Text('$fileName ($sizeString)');
|
||||||
}
|
}
|
||||||
return AlertDialog(
|
return AlertDialog.adaptive(
|
||||||
title: Text(sendStr),
|
title: Text(sendStr),
|
||||||
content: contentWidget,
|
content: contentWidget,
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
|
|
|
@ -9,7 +9,6 @@ import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/pages/chat/events/map_bubble.dart';
|
import 'package:fluffychat/pages/chat/events/map_bubble.dart';
|
||||||
import 'package:fluffychat/utils/platform_infos.dart';
|
|
||||||
|
|
||||||
class SendLocationDialog extends StatefulWidget {
|
class SendLocationDialog extends StatefulWidget {
|
||||||
final Room room;
|
final Room room;
|
||||||
|
@ -111,23 +110,7 @@ class SendLocationDialogState extends State<SendLocationDialog> {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (PlatformInfos.isCupertinoStyle) {
|
return AlertDialog.adaptive(
|
||||||
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(
|
|
||||||
title: Text(L10n.of(context)!.shareLocation),
|
title: Text(L10n.of(context)!.shareLocation),
|
||||||
content: contentWidget,
|
content: contentWidget,
|
||||||
actions: [
|
actions: [
|
||||||
|
|
Loading…
Reference in a new issue