Skip to content

Commit

Permalink
feat: expand the banner
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasXu0 authored and Azanul committed Oct 16, 2023
1 parent de2ef0d commit d948aab
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ extension Expectation on WidgetTester {

/// Expect to see the document banner.
void expectToSeeDocumentBanner() {
expect(find.byType(DocumentBanner), findsOneWidget);
expect(find.byType(RestoreAndDeleteBanner), findsOneWidget);
}

/// Expect not to see the document banner.
void expectNotToSeeDocumentBanner() {
expect(find.byType(DocumentBanner), findsNothing);
expect(find.byType(RestoreAndDeleteBanner), findsNothing);
}

/// Expect to the markdown file export success dialog.
Expand Down
74 changes: 0 additions & 74 deletions frontend/appflowy_flutter/lib/plugins/database_view/banner.dart

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:appflowy/plugins/database_view/application/tar_bar_bloc.dart';
import 'package:appflowy/plugins/database_view/banner.dart';
import 'package:appflowy/plugins/database_view/widgets/share_button.dart';
import 'package:appflowy/plugins/document/presentation/banner.dart';
import 'package:appflowy/plugins/util.dart';
import 'package:appflowy/startup/plugin/plugin.dart';
import 'package:appflowy/workspace/presentation/home/home_stack.dart';
Expand Down Expand Up @@ -86,35 +86,48 @@ class _DatabaseTabBarViewState extends State<DatabaseTabBarView> {
child: BlocBuilder<GridTabBarBloc, GridTabBarState>(
builder: (context, state) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
if (state.isDeleted) _buildBanner(context),
ValueListenableBuilder<bool>(
valueListenable: state
.tabBarControllerByViewId[state.parentView.id]!
.controller
.isLoading,
builder: (_, value, ___) {
if (value) {
return const SizedBox.shrink();
}
return SizedBox(
height: 30,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: GridSize.leadingHeaderPadding,
),
child: const TabBarHeader(),
),
);
},
),
pageSettingBarExtensionFromState(state),
Expanded(
child: PageView(
pageSnapping: false,
physics: const NeverScrollableScrollPhysics(),
controller: _pageController,
children: pageContentFromState(state),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 40,
vertical: 28,
),
child: Column(
children: [
ValueListenableBuilder<bool>(
valueListenable: state
.tabBarControllerByViewId[state.parentView.id]!
.controller
.isLoading,
builder: (_, value, ___) {
if (value) {
return const SizedBox.shrink();
}
return SizedBox(
height: 30,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: GridSize.leadingHeaderPadding,
),
child: const TabBarHeader(),
),
);
},
),
pageSettingBarExtensionFromState(state),
Expanded(
child: PageView(
pageSnapping: false,
physics: const NeverScrollableScrollPhysics(),
controller: _pageController,
children: pageContentFromState(state),
),
),
],
),
),
),
],
Expand All @@ -127,7 +140,7 @@ class _DatabaseTabBarViewState extends State<DatabaseTabBarView> {

Widget _buildBanner(BuildContext context) {
final bloc = context.read<GridTabBarBloc>();
return DatabaseViewBanner(
return RestoreAndDeleteBanner(
onRestore: () => bloc.add(const GridTabBarEvent.restorePage()),
onDelete: () => bloc.add(const GridTabBarEvent.deletePermanently()),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class _DocumentPageState extends State<DocumentPage> {
}

Widget _buildBanner(BuildContext context) {
return DocumentBanner(
return RestoreAndDeleteBanner(
onRestore: () => documentBloc.add(const DocumentEvent.restorePage()),
onDelete: () => documentBloc.add(const DocumentEvent.deletePermanently()),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flowy_infra_ui/widget/buttons/base_styled_button.dart';
import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flutter/material.dart';
import 'package:appflowy/generated/locale_keys.g.dart';

class DocumentBanner extends StatelessWidget {
class RestoreAndDeleteBanner extends StatelessWidget {
final void Function() onRestore;
final void Function() onDelete;
const DocumentBanner({
const RestoreAndDeleteBanner({
required this.onRestore,
required this.onDelete,
Key? key,
Expand Down
3 changes: 1 addition & 2 deletions frontend/appflowy_flutter/lib/startup/plugin/plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ abstract class PluginConfig {
abstract class PluginWidgetBuilder with NavigationItem {
List<NavigationItem> get navigationItems;

EdgeInsets get contentPadding =>
const EdgeInsets.symmetric(horizontal: 40, vertical: 28);
EdgeInsets get contentPadding => EdgeInsets.zero;

Widget buildWidget({PluginContext? context, required bool shrinkWrap});
}
Expand Down

0 comments on commit d948aab

Please sign in to comment.