feat: complete Simple Mode contextual routing and navigation state synchronization
This commit is contained in:
@@ -5,11 +5,15 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:lucide_icons/lucide_icons.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../../../app/theme/app_colors.dart';
|
||||
import '../../../data/services/equran_service.dart';
|
||||
import '../../../data/services/unsplash_service.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import '../../../data/local/hive_boxes.dart';
|
||||
import '../../../data/local/models/app_settings.dart';
|
||||
|
||||
/// Quran Murattal (audio player) screen.
|
||||
/// Implements full Surah playback using just_audio and EQuran v2 API.
|
||||
@@ -17,11 +21,13 @@ class QuranMurattalScreen extends ConsumerStatefulWidget {
|
||||
final String surahId;
|
||||
final String? initialQariId;
|
||||
final bool autoPlay;
|
||||
final bool isSimpleModeTab;
|
||||
const QuranMurattalScreen({
|
||||
super.key,
|
||||
required this.surahId,
|
||||
this.initialQariId,
|
||||
this.autoPlay = false,
|
||||
this.isSimpleModeTab = false,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -217,7 +223,7 @@ class _QuranMurattalScreenState extends ConsumerState<QuranMurattalScreen> {
|
||||
final isSelected = entry.key == _selectedQariId;
|
||||
return ListTile(
|
||||
leading: Icon(
|
||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||
isSelected ? LucideIcons.checkCircle2 : LucideIcons.circle,
|
||||
color: isSelected ? AppColors.primary : Colors.grey,
|
||||
),
|
||||
title: Text(
|
||||
@@ -327,7 +333,7 @@ class _QuranMurattalScreenState extends ConsumerState<QuranMurattalScreen> {
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
trailing: isCurrentSurah
|
||||
? Icon(Icons.graphic_eq, color: AppColors.primary, size: 20)
|
||||
? Icon(LucideIcons.music, color: AppColors.primary, size: 20)
|
||||
: null,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
@@ -354,6 +360,8 @@ class _QuranMurattalScreenState extends ConsumerState<QuranMurattalScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
final box = Hive.box<AppSettings>(HiveBoxes.settings);
|
||||
final isSimpleMode = box.get('default')?.simpleMode ?? false;
|
||||
final surahName = _surahData?['namaLatin'] ?? 'Surah ${widget.surahId}';
|
||||
|
||||
final hasPhoto = _unsplashPhoto != null;
|
||||
@@ -361,6 +369,17 @@ class _QuranMurattalScreenState extends ConsumerState<QuranMurattalScreen> {
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: hasPhoto,
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back,
|
||||
color: hasPhoto ? Colors.white : null),
|
||||
onPressed: () {
|
||||
if (widget.isSimpleModeTab) {
|
||||
context.go('/');
|
||||
} else {
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
backgroundColor: hasPhoto ? Colors.transparent : null,
|
||||
elevation: hasPhoto ? 0 : null,
|
||||
iconTheme: hasPhoto ? const IconThemeData(color: Colors.white) : null,
|
||||
@@ -393,7 +412,6 @@ class _QuranMurattalScreenState extends ConsumerState<QuranMurattalScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
),
|
||||
body: _isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
@@ -607,7 +625,7 @@ class _QuranMurattalScreenState extends ConsumerState<QuranMurattalScreen> {
|
||||
IconButton(
|
||||
onPressed: () => setState(() => _isShuffleEnabled = !_isShuffleEnabled),
|
||||
icon: Icon(
|
||||
Icons.shuffle_rounded,
|
||||
LucideIcons.shuffle,
|
||||
size: 24,
|
||||
color: _isShuffleEnabled
|
||||
? (_unsplashPhoto != null ? Colors.white : AppColors.primary)
|
||||
@@ -622,7 +640,7 @@ class _QuranMurattalScreenState extends ConsumerState<QuranMurattalScreen> {
|
||||
? () => _navigateToSurah(-1)
|
||||
: null,
|
||||
icon: Icon(
|
||||
Icons.skip_previous_rounded,
|
||||
LucideIcons.skipBack,
|
||||
size: 36,
|
||||
color: (int.tryParse(widget.surahId) ?? 1) > 1
|
||||
? (_unsplashPhoto != null ? Colors.white : (isDark ? AppColors.textSecondaryDark : AppColors.textSecondaryLight))
|
||||
@@ -669,8 +687,8 @@ class _QuranMurattalScreenState extends ConsumerState<QuranMurattalScreen> {
|
||||
)
|
||||
: Icon(
|
||||
_isPlaying
|
||||
? Icons.pause_rounded
|
||||
: Icons.play_arrow_rounded,
|
||||
? LucideIcons.pause
|
||||
: LucideIcons.play,
|
||||
size: 36,
|
||||
color: _unsplashPhoto != null
|
||||
? Colors.black87
|
||||
@@ -684,7 +702,7 @@ class _QuranMurattalScreenState extends ConsumerState<QuranMurattalScreen> {
|
||||
? () => _navigateToSurah(1)
|
||||
: null,
|
||||
icon: Icon(
|
||||
Icons.skip_next_rounded,
|
||||
LucideIcons.skipForward,
|
||||
size: 36,
|
||||
color: (int.tryParse(widget.surahId) ?? 1) < 114
|
||||
? (_unsplashPhoto != null ? Colors.white : (isDark ? AppColors.textSecondaryDark : AppColors.textSecondaryLight))
|
||||
@@ -695,7 +713,7 @@ class _QuranMurattalScreenState extends ConsumerState<QuranMurattalScreen> {
|
||||
IconButton(
|
||||
onPressed: _showSurahPlaylist,
|
||||
icon: Icon(
|
||||
Icons.playlist_play_rounded,
|
||||
LucideIcons.listMusic,
|
||||
size: 28,
|
||||
color: _unsplashPhoto != null
|
||||
? Colors.white70
|
||||
@@ -720,7 +738,7 @@ class _QuranMurattalScreenState extends ConsumerState<QuranMurattalScreen> {
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.person, size: 16,
|
||||
Icon(LucideIcons.user, size: 16,
|
||||
color: _unsplashPhoto != null ? Colors.white : AppColors.primary),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
@@ -732,7 +750,7 @@ class _QuranMurattalScreenState extends ConsumerState<QuranMurattalScreen> {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(Icons.expand_more,
|
||||
Icon(LucideIcons.chevronDown,
|
||||
size: 16,
|
||||
color: _unsplashPhoto != null ? Colors.white : AppColors.primary),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user