Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/ Update 1.18 branch with main changes #1463

Merged
merged 7 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading