refactor: Implement own adaptive dialogs and remove package
This commit is contained in:
parent
dea29161c8
commit
8819c40ebd
42 changed files with 597 additions and 439 deletions
|
|
@ -5,7 +5,6 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:desktop_drop/desktop_drop.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
|
|
@ -33,6 +32,9 @@ import 'package:fluffychat/utils/matrix_sdk_extensions/filtered_timeline_extensi
|
|||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:fluffychat/utils/show_scaffold_dialog.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/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:fluffychat/widgets/share_scaffold_dialog.dart';
|
||||
|
|
@ -691,23 +693,22 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
|
||||
void reportEventAction() async {
|
||||
final event = selectedEvents.single;
|
||||
final score = await showConfirmationDialog<int>(
|
||||
final score = await showModalActionPopup<int>(
|
||||
context: context,
|
||||
title: L10n.of(context).reportMessage,
|
||||
message: L10n.of(context).howOffensiveIsThisContent,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
okLabel: L10n.of(context).ok,
|
||||
actions: [
|
||||
AlertDialogAction(
|
||||
key: -100,
|
||||
AdaptiveModalAction(
|
||||
value: -100,
|
||||
label: L10n.of(context).extremeOffensive,
|
||||
),
|
||||
AlertDialogAction(
|
||||
key: -50,
|
||||
AdaptiveModalAction(
|
||||
value: -50,
|
||||
label: L10n.of(context).offensive,
|
||||
),
|
||||
AlertDialogAction(
|
||||
key: 0,
|
||||
AdaptiveModalAction(
|
||||
value: 0,
|
||||
label: L10n.of(context).inoffensive,
|
||||
),
|
||||
],
|
||||
|
|
@ -718,15 +719,15 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
title: L10n.of(context).whyDoYouWantToReportThis,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
textFields: [DialogTextField(hintText: L10n.of(context).reason)],
|
||||
hintText: L10n.of(context).reason,
|
||||
);
|
||||
if (reason == null || reason.single.isEmpty) return;
|
||||
if (reason == null || reason.isEmpty) return;
|
||||
final result = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.reportContent(
|
||||
event.roomId!,
|
||||
event.eventId,
|
||||
reason: reason.single,
|
||||
reason: reason,
|
||||
score: score,
|
||||
),
|
||||
);
|
||||
|
|
@ -765,18 +766,14 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
context: context,
|
||||
title: L10n.of(context).redactMessage,
|
||||
message: L10n.of(context).redactMessageDescription,
|
||||
isDestructiveAction: true,
|
||||
textFields: [
|
||||
DialogTextField(
|
||||
hintText: L10n.of(context).optionalRedactReason,
|
||||
),
|
||||
],
|
||||
isDestructive: true,
|
||||
hintText: L10n.of(context).optionalRedactReason,
|
||||
okLabel: L10n.of(context).remove,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
)
|
||||
: <String>[];
|
||||
: null;
|
||||
if (reasonInput == null) return;
|
||||
final reason = reasonInput.single.isEmpty ? null : reasonInput.single;
|
||||
final reason = reasonInput.isEmpty ? null : reasonInput;
|
||||
for (final event in selectedEvents) {
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
|
|
@ -1243,21 +1240,21 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
}
|
||||
});
|
||||
}
|
||||
final callType = await showModalActionSheet<CallType>(
|
||||
final callType = await showModalActionPopup<CallType>(
|
||||
context: context,
|
||||
title: L10n.of(context).warning,
|
||||
message: L10n.of(context).videoCallsBetaWarning,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
actions: [
|
||||
SheetAction(
|
||||
AdaptiveModalAction(
|
||||
label: L10n.of(context).voiceCall,
|
||||
icon: Icons.phone_outlined,
|
||||
key: CallType.kVoice,
|
||||
icon: const Icon(Icons.phone_outlined),
|
||||
value: CallType.kVoice,
|
||||
),
|
||||
SheetAction(
|
||||
AdaptiveModalAction(
|
||||
label: L10n.of(context).videoCall,
|
||||
icon: Icons.video_call_outlined,
|
||||
key: CallType.kVideo,
|
||||
icon: const Icon(Icons.video_call_outlined),
|
||||
value: CallType.kVideo,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue