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:
@@ -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)),
|
||||
|
||||
Reference in New Issue
Block a user