diff --git a/lib/home_page.dart b/lib/home_page.dart index 8881e61..7929dd2 100644 --- a/lib/home_page.dart +++ b/lib/home_page.dart @@ -25,7 +25,7 @@ class _MyHomePageState extends State { String? appName; String? appVersion; bool shuffling = false; - late final Future> sheets; + late Future> sheets; @override void initState() { @@ -87,6 +87,18 @@ class _MyHomePageState extends State { ).pushReplacement(MaterialPageRoute(builder: (_) => LoginPage())); } + void switchShufflingState(bool newState) async { + if (newState) { + (await sheets).shuffle(); + } else { + sheets = sortSheetsByAccessTime(await sheets); + } + + setState(() { + shuffling = newState; + }); + } + Drawer _buildDrawer() { return Drawer( child: SafeArea( @@ -104,22 +116,17 @@ class _MyHomePageState extends State { color: shuffling ? Colors.blue : null, ), title: const Text('Shuffle'), - trailing: Switch( - value: shuffling, - onChanged: (value) { - setState(() { - shuffling = value; - }); - }, - ), - ), - ListTile( - leading: const Icon(Icons.sync), - title: const Text('Sync Mode'), onTap: () { - // TODO + switchShufflingState(!shuffling); }, ), + // ListTile( + // leading: const Icon(Icons.sync), + // title: const Text('Sync Mode'), + // onTap: () { + // // TODO + // }, + // ), ListTile( leading: const Icon(Icons.logout), title: const Text('Logout'),