Skip to content

Commit

Permalink
fix: icon color, padding and banner constraints to width
Browse files Browse the repository at this point in the history
  • Loading branch information
squidrye committed Nov 15, 2023
1 parent 563b362 commit c152e1e
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class HomeSizes {
static const double editPanelTopBarHeight = 60;
static const double editPanelWidth = 400;
static const double tabBarHeight = 40;
static const double readOnlyBannerHeight = 24;
static const double tabWidth = 200;
static const double resizeBarThickness = 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ class PageManager {
selector: (context, notifier) => notifier.titleWidget,
builder: (context, widget, child) {
return MoveWindowDetector(
child: HomeTopBar(layout: layout, paneId: paneId),
child: HomeTopBar(

Check warning on line 253 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L252-L253

Added lines #L252 - L253 were not covered by tests
layout: layout,
paneId: paneId,
notifier: notifier,

Check warning on line 256 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L256

Added line #L256 was not covered by tests
),
);
},
),
Expand All @@ -276,55 +280,88 @@ class PageManager {
}

class HomeTopBar extends StatelessWidget {
const HomeTopBar({super.key, required this.layout, required this.paneId});
const HomeTopBar({

Check warning on line 283 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L283

Added line #L283 was not covered by tests
super.key,
required this.layout,
required this.paneId,
required this.notifier,
});

final PageNotifier notifier;
final HomeLayout layout;
final String paneId;

@override
Widget build(BuildContext context) {
return Container(
color: Theme.of(context).colorScheme.onSecondaryContainer,
height: HomeSizes.topBarHeight,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: HomeInsets.topBarTitlePadding,
return Column(
children: [
Container(
color: Theme.of(context).colorScheme.onSecondaryContainer,

Check warning on line 299 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L296-L299

Added lines #L296 - L299 were not covered by tests
height: HomeSizes.topBarHeight,
child: Padding(

Check warning on line 301 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L301

Added line #L301 was not covered by tests
padding: const EdgeInsets.symmetric(
horizontal: HomeInsets.topBarTitlePadding,
),
child: Row(

Check warning on line 305 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L305

Added line #L305 was not covered by tests
crossAxisAlignment: CrossAxisAlignment.center,
children: [
HSpace(layout.menuSpacing),
FlowyNavigation(currentPaneId: paneId),

Check warning on line 309 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L307-L309

Added lines #L307 - L309 were not covered by tests
const HSpace(16),
ChangeNotifierProvider.value(
value: Provider.of<PageNotifier>(context, listen: false),
child: Consumer(
builder: (_, PageNotifier notifier, __) =>
notifier.plugin.widgetBuilder.rightBarItem ??

Check warning on line 315 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L311-L315

Added lines #L311 - L315 were not covered by tests
const SizedBox.shrink(),
),
),
BlocBuilder<PanesBloc, PanesState>(
builder: (context, state) {
if (state.count <= 1) {

Check warning on line 321 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L319-L321

Added lines #L319 - L321 were not covered by tests
return const SizedBox.shrink();
}

return Padding(

Check warning on line 325 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L325

Added line #L325 was not covered by tests
padding: const EdgeInsets.all(2),
child: FlowyIconButton(

Check warning on line 327 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L327

Added line #L327 was not covered by tests
iconColorOnHover:
Theme.of(context).colorScheme.onSurface,
onPressed: () => context
.read<PanesBloc>()
.add(ClosePane(paneId: paneId)),

Check warning on line 332 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L329-L332

Added lines #L329 - L332 were not covered by tests
icon: const FlowySvg(FlowySvgs.close_s),
),
);
},
),
],
),
).bottomBorder(color: Theme.of(context).dividerColor),

Check warning on line 340 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L340

Added line #L340 was not covered by tests
),
if (notifier.readOnly) _buildReadOnlyBanner(context),

Check warning on line 342 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L342

Added line #L342 was not covered by tests
],
);
}

Widget _buildReadOnlyBanner(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return Container(

Check warning on line 349 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L347-L349

Added lines #L347 - L349 were not covered by tests
width: double.infinity,
color: colorScheme.primary,
child: FittedBox(

Check warning on line 352 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L351-L352

Added lines #L351 - L352 were not covered by tests
alignment: Alignment.center,
fit: BoxFit.scaleDown,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
HSpace(layout.menuSpacing),
FlowyNavigation(currentPaneId: paneId),
const HSpace(16),
ChangeNotifierProvider.value(
value: Provider.of<PageNotifier>(context, listen: false),
child: Consumer(
builder: (_, PageNotifier notifier, __) =>
notifier.plugin.widgetBuilder.rightBarItem ??
const SizedBox(),
),
),
BlocBuilder<PanesBloc, PanesState>(
builder: (context, state) {
if (state.count <= 1) {
return const SizedBox.shrink();
}

return Padding(
padding: const EdgeInsets.all(2),
child: FlowyIconButton(
iconColorOnHover: Theme.of(context).colorScheme.onSurface,
onPressed: () => context
.read<PanesBloc>()
.add(ClosePane(paneId: paneId)),
icon: const FlowySvg(FlowySvgs.close_s),
),
);
},
FlowyText.medium(
LocaleKeys.readOnlyViewText.tr(),

Check warning on line 358 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L357-L358

Added lines #L357 - L358 were not covered by tests
fontSize: 14,
color: Theme.of(context).colorScheme.onSurface,

Check warning on line 360 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L360

Added line #L360 was not covered by tests
),
],
),
).bottomBorder(color: Theme.of(context).dividerColor),
),
);
}
}
Expand Down Expand Up @@ -358,41 +395,36 @@ class _HomeBodyState extends State<HomeBody> {
if (widget.notifier.readOnly) {
return ValueListenableBuilder(
valueListenable: absorbTapsNotifier,
builder: (_, value, __) => Stack(
children: [
GestureDetector(
child: Listener(
behavior: HitTestBehavior.translucent,
onPointerPanZoomUpdate: (event) {
absorbTapsNotifier.value = false;
_timer?.cancel();
},
onPointerPanZoomEnd: (event) {
_timer?.cancel();
_applyTimer();
},
onPointerPanZoomStart: (event) {
absorbTapsNotifier.value = false;
_timer?.cancel();
},
onPointerSignal: (signal) {
if (signal is PointerScrollEvent) {
absorbTapsNotifier.value = false;
_timer?.cancel();
_applyTimer();
}
},
child: IgnorePointer(
ignoring: value,
child: Opacity(
opacity: 0.5,
child: _buildWidgetStack(onDeleted: widget.onDeleted),
),
),
builder: (_, value, __) => GestureDetector(
child: Listener(

Check warning on line 399 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L395-L399

Added lines #L395 - L399 were not covered by tests
behavior: HitTestBehavior.translucent,
onPointerPanZoomUpdate: (event) {
absorbTapsNotifier.value = false;
_timer?.cancel();

Check warning on line 403 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L401-L403

Added lines #L401 - L403 were not covered by tests
},
onPointerPanZoomEnd: (event) {
_timer?.cancel();
_applyTimer();

Check warning on line 407 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L405-L407

Added lines #L405 - L407 were not covered by tests
},
onPointerPanZoomStart: (event) {
absorbTapsNotifier.value = false;
_timer?.cancel();

Check warning on line 411 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L409-L411

Added lines #L409 - L411 were not covered by tests
},
onPointerSignal: (signal) {
if (signal is PointerScrollEvent) {
absorbTapsNotifier.value = false;
_timer?.cancel();
_applyTimer();

Check warning on line 417 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L413-L417

Added lines #L413 - L417 were not covered by tests
}
},
child: IgnorePointer(

Check warning on line 420 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L420

Added line #L420 was not covered by tests
ignoring: value,
child: Opacity(

Check warning on line 422 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L422

Added line #L422 was not covered by tests
opacity: 0.5,
child: _buildWidgetStack(onDeleted: widget.onDeleted),

Check warning on line 424 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L424

Added line #L424 was not covered by tests
),
),
Positioned(child: _buildReadOnlyBanner(context)),
],
),
),
);
}
Expand Down Expand Up @@ -430,27 +462,4 @@ class _HomeBodyState extends State<HomeBody> {
).toList(),

Check warning on line 462 in frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/home_stack.dart#L462

Added line #L462 was not covered by tests
);
}

Widget _buildReadOnlyBanner(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return ConstrainedBox(
constraints: const BoxConstraints(minHeight: 20),
child: Container(
width: double.infinity,
color: colorScheme.primary,
child: FittedBox(
alignment: Alignment.center,
fit: BoxFit.scaleDown,
child: Row(
children: [
FlowyText.medium(
LocaleKeys.readOnlyViewText.tr(),
fontSize: 14,
),
],
),
),
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ class _FlowyPaneState extends State<FlowyPane> {
create: (context) => widget.node.tabsController,
child: Consumer<TabsController>(
builder: (_, value, __) {
final topHeight = value.pages == 1
double topHeight = value.pages == 1

Check warning on line 49 in frontend/appflowy_flutter/lib/workspace/presentation/home/panes/flowy_pane.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/panes/flowy_pane.dart#L45-L49

Added lines #L45 - L49 were not covered by tests
? HomeSizes.topBarHeight
: HomeSizes.topBarHeight + HomeSizes.tabBarHeight;

Check warning on line 51 in frontend/appflowy_flutter/lib/workspace/presentation/home/panes/flowy_pane.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/panes/flowy_pane.dart#L51

Added line #L51 was not covered by tests

if (value.currentPageManager.readOnly) {
topHeight += HomeSizes.readOnlyBannerHeight;

Check warning on line 54 in frontend/appflowy_flutter/lib/workspace/presentation/home/panes/flowy_pane.dart

View check run for this annotation

Codecov / codecov/patch

frontend/appflowy_flutter/lib/workspace/presentation/home/panes/flowy_pane.dart#L53-L54

Added lines #L53 - L54 were not covered by tests
}

return DraggablePaneTarget(
size: Size(
widget.paneLayout.childPaneWidth,
Expand Down

0 comments on commit c152e1e

Please sign in to comment.