Skip to content
Open
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
206 changes: 147 additions & 59 deletions lib/ui/views/reader/reader_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,73 +35,168 @@ class ReaderView extends StackedView<ReaderViewModel> {
statusBarIconBrightness: Brightness.light,
statusBarColor: context.theme.appColors.appbarBackground,
));
final bool isTablet = MediaQuery.of(context).size.shortestSide >= 800;
final bool isLandscape =
MediaQuery.of(context).orientation == Orientation.landscape;

return Scaffold(
key: _scaffoldKey,
backgroundColor: context.theme.appColors.appbarBackground,
appBar: viewModel.showSecondaryArea
? PreferredSize(
preferredSize: const Size(double.infinity, kToolbarHeight),
child: SafeArea(
child: SecondaryReaderAppbar(
isReaderAreaPopupActive: viewModel.isSecondaryReaderAreaPopupActive,
onTapBook: () => viewModel.onTapBook(Area.secondary),
onTapBibleVersion: () => viewModel.onTapBibleVersion(Area.secondary),
onTapClose: viewModel.onTapCloseSecondaryArea,
),
),
)
: null,
body: SafeArea(
child: Stack(
child: Column(
children: [
Container(
color: context.theme.appColors.background,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
Expanded(
child: Stack(
children: [
Expanded(
child: WebViewWidget(
controller: viewModel.webviewController,
Container(
padding: EdgeInsets.only(
top: (!(isTablet || isLandscape) &&
viewModel.showSecondaryArea)
? 58.0
: 0.0,
),
color: context.theme.appColors.background,
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: WebViewWidget(
controller: viewModel.webviewController,
),
),
if (viewModel.primaryAreaBible.startsWith('OET') ||
viewModel.secondaryAreaBible.startsWith('OET'))
Container(
color: context.theme.appColors.background,
padding: const EdgeInsets.symmetric(
vertical: 4.0, horizontal: 12.0),
child: Text(
'This is still a very early look into the unfinished text of the Open English Translation of the Bible. Please double-check the text in advance before using in public. Found a mistake or have questions about the translation? Please visit www.openenglishtranslation.bible.',
style: TextStyle(
fontSize: 8.0,
color: context.theme.appColors.readerText,
),
),
),
],
),
),
if (viewModel.primaryAreaBible.startsWith('OET') || viewModel.secondaryAreaBible.startsWith('OET'))
Container(
color: context.theme.appColors.background,
padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 12.0),
child: Text(
'This is still a very early look into the unfinished text of the Open English Translation of the Bible. Please double-check the text in advance before using in public. Found a mistake or have questions about the translation? Please visit www.openenglishtranslation.bible.',
style: TextStyle(
fontSize: 8.0,
color: context.theme.appColors.readerText,
if (viewModel.isBusy)
Center(
child: CircularProgressIndicator(
color: context.theme.appColors.loadingSpinner,
),
),
if (viewModel.isSecondaryReaderAreaPopupActive &&
!(viewModel.isPrimaryReaderAreaPopupActive))
Padding(
padding: EdgeInsets.only(
top: (isLandscape || isTablet) ? 0.0 : 58.0,
),
child: Align(
alignment:
(isLandscape || isTablet) //TODO CHANGE ARROW BUTTON
? Alignment.bottomCenter
: Alignment.topCenter,
child: ReaderAreaPopup(
readerArea: Area.secondary,
onToggleSecondaryArea:
viewModel.onToggleSecondaryArea,
onToggleLinkedScrolling:
viewModel.onToggleLinkedScrolling,
),
),
),
if (viewModel.isPrimaryReaderAreaPopupActive &&
!(viewModel.isSecondaryReaderAreaPopupActive))
Align(
alignment: Alignment.bottomCenter,
child: ReaderAreaPopup(
readerArea: Area.primary,
onToggleSecondaryArea: viewModel.onToggleSecondaryArea,
onToggleLinkedScrolling:
viewModel.onToggleLinkedScrolling,
),
),
if (!(isTablet || isLandscape) &&
viewModel
.showSecondaryArea) //for portrait phones only, show secondary appbar at the top of the screen
Align(
alignment: Alignment.topCenter,
child: SecondaryReaderAppbar(
isReaderAreaPopupActive:
viewModel.isSecondaryReaderAreaPopupActive,
onTapBook: () => viewModel.onTapBook(Area.secondary),
onTapBibleVersion: () =>
viewModel.onTapBibleVersion(Area.secondary),
onTapClose: viewModel.onTapCloseSecondaryArea,
),
),
],
),
),
if (viewModel.isBusy)
if (viewModel.showSecondaryArea) //is there a secondary appbar?
// Tablet: side-by-side, Phone: secondary on top via Stack overlay + primary bottom.
//TODO: allow multiple screens (teriary, quaternary, etc) and make this more dynamic instead of just primary vs secondary
isTablet || isLandscape
? Row(
children: [
Expanded(
//Primary
child: Align(
alignment: Alignment.centerLeft,
child: PrimaryReaderAppbar(
isReaderAreaPopupActive:
viewModel.isPrimaryReaderAreaPopupActive,
onTapSearch: viewModel.onTapSearch,
onTapBook: () =>
viewModel.onTapBook(Area.primary),
onTapBibleVersion: () =>
viewModel.onTapBibleVersion(Area.primary),
),
),
),
Expanded(
//Secondary
child: Align(
alignment: Alignment.centerRight,
child: SecondaryReaderAppbar(
isReaderAreaPopupActive:
viewModel.isSecondaryReaderAreaPopupActive,
onTapBook: () =>
viewModel.onTapBook(Area.secondary),
onTapBibleVersion: () =>
viewModel.onTapBibleVersion(Area.secondary),
onTapClose: viewModel.onTapCloseSecondaryArea,
onTapMenu: () =>
_scaffoldKey.currentState?.openEndDrawer(),
),
),
),
],
)
: PrimaryReaderAppbar(
//if phone in portait
isReaderAreaPopupActive:
viewModel.isPrimaryReaderAreaPopupActive,
onTapSearch: viewModel.onTapSearch,
onTapBook: () => viewModel.onTapBook(Area.primary),
onTapBibleVersion: () =>
viewModel.onTapBibleVersion(Area.primary),
onTapMenu: () =>
_scaffoldKey.currentState?.openEndDrawer(),
)
else //no secondary appbar, just show the primary appbar regardless of screen size or orientation
Center(
child: CircularProgressIndicator(
color: context.theme.appColors.loadingSpinner,
),
),
if (viewModel.isSecondaryReaderAreaPopupActive)
Align(
alignment: Alignment.topCenter,
child: ReaderAreaPopup(
readerArea: Area.secondary,
onToggleSecondaryArea: viewModel.onToggleSecondaryArea,
onToggleLinkedScrolling: viewModel.onToggleLinkedScrolling,
),
),
if (viewModel.isPrimaryReaderAreaPopupActive)
Align(
alignment: Alignment.bottomCenter,
child: ReaderAreaPopup(
readerArea: Area.primary,
onToggleSecondaryArea: viewModel.onToggleSecondaryArea,
onToggleLinkedScrolling: viewModel.onToggleLinkedScrolling,
child: PrimaryReaderAppbar(
isReaderAreaPopupActive:
viewModel.isPrimaryReaderAreaPopupActive,
onTapSearch: viewModel.onTapSearch,
onTapBook: () => viewModel.onTapBook(Area.primary),
onTapBibleVersion: () =>
viewModel.onTapBibleVersion(Area.primary),
onTapMenu: () => _scaffoldKey.currentState?.openEndDrawer(),
),
),
],
Expand All @@ -110,13 +205,6 @@ class ReaderView extends StackedView<ReaderViewModel> {
endDrawer: SideNavigationDrawer(
closeNavigation: () => _scaffoldKey.currentState?.closeEndDrawer(),
),
bottomNavigationBar: PrimaryReaderAppbar(
isReaderAreaPopupActive: viewModel.isPrimaryReaderAreaPopupActive,
onTapSearch: viewModel.onTapSearch,
onTapBook: () => viewModel.onTapBook(Area.primary),
onTapBibleVersion: () => viewModel.onTapBibleVersion(Area.primary),
onTapMenu: () => _scaffoldKey.currentState?.openEndDrawer(),
),
// floatingActionButton: kDebugMode
// ? FloatingActionButton.small(
// backgroundColor: context.theme.appColors.appbarBackground,
Expand Down
1 change: 1 addition & 0 deletions lib/ui/views/reader/reader_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ class ReaderViewModel extends ReactiveViewModel {
}

void onTapCloseSecondaryArea() async {
log("ON TAP CLOSE SECONDARY AREA");
onToggleSecondaryArea();
isPrimaryReaderAreaPopupActive = false;
isSecondaryReaderAreaPopupActive = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class PrimaryReaderAppbar extends StackedView<PrimaryReaderAppbarModel> {
required this.onTapSearch,
required this.onTapBook,
required this.onTapBibleVersion,
required this.onTapMenu,
this.onTapMenu,
});

final bool isReaderAreaPopupActive;
final Function() onTapSearch;
final Function() onTapBook;
final Function() onTapBibleVersion;
final Function() onTapMenu;
final Function()? onTapMenu;

@override
Widget builder(
Expand Down Expand Up @@ -53,18 +53,21 @@ class PrimaryReaderAppbar extends StackedView<PrimaryReaderAppbarModel> {
onTapBook: onTapBook,
onTapBibleVersion: onTapBibleVersion,
),
InkWell(
onTap: onTapMenu,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: PhosphorIcon(
PhosphorIcons.list(PhosphorIconsStyle.bold),
color: context.theme.appColors.appbarIcon,
size: 20.0,
semanticLabel: 'Menu',
if (onTapMenu != null)
InkWell(
onTap: onTapMenu,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: PhosphorIcon(
PhosphorIcons.list(PhosphorIconsStyle.bold),
color: context.theme.appColors.appbarIcon,
size: 20.0,
semanticLabel: 'Menu',
),
),
),
),
)
else
const SizedBox(width: 52.0),
],
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ class SecondaryReaderAppbar extends StackedView<SecondaryReaderAppbarModel> {
required this.onTapBook,
required this.onTapBibleVersion,
required this.onTapClose,
this.onTapMenu,
});

final bool isReaderAreaPopupActive;
final Function() onTapBook;
final Function() onTapBibleVersion;
final Function() onTapClose;
final Function()? onTapMenu;

@override
Widget builder(
Expand All @@ -35,27 +37,47 @@ class SecondaryReaderAppbar extends StackedView<SecondaryReaderAppbarModel> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
width: 36,
width: 52,
height: 29,
),
ReaderSelectorBtn(
readerArea: Area.secondary,
isActive: isReaderAreaPopupActive,
onTapBook: onTapBook,
onTapBibleVersion: onTapBibleVersion,
),
InkWell(
onTap: onTapClose,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 9.0),
child: PhosphorIcon(
PhosphorIcons.x(PhosphorIconsStyle.bold),
color: context.theme.appColors.secondaryOnDark,
size: 20.0,
semanticLabel: 'Close',
Row(
mainAxisSize: MainAxisSize.min,
children: [
ReaderSelectorBtn(
readerArea: Area.secondary,
isActive: isReaderAreaPopupActive,
onTapBook: onTapBook,
onTapBibleVersion: onTapBibleVersion,
),
InkWell(
onTap: onTapClose,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 9.0),
child: PhosphorIcon(
PhosphorIcons.x(PhosphorIconsStyle.bold),
color: context.theme.appColors.secondaryOnDark,
size: 20.0,
semanticLabel: 'Close',
),
),
),
),
],
),
if (onTapMenu != null)
InkWell(
onTap: onTapMenu,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: PhosphorIcon(
PhosphorIcons.list(PhosphorIconsStyle.bold),
color: context.theme.appColors.appbarIcon,
size: 20.0,
semanticLabel: 'Menu',
),
),
)
else
const SizedBox(width: 52.0),
],
),
);
Expand Down
Loading