add drawer in home page
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:logging/logging.dart';
|
||||
import 'package:sheetless/login_page.dart';
|
||||
import 'package:sheetless/sheet_viewer_page.dart';
|
||||
import 'package:sheetless/storage_helper.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
import 'api.dart';
|
||||
import 'sheet.dart';
|
||||
@@ -21,10 +22,22 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
Future<bool> apiLoggedIn = Future.value(false);
|
||||
final StorageHelper _storageHelper = StorageHelper();
|
||||
final log = Logger("MyHomePage");
|
||||
String? appName;
|
||||
String? appVersion;
|
||||
bool shuffling = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadAppInfo();
|
||||
}
|
||||
|
||||
Future<void> _loadAppInfo() async {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
setState(() {
|
||||
appName = info.appName;
|
||||
appVersion = info.version;
|
||||
});
|
||||
}
|
||||
|
||||
Future<List<Sheet>> acquireSheets() async {
|
||||
@@ -72,19 +85,68 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
).pushReplacement(MaterialPageRoute(builder: (_) => LoginPage()));
|
||||
}
|
||||
|
||||
Drawer _buildDrawer() {
|
||||
return Drawer(
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: EdgeInsetsGeometry.directional(start: 10, end: 10, top: 30),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// Drawer Actions
|
||||
Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
Icons.shuffle,
|
||||
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
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.logout),
|
||||
title: const Text('Logout'),
|
||||
onTap: _logOut,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// App Info at bottom
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Text(
|
||||
'$appName v$appVersion',
|
||||
style: const TextStyle(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Sheetless"),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.logout),
|
||||
tooltip: 'Logout',
|
||||
onPressed: _logOut,
|
||||
),
|
||||
],
|
||||
),
|
||||
// Icon for drawer appears automatically
|
||||
appBar: AppBar(title: const Text("Sheetless")),
|
||||
endDrawer: _buildDrawer(),
|
||||
body: FutureBuilder(
|
||||
future: acquireSheets(),
|
||||
builder: (BuildContext context, AsyncSnapshot<List<Sheet>> snapshot) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import flutter_secure_storage_macos
|
||||
import package_info_plus
|
||||
import path_provider_foundation
|
||||
import screen_retriever_macos
|
||||
import sqflite_darwin
|
||||
@@ -14,6 +15,7 @@ import window_manager
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
||||
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
|
||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||
|
||||
16
pubspec.lock
16
pubspec.lock
@@ -352,6 +352,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.16.0"
|
||||
package_info_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: package_info_plus
|
||||
sha256: f69da0d3189a4b4ceaeb1a3defb0f329b3b352517f52bed4290f83d4f06bc08d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "9.0.0"
|
||||
package_info_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus_platform_interface
|
||||
sha256: "202a487f08836a592a6bd4f901ac69b3a8f146af552bbd14407b6b41e1c3f086"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.1"
|
||||
path:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
@@ -49,6 +49,7 @@ dependencies:
|
||||
flutter_launcher_icons: ^0.14.4
|
||||
hive: ^2.2.3
|
||||
flutter_fullscreen: ^1.2.0
|
||||
package_info_plus: ^9.0.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user