Skip to content

Commit 0e0d7b2

Browse files
committed
fix: complete the red dot
1 parent e4b654c commit 0e0d7b2

3 files changed

Lines changed: 82 additions & 29 deletions

File tree

frontend/appflowy_flutter/lib/workspace/presentation/home/navigation.dart

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import 'package:provider/provider.dart';
1515
import 'package:styled_widget/styled_widget.dart';
1616
import 'package:universal_platform/universal_platform.dart';
1717

18+
import '../notifications/number_red_dot.dart';
19+
1820
class NavigationNotifier with ChangeNotifier {
1921
NavigationNotifier({required this.navigationItems});
2022

@@ -81,20 +83,40 @@ class FlowyNavigation extends StatelessWidget {
8183
);
8284
return Padding(
8385
padding: const EdgeInsets.only(right: 8.0),
84-
child: RotationTransition(
85-
turns: const AlwaysStoppedAnimation(180 / 360),
86-
child: FlowyTooltip(
87-
richMessage: textSpan,
88-
child: Listener(
89-
onPointerDown: (event) =>
90-
context.read<HomeSettingBloc>().collapseMenu(),
91-
child: FlowyIconButton(
92-
width: 24,
93-
onPressed: () {},
94-
iconPadding: const EdgeInsets.all(4),
95-
icon: const FlowySvg(FlowySvgs.hide_menu_s),
86+
child: SizedBox(
87+
width: 24,
88+
height: 24,
89+
child: Stack(
90+
children: [
91+
RotationTransition(
92+
turns: const AlwaysStoppedAnimation(180 / 360),
93+
child: FlowyTooltip(
94+
richMessage: textSpan,
95+
child: Listener(
96+
onPointerDown: (event) =>
97+
context.read<HomeSettingBloc>().collapseMenu(),
98+
child: SizedBox(
99+
width: 24,
100+
height: 24,
101+
child: FlowyIconButton(
102+
width: 24,
103+
onPressed: () {},
104+
iconPadding: const EdgeInsets.all(4),
105+
icon: const FlowySvg(FlowySvgs.hide_menu_s),
106+
),
107+
),
108+
),
109+
),
96110
),
97-
),
111+
Align(
112+
alignment: Alignment.topRight,
113+
child: NumberedRedDot(
114+
size: 14,
115+
fontSize: 8,
116+
figmaLineHeight: 10,
117+
),
118+
),
119+
],
98120
),
99121
),
100122
);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import 'package:appflowy/user/application/reminder/reminder_bloc.dart';
2+
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:flutter_bloc/flutter_bloc.dart';
5+
6+
class NumberedRedDot extends StatelessWidget {
7+
const NumberedRedDot({
8+
super.key,
9+
this.size = 18,
10+
this.fontSize = 12,
11+
this.figmaLineHeight = 14,
12+
});
13+
final double size;
14+
final double fontSize;
15+
final double figmaLineHeight;
16+
17+
@override
18+
Widget build(BuildContext context) {
19+
return BlocBuilder<ReminderBloc, ReminderState>(
20+
builder: (context, state) {
21+
int unreadReminder = 0;
22+
for (final reminder in state.reminders) {
23+
if (!reminder.isRead) unreadReminder++;
24+
}
25+
if (unreadReminder == 0) return SizedBox.shrink();
26+
return Container(
27+
width: size,
28+
height: size,
29+
decoration: BoxDecoration(
30+
color: Colors.red,
31+
borderRadius: BorderRadius.all(Radius.circular(16)),
32+
),
33+
child: Center(
34+
child: FlowyText.medium(
35+
'$unreadReminder',
36+
color: Colors.white,
37+
fontSize: fontSize,
38+
figmaLineHeight: figmaLineHeight,
39+
),
40+
),
41+
);
42+
},
43+
);
44+
}
45+
}

frontend/appflowy_flutter/lib/workspace/presentation/notifications/widgets/notification_button.dart

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:appflowy/startup/startup.dart';
33
import 'package:appflowy/user/application/reminder/reminder_bloc.dart';
44
import 'package:appflowy/workspace/application/home/home_setting_bloc.dart';
55
import 'package:appflowy/workspace/application/settings/notifications/notification_settings_cubit.dart';
6+
import 'package:appflowy/workspace/presentation/notifications/number_red_dot.dart';
67
import 'package:appflowy_backend/protobuf/flowy-user/reminder.pb.dart';
78
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
89
import 'package:flutter/material.dart';
@@ -83,22 +84,7 @@ class _NotificationButtonState extends State<NotificationButton> {
8384
child: Container(
8485
height: 24,
8586
padding: EdgeInsets.all(3),
86-
child: Container(
87-
height: 18,
88-
padding: EdgeInsets.symmetric(horizontal: 6),
89-
decoration: BoxDecoration(
90-
color: Colors.red,
91-
borderRadius: BorderRadius.all(Radius.circular(16)),
92-
),
93-
child: Center(
94-
child: FlowyText.medium(
95-
'$unreadReminder',
96-
color: Colors.white,
97-
fontSize: 12,
98-
figmaLineHeight: 14,
99-
),
100-
),
101-
),
87+
child: NumberedRedDot(),
10288
),
10389
),
10490
);

0 commit comments

Comments
 (0)