77 lines
1.8 KiB
Dart
77 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// Callback for shuffle state changes.
|
|
typedef ShuffleCallback = void Function(bool enabled);
|
|
|
|
/// Navigation drawer for the home page.
|
|
///
|
|
/// Provides access to app-level actions like shuffle mode and logout.
|
|
class AppDrawer extends StatelessWidget {
|
|
final bool isShuffling;
|
|
final ShuffleCallback onShuffleChanged;
|
|
final VoidCallback onLogout;
|
|
final String? appName;
|
|
final String? appVersion;
|
|
|
|
const AppDrawer({
|
|
super.key,
|
|
required this.isShuffling,
|
|
required this.onShuffleChanged,
|
|
required this.onLogout,
|
|
this.appName,
|
|
this.appVersion,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Drawer(
|
|
child: SafeArea(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 30),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
_buildActions(),
|
|
_buildAppInfo(),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildActions() {
|
|
return Column(
|
|
children: [
|
|
ListTile(
|
|
leading: Icon(
|
|
Icons.shuffle,
|
|
color: isShuffling ? Colors.blue : null,
|
|
),
|
|
title: const Text('Shuffle'),
|
|
onTap: () => onShuffleChanged(!isShuffling),
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.logout),
|
|
title: const Text('Logout'),
|
|
onTap: onLogout,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildAppInfo() {
|
|
final versionText = appName != null && appVersion != null
|
|
? '$appName v$appVersion'
|
|
: 'Loading...';
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Text(
|
|
versionText,
|
|
style: const TextStyle(color: Colors.grey),
|
|
),
|
|
);
|
|
}
|
|
}
|