Skip to content

Commit b7853cb

Browse files
klopez4212Terp
andcommitted
fix(mobile): consolidate Solo header controls and compact agent picker
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Signed-off-by: kenny lopez <[email protected]>
1 parent e5a1e7a commit b7853cb

5 files changed

Lines changed: 87 additions & 66 deletions

File tree

‎mobile/lib/features/channels/me/me_assistant_list.dart‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@ class MeAssistantList extends ConsumerWidget {
2323
@override
2424
Widget build(BuildContext context, WidgetRef ref) {
2525
final profiles = ref.watch(userCacheProvider);
26-
return SizedBox(
27-
height: (MediaQuery.sizeOf(context).height * 0.6).clamp(0.0, 400.0),
26+
return ConstrainedBox(
27+
constraints: BoxConstraints(
28+
maxHeight: MediaQuery.sizeOf(context).height * 0.6,
29+
),
2830
child: choices.isEmpty
29-
? const Center(child: Text('No agents are available.'))
31+
? const Padding(
32+
padding: EdgeInsets.all(Grid.gutter),
33+
child: Text('No agents are available.'),
34+
)
3035
: ListView(
36+
shrinkWrap: true,
3137
padding: const EdgeInsets.fromLTRB(
3238
Grid.gutter,
3339
0,

‎mobile/lib/features/channels/me/me_chat_assistant.dart‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ useMeChatAssistant(
229229
nativeAction: IosNavigationAction(
230230
label: label,
231231
symbol: 'person.crop.circle',
232+
sharesBackground: false,
232233
avatarIdentity: selected,
233234
avatarIsAgent: selected != null,
234235
imageUrl: profile?.avatarUrl,

‎mobile/lib/features/channels/me/me_chat_draft.dart‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ class _MeChatDraft extends HookConsumerWidget {
135135
leading: BackButton(
136136
onPressed: () => Navigator.of(context).maybePop(),
137137
),
138+
nativeLeading: IosNavigationAction(
139+
label: 'Back',
140+
symbol: 'chevron.backward',
141+
onPressed: () => Navigator.of(context).maybePop(),
142+
),
138143
title: const Text('New chat'),
139144
nativeTitle: 'New chat',
140145
centerTitle: true,
@@ -143,6 +148,7 @@ class _MeChatDraft extends HookConsumerWidget {
143148
IosNavigationAction(
144149
label: label,
145150
symbol: 'person.crop.circle',
151+
sharesBackground: false,
146152
avatarIdentity: selected,
147153
avatarIsAgent: selected != null,
148154
imageUrl: agent?.avatarUrl ?? profile?.avatarUrl,

‎mobile/lib/features/channels/me/me_workspace_picker.dart‎

Lines changed: 60 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import 'package:flutter_hooks/flutter_hooks.dart';
33
import 'package:hooks_riverpod/hooks_riverpod.dart';
44

55
import '../../../shared/me/me_sync.dart';
6-
import '../../../shared/theme/theme.dart';
76
import '../../../shared/theme/buzz_icons.dart';
87
import '../../../shared/widgets/feedback_snackbar.dart';
98
import '../../../shared/widgets/frosted_app_bar.dart';
10-
import '../../../shared/widgets/modal_presentation.dart';
119
import 'new_me_project.dart';
1210

1311
/// The workspace control shared by draft and existing Solo conversations.
@@ -22,7 +20,8 @@ import 'new_me_project.dart';
2220
}) {
2321
final busy = useState(false);
2422
final sync = enabled ? ref.watch(meSyncProvider) : null;
25-
final groups = enabled ? ref.watch(meGroupsProvider).value : null;
23+
final groupState = enabled ? ref.watch(meGroupsProvider) : null;
24+
final groups = groupState?.value;
2625
final current = channelId == null ? selected : groups?.assignments[channelId];
2726
final name =
2827
groups?.groups
@@ -32,18 +31,14 @@ import 'new_me_project.dart';
3231
final label = current == null
3332
? 'Choose workspace'
3433
: 'Workspace: ${name ?? "Unavailable workspace"}';
35-
Future<void> choose() async {
34+
Future<void> choose(String picked) async {
3635
if (sync == null || busy.value) return;
36+
if (picked == '+reload') {
37+
ref.invalidate(meGroupsProvider);
38+
return;
39+
}
3740
busy.value = true;
3841
try {
39-
final picked = await showBuzzModalBottomSheet<String>(
40-
context: context,
41-
title: 'Workspace',
42-
isScrollControlled: true,
43-
showDragHandle: true,
44-
builder: (_) => _WorkspaceChoices(selected: current),
45-
);
46-
if (picked == null || !context.mounted) return;
4742
sync.check();
4843
final id = picked == '+create'
4944
? await createMeProject(
@@ -81,66 +76,68 @@ import 'new_me_project.dart';
8176
}
8277
}
8378

84-
final onPressed = !enabled || locked || busy.value ? null : choose;
79+
final available =
80+
enabled &&
81+
!locked &&
82+
!busy.value &&
83+
(groups != null || groupState?.hasError == true);
8584
return (
8685
busy: busy.value,
87-
action: IconButton(
86+
action: PopupMenuButton<String>(
8887
key: const ValueKey('me-workspace-button'),
8988
tooltip: label,
90-
onPressed: onPressed,
89+
enabled: available,
9190
icon: const Icon(BuzzIcons.workspace),
91+
onSelected: choose,
92+
itemBuilder: (_) => [
93+
CheckedPopupMenuItem(
94+
value: '',
95+
checked: current == null,
96+
child: const Text('No Workspace'),
97+
),
98+
for (final group in groups?.groups ?? <Map<String, dynamic>>[])
99+
CheckedPopupMenuItem(
100+
value: group['id'] as String,
101+
checked: current == group['id'],
102+
child: Text(group['name'] as String),
103+
),
104+
if (groupState?.hasError == true)
105+
const PopupMenuItem(
106+
value: '+reload',
107+
child: Text('Reload workspaces'),
108+
),
109+
const PopupMenuItem(value: '+create', child: Text('Create workspace')),
110+
],
92111
),
93112
nativeAction: IosNavigationAction(
94113
label: label,
95114
icon: BuzzIcons.workspace,
96-
onPressed: onPressed,
97-
),
98-
);
99-
}
100-
101-
class _WorkspaceChoices extends ConsumerWidget {
102-
const _WorkspaceChoices({required this.selected});
103-
final String? selected;
104-
@override
105-
Widget build(BuildContext context, WidgetRef ref) {
106-
final groups = ref.watch(meGroupsProvider);
107-
return SizedBox(
108-
height: (MediaQuery.sizeOf(context).height * 0.6).clamp(0.0, 420.0),
109-
child: Material(
110-
type: MaterialType.transparency,
111-
child: ListView(
112-
padding: const EdgeInsets.symmetric(horizontal: Grid.gutter),
113-
children: [
114-
ListTile(
115-
title: const Text('No workspace'),
116-
selected: selected == null,
117-
trailing: selected == null ? const Icon(BuzzIcons.check) : null,
118-
onTap: () => Navigator.pop(context, ''),
119-
),
120-
if (groups.isLoading) const LinearProgressIndicator(),
121-
if (groups.hasError)
122-
TextButton(
123-
onPressed: () => ref.invalidate(meGroupsProvider),
124-
child: const Text('Reload workspaces'),
115+
sharesBackground: false,
116+
children: !available
117+
? const []
118+
: [
119+
IosNavigationAction(
120+
label: 'No Workspace',
121+
selected: current == null,
122+
onPressed: () => choose(''),
125123
),
126-
for (final group
127-
in groups.value?.groups ?? <Map<String, dynamic>>[])
128-
ListTile(
129-
title: Text(group['name'] as String),
130-
selected: selected == group['id'],
131-
trailing: selected == group['id']
132-
? const Icon(BuzzIcons.check)
133-
: null,
134-
onTap: () => Navigator.pop(context, group['id'] as String),
124+
for (final group in groups?.groups ?? <Map<String, dynamic>>[])
125+
IosNavigationAction(
126+
label: group['name'] as String,
127+
selected: current == group['id'],
128+
onPressed: () => choose(group['id'] as String),
129+
),
130+
if (groupState?.hasError == true)
131+
IosNavigationAction(
132+
label: 'Reload workspaces',
133+
onPressed: () => choose('+reload'),
134+
),
135+
IosNavigationAction(
136+
label: 'Create workspace',
137+
icon: BuzzIcons.plus,
138+
onPressed: () => choose('+create'),
135139
),
136-
ListTile(
137-
leading: const Icon(BuzzIcons.plus),
138-
title: const Text('Create workspace'),
139-
onTap: () => Navigator.pop(context, '+create'),
140-
),
141-
],
142-
),
143-
),
144-
);
145-
}
140+
],
141+
),
142+
);
146143
}

‎mobile/test/features/channels/me/me_page_test.dart‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,25 @@ void main() {
279279
'Choose workspace',
280280
'Change agent: My Bestie',
281281
]);
282+
expect(bar.nativeLeading?.symbol, 'chevron.backward');
283+
expect(
284+
bar.nativeActions!.every((action) => !action.sharesBackground),
285+
isTrue,
286+
);
282287
await tester.tap(find.byTooltip('Choose workspace'));
283288
await tester.pumpAndSettle();
289+
expect(find.byType(BottomSheet), findsNothing);
290+
expect(
291+
find.widgetWithText(CheckedPopupMenuItem<String>, 'No Workspace'),
292+
findsOneWidget,
293+
);
284294
expect(find.text('Create workspace'), findsOneWidget);
285295
await tester.tap(find.text('Mobile app').last);
286296
await tester.pumpAndSettle();
287297
expect(find.byTooltip('Workspace: Mobile app'), findsOneWidget);
288298
await tester.tap(find.byTooltip('Change agent: My Bestie'));
289299
await tester.pumpAndSettle();
300+
expect(tester.getSize(find.byType(ListView).last).height, lessThan(300));
290301
await tester.tap(find.text('Other agent'));
291302
await tester.pumpAndSettle();
292303
bestie.add(null);

0 commit comments

Comments
 (0)