mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 10:17:16 +08:00
@ -7,6 +7,7 @@ import 'package:gitjournal/core/note.dart';
|
||||
import 'package:gitjournal/core/notes_folder.dart';
|
||||
import 'package:gitjournal/core/sorting_mode.dart';
|
||||
import 'package:gitjournal/folder_views/list_view.dart';
|
||||
import 'package:gitjournal/widgets/highlighted_text.dart';
|
||||
|
||||
class JournalView extends StatelessWidget {
|
||||
final NoteSelectedFunction noteTapped;
|
||||
@ -16,6 +17,7 @@ class JournalView extends StatelessWidget {
|
||||
final NotesFolder folder;
|
||||
final String emptyText;
|
||||
final String searchTerm;
|
||||
final String searchTermLowerCase;
|
||||
|
||||
static final _dateFormat = DateFormat('dd MMM, yyyy ');
|
||||
static final _timeFormat = DateFormat('Hm');
|
||||
@ -27,7 +29,7 @@ class JournalView extends StatelessWidget {
|
||||
@required this.isNoteSelected,
|
||||
@required this.emptyText,
|
||||
@required this.searchTerm,
|
||||
});
|
||||
}) : searchTermLowerCase = searchTerm.toLowerCase();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -70,11 +72,13 @@ class JournalView extends StatelessWidget {
|
||||
|
||||
var children = <Widget>[
|
||||
const SizedBox(height: 8.0),
|
||||
Text(
|
||||
note.summary + '\n', // no minLines option
|
||||
HighlightedText(
|
||||
text: note.summary + '\n', // no minLines option
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: textTheme.bodyText2,
|
||||
highlightText: searchTerm,
|
||||
highlightTextLowerCase: searchTermLowerCase,
|
||||
),
|
||||
];
|
||||
|
||||
|
@ -7,6 +7,7 @@ import 'package:gitjournal/core/note.dart';
|
||||
import 'package:gitjournal/core/notes_folder.dart';
|
||||
import 'package:gitjournal/core/sorting_mode.dart';
|
||||
import 'package:gitjournal/folder_views/list_view.dart';
|
||||
import 'package:gitjournal/widgets/highlighted_text.dart';
|
||||
|
||||
enum StandardViewHeader {
|
||||
TitleOrFileName,
|
||||
@ -26,6 +27,7 @@ class StandardView extends StatelessWidget {
|
||||
final bool showSummary;
|
||||
|
||||
final String searchTerm;
|
||||
final String searchTermLowerCase;
|
||||
|
||||
static final _dateFormat = DateFormat('dd MMM, yyyy');
|
||||
|
||||
@ -38,9 +40,8 @@ class StandardView extends StatelessWidget {
|
||||
@required this.showSummary,
|
||||
@required this.isNoteSelected,
|
||||
@required this.searchTerm,
|
||||
});
|
||||
}) : searchTermLowerCase = searchTerm.toLowerCase();
|
||||
|
||||
@override
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FolderListView(
|
||||
@ -79,10 +80,12 @@ class StandardView extends StatelessWidget {
|
||||
assert(false, "StandardViewHeader must not be null");
|
||||
}
|
||||
|
||||
Widget titleWidget = Text(
|
||||
title,
|
||||
Widget titleWidget = HighlightedText(
|
||||
text: title,
|
||||
style: textTheme.headline6,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
highlightText: searchTerm,
|
||||
highlightTextLowerCase: searchTermLowerCase,
|
||||
);
|
||||
Widget trailing = Container();
|
||||
|
||||
@ -110,11 +113,13 @@ class StandardView extends StatelessWidget {
|
||||
if (showSummary) {
|
||||
var summary = <Widget>[
|
||||
const SizedBox(height: 8.0),
|
||||
Text(
|
||||
note.summary + '\n', // no minLines option
|
||||
HighlightedText(
|
||||
text: note.summary + '\n', // no minLines option
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: textTheme.bodyText2,
|
||||
highlightText: searchTerm,
|
||||
highlightTextLowerCase: searchTermLowerCase,
|
||||
),
|
||||
];
|
||||
|
||||
|
@ -21,22 +21,12 @@ class HighlightedText extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (highlightText.isEmpty) {
|
||||
return Text(
|
||||
text,
|
||||
maxLines: maxLines - 1,
|
||||
overflow: overflow,
|
||||
style: style,
|
||||
);
|
||||
return Text(text, maxLines: maxLines, overflow: overflow, style: style);
|
||||
}
|
||||
|
||||
var i = text.toLowerCase().indexOf(highlightTextLowerCase);
|
||||
if (i == -1) {
|
||||
return Text(
|
||||
text,
|
||||
maxLines: maxLines - 1,
|
||||
overflow: overflow,
|
||||
style: style,
|
||||
);
|
||||
return Text(text, maxLines: maxLines, overflow: overflow, style: style);
|
||||
}
|
||||
|
||||
var highlightStyle = style.copyWith(
|
||||
|
Reference in New Issue
Block a user