Fix snackbar covering bottom appbar in viewer

This commit is contained in:
Ming Ming 2023-03-19 17:02:42 +08:00
parent 8a429dc4cd
commit f5aca6f016
2 changed files with 72 additions and 95 deletions

View file

@ -192,6 +192,7 @@ ThemeData _applyColorScheme(ColorScheme colorScheme, Color seedColor) {
color: colorScheme.onInverseSurface, color: colorScheme.onInverseSurface,
), ),
actionTextColor: colorScheme.inversePrimary, actionTextColor: colorScheme.inversePrimary,
behavior: SnackBarBehavior.floating,
), ),
extensions: [ extensions: [
M3( M3(

View file

@ -26,7 +26,6 @@ import 'package:nc_photos/theme.dart';
import 'package:nc_photos/use_case/inflate_file_descriptor.dart'; import 'package:nc_photos/use_case/inflate_file_descriptor.dart';
import 'package:nc_photos/use_case/remove_from_album.dart'; import 'package:nc_photos/use_case/remove_from_album.dart';
import 'package:nc_photos/use_case/update_property.dart'; import 'package:nc_photos/use_case/update_property.dart';
import 'package:nc_photos/widget/animated_visibility.dart';
import 'package:nc_photos/widget/disposable.dart'; import 'package:nc_photos/widget/disposable.dart';
import 'package:nc_photos/widget/handler/archive_selection_handler.dart'; import 'package:nc_photos/widget/handler/archive_selection_handler.dart';
import 'package:nc_photos/widget/handler/remove_selection_handler.dart'; import 'package:nc_photos/widget/handler/remove_selection_handler.dart';
@ -101,7 +100,7 @@ class Viewer extends StatefulWidget {
class _ViewerState extends State<Viewer> class _ViewerState extends State<Viewer>
with DisposableManagerMixin<Viewer>, ViewerControllersMixin<Viewer> { with DisposableManagerMixin<Viewer>, ViewerControllersMixin<Viewer> {
@override @override
initState() { void initState() {
super.initState(); super.initState();
_streamFilesView = widget.streamFiles; _streamFilesView = widget.streamFiles;
} }
@ -112,6 +111,10 @@ class _ViewerState extends State<Viewer>
return Theme( return Theme(
data: buildDarkTheme(), data: buildDarkTheme(),
child: Scaffold( child: Scaffold(
extendBodyBehindAppBar: true,
extendBody: true,
appBar: _isShowAppBar ? _buildAppBar(context) : null,
bottomNavigationBar: _isShowAppBar ? _buildBottomAppBar(context) : null,
body: Builder( body: Builder(
builder: (context) => _buildContent(context, originalBrightness), builder: (context) => _buildContent(context, originalBrightness),
), ),
@ -147,67 +150,52 @@ class _ViewerState extends State<Viewer>
setState(() {}); setState(() {});
}, },
), ),
_buildBottomAppBar(context), if (_isShowAppBar)
_buildAppBar(context), Container(
// + status bar height
height: kToolbarHeight + MediaQuery.of(context).padding.top,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment(0, -1),
end: Alignment(0, 1),
colors: [
Color.fromARGB(192, 0, 0, 0),
Color.fromARGB(0, 0, 0, 0),
],
),
),
),
], ],
), ),
); );
} }
Widget _buildAppBar(BuildContext context) { AppBar _buildAppBar(BuildContext context) {
final index = final index =
_isViewerLoaded ? _viewerController.currentPage : widget.startIndex; _isViewerLoaded ? _viewerController.currentPage : widget.startIndex;
final file = _streamFilesView[index]; final file = _streamFilesView[index];
return Wrap( return AppBar(
children: [ backgroundColor: Colors.transparent,
AnimatedVisibility( elevation: 0,
opacity: _isShowAppBar ? 1.0 : 0.0, actions: [
duration: k.animationDurationNormal, if (!_isDetailPaneActive && _canOpenDetailPane()) ...[
child: Stack( (_pageStates[index]?.favoriteOverride ?? file.fdIsFavorite) == true
children: [ ? IconButton(
Container( icon: const Icon(Icons.star),
// + status bar height tooltip: L10n.global().unfavoriteTooltip,
height: kToolbarHeight + MediaQuery.of(context).padding.top, onPressed: () => _onUnfavoritePressed(index),
decoration: const BoxDecoration( )
gradient: LinearGradient( : IconButton(
begin: Alignment(0, -1), icon: const Icon(Icons.star_border),
end: Alignment(0, 1), tooltip: L10n.global().favoriteTooltip,
colors: [ onPressed: () => _onFavoritePressed(index),
Color.fromARGB(192, 0, 0, 0),
Color.fromARGB(0, 0, 0, 0),
],
),
), ),
), IconButton(
AppBar( icon: const Icon(Icons.more_vert),
backgroundColor: Colors.transparent, tooltip: L10n.global().detailsTooltip,
elevation: 0, onPressed: _onDetailsPressed,
actions: [
if (!_isDetailPaneActive && _canOpenDetailPane()) ...[
(_pageStates[index]?.favoriteOverride ??
file.fdIsFavorite) ==
true
? IconButton(
icon: const Icon(Icons.star),
tooltip: L10n.global().unfavoriteTooltip,
onPressed: () => _onUnfavoritePressed(index),
)
: IconButton(
icon: const Icon(Icons.star_border),
tooltip: L10n.global().favoriteTooltip,
onPressed: () => _onFavoritePressed(index),
),
IconButton(
icon: const Icon(Icons.more_vert),
tooltip: L10n.global().detailsTooltip,
onPressed: _onDetailsPressed,
),
],
],
),
],
), ),
), ],
], ],
); );
} }
@ -216,49 +204,37 @@ class _ViewerState extends State<Viewer>
final index = final index =
_isViewerLoaded ? _viewerController.currentPage : widget.startIndex; _isViewerLoaded ? _viewerController.currentPage : widget.startIndex;
final file = _streamFilesView[index]; final file = _streamFilesView[index];
return Align( return ViewerBottomAppBar(
alignment: Alignment.bottomCenter, children: [
child: Material( IconButton(
type: MaterialType.transparency, icon: const Icon(Icons.share_outlined),
child: AnimatedVisibility( tooltip: L10n.global().shareTooltip,
opacity: (_isShowAppBar && !_isDetailPaneActive) ? 1.0 : 0.0, onPressed: () => _onSharePressed(context),
duration: !_isDetailPaneActive
? k.animationDurationNormal
: const Duration(milliseconds: 1),
child: ViewerBottomAppBar(
children: [
IconButton(
icon: const Icon(Icons.share_outlined),
tooltip: L10n.global().shareTooltip,
onPressed: () => _onSharePressed(context),
),
if (features.isSupportEnhancement &&
ImageEnhancer.isSupportedFormat(file)) ...[
IconButton(
icon: const Icon(Icons.tune_outlined),
tooltip: L10n.global().editTooltip,
onPressed: () => _onEditPressed(context),
),
IconButton(
icon: const Icon(Icons.auto_fix_high_outlined),
tooltip: L10n.global().enhanceTooltip,
onPressed: () => _onEnhancePressed(context),
),
],
IconButton(
icon: const Icon(Icons.download_outlined),
tooltip: L10n.global().downloadTooltip,
onPressed: _onDownloadPressed,
),
IconButton(
icon: const Icon(Icons.delete_outlined),
tooltip: L10n.global().deleteTooltip,
onPressed: () => _onDeletePressed(context),
),
],
),
), ),
), if (features.isSupportEnhancement &&
ImageEnhancer.isSupportedFormat(file)) ...[
IconButton(
icon: const Icon(Icons.tune_outlined),
tooltip: L10n.global().editTooltip,
onPressed: () => _onEditPressed(context),
),
IconButton(
icon: const Icon(Icons.auto_fix_high_outlined),
tooltip: L10n.global().enhanceTooltip,
onPressed: () => _onEnhancePressed(context),
),
],
IconButton(
icon: const Icon(Icons.download_outlined),
tooltip: L10n.global().downloadTooltip,
onPressed: _onDownloadPressed,
),
IconButton(
icon: const Icon(Icons.delete_outlined),
tooltip: L10n.global().deleteTooltip,
onPressed: () => _onDeletePressed(context),
),
],
); );
} }