[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) {
return DocBanner(
onRestore: () {
context.read<DocBloc>().add(const DocEvent.restorePage());
},
onDelete: () {
context.read<DocBloc>().add(const DocEvent.deletePermanently());
},
onRestore: () => context.read<DocBloc>().add(const DocEvent.restorePage()),
onDelete: () => context.read<DocBloc>().add(const DocEvent.deletePermanently()),
);
}

View File

@ -16,11 +16,10 @@ class DocBanner extends StatelessWidget {
final theme = context.watch<AppTheme>();
// [[Row]] CrossAxisAlignment vs mainAxisAlignment
// https://stackoverflow.com/questions/53850149/flutter-crossaxisalignment-vs-mainaxisalignment
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
return ConstrainedBox(
constraints: const BoxConstraints(minHeight: 60),
child: Container(
color: theme.main1,
height: 60,
child: Row(
children: [
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
return Container(
color: Theme.of(context).colorScheme.background,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
_renderTopBar(context),
const VSpace(32),
_renderApps(context),
],
).padding(horizontal: Insets.l),
),
const VSpace(20),
_renderTrash(context).padding(horizontal: Insets.l),
const VSpace(20),
_renderNewAppButton(context),
],
child: ChangeNotifierProvider(
create: (_) => MenuSharedState(),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
_renderTopBar(context),
const VSpace(32),
_renderApps(context),
],
).padding(horizontal: Insets.l),
),
const VSpace(20),
_renderTrash(context).padding(horizontal: Insets.l),
const VSpace(20),
_renderNewAppButton(context),
],
),
),
);
}
@ -123,22 +126,19 @@ class HomeMenu extends StatelessWidget {
child: Expanded(
child: ScrollConfiguration(
behavior: const ScrollBehavior().copyWith(scrollbars: false),
child: ChangeNotifierProvider(
create: (_) => MenuSharedState(),
child: ListView.separated(
itemCount: menuItems.length,
separatorBuilder: (context, index) {
if (index == 0) {
return const VSpace(29);
} else {
return VSpace(MenuAppSizes.appVPadding);
}
},
physics: StyledScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return menuItems[index];
},
),
child: ListView.separated(
itemCount: menuItems.length,
separatorBuilder: (context, index) {
if (index == 0) {
return const VSpace(29);
} else {
return VSpace(MenuAppSizes.appVPadding);
}
},
physics: StyledScrollPhysics(),
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/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/widgets/menu/menu.dart';
import 'package:flowy_infra/image.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
class MenuTrash extends StatelessWidget {
const MenuTrash({Key? key}) : super(key: key);
@ -16,6 +18,7 @@ class MenuTrash extends StatelessWidget {
height: 26,
child: InkWell(
onTap: () {
Provider.of<MenuSharedState>(context, listen: false).selectedView = null;
getIt<HomeStackManager>().setStack(TrashStackContext());
},
child: _render(context),