From cb44a885a17f2e1cc15a8b93526bec2f847a34cf Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 27 May 2024 15:37:05 +0800 Subject: [PATCH] fix: dragging the Unsplash cover triggers an assertion error (#5404) --- .../page_style/_page_style_cover_image.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/page_style/_page_style_cover_image.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/page_style/_page_style_cover_image.dart index 84d8c751f4..fd0aa86fa7 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/page_style/_page_style_cover_image.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/page_style/_page_style_cover_image.dart @@ -20,13 +20,13 @@ import 'package:appflowy_backend/log.dart'; import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart'; import 'package:appflowy_result/appflowy_result.dart'; import 'package:easy_localization/easy_localization.dart'; +import 'package:flowy_infra/theme_extension.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/style_widget/snap_bar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:image_picker/image_picker.dart'; -import 'package:flowy_infra/theme_extension.dart'; class PageStyleCoverImage extends StatelessWidget { PageStyleCoverImage({ @@ -257,6 +257,9 @@ class PageStyleCoverImage extends StatelessWidget { void _showUnsplash(BuildContext context) { final pageStyleBloc = context.read(); + final backgroundColor = AFThemeExtension.of(context).background; + final maxHeight = MediaQuery.of(context).size.height * 0.6; + context.pop(); showMobileBottomSheet( @@ -267,7 +270,7 @@ class PageStyleCoverImage extends StatelessWidget { showHeader: true, showRemoveButton: true, title: LocaleKeys.pageStyle_unsplash.tr(), - backgroundColor: AFThemeExtension.of(context).background, + backgroundColor: backgroundColor, onRemove: () { pageStyleBloc.add( DocumentPageStyleEvent.updateCoverImage( @@ -278,11 +281,11 @@ class PageStyleCoverImage extends StatelessWidget { builder: (_) { return ConstrainedBox( constraints: BoxConstraints( - maxHeight: MediaQuery.of(context).size.height * 0.6, + maxHeight: maxHeight, minHeight: 80, ), child: BlocProvider.value( - value: context.read(), + value: pageStyleBloc, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), child: UnsplashImageWidget(