fix: android navigation bar issues (#5294)

This commit is contained in:
Lucas.Xu 2024-05-10 10:09:11 +08:00 committed by GitHub
parent a490f34a61
commit f3b8ec8a04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 28 deletions

View File

@ -1,6 +1,7 @@
import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/application/base/mobile_view_page_bloc.dart'; import 'package:appflowy/mobile/application/base/mobile_view_page_bloc.dart';
import 'package:appflowy/mobile/application/page_style/document_page_style_bloc.dart'; import 'package:appflowy/mobile/application/page_style/document_page_style_bloc.dart';
import 'package:appflowy/mobile/presentation/base/app_bar/app_bar.dart';
import 'package:appflowy/mobile/presentation/base/view_page/app_bar_buttons.dart'; import 'package:appflowy/mobile/presentation/base/view_page/app_bar_buttons.dart';
import 'package:appflowy/mobile/presentation/widgets/flowy_mobile_state_container.dart'; import 'package:appflowy/mobile/presentation/widgets/flowy_mobile_state_container.dart';
import 'package:appflowy/plugins/base/emoji/emoji_text.dart'; import 'package:appflowy/plugins/base/emoji/emoji_text.dart';
@ -103,19 +104,21 @@ class _MobileViewPageState extends State<MobileViewPage> {
ViewPB? view, ViewPB? view,
Widget child, Widget child,
) { ) {
final isImmersiveMode = view?.layout.isDocumentView ?? false; final isDocument = view?.layout.isDocumentView ?? false;
final title = _buildTitle(context, view); final title = _buildTitle(context, view);
final appBar = MobileViewPageImmersiveAppBar( final actions = _buildAppBarActions(context, view);
preferredSize: Size( final appBar = isDocument
double.infinity, ? MobileViewPageImmersiveAppBar(
AppBarTheme.of(context).toolbarHeight ?? kToolbarHeight, preferredSize: Size(
), double.infinity,
title: title, AppBarTheme.of(context).toolbarHeight ?? kToolbarHeight,
isImmersiveMode: isImmersiveMode, ),
appBarOpacity: _appBarOpacity, title: title,
actions: _buildAppBarActions(context, view), appBarOpacity: _appBarOpacity,
); actions: actions,
final body = isImmersiveMode )
: FlowyAppBar(title: title, actions: actions);
final body = isDocument
? Builder( ? Builder(
builder: (context) { builder: (context) {
_rebuildScrollNotificationObserver(context); _rebuildScrollNotificationObserver(context);
@ -124,7 +127,7 @@ class _MobileViewPageState extends State<MobileViewPage> {
) )
: child; : child;
return Scaffold( return Scaffold(
extendBodyBehindAppBar: isImmersiveMode, extendBodyBehindAppBar: isDocument,
appBar: appBar, appBar: appBar,
body: body, body: body,
); );
@ -190,12 +193,12 @@ class _MobileViewPageState extends State<MobileViewPage> {
), ),
const HSpace(16.0), const HSpace(16.0),
DocumentSyncIndicator(view: view), DocumentSyncIndicator(view: view),
const HSpace(8.0), const HSpace(12.0),
]); ]);
} else { } else {
actions.addAll([ actions.addAll([
DatabaseSyncIndicator(view: view), DatabaseSyncIndicator(view: view),
const HSpace(8.0), const HSpace(12.0),
]); ]);
} }
} }

View File

@ -1,5 +1,6 @@
import 'package:appflowy/generated/flowy_svgs.g.dart'; import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/application/base/mobile_view_page_bloc.dart';
import 'package:appflowy/mobile/application/page_style/document_page_style_bloc.dart'; import 'package:appflowy/mobile/application/page_style/document_page_style_bloc.dart';
import 'package:appflowy/mobile/presentation/base/app_bar/app_bar.dart'; import 'package:appflowy/mobile/presentation/base/app_bar/app_bar.dart';
import 'package:appflowy/mobile/presentation/base/app_bar/app_bar_actions.dart'; import 'package:appflowy/mobile/presentation/base/app_bar/app_bar_actions.dart';
@ -21,13 +22,11 @@ class MobileViewPageImmersiveAppBar extends StatelessWidget
const MobileViewPageImmersiveAppBar({ const MobileViewPageImmersiveAppBar({
super.key, super.key,
required this.preferredSize, required this.preferredSize,
required this.isImmersiveMode,
required this.appBarOpacity, required this.appBarOpacity,
required this.title, required this.title,
required this.actions, required this.actions,
}); });
final bool isImmersiveMode;
final ValueListenable appBarOpacity; final ValueListenable appBarOpacity;
final Widget title; final Widget title;
final List<Widget> actions; final List<Widget> actions;
@ -37,13 +36,6 @@ class MobileViewPageImmersiveAppBar extends StatelessWidget
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (!isImmersiveMode) {
FlowyAppBar(
title: title,
actions: actions,
);
}
return ValueListenableBuilder( return ValueListenableBuilder(
valueListenable: appBarOpacity, valueListenable: appBarOpacity,
builder: (_, opacity, __) => FlowyAppBar( builder: (_, opacity, __) => FlowyAppBar(
@ -68,7 +60,8 @@ class MobileViewPageImmersiveAppBar extends StatelessWidget
icon: FlowySvgs.m_app_bar_back_s, icon: FlowySvgs.m_app_bar_back_s,
dimension: 30.0, dimension: 30.0,
iconPadding: 6.0, iconPadding: 6.0,
isImmersiveMode: isImmersiveMode, isImmersiveMode:
context.read<MobileViewPageBloc>().state.isImmersiveMode,
appBarOpacity: appBarOpacity, appBarOpacity: appBarOpacity,
), ),
); );

View File

@ -162,9 +162,12 @@ class _DocumentImmersiveCoverState extends State<DocumentImmersiveCover> {
Widget _buildIcon(BuildContext context, String icon) { Widget _buildIcon(BuildContext context, String icon) {
return GestureDetector( return GestureDetector(
child: EmojiIconWidget( child: ConstrainedBox(
emoji: icon, constraints: const BoxConstraints.tightFor(width: 34.0),
emojiSize: 26, child: EmojiIconWidget(
emoji: icon,
emojiSize: 26,
),
), ),
onTap: () async { onTap: () async {
final result = await context.push<EmojiPickerResult>( final result = await context.push<EmojiPickerResult>(