From f81b6556c4d364efd87f1e8b48ce3ee62d568521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Mon, 27 Mar 2023 19:50:13 +0200 Subject: [PATCH] fix: sort and double recent heading --- lib/views/home.dart | 46 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/lib/views/home.dart b/lib/views/home.dart index 0c20ecd..dc46829 100644 --- a/lib/views/home.dart +++ b/lib/views/home.dart @@ -29,29 +29,15 @@ class _HomeViewState extends State { height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width * 0.9, child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: (_recents.isEmpty) - ? [ - const Flexible( - child: Text( - "You haven't opened anything recently, swipe right and start searching."), - ) - ] - : _recents - ..insert( - 0, - const Text( - "Recent pages", - style: PageStyles.h1, - ), - ) - ..insert( - 1, - const SizedBox( - height: 15, - ), - ), - ), + mainAxisAlignment: MainAxisAlignment.center, + children: (_recents.isEmpty) + ? [ + const Flexible( + child: Text( + "You haven't opened anything recently, swipe right and start searching."), + ) + ] + : _recents), ), ), ); @@ -62,12 +48,20 @@ class _HomeViewState extends State { if (recent.isEmpty) return; recent.sort((a, b) => DateTime.fromMillisecondsSinceEpoch(a["date"]) .isAfter(DateTime.fromMillisecondsSinceEpoch(b["date"])) - ? 1 + ? -1 : DateTime.fromMillisecondsSinceEpoch(a["date"]).isAtSameMomentAs( DateTime.fromMillisecondsSinceEpoch(b["date"])) ? 0 - : -1); - _recents = []; + : 1); + _recents = [ + const Text( + "Recent pages", + style: PageStyles.h1, + ), + const SizedBox( + height: 15, + ), + ]; for (var r in recent) { if (!mounted) return; _recents.add(