Add audio file selection callback and integrate audio player bar in file explorer and home page

This commit is contained in:
Leon Bösche
2026-01-16 15:49:33 +01:00
parent 13c5aed435
commit 0b2a9bad2f
4 changed files with 79 additions and 518 deletions

View File

@@ -17,6 +17,7 @@ import '../theme/app_theme.dart';
import '../theme/modern_glass_button.dart';
import 'login_form.dart' show LoginForm;
import 'file_explorer.dart';
import '../widgets/audio_player_bar.dart';
import '../injection.dart';
class HomePage extends StatefulWidget {
@@ -27,6 +28,12 @@ class HomePage extends StatefulWidget {
}
class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
// Audio bar state
String? _audioFileName;
String? _audioFileUrl;
bool _showAudioBar = false;
late AnimationController _audioBarController;
late Animation<Offset> _audioBarOffset;
late String _selectedTab = 'Drive';
late AnimationController _animationController;
bool _isSignupMode = false;
@@ -46,6 +53,18 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
vsync: this,
);
_audioBarController = AnimationController(
duration: const Duration(milliseconds: 400),
vsync: this,
);
_audioBarOffset =
Tween<Offset>(begin: const Offset(0, -1), end: Offset.zero).animate(
CurvedAnimation(
parent: _audioBarController,
curve: Curves.easeOutBack,
),
);
_permissionBloc = PermissionBloc();
_fileBrowserBloc = FileBrowserBloc(getIt<FileService>());
_uploadBloc = UploadBloc(getIt<FileRepository>());
@@ -60,6 +79,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
@override
void dispose() {
_animationController.dispose();
_audioBarController.dispose();
_organizationBloc.close();
_uploadBloc.close();
_fileBrowserBloc.close();
@@ -67,6 +87,15 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
super.dispose();
}
void _onAudioFileSelected(String fileName, String fileUrl) {
setState(() {
_audioFileName = fileName;
_audioFileUrl = fileUrl;
_showAudioBar = true;
});
_audioBarController.forward();
}
void _setSignupMode(bool isSignup) {
if (_isSignupMode && !isSignup) {
Future.delayed(const Duration(milliseconds: 200), () {
@@ -317,7 +346,10 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
orgId = '';
}
return FileExplorer(orgId: orgId);
return FileExplorer(
orgId: orgId,
onAudioFileSelected: _onAudioFileSelected,
);
}
Widget _buildNavButton(String label, IconData icon, {bool isAvatar = false}) {
@@ -373,6 +405,37 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
backgroundColor: AppTheme.primaryBackground,
body: Stack(
children: [
// Audio bar between title and button row
Positioned(
top: MediaQuery.of(context).size.width < 600 ? 36 : 60,
left: 0,
right: 0,
child: AnimatedBuilder(
animation: _audioBarController,
builder: (context, child) {
return (_showAudioBar &&
_audioFileName != null &&
_audioFileUrl != null)
? SlideTransition(
position: _audioBarOffset,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 32.0,
),
child: AudioPlayerBar(
fileName: _audioFileName!,
fileUrl: _audioFileUrl!,
onClose: () {
_audioBarController.reverse();
setState(() => _showAudioBar = false);
},
),
),
)
: const SizedBox.shrink();
},
),
),
Center(
child: BlocBuilder<AuthBloc, AuthState>(
builder: (context, state) {