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