Skip to content

Commit

Permalink
fix: the view title doesn't refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasXu0 committed Nov 14, 2023
1 parent e788c71 commit ab734e8
Showing 1 changed file with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:appflowy/workspace/application/view/view_service.dart';
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/widget/flowy_tooltip.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

Expand Down Expand Up @@ -51,7 +52,7 @@ class _ViewTitleBarState extends State<ViewTitleBar> {
if (ancestors == null) {
return const SizedBox.shrink();
}
const maxWidth = WindowSizeManager.minWindowWidth - 100;
const maxWidth = WindowSizeManager.minWindowWidth - 200;
final replacement = Row(
// refresh the view title bar when the ancestors changed
key: ValueKey(ancestors.hashCode),
Expand All @@ -64,6 +65,7 @@ class _ViewTitleBarState extends State<ViewTitleBar> {
replacement: replacement,
// if the width is too small, only show one view title bar without the ancestors
child: _ViewTitle(
key: ValueKey(ancestors.last),
view: ancestors.last,
behavior: _ViewTitleBehavior.editable,
maxTitleWidth: constraints.maxWidth - 50.0,
Expand Down Expand Up @@ -123,6 +125,7 @@ enum _ViewTitleBehavior {

class _ViewTitle extends StatefulWidget {
const _ViewTitle({
super.key,
required this.view,
this.behavior = _ViewTitleBehavior.editable,
this.maxTitleWidth = 180,
Expand Down Expand Up @@ -187,23 +190,26 @@ class _ViewTitleState extends State<_ViewTitle> {
);
}

final child = Row(
children: [
FlowyText.regular(
icon,
fontSize: 18.0,
),
const HSpace(2.0),
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: widget.maxTitleWidth,
final child = FlowyTooltip(
message: name,
child: Row(
children: [
FlowyText.regular(
icon,
fontSize: 18.0,
),
child: FlowyText.regular(
name,
overflow: TextOverflow.ellipsis,
const HSpace(2.0),
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: widget.maxTitleWidth,
),
child: FlowyText.regular(
name,
overflow: TextOverflow.ellipsis,
),
),
),
],
],
),
);

if (widget.behavior == _ViewTitleBehavior.uneditable) {
Expand Down

0 comments on commit ab734e8

Please sign in to comment.