Skip to content

Commit

Permalink
Fix/ Update 1.18 branch with main changes (#1463)
Browse files Browse the repository at this point in the history
* fix: Improve Quran Download and Navigation Experience (#1452)

* fix: Ensure correct Moshaf type (Hafs) is displayed after download

* fix: display Hafs Quran correctly and remove success dialog

- Set Hafs as default Moshaf type if none is selected.
- Auto-dismiss success dialog on download completion.
- Improved state invalidation for Quran reading updates.
- Added FocusNode for better dialog interaction.
- Optimized resource management with keepAlive and link.close().

* fix: improve Quran Download and Navigation Experience

- Redirect user to Quran reading screen automatically after successful download and extraction of Quran (Hafs).
- Remove the unnecessary "OK" button to confirm Quran download completion, streamlining the user experience.
- Enhance state management for download-related UI in `quran_reading_screen.dart` to handle various download states (needed, downloading, extracting).
- Update `download_quran_popup.dart` to ensure proper navigation based on the user's first-time download experience.
- Improve error handling and loading indicators for a smoother and more intuitive flow.

* fix formating

* Update pubspec.yaml

* fix: Resolve overlapping and focus issues for Back and Switch buttons (#1457)

* fix: Resolve pop-up issue when selecting Listening mode (#1455)

- updated `_handleNavigation` method in `quran_mode_selection_screen.dart` to use `async/await` for ensuring proper completion of Quran mode selection before navigation.
- fixed unexpected pop-ups by adjusting the handling of the `moshafType` state in `download_quran_popup.dart`.
- improved navigation flow for both Reading and Listening modes, ensuring seamless user experience.

Co-authored-by: Ghassen Ben Zahra <[email protected]>

* Update pubspec.yaml

---------

Co-authored-by: Yassin Nouh <[email protected]>
Co-authored-by: Ibrahim ZEHHAF <[email protected]>
  • Loading branch information
3 people committed Dec 3, 2024
1 parent e8ebc98 commit d1e490d
Show file tree
Hide file tree
Showing 5 changed files with 268 additions and 168 deletions.
6 changes: 3 additions & 3 deletions lib/src/pages/quran/page/quran_mode_selection_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ class _QuranModeSelectionState extends ConsumerState<QuranModeSelection> {
}
}

void _handleNavigation(int index) {
Future<void> _handleNavigation(int index) async {
if (index == 0) {
ref.read(quranNotifierProvider.notifier).selectModel(QuranMode.reading);
await ref.read(quranNotifierProvider.notifier).selectModel(QuranMode.reading);
Navigator.pushReplacementNamed(context, Routes.quranReading);
} else {
ref.read(quranNotifierProvider.notifier).selectModel(QuranMode.listening);
await ref.read(quranNotifierProvider.notifier).selectModel(QuranMode.listening);
Navigator.pushReplacementNamed(context, Routes.quranReciter);
}
}
Expand Down
94 changes: 53 additions & 41 deletions lib/src/pages/quran/reading/quran_reading_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ class NormalViewStrategy implements QuranViewStrategy {
) {
if (isPortrait) {
return [
BackButtonWidget(
isPortrait: isPortrait,
userPrefs: userPrefs,
focusNode: focusNodes.backButtonNode,
),
SurahSelectorWidget(
isPortrait: isPortrait,
focusNode: focusNodes.surahSelectorNode,
Expand All @@ -157,15 +152,15 @@ class NormalViewStrategy implements QuranViewStrategy {
focusNode: focusNodes.switchQuranNode,
isThereCurrentDialogShowing: false,
),
BackButtonWidget(
isPortrait: isPortrait,
userPrefs: userPrefs,
focusNode: focusNodes.backButtonNode,
),
];
}

return [
BackButtonWidget(
isPortrait: isPortrait,
userPrefs: userPrefs,
focusNode: focusNodes.backButtonNode,
),
_buildNavigationButtons(
context,
focusNodes,
Expand All @@ -188,6 +183,11 @@ class NormalViewStrategy implements QuranViewStrategy {
focusNode: focusNodes.switchQuranNode,
isThereCurrentDialogShowing: false,
),
BackButtonWidget(
isPortrait: isPortrait,
userPrefs: userPrefs,
focusNode: focusNodes.backButtonNode,
),
];
}

Expand Down Expand Up @@ -247,7 +247,6 @@ class _QuranReadingScreenState extends ConsumerState<QuranReadingScreen> {

WidgetsBinding.instance.addPostFrameCallback((_) async {
ref.read(downloadQuranNotifierProvider);
ref.read(quranReadingNotifierProvider);
});
}

Expand Down Expand Up @@ -321,38 +320,51 @@ class _QuranReadingScreenState extends ConsumerState<QuranReadingScreen> {
});

final autoReadingState = ref.watch(autoScrollNotifierProvider);

return WillPopScope(
onWillPop: () async {
userPrefs.orientationLandscape = true;
return true;
},
child: quranReadingState.when(
data: (state) {
setState(() {
_isRotated = state.isRotated;
});
return RotatedBox(
quarterTurns: state.isRotated ? -1 : 0,
child: SizedBox(
width: MediaQuery.of(context).size.height,
height: MediaQuery.of(context).size.width,
child: Scaffold(
backgroundColor: Colors.white,
floatingActionButtonLocation: _getFloatingActionButtonLocation(context),
floatingActionButton: QuranFloatingActionControls(
switchScreenViewFocusNode: _switchScreenViewFocusNode,
switchQuranModeNode: _switchQuranModeNode,
switchToPlayQuranFocusNode: _switchToPlayQuranFocusNode,
),
body: _buildBody(quranReadingState, state.isRotated, userPrefs, autoReadingState),
),
final downloadState = ref.watch(downloadQuranNotifierProvider);
return downloadState.when(
data: (data) {
if (data is NeededDownloadedQuran || data is Downloading || data is Extracting) {
return Scaffold(
body: Container(
color: Colors.white,
),
);
},
loading: () => SizedBox(),
error: (error, stack) => const Icon(Icons.error),
),
}
return WillPopScope(
onWillPop: () async {
userPrefs.orientationLandscape = true;
return true;
},
child: quranReadingState.when(
data: (state) {
setState(() {
_isRotated = state.isRotated;
});
return RotatedBox(
quarterTurns: state.isRotated ? -1 : 0,
child: SizedBox(
width: MediaQuery.of(context).size.height,
height: MediaQuery.of(context).size.width,
child: Scaffold(
backgroundColor: Colors.white,
floatingActionButtonLocation: _getFloatingActionButtonLocation(context),
floatingActionButton: QuranFloatingActionControls(
switchScreenViewFocusNode: _switchScreenViewFocusNode,
switchQuranModeNode: _switchQuranModeNode,
switchToPlayQuranFocusNode: _switchToPlayQuranFocusNode,
),
body: _buildBody(quranReadingState, state.isRotated, userPrefs, autoReadingState),
),
),
);
},
loading: () => Scaffold(body: SizedBox()),
error: (error, stack) => Scaffold(body: const Icon(Icons.error)),
),
);
},
loading: () => Scaffold(body: _buildLoadingIndicator()),
error: (error, stack) => Scaffold(body: _buildErrorIndicator(error)),
);
}

Expand Down
Loading

0 comments on commit d1e490d

Please sign in to comment.