From 76c3e440e72d1954d3dbe32fff96bb07a791d6e2 Mon Sep 17 00:00:00 2001 From: Victor Teles Date: Wed, 10 Aug 2022 02:17:27 -0300 Subject: [PATCH 1/3] fix: fixed controls space --- .../presentation/home/home_layout.dart | 2 ++ .../presentation/home/home_screen.dart | 4 ++- .../presentation/home/home_stack.dart | 25 ++++++++----------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart index dde5091d44..94cb1874cd 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart @@ -15,6 +15,7 @@ class HomeLayout { late double editPanelWidth; late double homePageLOffset; late double homePageROffset; + late double menuSpacing; late Duration animDuration; HomeLayout(BuildContext context, BoxConstraints homeScreenConstraint, @@ -37,6 +38,7 @@ class HomeLayout { } homePageLOffset = showMenu ? menuWidth : 0.0; + menuSpacing = showMenu ? 0 : 80.0; animDuration = .35.seconds; editPanelWidth = HomeSizes.editPanelWidth; diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart index e38a2f4614..3259e3d843 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart @@ -87,7 +87,9 @@ class _HomeScreenState extends State { return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { final layout = HomeLayout(context, constraints, state.forceCollapse); - const homeStack = HomeStack(); + final homeStack = HomeStack( + layout: layout, + ); final menu = _buildHomeMenu( layout: layout, context: context, diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart index d58f849cd7..a64fc8b5b5 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart @@ -17,11 +17,14 @@ import 'package:app_flowy/core/frameless_window.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_infra_ui/style_widget/extension.dart'; import 'package:flowy_infra/notifier.dart'; +import 'home_layout.dart'; typedef NavigationCallback = void Function(String id); class HomeStack extends StatelessWidget { - const HomeStack({Key? key}) : super(key: key); + const HomeStack({Key? key, required this.layout}) : super(key: key); + + final HomeLayout layout; @override Widget build(BuildContext context) { @@ -30,7 +33,7 @@ class HomeStack extends StatelessWidget { return Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - getIt().stackTopBar(), + getIt().stackTopBar(layout: layout), Expanded( child: Container( color: theme.surface, @@ -143,7 +146,7 @@ class HomeStackManager { void setStackWithId(String id) {} - Widget stackTopBar() { + Widget stackTopBar({required HomeLayout layout}) { return MultiProvider( providers: [ ChangeNotifierProvider.value(value: _notifier), @@ -151,7 +154,7 @@ class HomeStackManager { child: Selector( selector: (context, notifier) => notifier.titleWidget, builder: (context, widget, child) { - return const MoveWindowDetector(child: HomeTopBar()); + return MoveWindowDetector(child: HomeTopBar(layout: layout)); }, ), ); @@ -181,7 +184,9 @@ class HomeStackManager { } class HomeTopBar extends StatelessWidget { - const HomeTopBar({Key? key}) : super(key: key); + const HomeTopBar({Key? key, required this.layout}) : super(key: key); + + final HomeLayout layout; @override Widget build(BuildContext context) { @@ -192,15 +197,7 @@ class HomeTopBar extends StatelessWidget { child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - BlocBuilder( - buildWhen: ((previous, current) => - previous.isMenuCollapsed != current.isMenuCollapsed), - builder: (context, state) { - if (state.isMenuCollapsed && Platform.isMacOS) { - return const HSpace(80); - } - return const HSpace(0); - }), + HSpace(layout.menuSpacing), const FlowyNavigation(), const HSpace(16), ChangeNotifierProvider.value( From 5c011fbd7ec8469c1da635f72ba2c275f3ec8752 Mon Sep 17 00:00:00 2001 From: Victor Teles Date: Wed, 10 Aug 2022 11:46:29 -0300 Subject: [PATCH 2/3] refactor: added Platform.isMacOS to validation --- .../lib/workspace/presentation/home/home_layout.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart index 94cb1874cd..5194b9edb7 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_layout.dart @@ -1,3 +1,5 @@ +import 'dart:io' show Platform; + import 'package:app_flowy/workspace/application/home/home_bloc.dart'; import 'package:flowy_infra/size.dart'; import 'package:flowy_infra/time/duration.dart'; @@ -38,7 +40,8 @@ class HomeLayout { } homePageLOffset = showMenu ? menuWidth : 0.0; - menuSpacing = showMenu ? 0 : 80.0; + + menuSpacing = !showMenu && Platform.isMacOS ? 80.0 : 0.0; animDuration = .35.seconds; editPanelWidth = HomeSizes.editPanelWidth; From f637839cfefcf400b01005fe40dc364c0e5ffda7 Mon Sep 17 00:00:00 2001 From: Victor Teles Date: Thu, 11 Aug 2022 10:39:32 -0300 Subject: [PATCH 3/3] refactor: fixed lint warnings --- .../app_flowy/lib/workspace/presentation/home/home_stack.dart | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart index a64fc8b5b5..73ebde5141 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart @@ -1,13 +1,9 @@ -import 'dart:io' show Platform; - import 'package:app_flowy/startup/startup.dart'; -import 'package:app_flowy/workspace/application/home/home_bloc.dart'; import 'package:app_flowy/plugins/blank/blank.dart'; import 'package:app_flowy/workspace/presentation/home/toast.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_sdk/log.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:provider/provider.dart'; import 'package:time/time.dart'; import 'package:app_flowy/startup/plugin/plugin.dart';