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/login_page.dart';
|
||||||
import 'package:sheetless/sheet_viewer_page.dart';
|
import 'package:sheetless/sheet_viewer_page.dart';
|
||||||
import 'package:sheetless/storage_helper.dart';
|
import 'package:sheetless/storage_helper.dart';
|
||||||
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
|
||||||
import 'api.dart';
|
import 'api.dart';
|
||||||
import 'sheet.dart';
|
import 'sheet.dart';
|
||||||
@@ -21,10 +22,22 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Future<bool> apiLoggedIn = Future.value(false);
|
Future<bool> apiLoggedIn = Future.value(false);
|
||||||
final StorageHelper _storageHelper = StorageHelper();
|
final StorageHelper _storageHelper = StorageHelper();
|
||||||
final log = Logger("MyHomePage");
|
final log = Logger("MyHomePage");
|
||||||
|
String? appName;
|
||||||
|
String? appVersion;
|
||||||
|
bool shuffling = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.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 {
|
Future<List<Sheet>> acquireSheets() async {
|
||||||
@@ -72,19 +85,68 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
).pushReplacement(MaterialPageRoute(builder: (_) => LoginPage()));
|
).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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
// Icon for drawer appears automatically
|
||||||
title: const Text("Sheetless"),
|
appBar: AppBar(title: const Text("Sheetless")),
|
||||||
actions: [
|
endDrawer: _buildDrawer(),
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.logout),
|
|
||||||
tooltip: 'Logout',
|
|
||||||
onPressed: _logOut,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: FutureBuilder(
|
body: FutureBuilder(
|
||||||
future: acquireSheets(),
|
future: acquireSheets(),
|
||||||
builder: (BuildContext context, AsyncSnapshot<List<Sheet>> snapshot) {
|
builder: (BuildContext context, AsyncSnapshot<List<Sheet>> snapshot) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import FlutterMacOS
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
import flutter_secure_storage_macos
|
import flutter_secure_storage_macos
|
||||||
|
import package_info_plus
|
||||||
import path_provider_foundation
|
import path_provider_foundation
|
||||||
import screen_retriever_macos
|
import screen_retriever_macos
|
||||||
import sqflite_darwin
|
import sqflite_darwin
|
||||||
@@ -14,6 +15,7 @@ import window_manager
|
|||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
||||||
|
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
|
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
|
||||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||||
|
|||||||
16
pubspec.lock
16
pubspec.lock
@@ -352,6 +352,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.16.0"
|
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:
|
path:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ dependencies:
|
|||||||
flutter_launcher_icons: ^0.14.4
|
flutter_launcher_icons: ^0.14.4
|
||||||
hive: ^2.2.3
|
hive: ^2.2.3
|
||||||
flutter_fullscreen: ^1.2.0
|
flutter_fullscreen: ^1.2.0
|
||||||
|
package_info_plus: ^9.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user