Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring : Pin Details and Attachments #2067

Merged
merged 27 commits into from
Aug 19, 2024
Merged

Refactoring : Pin Details and Attachments #2067

merged 27 commits into from
Aug 19, 2024

Conversation

kumarpalsinh25
Copy link
Contributor

@kumarpalsinh25 kumarpalsinh25 commented Aug 15, 2024

This PR contains refactoring of entire Pin Details page and Attachment module as below.

  • Better UI placement of Pin Title, Space Name and Pin Description in detail page
  • Better Attachment List UI with Download Button (Show-case that file is not yet downloaded) and More Menu (For Edit and Delete attachment item)
  • Pin Link is now part of attachment list (Also added backward support so if there is link attachment with pin directly then with be removed from there and added to attachment).
  • Improvement in code structure for Pin detail page.
  • You can now add customised optional Title for Pin Attachment Items. (For files, if title not given then file name will be used as default)

Reference video:

Pin.Details.mov

Note for Reviewers:

  • Added few comments on the code to give better explanation about changes.
  • Entire PR can be reviewed directly but if faced any difficulties then check it by commits as most of the commits are based on the incremental changes of the entire PR work and highlight specific piece of the work changes.

@kumarpalsinh25 kumarpalsinh25 changed the title Pin Refactorig Refactoring : Pin Details and Attachments Aug 16, 2024
Copy link
Contributor Author

@kumarpalsinh25 kumarpalsinh25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added few comments for better understanding and code review process.

Comment on lines -89 to -91
final linkField = find.byKey(PinItem.linkFieldKey);
await linkField.should(findsOneWidget);
await linkField.replaceText(url);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Link is no more part of pin section, it is now part of attachment.

Comment on lines -93 to -110
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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • No more Edit Pin Page options as everything is now editable with Inline support!

import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';

void showEditLinkBottomSheet({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as mentioned above. Link is no more part of pin section, it is now part of attachment.

@@ -3,9 +3,14 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class SpaceNameWidget extends ConsumerWidget {
final String? spaceId;
final String spaceId;
final bool isShowBrackets;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helpful when we need to re-use this widget in other place where we want to show space name but without Brackets.

@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';

void showPinLinkBottomSheet({
void showAddEditLinkBottomSheet({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add link related stuff are now part of Attachment Common option so make related naming changes and also putted in appropriate folder.

import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

void showEditPintTitleDialog(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to pull out action code as much as possible from main files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function and inner call names are kinda misleading...

static const createPinPageKey = Key('create-pin-page');
static const titleFieldKey = Key('create-pin-title-field');
static const descriptionFieldKey = Key('create-pin-description-field');
static const submitBtn = Key('create-pin-submit');

final String? initialSelectedSpace;

const CreatePin({
const CreatePinPage({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming changes!

import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:skeletonizer/skeletonizer.dart';

class PinDetailsPage extends ConsumerStatefulWidget {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So created this page from scratch to get rid from unknown issues and better code management with new UI-UX.

);
}

Widget pinIconUI() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In future, this will be dynamic and putted into common widget for Icon Identity management.

@kumarpalsinh25 kumarpalsinh25 marked this pull request as ready for review August 16, 2024 12:42
Copy link
Contributor

@gtalha07 gtalha07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay it was a huge changeset and lot of nice changes 🎉 . But I feel it lacks behind in certain areas of code improvement, particularly I see redundancy with dialogs, adaptiveness of it, non-functional widgets in there and minor code addressal before it can be approved for merge on my behalf.

@gnunicorn gnunicorn added the s-pins issues related to the Pinwall-section label Aug 16, 2024
Copy link
Contributor

@gnunicorn gnunicorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is overall fine, but the backward compat code is not something I can sign off of as is. I provided the approach I'd take.

@kumarpalsinh25
Copy link
Contributor Author

kumarpalsinh25 commented Aug 17, 2024

@gnunicorn
I have address all your feedback points. Here is the summary of the all commits details. Read all notes before reviewing code for better judgement.

1) General Feedback Points: 9272e3b

Note: Due to one change in above commit, filename was not showing in attachment item if title is empty. which is fixes by this commit.

2) Backward Link Support Feedback: c88120f

Note: Forgot do some of things on above commit which is correct by below commit.

  • CanCheck for Edit Link Title: 2c11b5c
  • Use ref.read instead of ref.watch in function call : f8290de

Reference Video:

Pin Backward
Pin.backward.support.mov

3) Fixed canRedact issue which caused to not showing Remove Pin menu item: 1f7fa6f

FEEL FREE TO MERGE IT IF THINGS ARE ADDRESSED AND NO MORE ISSUES. :)

Copy link
Contributor

@gnunicorn gnunicorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last minor thing ... I'll address it on the following commit and merge it.

},
child: Text(L10n.of(context).edit),
),
PopupMenuItem<String>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can the user delete a pin if they don't have pin-edit-permissions? I think the entire menu needs to be behind that permission flag, no?

@gnunicorn gnunicorn enabled auto-merge August 18, 2024 12:09
@gnunicorn gnunicorn disabled auto-merge August 19, 2024 09:10
@gnunicorn gnunicorn dismissed gtalha07’s stale review August 19, 2024 09:10

this has been fixed now.

@gnunicorn gnunicorn merged commit 18ab10e into main Aug 19, 2024
17 checks passed
@gnunicorn gnunicorn deleted the kumar/refactor-pin branch August 19, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s-pins issues related to the Pinwall-section
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants