镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mobile/ios/Runner/NativeConfirmationDialog.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Flutter
import UIKit

/// Owns a destructive UIKit alert until dismissal and replies exactly once.
/// Owns a UIKit confirmation alert until dismissal and replies exactly once.
final class NativeConfirmationDialogCoordinator: NSObject {
private let channel: FlutterMethodChannel
private weak var parent: UIViewController?
Expand Down Expand Up @@ -46,7 +46,8 @@ final class NativeConfirmationDialogCoordinator: NSObject {
alert.addAction(UIAlertAction(title: cancelLabel, style: .cancel) { [weak self] _ in
self?.cancel()
})
alert.addAction(UIAlertAction(title: confirmLabel, style: .destructive) { [weak self] _ in
let destructive = data["destructive"] as? Bool ?? true
alert.addAction(UIAlertAction(title: confirmLabel, style: destructive ? .destructive : .default) { [weak self] _ in
self?.finish(true)
})
pendingResult = result
Expand Down
1 change: 1 addition & 0 deletions mobile/lib/features/channels/channel_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'bestie_welcome.dart';
import 'bestie_welcome_storage.dart';
import 'agent_reply_handoff.dart';
import 'huddle_timeline.dart';
import '../../shared/widgets/confirmation_dialog.dart';
import '../../shared/widgets/modal_presentation.dart';
import '../../shared/widgets/ios_scroll_to_top.dart';
import 'message_footer_layout.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,15 @@ IosNavigationAction _huddleNavigationAction(
);
return;
}
// The header button is easy to hit by accident, so a new call asks first.
final confirmed = await showConfirmation(
context: context,
title: 'Start a Huddle?',
message:
'Your microphone will turn on, and others in this conversation can join.',
confirmLabel: 'Start Huddle',
);
if (!confirmed || !context.mounted) return;
try {
await ref
.read(mobileHuddleControllerProvider.notifier)
Expand Down
25 changes: 22 additions & 3 deletions mobile/lib/shared/widgets/confirmation_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ Future<bool> showDestructiveConfirmation({
required String title,
required String message,
required String confirmLabel,
}) => showConfirmation(
context: context,
title: title,
message: message,
confirmLabel: confirmLabel,
destructive: true,
);

/// Confirms an action using a UIKit alert on iOS.
/// Returns true only when the person explicitly chooses the confirm action.
Future<bool> showConfirmation({
required BuildContext context,
required String title,
required String message,
required String confirmLabel,
bool destructive = false,
}) async {
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.iOS) {
return await const MethodChannel(
Expand All @@ -21,6 +37,7 @@ Future<bool> showDestructiveConfirmation({
'message': message,
'confirmLabel': confirmLabel,
'cancelLabel': 'Cancel',
'destructive': destructive,
'dark': context.theme.brightness == Brightness.dark,
}) ==
true;
Expand All @@ -37,9 +54,11 @@ Future<bool> showDestructiveConfirmation({
),
FilledButton(
onPressed: () => Navigator.of(dialogContext).pop(true),
style: FilledButton.styleFrom(
backgroundColor: context.colors.error,
),
style: destructive
? FilledButton.styleFrom(
backgroundColor: context.colors.error,
)
: null,
child: Text(confirmLabel),
),
],
Expand Down
12 changes: 12 additions & 0 deletions mobile/test/features/channels/channel_detail_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9529,7 +9529,19 @@ void main() {
);
await tester.pumpAndSettle();

// A stray tap asks first; Cancel leaves no Huddle behind.
await tester.tap(find.byKey(const ValueKey('channel-huddle-button')));
await tester.pumpAndSettle();
expect(find.text('Start a Huddle?'), findsOneWidget);
await tester.tap(find.widgetWithText(TextButton, 'Cancel'));
await tester.pumpAndSettle();
expect(find.text('Start a Huddle?'), findsNothing);
expect(relaySession.huddleCreatePublishStarted.isCompleted, isFalse);

await tester.tap(find.byKey(const ValueKey('channel-huddle-button')));
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(FilledButton, 'Start Huddle'));
await tester.pump();
await relaySession.huddleCreatePublishStarted.future;
var transitionCompleted = false;
final transition =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ void main() {
);
expect(calls.single.arguments, containsPair('confirmLabel', 'Remove'));
expect(calls.single.arguments, containsPair('cancelLabel', 'Cancel'));
expect(calls.single.arguments, containsPair('destructive', true));
expect(find.byType(AlertDialog), findsNothing);
expect(actions.calls, isEmpty);
response.complete(confirmed);
Expand Down
Loading