home_page: implement shuffling
This commit is contained in:
@@ -25,7 +25,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
String? appName;
|
||||
String? appVersion;
|
||||
bool shuffling = false;
|
||||
late final Future<List<Sheet>> sheets;
|
||||
late Future<List<Sheet>> sheets;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -87,6 +87,18 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
).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<MyHomePage> {
|
||||
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'),
|
||||
|
||||
Reference in New Issue
Block a user