Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:appflowy/mobile/presentation/selection_menu/mobile_selection_menu_item.dart';
import 'package:appflowy/mobile/presentation/selection_menu/mobile_selection_menu_item_widget.dart';
import 'package:appflowy/mobile/presentation/selection_menu/mobile_selection_menu_widget.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/slash_menu/slash_menu_items/mobile_items.dart';
Expand Down Expand Up @@ -36,8 +37,16 @@ void main() {
await tester.ime.insertText(searchText);
final itemWidgets = find.byType(MobileSelectionMenuItemWidget);
int number = 0;
for (final mobileItem in mobileItems) {
for (final item in mobileItem.children) {
for (final item in mobileItems) {
if (item is MobileSelectionMenuItem) {
for (final childItem in item.children) {
if (childItem.name
.toLowerCase()
.contains(searchText.toLowerCase())) {
number++;
}
}
} else {
if (item.name.toLowerCase().contains(searchText.toLowerCase())) {
number++;
}
Expand All @@ -55,6 +64,7 @@ void main() {
matching: find.byType(ListView),
);
for (final item in mobileItems) {
if (item is! MobileSelectionMenuItem) continue;
await tester.editor.showSlashMenu();
await tester.scrollUntilVisible(
find.text(item.name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,13 @@ class _MobileViewPageState extends State<MobileViewPage> {
),
const HSpace(4),
],
FlowyText.medium(
name,
fontSize: 15.0,
overflow: TextOverflow.ellipsis,
figmaLineHeight: 18.0,
Flexible(
child: FlowyText.medium(
name,
fontSize: 15.0,
overflow: TextOverflow.ellipsis,
figmaLineHeight: 18.0,
),
),
const HSpace(4.0),
_buildLockStatusIcon(context, view),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,14 @@ class MobileInlineActionsWidget extends StatelessWidget {
item.icon!.call(isSelected),
SizedBox(width: 12),
],
FlowyText.regular(
item.label,
figmaLineHeight: 18,
overflow: TextOverflow.ellipsis,
fontSize: 16,
color: style.menuItemSelectedTextColor,
Flexible(
child: FlowyText.regular(
item.label,
figmaLineHeight: 18,
overflow: TextOverflow.ellipsis,
fontSize: 16,
color: style.menuItemSelectedTextColor,
),
),
],
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'dart:async';
import 'dart:math';

import 'package:appflowy/mobile/presentation/selection_menu/mobile_selection_menu_item.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/material.dart';

import 'mobile_selection_menu_item_widget.dart';
import 'mobile_selection_menu_widget.dart';

class MobileSelectionMenu extends SelectionMenuService {
Expand All @@ -13,7 +15,7 @@ class MobileSelectionMenu extends SelectionMenuService {
required this.selectionMenuItems,
this.deleteSlashByDefault = false,
this.deleteKeywordsByDefault = false,
this.style = SelectionMenuStyle.light,
this.style = MobileSelectionMenuStyle.light,
this.itemCountFilter = 0,
this.startOffset = 0,
this.singleColumn = false,
Expand All @@ -27,7 +29,7 @@ class MobileSelectionMenu extends SelectionMenuService {
final bool singleColumn;

@override
final SelectionMenuStyle style;
final MobileSelectionMenuStyle style;

OverlayEntry? _selectionMenuEntry;
Offset _offset = Offset.zero;
Expand Down Expand Up @@ -172,7 +174,7 @@ class MobileSelectionMenu extends SelectionMenuService {
// Workaround: We can customize the padding through the [EditorStyle],
// but the coordinates of overlay are not properly converted currently.
// Just subtract the padding here as a result.
const menuHeight = 192.0;
const menuHeight = 192.0, menuWidth = 240.0 + 10;
const menuOffset = Offset(0, 10);
final editorOffset =
editorState.renderBox?.localToGlobal(Offset.zero) ?? Offset.zero;
Expand All @@ -194,8 +196,9 @@ class MobileSelectionMenu extends SelectionMenuService {
offset = topRight - menuOffset;
_alignment = Alignment.bottomLeft;

final limitX = editorWidth - menuWidth;
_offset = Offset(
offset.dx,
min(offset.dx, limitX),
MediaQuery.of(context).size.height - offset.dy,
);
}
Expand All @@ -206,8 +209,10 @@ class MobileSelectionMenu extends SelectionMenuService {
? Alignment.topRight
: Alignment.bottomRight;

final x = editorWidth - _offset.dx + editorOffset.dx;
final limitX = editorWidth - menuWidth + editorOffset.dx;
_offset = Offset(
editorWidth - _offset.dx + editorOffset.dx,
min(x, limitX),
_offset.dy,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ class MobileSelectionMenuItemWidget extends StatelessWidget {
required this.item,
required this.isSelected,
required this.selectionMenuStyle,
required this.onTap,
});

final EditorState editorState;
final SelectionMenuService menuService;
final SelectionMenuItem item;
final bool isSelected;
final SelectionMenuStyle selectionMenuStyle;
final MobileSelectionMenuStyle selectionMenuStyle;
final VoidCallback onTap;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -58,12 +60,13 @@ class MobileSelectionMenuItemWidget extends StatelessWidget {
Spacer(),
Icon(
Icons.keyboard_arrow_right_rounded,
color: Color(0xff1E2022).withValues(alpha: 0.3),
color: style.selectionMenuItemRightIconColor,
),
],
],
),
onPressed: () {
onTap.call();
item.handler(
editorState,
menuService,
Expand All @@ -74,3 +77,37 @@ class MobileSelectionMenuItemWidget extends StatelessWidget {
);
}
}

class MobileSelectionMenuStyle extends SelectionMenuStyle {
const MobileSelectionMenuStyle({
required super.selectionMenuBackgroundColor,
required super.selectionMenuItemTextColor,
required super.selectionMenuItemIconColor,
required super.selectionMenuItemSelectedTextColor,
required super.selectionMenuItemSelectedIconColor,
required super.selectionMenuItemSelectedColor,
required this.selectionMenuItemRightIconColor,
});

final Color selectionMenuItemRightIconColor;

static const MobileSelectionMenuStyle light = MobileSelectionMenuStyle(
selectionMenuBackgroundColor: Color(0xFFFFFFFF),
selectionMenuItemTextColor: Color(0xFF1F2225),
selectionMenuItemIconColor: Color(0xFF333333),
selectionMenuItemSelectedColor: Color(0xFFF2F5F7),
selectionMenuItemRightIconColor: Color(0xB31E2022),
selectionMenuItemSelectedTextColor: Color.fromARGB(255, 56, 91, 247),
selectionMenuItemSelectedIconColor: Color.fromARGB(255, 56, 91, 247),
);

static const MobileSelectionMenuStyle dark = MobileSelectionMenuStyle(
selectionMenuBackgroundColor: Color(0xFF424242),
selectionMenuItemTextColor: Color(0xFFFFFFFF),
selectionMenuItemIconColor: Color(0xFFFFFFFF),
selectionMenuItemSelectedColor: Color(0xFF666666),
selectionMenuItemRightIconColor: Color(0xB3FFFFFF),
selectionMenuItemSelectedTextColor: Color(0xFF131720),
selectionMenuItemSelectedIconColor: Color(0xFF131720),
);
}
Loading
Loading