[flutter]: reset the selected view after open the trash

This commit is contained in:
appflowy 2021-11-02 13:45:01 +08:00
parent 6c1bc2cbd9
commit d790ac1e82
4 changed files with 41 additions and 43 deletions

View File

@ -88,12 +88,8 @@ class _DocPageState extends State<DocPage> {
Widget _renderBanner(BuildContext context) { Widget _renderBanner(BuildContext context) {
return DocBanner( return DocBanner(
onRestore: () { onRestore: () => context.read<DocBloc>().add(const DocEvent.restorePage()),
context.read<DocBloc>().add(const DocEvent.restorePage()); onDelete: () => context.read<DocBloc>().add(const DocEvent.deletePermanently()),
},
onDelete: () {
context.read<DocBloc>().add(const DocEvent.deletePermanently());
},
); );
} }

View File

@ -16,11 +16,10 @@ class DocBanner extends StatelessWidget {
final theme = context.watch<AppTheme>(); final theme = context.watch<AppTheme>();
// [[Row]] CrossAxisAlignment vs mainAxisAlignment // [[Row]] CrossAxisAlignment vs mainAxisAlignment
// https://stackoverflow.com/questions/53850149/flutter-crossaxisalignment-vs-mainaxisalignment // https://stackoverflow.com/questions/53850149/flutter-crossaxisalignment-vs-mainaxisalignment
return SingleChildScrollView( return ConstrainedBox(
scrollDirection: Axis.horizontal, constraints: const BoxConstraints(minHeight: 60),
child: Container( child: Container(
color: theme.main1, color: theme.main1,
height: 60,
child: Row( child: Row(
children: [ children: [
const FlowyText.medium('This page is in Trash', color: Colors.white), const FlowyText.medium('This page is in Trash', color: Colors.white),

View File

@ -85,24 +85,27 @@ class HomeMenu extends StatelessWidget {
// nested cloumn: https://siddharthmolleti.com/flutter-box-constraints-nested-column-s-row-s-3dfacada7361 // nested cloumn: https://siddharthmolleti.com/flutter-box-constraints-nested-column-s-row-s-3dfacada7361
return Container( return Container(
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.background,
child: Column( child: ChangeNotifierProvider(
mainAxisAlignment: MainAxisAlignment.start, create: (_) => MenuSharedState(),
children: [ child: Column(
Expanded( mainAxisAlignment: MainAxisAlignment.start,
child: Column( children: [
mainAxisAlignment: MainAxisAlignment.start, Expanded(
children: [ child: Column(
_renderTopBar(context), mainAxisAlignment: MainAxisAlignment.start,
const VSpace(32), children: [
_renderApps(context), _renderTopBar(context),
], const VSpace(32),
).padding(horizontal: Insets.l), _renderApps(context),
), ],
const VSpace(20), ).padding(horizontal: Insets.l),
_renderTrash(context).padding(horizontal: Insets.l), ),
const VSpace(20), const VSpace(20),
_renderNewAppButton(context), _renderTrash(context).padding(horizontal: Insets.l),
], const VSpace(20),
_renderNewAppButton(context),
],
),
), ),
); );
} }
@ -123,22 +126,19 @@ class HomeMenu extends StatelessWidget {
child: Expanded( child: Expanded(
child: ScrollConfiguration( child: ScrollConfiguration(
behavior: const ScrollBehavior().copyWith(scrollbars: false), behavior: const ScrollBehavior().copyWith(scrollbars: false),
child: ChangeNotifierProvider( child: ListView.separated(
create: (_) => MenuSharedState(), itemCount: menuItems.length,
child: ListView.separated( separatorBuilder: (context, index) {
itemCount: menuItems.length, if (index == 0) {
separatorBuilder: (context, index) { return const VSpace(29);
if (index == 0) { } else {
return const VSpace(29); return VSpace(MenuAppSizes.appVPadding);
} else { }
return VSpace(MenuAppSizes.appVPadding); },
} physics: StyledScrollPhysics(),
}, itemBuilder: (BuildContext context, int index) {
physics: StyledScrollPhysics(), return menuItems[index];
itemBuilder: (BuildContext context, int index) { },
return menuItems[index];
},
),
), ),
), ),
), ),

View File

@ -1,11 +1,13 @@
import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/startup/startup.dart';
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart'; import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
import 'package:app_flowy/workspace/presentation/stack_page/trash/trash_page.dart'; import 'package:app_flowy/workspace/presentation/stack_page/trash/trash_page.dart';
import 'package:app_flowy/workspace/presentation/widgets/menu/menu.dart';
import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/image.dart';
import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
class MenuTrash extends StatelessWidget { class MenuTrash extends StatelessWidget {
const MenuTrash({Key? key}) : super(key: key); const MenuTrash({Key? key}) : super(key: key);
@ -16,6 +18,7 @@ class MenuTrash extends StatelessWidget {
height: 26, height: 26,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
Provider.of<MenuSharedState>(context, listen: false).selectedView = null;
getIt<HomeStackManager>().setStack(TrashStackContext()); getIt<HomeStackManager>().setStack(TrashStackContext());
}, },
child: _render(context), child: _render(context),