feat: add quotations from marked text, with citations and sharing
This commit is contained in:
parent
0e2027c9e2
commit
e6e84fdc01
25 changed files with 1558 additions and 4 deletions
|
|
@ -1185,6 +1185,63 @@ void main() {
|
|||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('1 unread post'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('marked text can be kept as a quotation', (tester) async {
|
||||
final source = '''
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head><title>Cats</title>
|
||||
<meta name="mews-profile" content="0.1" />
|
||||
<meta name="author" content="A. Author" />
|
||||
</head>
|
||||
<body><p>The finest sentence about cats ever written.</p></body>
|
||||
</html>
|
||||
''';
|
||||
final stubDeps = AppDependencies(
|
||||
database: MewsDatabase.test(NativeDatabase.memory()),
|
||||
fetch: FakeFetch({'https://example.com/cats.html': source}),
|
||||
strings: strings,
|
||||
);
|
||||
await tester.pumpWidget(MewsApp(deps: stubDeps, strings: strings));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await stubDeps.browser.open('https://example.com/cats.html');
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// A long press on the word 'written' selects it and shows the toolbar.
|
||||
// The press lands on the glyphs: a wrapped line's geometric center can
|
||||
// sit between the lines, where no word is. The word is on the page's
|
||||
// second line, where the toolbar fits above it; on the first line the
|
||||
// toolbar would open past the top of the screen.
|
||||
final paragraph = tester.renderObject<RenderParagraph>(
|
||||
find.descendant(
|
||||
of: find.textContaining('finest sentence'),
|
||||
matching: find.byType(RichText)));
|
||||
final plain = paragraph.text.toPlainText();
|
||||
final word = plain.indexOf('written');
|
||||
final box = paragraph
|
||||
.getBoxesForSelection(
|
||||
TextSelection(baseOffset: word, extentOffset: word + 7))
|
||||
.first;
|
||||
final onWord = paragraph.localToGlobal(
|
||||
Offset((box.left + box.right) / 2, (box.top + box.bottom) / 2));
|
||||
final gesture = await tester.startGesture(onWord);
|
||||
await tester.pump(const Duration(milliseconds: 600));
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.text('Save as quotation'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// The selection kept its page: address, title and the author the page's
|
||||
// metadata named.
|
||||
final kept = await stubDeps.db.quotationsList();
|
||||
expect(kept, hasLength(1));
|
||||
expect(kept.single.pageUrl, 'https://example.com/cats.html');
|
||||
expect(kept.single.pageTitle, 'Cats');
|
||||
expect(kept.single.author, 'A. Author');
|
||||
expect(kept.single.quote, contains('written'));
|
||||
});
|
||||
}
|
||||
|
||||
MewsPage parseSource(String source, String url) =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue