fix: sort and double recent heading
This commit is contained in:
parent
925174bcb6
commit
f81b6556c4
1 changed files with 20 additions and 26 deletions
|
@ -29,29 +29,15 @@ class _HomeViewState extends State<HomeView> {
|
||||||
height: MediaQuery.of(context).size.height,
|
height: MediaQuery.of(context).size.height,
|
||||||
width: MediaQuery.of(context).size.width * 0.9,
|
width: MediaQuery.of(context).size.width * 0.9,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: (_recents.isEmpty)
|
children: (_recents.isEmpty)
|
||||||
? [
|
? [
|
||||||
const Flexible(
|
const Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
"You haven't opened anything recently, swipe right and start searching."),
|
"You haven't opened anything recently, swipe right and start searching."),
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
: _recents
|
: _recents),
|
||||||
..insert(
|
|
||||||
0,
|
|
||||||
const Text(
|
|
||||||
"Recent pages",
|
|
||||||
style: PageStyles.h1,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
..insert(
|
|
||||||
1,
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -62,12 +48,20 @@ class _HomeViewState extends State<HomeView> {
|
||||||
if (recent.isEmpty) return;
|
if (recent.isEmpty) return;
|
||||||
recent.sort((a, b) => DateTime.fromMillisecondsSinceEpoch(a["date"])
|
recent.sort((a, b) => DateTime.fromMillisecondsSinceEpoch(a["date"])
|
||||||
.isAfter(DateTime.fromMillisecondsSinceEpoch(b["date"]))
|
.isAfter(DateTime.fromMillisecondsSinceEpoch(b["date"]))
|
||||||
? 1
|
? -1
|
||||||
: DateTime.fromMillisecondsSinceEpoch(a["date"]).isAtSameMomentAs(
|
: DateTime.fromMillisecondsSinceEpoch(a["date"]).isAtSameMomentAs(
|
||||||
DateTime.fromMillisecondsSinceEpoch(b["date"]))
|
DateTime.fromMillisecondsSinceEpoch(b["date"]))
|
||||||
? 0
|
? 0
|
||||||
: -1);
|
: 1);
|
||||||
_recents = [];
|
_recents = [
|
||||||
|
const Text(
|
||||||
|
"Recent pages",
|
||||||
|
style: PageStyles.h1,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
];
|
||||||
for (var r in recent) {
|
for (var r in recent) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
_recents.add(
|
_recents.add(
|
||||||
|
|
Loading…
Reference in a new issue