Implement refresh on drag down

This commit is contained in:
2026-01-24 20:06:56 +01:00
parent 11140a748a
commit f564a39975

View File

@@ -93,6 +93,12 @@ class _MyHomePageState extends State<MyHomePage> with FullScreenListener {
return sheets;
}
Future<void> _refreshSheets() async {
setState(() {
sheets = acquireSheets();
});
}
Future<void> _logOut() async {
// Delete saved jwt
await _storageHelper.writeSecure(SecureStorageKey.jwt, null);
@@ -189,14 +195,17 @@ class _MyHomePageState extends State<MyHomePage> with FullScreenListener {
// Icon for drawer appears automatically
appBar: AppBar(title: const Text("Sheetless")),
endDrawer: _buildDrawer(),
body: FutureBuilder(
body: RefreshIndicator(
onRefresh: _refreshSheets,
child: FutureBuilder(
future: sheets,
builder: (BuildContext context, AsyncSnapshot<List<Sheet>> snapshot) {
if (snapshot.hasData) {
return SheetsWidget(
sheets: snapshot.data!,
onSheetOpenRequest: (sheet) {
_storageHelper.writeSheetAccessTime(sheet.uuid, DateTime.now());
_storageHelper.writeSheetAccessTime(
sheet.uuid, DateTime.now());
Navigator.push(
context,
MaterialPageRoute(
@@ -225,6 +234,7 @@ class _MyHomePageState extends State<MyHomePage> with FullScreenListener {
}
},
),
),
);
}
}