home_page: implement shuffling
This commit is contained in:
@@ -25,7 +25,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
String? appName;
|
String? appName;
|
||||||
String? appVersion;
|
String? appVersion;
|
||||||
bool shuffling = false;
|
bool shuffling = false;
|
||||||
late final Future<List<Sheet>> sheets;
|
late Future<List<Sheet>> sheets;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -87,6 +87,18 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
).pushReplacement(MaterialPageRoute(builder: (_) => LoginPage()));
|
).pushReplacement(MaterialPageRoute(builder: (_) => LoginPage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void switchShufflingState(bool newState) async {
|
||||||
|
if (newState) {
|
||||||
|
(await sheets).shuffle();
|
||||||
|
} else {
|
||||||
|
sheets = sortSheetsByAccessTime(await sheets);
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
shuffling = newState;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Drawer _buildDrawer() {
|
Drawer _buildDrawer() {
|
||||||
return Drawer(
|
return Drawer(
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
@@ -104,22 +116,17 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
color: shuffling ? Colors.blue : null,
|
color: shuffling ? Colors.blue : null,
|
||||||
),
|
),
|
||||||
title: const Text('Shuffle'),
|
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: () {
|
onTap: () {
|
||||||
// TODO
|
switchShufflingState(!shuffling);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
// ListTile(
|
||||||
|
// leading: const Icon(Icons.sync),
|
||||||
|
// title: const Text('Sync Mode'),
|
||||||
|
// onTap: () {
|
||||||
|
// // TODO
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.logout),
|
leading: const Icon(Icons.logout),
|
||||||
title: const Text('Logout'),
|
title: const Text('Logout'),
|
||||||
|
|||||||
Reference in New Issue
Block a user