Skip to content

Commit

Permalink
feat: banner force close
Browse files Browse the repository at this point in the history
Signed-off-by: Azanul <[email protected]>
  • Loading branch information
Azanul committed Oct 16, 2023
1 parent 2e32c6c commit 13bfef5
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 48 deletions.
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/widgets/share_button.dart';
import 'package:appflowy/plugins/document/presentation/banner.dart';
import 'package:appflowy/plugins/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 @@ -41,10 +41,12 @@ abstract class DatabaseTabBarItemBuilder {

class DatabaseTabBarView extends StatefulWidget {
final ViewPB view;
final VoidCallback onDeleted;
final bool shrinkWrap;
const DatabaseTabBarView({
required this.view,
required this.shrinkWrap,
required this.onDeleted,
super.key,
});

Expand Down Expand Up @@ -85,53 +87,58 @@ class _DatabaseTabBarViewState extends State<DatabaseTabBarView> {
],
child: BlocBuilder<GridTabBarBloc, GridTabBarState>(
builder: (context, state) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
if (state.isDeleted) _buildBanner(context),
Expanded(
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,
if (state.forceClose) {
widget.onDeleted();
return const SizedBox.shrink();
} else {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
if (state.isDeleted) _buildBanner(context),
Expanded(
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(),
),
child: const TabBarHeader(),
),
);
},
),
pageSettingBarExtensionFromState(state),
Expanded(
child: PageView(
pageSnapping: false,
physics: const NeverScrollableScrollPhysics(),
controller: _pageController,
children: pageContentFromState(state),
);
},
),
pageSettingBarExtensionFromState(state),
Expanded(
child: PageView(
pageSnapping: false,
physics: const NeverScrollableScrollPhysics(),
controller: _pageController,
children: pageContentFromState(state),
),
),
),
],
],
),
),
),
),
],
);
],
);
}
},
),
),
Expand Down Expand Up @@ -198,7 +205,7 @@ class DatabaseTabBarViewPlugin extends Plugin {

class DatabasePluginWidgetBuilder extends PluginWidgetBuilder {
final ViewPluginNotifier notifier;

int? deletedViewIndex;
DatabasePluginWidgetBuilder({
required this.notifier,
Key? key,
Expand All @@ -215,13 +222,15 @@ class DatabasePluginWidgetBuilder extends PluginWidgetBuilder {
notifier.isDeleted.addListener(() {
notifier.isDeleted.value.fold(() => null, (deletedView) {
if (deletedView.hasIndex()) {
context?.onDeleted(notifier.view, deletedView.index);
deletedViewIndex = deletedView.index;
}
});
});

return DatabaseTabBarView(
key: ValueKey(notifier.view.id),
view: notifier.view,
onDeleted: () => context?.onDeleted(notifier.view, deletedViewIndex),
shrinkWrap: shrinkWrap,
);
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/appflowy_flutter/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,10 @@ packages:
dependency: transitive
description:
name: intl_utils
sha256: "0d38f605f292321c0729f8c0632b845be77aa12d272b7bc5e3022bb670a7309e"
sha256: "5cad11e11ff7662c3cd0ef04729248591d71ed023d4ef0903a137528b4568adf"
url: "https://pub.dev"
source: hosted
version: "2.8.4"
version: "2.8.5"
io:
dependency: transitive
description:
Expand Down

0 comments on commit 13bfef5

Please sign in to comment.