Remove Cupertino folder picker branches

Keep the Material-only folder picker implementation while preserving public cupertino parameters for callers. Narrow the matching tests to the supported Material host.
This commit is contained in:
2026-11-11 10:56:54 +00:00
parent a3fdecbbcb
commit 1c2bb8733a
7 changed files with 185 additions and 401 deletions
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../data/directory_listing.dart';
@@ -36,7 +35,6 @@ class FolderPickerList extends StatelessWidget {
FolderSectionHeader(cupertino: cupertino, text: 'Recent folders'),
for (final path in recents)
_RecentRow(
cupertino: cupertino,
label: homeRelativeLabel(listing.home, path),
onTap: () => controller.open(path),
),
@@ -47,7 +45,6 @@ class FolderPickerList extends StatelessWidget {
],
for (final entry in entries)
_EntryRow(
cupertino: cupertino,
entry: entry,
onTap: controller.canEnter(entry)
? () => controller.open(entry.path)
@@ -78,26 +75,13 @@ class FolderPickerList extends StatelessWidget {
}
class _RecentRow extends StatelessWidget {
const _RecentRow({
required this.cupertino,
required this.label,
required this.onTap,
});
const _RecentRow({required this.label, required this.onTap});
final bool cupertino;
final String label;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
if (cupertino) {
return CupertinoListTile(
leading: const Icon(CupertinoIcons.clock),
title: Text(label),
trailing: const CupertinoListTileChevron(),
onTap: onTap,
);
}
return ListTile(
leading: const Icon(Icons.history),
title: Text(label),
@@ -108,13 +92,8 @@ class _RecentRow extends StatelessWidget {
}
class _EntryRow extends StatelessWidget {
const _EntryRow({
required this.cupertino,
required this.entry,
required this.onTap,
});
const _EntryRow({required this.entry, required this.onTap});
final bool cupertino;
final DirectoryEntry entry;
final VoidCallback? onTap;
@@ -128,27 +107,12 @@ class _EntryRow extends StatelessWidget {
? Row(
mainAxisSize: MainAxisSize.min,
children: [
if (entry.isGitRepo) FolderGitBadge(cupertino: cupertino),
if (entry.isGitRepo) const FolderGitBadge(cupertino: false),
const SizedBox(width: 4),
cupertino
? const CupertinoListTileChevron()
: const Icon(Icons.chevron_right),
const Icon(Icons.chevron_right),
],
)
: null;
if (cupertino) {
final dim = CupertinoColors.tertiaryLabel.resolveFrom(context);
return CupertinoListTile(
key: ValueKey('folder-entry-${entry.path}'),
leading: Icon(
folder ? CupertinoIcons.folder_fill : CupertinoIcons.doc,
color: enabled ? null : dim,
),
title: Text(entry.name, style: enabled ? null : TextStyle(color: dim)),
trailing: trailing,
onTap: onTap,
);
}
return ListTile(
key: ValueKey('folder-entry-${entry.path}'),
enabled: enabled,
@@ -171,29 +135,11 @@ class FolderGitBadge extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (!cupertino) {
final scheme = Theme.of(context).colorScheme;
return Badge(
label: const Text('git'),
backgroundColor: scheme.secondaryContainer,
textColor: scheme.onSecondaryContainer,
);
}
return DecoratedBox(
decoration: BoxDecoration(
color: CupertinoColors.systemGrey5.resolveFrom(context),
borderRadius: BorderRadius.circular(6),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),
child: Text(
'git',
style: TextStyle(
fontSize: 12,
color: CupertinoColors.secondaryLabel.resolveFrom(context),
),
),
),
final scheme = Theme.of(context).colorScheme;
return Badge(
label: const Text('git'),
backgroundColor: scheme.secondaryContainer,
textColor: scheme.onSecondaryContainer,
);
}
}
@@ -1,9 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../../core/api_gateway.dart';
import '../../../../ui/adaptive/segmented_bar.dart';
import '../sessions/chat_adaptive.dart';
import 'folder_picker_controller.dart';
import 'folder_picker_list.dart';
import 'folder_picker_parts.dart';
@@ -79,25 +77,20 @@ class _FolderPickerPageState extends State<FolderPickerPage> {
@override
Widget build(BuildContext context) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final body = Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
FolderBreadcrumbs(cupertino: cupertino, controller: _controller),
FolderBreadcrumbs(cupertino: false, controller: _controller),
FolderPickerToolbar(
cupertino: cupertino,
cupertino: false,
controller: _controller,
filter: _filter,
),
Expanded(
child: FolderPickerList(
cupertino: cupertino,
controller: _controller,
),
child: FolderPickerList(cupertino: false, controller: _controller),
),
FolderStartBar(
cupertino: cupertino,
cupertino: false,
path: _controller.selectable,
home: _controller.home,
onStart: _start,
@@ -110,48 +103,31 @@ class _FolderPickerPageState extends State<FolderPickerPage> {
onPopInvokedWithResult: (didPop, _) {
if (!didPop) _back();
},
child: cupertino ? _cupertino(context, body) : _material(body),
child: _material(body),
);
}
/// The app's segmented bar: Back (climbing one folder), the title, and
/// Cancel in the actions pill, each popping in like every other bar.
SegmentedBar _bar(bool cupertino) => SegmentedBar(
cupertino: cupertino,
SegmentedBar _bar() => SegmentedBar(
cupertino: false,
automaticallyImplyLeading: false,
leading: SegmentedBackButton(cupertino: cupertino, onPressed: _back),
leading: SegmentedBackButton(cupertino: false, onPressed: _back),
title: widget.purpose.title,
actions: [
if (cupertino)
CupertinoButton(
padding: const EdgeInsets.symmetric(horizontal: 16),
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
)
else
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
],
);
Widget _material(Widget body) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: _bar(false),
appBar: _bar(),
// Inset below the floating bar, which the scaffold reports as padding.
body: SafeArea(child: body),
);
}
Widget _cupertino(BuildContext context, Widget body) {
return CupertinoPageScaffold(
navigationBar: _bar(true),
child: DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: SafeArea(child: body),
),
);
}
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../data/directory_listing.dart';
@@ -27,12 +26,7 @@ class FolderBreadcrumbs extends StatelessWidget {
final crumb = crumbs[i];
final last = i == crumbs.length - 1;
if (i > 0) {
children.add(
Icon(
cupertino ? CupertinoIcons.chevron_right : Icons.chevron_right,
size: 16,
),
);
children.add(Icon(Icons.chevron_right, size: 16));
}
children.add(
Semantics(
@@ -70,29 +64,13 @@ class FolderBreadcrumbs extends StatelessWidget {
? Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(cupertino ? CupertinoIcons.house : Icons.home_outlined),
const Icon(Icons.home_outlined),
const SizedBox(width: 4),
text,
],
)
: text;
final onPressed = last ? null : () => controller.open(crumb.path);
if (cupertino) {
return CupertinoButton(
key: ValueKey('folder-crumb-${crumb.path}'),
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 8),
onPressed: onPressed,
disabledColor: CupertinoColors.transparent,
child: last
? DefaultTextStyle.merge(
style: TextStyle(
color: CupertinoColors.label.resolveFrom(context),
),
child: label,
)
: label,
);
}
return TextButton(
key: ValueKey('folder-crumb-${crumb.path}'),
onPressed: onPressed,
@@ -124,61 +102,33 @@ class FolderPickerToolbar extends StatelessWidget {
final hiddenLabel = controller.hiddenCount > 0
? 'Show hidden (${controller.hiddenCount})'
: 'Show hidden';
final field = cupertino
? CupertinoSearchTextField(
key: const Key('folder-picker-filter'),
controller: filter,
placeholder: 'Filter this folder',
onChanged: controller.setFilter,
)
: TextField(
key: const Key('folder-picker-filter'),
controller: filter,
onChanged: controller.setFilter,
decoration: InputDecoration(
isDense: true,
prefixIcon: const Icon(Icons.search),
hintText: 'Filter this folder',
border: const OutlineInputBorder(),
suffixIcon: filter.text.isEmpty
? null
: IconButton(
tooltip: 'Clear filter',
icon: const Icon(Icons.clear),
onPressed: () {
filter.clear();
controller.setFilter('');
},
),
),
);
final toggle = cupertino
? Semantics(
label: 'Show hidden',
toggled: controller.showHidden,
excludeSemantics: true,
child: GestureDetector(
onTap: () => controller.setShowHidden(!controller.showHidden),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(hiddenLabel),
const SizedBox(width: 6),
CupertinoSwitch(
key: const Key('folder-picker-hidden'),
value: controller.showHidden,
onChanged: controller.setShowHidden,
),
],
final field = TextField(
key: const Key('folder-picker-filter'),
controller: filter,
onChanged: controller.setFilter,
decoration: InputDecoration(
isDense: true,
prefixIcon: const Icon(Icons.search),
hintText: 'Filter this folder',
border: const OutlineInputBorder(),
suffixIcon: filter.text.isEmpty
? null
: IconButton(
tooltip: 'Clear filter',
icon: const Icon(Icons.clear),
onPressed: () {
filter.clear();
controller.setFilter('');
},
),
),
)
: FilterChip(
key: const Key('folder-picker-hidden'),
label: Text(hiddenLabel),
selected: controller.showHidden,
onSelected: controller.setShowHidden,
);
),
);
final toggle = FilterChip(
key: const Key('folder-picker-hidden'),
label: Text(hiddenLabel),
selected: controller.showHidden,
onSelected: controller.setShowHidden,
);
return Padding(
padding: const EdgeInsets.fromLTRB(16, 4, 16, 8),
child: Wrap(
@@ -222,18 +172,12 @@ class FolderStartBar extends StatelessWidget {
? 'No folder selected'
: purpose.describe(homeRelativeLabel(home!, path!));
final onPressed = path == null ? null : onStart;
final button = cupertino
? CupertinoButton.filled(
key: const Key('folder-picker-start'),
onPressed: onPressed,
child: Text(purpose.confirmLabel),
)
: FilledButton.icon(
key: const Key('folder-picker-start'),
onPressed: onPressed,
icon: Icon(purpose.icon),
label: Text(purpose.confirmLabel),
);
final button = FilledButton.icon(
key: const Key('folder-picker-start'),
onPressed: onPressed,
icon: Icon(purpose.icon),
label: Text(purpose.confirmLabel),
);
final content = Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 12),
child: Column(
@@ -251,19 +195,6 @@ class FolderStartBar extends StatelessWidget {
],
),
);
if (cupertino) {
return DecoratedBox(
decoration: BoxDecoration(
border: Border(
top: BorderSide(
color: CupertinoColors.separator.resolveFrom(context),
width: 0,
),
),
),
child: content,
);
}
return Material(
color: Theme.of(context).colorScheme.surfaceContainer,
child: content,
@@ -1,10 +1,8 @@
import 'dart:math' as math;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../../core/api_gateway.dart';
import '../sessions/chat_adaptive.dart';
import 'folder_picker_page.dart';
import 'folder_picker_purpose.dart';
@@ -27,7 +25,6 @@ Future<String?> showFolderPicker(
List<String> recents = const [],
FolderPickerPurpose purpose = FolderPickerPurpose.startChat,
}) {
final cupertino = chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final size = MediaQuery.sizeOf(context);
final wide = size.width >= folderPickerDialogBreakpoint;
final navigator = Navigator.of(context, rootNavigator: true);
@@ -39,9 +36,7 @@ Future<String?> showFolderPicker(
);
if (!wide) {
return navigator.push<String>(
cupertino
? CupertinoPageRoute(fullscreenDialog: true, builder: page)
: MaterialPageRoute(fullscreenDialog: true, builder: page),
MaterialPageRoute(fullscreenDialog: true, builder: page),
);
}
Widget bounded(BuildContext context) {
@@ -53,18 +48,6 @@ Future<String?> showFolderPicker(
);
}
if (cupertino) {
return showCupertinoDialog<String>(
context: context,
useRootNavigator: true,
builder: (context) => Center(
child: ClipRRect(
borderRadius: BorderRadius.circular(14),
child: bounded(context),
),
),
);
}
return showDialog<String>(
context: context,
useRootNavigator: true,
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../data/directory_listing.dart';
@@ -15,9 +14,7 @@ class FolderPickerLoading extends StatelessWidget {
return Center(
child: Semantics(
label: 'Loading folder',
child: cupertino
? const CupertinoActivityIndicator()
: const CircularProgressIndicator(),
child: const CircularProgressIndicator(),
),
);
}
@@ -33,12 +30,7 @@ class FolderPickerLoadingBar extends StatelessWidget {
Widget build(BuildContext context) {
return Semantics(
label: 'Loading folder',
child: cupertino
? const Padding(
padding: EdgeInsets.all(8),
child: CupertinoActivityIndicator(),
)
: const LinearProgressIndicator(),
child: const LinearProgressIndicator(),
);
}
}
@@ -57,9 +49,7 @@ class FolderPickerError extends StatelessWidget {
@override
Widget build(BuildContext context) {
final color = cupertino
? CupertinoColors.systemRed.resolveFrom(context)
: Theme.of(context).colorScheme.error;
final color = Theme.of(context).colorScheme.error;
final listing = controller.listing;
final actions = <(String, VoidCallback)>[
('Retry', controller.retry),
@@ -76,12 +66,7 @@ class FolderPickerError extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
cupertino
? CupertinoIcons.exclamationmark_triangle
: Icons.error_outline,
color: color,
),
Icon(Icons.error_outline, color: color),
const SizedBox(height: 8),
Text(
"Can't open this folder",
@@ -101,9 +86,7 @@ class FolderPickerError extends StatelessWidget {
alignment: WrapAlignment.center,
children: [
for (final (label, onPressed) in actions)
cupertino
? CupertinoButton(onPressed: onPressed, child: Text(label))
: TextButton(onPressed: onPressed, child: Text(label)),
TextButton(onPressed: onPressed, child: Text(label)),
],
),
],
@@ -125,14 +108,9 @@ class FolderSectionHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
final style = cupertino
? TextStyle(
fontSize: 13,
color: CupertinoColors.secondaryLabel.resolveFrom(context),
)
: Theme.of(context).textTheme.labelLarge?.copyWith(
color: Theme.of(context).colorScheme.primary,
);
final style = Theme.of(context).textTheme.labelLarge?.copyWith(
color: Theme.of(context).colorScheme.primary,
);
return Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
child: Text(text, style: style),
@@ -153,9 +131,7 @@ class FolderPickerNote extends StatelessWidget {
@override
Widget build(BuildContext context) {
final color = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
final color = Theme.of(context).colorScheme.onSurfaceVariant;
return Padding(
padding: const EdgeInsets.all(16),
child: Text(text, style: TextStyle(color: color)),
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/ui/folder_picker/folder_picker_route.dart';
@@ -22,7 +21,7 @@ class _Launcher extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: CupertinoButton(
child: TextButton(
child: const Text('Open picker'),
onPressed: () async => onResult(
await showFolderPicker(
@@ -37,11 +36,8 @@ class _Launcher extends StatelessWidget {
}
}
enum _Host { material, cupertino }
Future<void> _pump(
WidgetTester tester,
_Host host,
Widget launcher, {
Size size = const Size(420, 900),
}) async {
@@ -49,12 +45,10 @@ Future<void> _pump(
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
host == _Host.material
? MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: Scaffold(body: launcher),
)
: CupertinoApp(home: CupertinoPageScaffold(child: launcher)),
MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: Scaffold(body: launcher),
),
);
await tester.tap(find.text('Open picker'));
await tester.pumpAndSettle();
@@ -63,123 +57,114 @@ Future<void> _pump(
Finder _crumb(String path) => find.byKey(ValueKey('folder-crumb-$path'));
void main() {
for (final host in _Host.values) {
testWidgets('${host.name}: opens at home, navigates, jumps up and returns '
'the folder', (tester) async {
final gateway = FakeDirectoryGateway();
String? result = 'unset';
await _pump(
tester,
host,
_Launcher(gateway: gateway, onResult: (value) => result = value),
);
expect(gateway.requests, [null]);
expect(find.text('Choose folder'), findsOneWidget);
expect(find.text('projects'), findsOneWidget);
expect(find.text('src'), findsOneWidget);
expect(find.text('git'), findsOneWidget);
expect(find.text('notes.txt'), findsOneWidget);
expect(find.text('Start in ~'), findsOneWidget);
testWidgets('opens at home, navigates, jumps up and returns the folder', (
tester,
) async {
final gateway = FakeDirectoryGateway();
String? result = 'unset';
await _pump(
tester,
_Launcher(gateway: gateway, onResult: (value) => result = value),
);
expect(gateway.requests, [null]);
expect(find.text('Choose folder'), findsOneWidget);
expect(find.text('projects'), findsOneWidget);
expect(find.text('src'), findsOneWidget);
expect(find.text('git'), findsOneWidget);
expect(find.text('notes.txt'), findsOneWidget);
expect(find.text('Start in ~'), findsOneWidget);
await tester.tap(find.text('projects'));
await tester.pumpAndSettle();
expect(gateway.requests.last, '$fakeHome/projects');
expect(find.text('app'), findsOneWidget);
expect(find.text('README.md'), findsOneWidget);
expect(find.text('Start in ~/projects'), findsOneWidget);
await tester.tap(find.text('projects'));
await tester.pumpAndSettle();
expect(gateway.requests.last, '$fakeHome/projects');
expect(find.text('app'), findsOneWidget);
expect(find.text('README.md'), findsOneWidget);
expect(find.text('Start in ~/projects'), findsOneWidget);
await tester.tap(find.text('app'));
await tester.pumpAndSettle();
expect(find.text('lib'), findsOneWidget);
// The home crumb jumps straight back up two levels.
await tester.tap(_crumb(fakeHome));
await tester.pumpAndSettle();
expect(gateway.requests.last, fakeHome);
expect(find.text('Start in ~'), findsOneWidget);
await tester.tap(find.text('app'));
await tester.pumpAndSettle();
expect(find.text('lib'), findsOneWidget);
// The home crumb jumps straight back up two levels.
await tester.tap(_crumb(fakeHome));
await tester.pumpAndSettle();
expect(gateway.requests.last, fakeHome);
expect(find.text('Start in ~'), findsOneWidget);
// Back climbs one folder instead of leaving the picker.
await tester.tap(find.text('projects'));
await tester.pumpAndSettle();
await tester.tap(find.text('web'));
await tester.pumpAndSettle();
expect(find.text('This folder is empty.'), findsOneWidget);
await tester.tap(
host == _Host.material
? find.byType(BackButton)
: find.byType(CupertinoNavigationBarBackButton),
);
await tester.pumpAndSettle();
expect(find.text('Start in ~/projects'), findsOneWidget);
expect(result, 'unset');
// Back climbs one folder instead of leaving the picker.
await tester.tap(find.text('projects'));
await tester.pumpAndSettle();
await tester.tap(find.text('web'));
await tester.pumpAndSettle();
expect(find.text('This folder is empty.'), findsOneWidget);
await tester.tap(find.byType(BackButton));
await tester.pumpAndSettle();
expect(find.text('Start in ~/projects'), findsOneWidget);
expect(result, 'unset');
await tester.tap(find.byKey(const Key('folder-picker-start')));
await tester.pumpAndSettle();
expect(result, '$fakeHome/projects');
expect(find.text('Choose folder'), findsNothing);
});
await tester.tap(find.byKey(const Key('folder-picker-start')));
await tester.pumpAndSettle();
expect(result, '$fakeHome/projects');
expect(find.text('Choose folder'), findsNothing);
});
testWidgets('${host.name}: hidden toggle and filter', (tester) async {
final gateway = FakeDirectoryGateway();
await _pump(tester, host, _Launcher(gateway: gateway, onResult: (_) {}));
expect(find.text('.config'), findsNothing);
expect(find.text('.zshrc'), findsNothing);
expect(find.text('Show hidden (2)'), findsOneWidget);
await tester.tap(find.byKey(const Key('folder-picker-hidden')));
await tester.pumpAndSettle();
expect(find.text('.config'), findsOneWidget);
expect(find.text('.zshrc'), findsOneWidget);
testWidgets('hidden toggle and filter', (tester) async {
final gateway = FakeDirectoryGateway();
await _pump(tester, _Launcher(gateway: gateway, onResult: (_) {}));
expect(find.text('.config'), findsNothing);
expect(find.text('.zshrc'), findsNothing);
expect(find.text('Show hidden (2)'), findsOneWidget);
await tester.tap(find.byKey(const Key('folder-picker-hidden')));
await tester.pumpAndSettle();
expect(find.text('.config'), findsOneWidget);
expect(find.text('.zshrc'), findsOneWidget);
await tester.enterText(
find.byKey(const Key('folder-picker-filter')),
'PRO',
);
await tester.pumpAndSettle();
expect(find.text('projects'), findsOneWidget);
expect(find.text('src'), findsNothing);
await tester.enterText(
find.byKey(const Key('folder-picker-filter')),
'zzz',
);
await tester.pumpAndSettle();
expect(find.textContaining('Nothing here matches'), findsOneWidget);
});
await tester.enterText(
find.byKey(const Key('folder-picker-filter')),
'PRO',
);
await tester.pumpAndSettle();
expect(find.text('projects'), findsOneWidget);
expect(find.text('src'), findsNothing);
await tester.enterText(
find.byKey(const Key('folder-picker-filter')),
'zzz',
);
await tester.pumpAndSettle();
expect(find.textContaining('Nothing here matches'), findsOneWidget);
});
testWidgets('${host.name}: a refused folder is shown inline and home '
'recovers', (tester) async {
final gateway = FakeDirectoryGateway();
String? result = 'unset';
await _pump(
tester,
host,
_Launcher(
gateway: gateway,
initialPath: '/etc',
onResult: (value) => result = value,
),
);
expect(find.textContaining('outside the home directory'), findsOneWidget);
expect(find.text('No folder selected'), findsOneWidget);
await tester.tap(find.byKey(const Key('folder-picker-start')));
await tester.pumpAndSettle();
expect(result, 'unset');
testWidgets('a refused folder is shown inline and home recovers', (
tester,
) async {
final gateway = FakeDirectoryGateway();
String? result = 'unset';
await _pump(
tester,
_Launcher(
gateway: gateway,
initialPath: '/etc',
onResult: (value) => result = value,
),
);
expect(find.textContaining('outside the home directory'), findsOneWidget);
expect(find.text('No folder selected'), findsOneWidget);
await tester.tap(find.byKey(const Key('folder-picker-start')));
await tester.pumpAndSettle();
expect(result, 'unset');
await tester.tap(find.text('Go to home'));
await tester.pumpAndSettle();
expect(find.text('projects'), findsOneWidget);
await tester.tap(find.text('Go to home'));
await tester.pumpAndSettle();
expect(find.text('projects'), findsOneWidget);
gateway.denied.add('$fakeHome/projects');
await tester.tap(find.text('projects'));
await tester.pumpAndSettle();
expect(
find.text('permission denied: $fakeHome/projects'),
findsOneWidget,
);
await tester.tap(find.text('Back to ~'));
await tester.pumpAndSettle();
expect(find.text('projects'), findsOneWidget);
expect(find.text('Start in ~'), findsOneWidget);
});
}
gateway.denied.add('$fakeHome/projects');
await tester.tap(find.text('projects'));
await tester.pumpAndSettle();
expect(find.text('permission denied: $fakeHome/projects'), findsOneWidget);
await tester.tap(find.text('Back to ~'));
await tester.pumpAndSettle();
expect(find.text('projects'), findsOneWidget);
expect(find.text('Start in ~'), findsOneWidget);
});
testWidgets('opens at an initial folder and offers recents at home', (
tester,
@@ -187,7 +172,6 @@ void main() {
final gateway = FakeDirectoryGateway();
await _pump(
tester,
_Host.material,
_Launcher(
gateway: gateway,
initialPath: '$fakeHome/projects',
@@ -207,31 +191,20 @@ void main() {
expect(find.text('lib'), findsOneWidget);
});
for (final host in _Host.values) {
testWidgets('${host.name}: wide windows get a dialog, phones a page', (
testWidgets('wide windows get a dialog, phones a page', (tester) async {
final gateway = FakeDirectoryGateway();
await _pump(
tester,
) async {
final gateway = FakeDirectoryGateway();
await _pump(
tester,
host,
_Launcher(gateway: gateway, onResult: (_) {}),
size: const Size(1000, 900),
);
final page = tester.getSize(find.text('Choose folder'));
expect(page.width, greaterThan(0));
final scaffoldType = host == _Host.material
? Scaffold
: CupertinoPageScaffold;
final picker = find.ancestor(
of: find.text('Choose folder'),
matching: find.byType(scaffoldType),
);
expect(tester.getSize(picker.first).width, lessThan(1000));
expect(
host == _Host.material ? find.byType(Dialog) : find.byType(ClipRRect),
findsWidgets,
);
});
}
_Launcher(gateway: gateway, onResult: (_) {}),
size: const Size(1000, 900),
);
final page = tester.getSize(find.text('Choose folder'));
expect(page.width, greaterThan(0));
final picker = find.ancestor(
of: find.text('Choose folder'),
matching: find.byType(Scaffold),
);
expect(tester.getSize(picker.first).width, lessThan(1000));
expect(find.byType(Dialog), findsWidgets);
});
}
@@ -19,7 +19,6 @@ FakeChatGateway _gateway(FakeDirectoryGateway directories) {
void main() {
final hosts = <String, Future<void> Function(WidgetTester, FakeChatGateway)>{
'material': (tester, gateway) => pumpMaterialChat(tester, gateway),
'cupertino': (tester, gateway) => pumpCupertinoChat(tester, gateway),
'ios material': (tester, gateway) => pumpIosMaterialChat(tester, gateway),
};
for (final MapEntry(key: name, value: pump) in hosts.entries) {