Escape closes the full-screen diff page
The file diff page (from a turn's files-changed chip or run Changes) now closes on Escape, like its back button.
This commit is contained in:
@@ -306,10 +306,12 @@ class _FileDiffPageState extends State<FileDiffPage> {
|
|||||||
onPrevious: _index > 0 ? () => _step(-1) : null,
|
onPrevious: _index > 0 ? () => _step(-1) : null,
|
||||||
onNext: _index < count - 1 ? () => _step(1) : null,
|
onNext: _index < count - 1 ? () => _step(1) : null,
|
||||||
);
|
);
|
||||||
// Left/right arrows step between changed files, like the chevrons.
|
// Left/right arrows step between changed files, like the chevrons;
|
||||||
|
// Escape closes the page, like its back button.
|
||||||
final body = ArrowKeyPager(
|
final body = ArrowKeyPager(
|
||||||
onPrevious: _index > 0 ? () => _step(-1) : null,
|
onPrevious: _index > 0 ? () => _step(-1) : null,
|
||||||
onNext: _index < count - 1 ? () => _step(1) : null,
|
onNext: _index < count - 1 ? () => _step(1) : null,
|
||||||
|
onEscape: () => Navigator.of(context).maybePop(),
|
||||||
child: FloatingBarOverlay(
|
child: FloatingBarOverlay(
|
||||||
bar: pager == null
|
bar: pager == null
|
||||||
? const SizedBox.shrink()
|
? const SizedBox.shrink()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/features/changes/changes.dart';
|
import 'package:pipelines_app/features/changes/changes.dart';
|
||||||
import 'package:pipelines_app/features/changes/widgets/change_style.dart';
|
import 'package:pipelines_app/features/changes/widgets/change_style.dart';
|
||||||
@@ -439,4 +440,26 @@ void main() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (final cupertino in [false, true]) {
|
||||||
|
testWidgets('Escape closes the full-screen diff '
|
||||||
|
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
|
||||||
|
final file = FileChange(
|
||||||
|
path: 'lib/first.dart',
|
||||||
|
kind: ChangeKind.modified,
|
||||||
|
patch: _raggedPatch,
|
||||||
|
);
|
||||||
|
final opener = _diffDialogOpener(file);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
cupertino ? cupertinoHost(opener) : materialHost(opener),
|
||||||
|
);
|
||||||
|
await tester.tap(find.text('Open diff'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.byType(FileDiffPage), findsOneWidget);
|
||||||
|
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.byType(FileDiffPage), findsNothing);
|
||||||
|
expect(find.text('Open diff'), findsOneWidget);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user