mirror of
https://github.com/block/buzz.git
synced 2026-11-24 10:12:19 +00:00
## Summary On unfolded Duo landscape, channel/DM actions and Solo details now open in a UIKit sheet above the app’s native controls, while retaining Buzz’s Flutter tiles, member rows, and grouped cards. Content drags take priority over sheet dragging; the native top bar still supports dismissal. The presentation-only engine starts only when an eligible sheet is presented, without account, camera, audio, or storage plugins. It is destroyed on dismissal; other iPhones pay no second-engine launch cost. The main app retains live permissions and actions, and the native sheet dismisses before opening follow-up screens. Cover-display and portrait postures retain the existing bottom sheet. Pending avatar requests are abandoned on dismissal, including after the display wait expires; the display timeout alone lets the download finish and cache. Confirmed lifecycle actions retire the invisible owner route before waiting for the relay. ### Related issue Follow-up to #8568. No duplicate sheet PR found. ### Testing - `just mobile-install mobile-check mobile-test`: clean analysis; 4,900 Flutter tests passed (71 skipped), plus gateway/package checks. - Mobile file-size and diff checks passed. - Earlier signed device preview built, installed, and launched; owner confirmed its scrolling. The later lazy-start and lifecycle fixes have not been rechecked on the device. - Unsigned iOS release build passed for `4ed94c6eb4` (Xcode 116.7s). - Journeys cover bridge permissions, copy/close callbacks, the content renderer, full profile-to-DM return, and reopening the list during a held archive. Avatar tests cover immediate cancellation, display timeout followed by cancellation, and timeout followed by completion and cache reuse; regression probes fail with the fixes disabled. UIKit drag handling still lacks automated interaction coverage. ### Snapshots Actual Flutter sheet contents at 540×580 points with sample data. These show the content layout; they do not show UIKit’s surrounding sheet or its animation. | Surface | Light | Dark | | --- | --- | --- | | Solo details |  |  | | Channel actions |  |  | --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
222 lines
7.6 KiB
Dart
222 lines
7.6 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:buzz/features/channels/channel.dart';
|
|
import 'package:buzz/features/channels/channel_actions_sheet.dart';
|
|
import 'package:buzz/features/channels/channel_detail_page.dart';
|
|
import 'package:buzz/features/channels/channel_management_provider.dart';
|
|
import 'package:buzz/features/channels/compose_bar.dart';
|
|
import 'package:buzz/features/profile/user_profile_sheet.dart';
|
|
import 'package:buzz/shared/me/me_sync.dart';
|
|
import 'package:buzz/shared/mentions/agent_identity_provider.dart';
|
|
import 'package:buzz/shared/profile/user_cache_provider.dart';
|
|
import 'package:buzz/shared/profile/user_profile.dart';
|
|
import 'package:buzz/shared/theme/theme.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
void main() {
|
|
final peer = 'a' * 64;
|
|
|
|
for (final nativeSheet in [false, true]) {
|
|
testWidgets(
|
|
'Message opens the DM without waiting on Solo (native sheet: $nativeSheet)',
|
|
(tester) async {
|
|
final dm = Channel(
|
|
id: 'dm-peer',
|
|
name: 'Peer',
|
|
channelType: 'dm',
|
|
visibility: 'private',
|
|
description: '',
|
|
memberCount: 2,
|
|
createdBy: 'self',
|
|
createdAt: DateTime(2025),
|
|
isMember: true,
|
|
);
|
|
final solo = Channel(
|
|
id: 'solo-project',
|
|
name: 'Project',
|
|
channelType: 'group',
|
|
visibility: 'private',
|
|
description: '',
|
|
memberCount: 2,
|
|
createdBy: 'self',
|
|
createdAt: DateTime(2025),
|
|
isMember: true,
|
|
);
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
addTearDown(() => debugDefaultTargetPlatformOverride = null);
|
|
const bridge = MethodChannel('buzz/channel_actions_sheet');
|
|
Completer<String?>? nativeResult;
|
|
var presentations = 0;
|
|
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(bridge, (
|
|
call,
|
|
) async {
|
|
if (call.method == 'present') {
|
|
presentations++;
|
|
nativeResult = Completer<String?>();
|
|
return nativeResult!.future;
|
|
}
|
|
return null;
|
|
});
|
|
addTearDown(
|
|
() => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
|
bridge,
|
|
null,
|
|
),
|
|
);
|
|
final opened = <List<String>>[];
|
|
final waits = <bool>[];
|
|
SharedPreferences.setMockInitialValues({});
|
|
final prefs = await SharedPreferences.getInstance();
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
overrides: [
|
|
currentPubkeyProvider.overrideWith((ref) => 'self'),
|
|
agentOwnersProvider.overrideWithValue(
|
|
const AsyncValue.data(<String, String>{}),
|
|
),
|
|
channelMembersProvider(solo.id).overrideWith(
|
|
(ref) async => [
|
|
ChannelMember(
|
|
pubkey: peer,
|
|
role: 'member',
|
|
joinedAt: DateTime(2025),
|
|
),
|
|
],
|
|
),
|
|
userCacheProvider.overrideWith(
|
|
() => _UserCache({
|
|
peer: UserProfile(pubkey: peer, displayName: 'Peer'),
|
|
}),
|
|
),
|
|
channelActionsProvider.overrideWith(
|
|
(ref) => _FakeDmActions(dm, opened, waits),
|
|
),
|
|
savedPrefsProvider.overrideWithValue(prefs),
|
|
// Solo organization is still loading.
|
|
meGroupsProvider.overrideWith((ref) => const Stream.empty()),
|
|
],
|
|
child: MaterialApp(
|
|
theme: AppTheme.light(),
|
|
home: Builder(
|
|
builder: (context) => Scaffold(
|
|
body: TextButton(
|
|
onPressed: () => nativeSheet
|
|
? showChannelDetailsSheet(
|
|
context: context,
|
|
channel: solo,
|
|
currentPubkey: 'self',
|
|
personalChat: true,
|
|
onMemberTap: (context, pubkey) =>
|
|
showUserProfileSheet(context, pubkey),
|
|
)
|
|
: showUserProfileSheet(context, peer),
|
|
child: const Text('Open profile'),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
Future<void> openProfile() async {
|
|
if (nativeSheet) {
|
|
tester.view.physicalSize = const Size(1200, 800);
|
|
tester.view.padding = const FakeViewPadding(right: 76);
|
|
tester.view.viewPadding = tester.view.padding;
|
|
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
|
await tester.pumpAndSettle();
|
|
}
|
|
await tester.tap(find.text('Open profile'));
|
|
await tester.pumpAndSettle();
|
|
if (nativeSheet) {
|
|
// UIKit selection is the OS boundary; follow-up profile/DM routes are real.
|
|
debugDefaultTargetPlatformOverride = null;
|
|
expect(nativeResult, isNotNull);
|
|
expect(
|
|
nativeResult!.isCompleted,
|
|
isFalse,
|
|
reason: 'The underlying list must accept another tap',
|
|
);
|
|
nativeResult!.complete('member:$peer');
|
|
await tester.pumpAndSettle();
|
|
}
|
|
expect(find.byType(UserProfileSheet), findsOneWidget);
|
|
}
|
|
|
|
await openProfile();
|
|
if (nativeSheet) {
|
|
Navigator.of(tester.element(find.byType(UserProfileSheet))).pop();
|
|
await tester.pumpAndSettle();
|
|
// A stranded transparent owner route prevents this real tap from opening again.
|
|
await openProfile();
|
|
expect(presentations, 2);
|
|
}
|
|
await tester.tap(find.text('Message'));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(seconds: 1));
|
|
|
|
expect(opened, [
|
|
[peer],
|
|
]);
|
|
// The page opens at once instead of waiting on the full channel list.
|
|
expect(waits, [false]);
|
|
expect(
|
|
tester
|
|
.widget<ChannelDetailPage>(find.byType(ChannelDetailPage))
|
|
.channel,
|
|
dm,
|
|
);
|
|
// The DM is usable at once, not a placement spinner.
|
|
expect(find.byType(ComposeBar), findsOneWidget);
|
|
if (nativeSheet) {
|
|
Navigator.of(tester.element(find.byType(ChannelDetailPage))).pop();
|
|
await tester.pumpAndSettle();
|
|
await openProfile();
|
|
expect(presentations, 3);
|
|
Navigator.of(tester.element(find.byType(UserProfileSheet))).pop();
|
|
await tester.pumpAndSettle();
|
|
}
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
class _UserCache extends UserCacheNotifier {
|
|
_UserCache(this._initial);
|
|
|
|
final Map<String, UserProfile> _initial;
|
|
|
|
@override
|
|
Map<String, UserProfile> build() => _initial;
|
|
|
|
@override
|
|
Future<bool> preload(List<String> pubkeys) async => true;
|
|
}
|
|
|
|
class _FakeDmActions implements ChannelActions {
|
|
_FakeDmActions(this.dm, this.opened, this.waits);
|
|
|
|
final Channel dm;
|
|
final List<List<String>> opened;
|
|
final List<bool> waits;
|
|
|
|
@override
|
|
Future<Channel> openDm({
|
|
required List<String> pubkeys,
|
|
bool waitForChannelList = true,
|
|
}) async {
|
|
opened.add(pubkeys);
|
|
waits.add(waitForChannelList);
|
|
return dm;
|
|
}
|
|
|
|
@override
|
|
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
|
}
|