diff --git a/app/integration_test/tests/pins.dart b/app/integration_test/tests/pins.dart index ea31515cfc88..dfb89fb21bf0 100644 --- a/app/integration_test/tests/pins.dart +++ b/app/integration_test/tests/pins.dart @@ -4,7 +4,6 @@ import 'package:acter/common/widgets/spaces/select_space_form_field.dart'; import 'package:acter/features/home/data/keys.dart'; import 'package:acter/features/pins/pages/create_pin_page.dart'; import 'package:acter/features/pins/pages/pin_details_page.dart'; -import 'package:acter/features/pins/widgets/pin_item.dart'; import 'package:acter/features/search/model/keys.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:convenient_test_dev/convenient_test_dev.dart'; @@ -86,29 +85,6 @@ extension ActerNews on ConvenientTest { await titleField.should(findsOneWidget); await titleField.replaceText(title); - final linkField = find.byKey(PinItem.linkFieldKey); - await linkField.should(findsOneWidget); - await linkField.replaceText(url); - - final descriptionField = find.byKey(PinItem.descriptionFieldKey); - await descriptionField.should(findsOneWidget); - final textEditorState = - (tester.firstState(descriptionField) as HtmlEditorState).editorState; - final lastSelectable = textEditorState.getLastSelectable()!; - final transaction = textEditorState.transaction; - transaction.insertText( - lastSelectable.$1, - 35, - content, - ); - await textEditorState.apply(transaction); - textEditorState.service.keyboardService!.closeKeyboard(); - - final saveBtnKey = find.byKey(PinItem.saveBtnKey); - await saveBtnKey.should(findsOneWidget); - await tester.ensureVisible(saveBtnKey); - await saveBtnKey.tap(); - final pinPage = find.byKey(PinDetailsPage.pinPageKey); await pinPage.should(findsOneWidget); final page = pinPage.evaluate().first.widget as PinDetailsPage; diff --git a/app/lib/features/pins/pages/pin_details_page.dart b/app/lib/features/pins/pages/pin_details_page.dart index fd4cb8aee37f..eb508ae79945 100644 --- a/app/lib/features/pins/pages/pin_details_page.dart +++ b/app/lib/features/pins/pages/pin_details_page.dart @@ -22,6 +22,7 @@ class PinDetailsPage extends ConsumerStatefulWidget { static const actionMenuKey = Key('pin-action-menu'); static const editBtnKey = Key('pin-edit-btn'); static const titleFieldKey = Key('edit-pin-title-field'); + static const descriptionFieldKey = Key('edit-pin-description-field'); final String pinId; diff --git a/app/lib/features/pins/widgets/pin_item.dart b/app/lib/features/pins/widgets/pin_item.dart deleted file mode 100644 index cfa313588bd2..000000000000 --- a/app/lib/features/pins/widgets/pin_item.dart +++ /dev/null @@ -1,146 +0,0 @@ -import 'package:acter/common/utils/utils.dart'; -import 'package:acter/common/widgets/edit_html_description_sheet.dart'; -import 'package:acter/common/widgets/edit_link_sheet.dart'; -import 'package:acter/common/widgets/render_html.dart'; -import 'package:acter/features/home/widgets/space_chip.dart'; -import 'package:acter/features/pins/Utils/pins_utils.dart'; -import 'package:acter/features/pins/providers/pins_provider.dart'; -import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart' show ActerPin; -import 'package:atlas_icons/atlas_icons.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -class PinItem extends ConsumerStatefulWidget { - static const linkFieldKey = Key('edit-pin-link-field'); - static const descriptionFieldKey = Key('edit-pin-description-field'); - static const saveBtnKey = Key('pin-edit-save'); - final ActerPin pin; - - const PinItem(this.pin, {super.key}); - - @override - ConsumerState createState() => _PinItemState(); -} - -class _PinItemState extends ConsumerState { - final GlobalKey _formkey = - GlobalKey(debugLabel: 'pin edit form'); - int? attachmentCount; - - @override - Widget build(BuildContext context) { - final pin = widget.pin; - final spaceId = pin.roomIdStr(); - final isLink = pin.isLink(); - - return Form( - key: _formkey, - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - alignment: Alignment.topLeft, - margin: const EdgeInsets.all(8), - child: SpaceChip(spaceId: spaceId), - ), - if (isLink) _buildPinLink(), - _pinDescription(), - ], - ), - ); - } - - Widget _pinDescription() { - final description = widget.pin.content(); - if (description == null) return const SizedBox.shrink(); - final formattedBody = description.formattedBody(); - - return Container( - margin: const EdgeInsets.all(12), - padding: const EdgeInsets.all(8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SelectionArea( - child: GestureDetector( - onTap: () { - showEditHtmlDescriptionBottomSheet( - context: context, - descriptionHtmlValue: description.formattedBody(), - descriptionMarkdownValue: description.body(), - onSave: (htmlBodyDescription, plainDescription) async { - saveDescription( - context, - htmlBodyDescription, - plainDescription, - widget.pin, - ); - }, - ); - }, - child: formattedBody != null - ? RenderHtml( - text: formattedBody, - defaultTextStyle: Theme.of(context).textTheme.labelLarge, - ) - : Text( - description.body(), - style: Theme.of(context).textTheme.labelLarge, - ), - ), - ), - const SizedBox(height: 20), - ], - ), - ); - } - - // pin link widget - Widget _buildPinLink() { - return SelectionArea( - child: GestureDetector( - onTap: () async { - await openLink(widget.pin.url() ?? '', context); - }, - child: Card( - child: Padding( - padding: const EdgeInsets.all(16), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Icon(Atlas.link_chain_thin, size: 18), - const SizedBox(width: 16), - Expanded( - child: Text( - widget.pin.url() ?? '', - softWrap: false, - overflow: TextOverflow.ellipsis, - ), - ), - GestureDetector( - onTap: () { - showEditLinkBottomSheet( - context: context, - bottomSheetTitle: L10n.of(context).editLink, - linkValue: widget.pin.url() ?? '', - onSave: (newLink) async { - final pinEditNotifier = - ref.watch(pinEditProvider(widget.pin).notifier); - pinEditNotifier.setLink(newLink); - savePinLink(context, widget.pin, newLink); - }, - ); - }, - child: const Icon(Atlas.pencil_edit, size: 18), - ), - ], - ), - ), - ), - ), - ); - } -}