mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-09-15 16:03:34 +08:00

This reverts commit 303192d9d575b26a77a00f7a62212f310ec1e329. This reverts commit cd9d128b47ed523036f7ae1232ec7adcf04ed8a9. GitJournal is used by non-English speakers (a lot in China and Russia) and while we don't support those languages completely, we do support them a little bit. I don't want to loose this functionality. It would be better for us to fix the bug in intl.
101 lines
2.5 KiB
Dart
101 lines
2.5 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:gitjournal/folder_views/list_view.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
import 'package:gitjournal/core/sorting_mode.dart';
|
|
import 'package:gitjournal/core/note.dart';
|
|
import 'package:gitjournal/core/notes_folder.dart';
|
|
|
|
class JournalView extends StatelessWidget {
|
|
final NoteSelectedFunction noteSelectedFunction;
|
|
final NotesFolder folder;
|
|
final String emptyText;
|
|
|
|
static final _dateFormat = DateFormat('dd MMM, yyyy ');
|
|
static final _timeFormat = DateFormat('Hm');
|
|
|
|
JournalView({
|
|
@required this.folder,
|
|
@required this.noteSelectedFunction,
|
|
@required this.emptyText,
|
|
});
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FolderListView(
|
|
folder: folder,
|
|
emptyText: emptyText,
|
|
noteTileBuilder: _buildRow,
|
|
);
|
|
}
|
|
|
|
Widget _buildRow(BuildContext context, Note note) {
|
|
Widget titleWidget = Container();
|
|
var textTheme = Theme.of(context).textTheme;
|
|
|
|
DateTime date;
|
|
var sortingMode = folder.config.sortingMode;
|
|
if (sortingMode == SortingMode.Created) {
|
|
date = note.created;
|
|
} else {
|
|
date = note.modified;
|
|
}
|
|
|
|
if (date != null) {
|
|
var dateStr = _dateFormat.format(date);
|
|
var time = _timeFormat.format(date);
|
|
|
|
var timeColor = textTheme.bodyText2.color.withAlpha(100);
|
|
|
|
titleWidget = Row(
|
|
children: <Widget>[
|
|
Text(dateStr, style: textTheme.headline6),
|
|
Text(time, style: textTheme.bodyText2.copyWith(color: timeColor)),
|
|
],
|
|
crossAxisAlignment: CrossAxisAlignment.baseline,
|
|
textBaseline: TextBaseline.alphabetic,
|
|
);
|
|
}
|
|
|
|
var children = <Widget>[
|
|
const SizedBox(height: 8.0),
|
|
Text(
|
|
note.summary + '\n', // no minLines option
|
|
maxLines: 3,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: textTheme.bodyText2,
|
|
),
|
|
];
|
|
|
|
var tile = ListTile(
|
|
isThreeLine: true,
|
|
title: titleWidget,
|
|
subtitle: Column(
|
|
children: children,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
),
|
|
onTap: () => noteSelectedFunction(note),
|
|
);
|
|
|
|
var dc = Theme.of(context).dividerColor;
|
|
var divider = Container(
|
|
height: 1.0,
|
|
child: Divider(color: dc.withOpacity(dc.opacity / 3)),
|
|
);
|
|
|
|
return Column(
|
|
children: <Widget>[
|
|
divider,
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 16.0, bottom: 16.0),
|
|
child: tile,
|
|
),
|
|
divider,
|
|
],
|
|
);
|
|
}
|
|
}
|