// lib/screens/permission_screen.dart // // Shown when the user hasn't yet granted Notification Listener access. // Explains why it's needed and opens the system settings page. import 'package:flutter/material.dart'; import '../services/media_service.dart'; class PermissionScreen extends StatelessWidget { final MediaService mediaService; final VoidCallback onPermissionGranted; const PermissionScreen({ super.key, required this.mediaService, required this.onPermissionGranted, }); Future _openSettings(BuildContext context) async { await mediaService.requestPermission(); // Poll after a short delay — the user may have just come back from settings await Future.delayed(const Duration(seconds: 1)); final granted = await mediaService.hasPermission(); if (granted) onPermissionGranted(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: const Color(0xFF0D0D0D), body: SafeArea( child: Padding( padding: const EdgeInsets.all(36), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Icon( Icons.notifications_active_outlined, color: Colors.white54, size: 72, ), const SizedBox(height: 32), const Text( 'Notification Access Needed', style: TextStyle( color: Colors.white, fontSize: 22, fontWeight: FontWeight.w700, ), textAlign: TextAlign.center, ), const SizedBox(height: 16), Text( 'OpenVinyl reads your currently playing music from your notification shade — ' 'it never accesses your messages or other notifications.\n\n' 'Tap below to open system settings and enable access for OpenVinyl.', style: TextStyle( color: Colors.white.withOpacity(0.6), fontSize: 15, height: 1.55, ), textAlign: TextAlign.center, ), const SizedBox(height: 40), FilledButton.icon( onPressed: () => _openSettings(context), icon: const Icon(Icons.settings_outlined), label: const Text('Open Settings'), style: FilledButton.styleFrom( backgroundColor: Colors.white, foregroundColor: Colors.black, padding: const EdgeInsets.symmetric( horizontal: 32, vertical: 14, ), textStyle: const TextStyle( fontSize: 16, fontWeight: FontWeight.w600, ), ), ), ], ), ), ), ); } }