|
@@ -1,3 +1,6 @@
|
|
|
|
+import 'dart:io';
|
|
|
|
+
|
|
|
|
+import 'package:app_flowy/generated/locale_keys.g.dart';
|
|
import 'package:app_flowy/workspace/application/home/home_bloc.dart';
|
|
import 'package:app_flowy/workspace/application/home/home_bloc.dart';
|
|
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
|
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
|
|
import 'package:flowy_infra/image.dart';
|
|
import 'package:flowy_infra/image.dart';
|
|
@@ -14,7 +17,8 @@ typedef NaviAction = void Function();
|
|
class NavigationNotifier with ChangeNotifier {
|
|
class NavigationNotifier with ChangeNotifier {
|
|
List<NavigationItem> navigationItems;
|
|
List<NavigationItem> navigationItems;
|
|
PublishNotifier<bool> collapasedNotifier;
|
|
PublishNotifier<bool> collapasedNotifier;
|
|
- NavigationNotifier({required this.navigationItems, required this.collapasedNotifier});
|
|
|
|
|
|
+ NavigationNotifier(
|
|
|
|
+ {required this.navigationItems, required this.collapasedNotifier});
|
|
|
|
|
|
void update(HomeStackNotifier notifier) {
|
|
void update(HomeStackNotifier notifier) {
|
|
bool shouldNotify = false;
|
|
bool shouldNotify = false;
|
|
@@ -69,7 +73,8 @@ class FlowyNavigation extends StatelessWidget {
|
|
child: Row(children: [
|
|
child: Row(children: [
|
|
Selector<NavigationNotifier, PublishNotifier<bool>>(
|
|
Selector<NavigationNotifier, PublishNotifier<bool>>(
|
|
selector: (context, notifier) => notifier.collapasedNotifier,
|
|
selector: (context, notifier) => notifier.collapasedNotifier,
|
|
- builder: (ctx, collapsedNotifier, child) => _renderCollapse(ctx, collapsedNotifier, theme)),
|
|
|
|
|
|
+ builder: (ctx, collapsedNotifier, child) =>
|
|
|
|
+ _renderCollapse(ctx, collapsedNotifier, theme)),
|
|
Selector<NavigationNotifier, List<NavigationItem>>(
|
|
Selector<NavigationNotifier, List<NavigationItem>>(
|
|
selector: (context, notifier) => notifier.navigationItems,
|
|
selector: (context, notifier) => notifier.navigationItems,
|
|
builder: (ctx, items, child) => Expanded(
|
|
builder: (ctx, items, child) => Expanded(
|
|
@@ -84,7 +89,8 @@ class FlowyNavigation extends StatelessWidget {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- Widget _renderCollapse(BuildContext context, PublishNotifier<bool> collapsedNotifier, AppTheme theme) {
|
|
|
|
|
|
+ Widget _renderCollapse(BuildContext context,
|
|
|
|
+ PublishNotifier<bool> collapsedNotifier, AppTheme theme) {
|
|
return ChangeNotifierProvider.value(
|
|
return ChangeNotifierProvider.value(
|
|
value: collapsedNotifier,
|
|
value: collapsedNotifier,
|
|
child: Consumer(
|
|
child: Consumer(
|
|
@@ -92,15 +98,23 @@ class FlowyNavigation extends StatelessWidget {
|
|
if (notifier.currentValue ?? false) {
|
|
if (notifier.currentValue ?? false) {
|
|
return RotationTransition(
|
|
return RotationTransition(
|
|
turns: const AlwaysStoppedAnimation(180 / 360),
|
|
turns: const AlwaysStoppedAnimation(180 / 360),
|
|
- child: FlowyIconButton(
|
|
|
|
- width: 24,
|
|
|
|
- onPressed: () {
|
|
|
|
- notifier.value = false;
|
|
|
|
- ctx.read<HomeBloc>().add(const HomeEvent.collapseMenu());
|
|
|
|
- },
|
|
|
|
- iconPadding: const EdgeInsets.fromLTRB(2, 2, 2, 2),
|
|
|
|
- icon: svgWidget("home/hide_menu", color: theme.iconColor),
|
|
|
|
- ),
|
|
|
|
|
|
+ child: Tooltip(
|
|
|
|
+ richMessage: TextSpan(children: [
|
|
|
|
+ const TextSpan(text: LocaleKeys.sideBar_openSidebar + "\n"),
|
|
|
|
+ TextSpan(
|
|
|
|
+ text: Platform.isMacOS ? "⌘+\\" : "Ctrl+\\",
|
|
|
|
+ style: const TextStyle(color: Colors.white60),
|
|
|
|
+ ),
|
|
|
|
+ ]),
|
|
|
|
+ child: FlowyIconButton(
|
|
|
|
+ width: 24,
|
|
|
|
+ onPressed: () {
|
|
|
|
+ notifier.value = false;
|
|
|
|
+ ctx.read<HomeBloc>().add(const HomeEvent.collapseMenu());
|
|
|
|
+ },
|
|
|
|
+ iconPadding: const EdgeInsets.fromLTRB(2, 2, 2, 2),
|
|
|
|
+ icon: svgWidget("home/hide_menu", color: theme.iconColor),
|
|
|
|
+ )),
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
return Container();
|
|
return Container();
|
|
@@ -154,7 +168,8 @@ class NaviItemWidget extends StatelessWidget {
|
|
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
- return Expanded(child: item.leftBarItem.padding(horizontal: 2, vertical: 2));
|
|
|
|
|
|
+ return Expanded(
|
|
|
|
+ child: item.leftBarItem.padding(horizontal: 2, vertical: 2));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|