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

Add item index support #83

Open
AfroCyberGuy opened this issue Feb 20, 2024 · 2 comments
Open

Add item index support #83

AfroCyberGuy opened this issue Feb 20, 2024 · 2 comments

Comments

@AfroCyberGuy
Copy link

AfroCyberGuy commented Feb 20, 2024

Platforms

dart

Description

Can we add a feature to accept an optional index on the like button it helps when we want to do a request that required to get the item liked i.e in this case with an index. because onTap: Future<bool?> Function(bool)? onTap function is very limited i will be happy to contribute.

Why

Screenshot 2024-02-20 at 10 11 00
 child: RecommendedCard(
                            width: getScreenWidth(context) / 2.5,
                            height: getScreenWidth(context) / 2.5,
                            image: '$imageBaseUrl/${event.image}',
                            tagText: event.category?.name ?? '',
                            titleText: event.title ?? '',
                            dateText: event.date ?? '',
                            onLike: () async {
                              await notifier.like(event.id ?? 0, index);
                            },
                            isFavourite: event.isliked ?? 0,
                           //onLikeButtonTapped does a request and it needs and index button like button only accept this function type[ Future<bool?> Function(bool)? onTap ]
                            onTap: notifier.onLikeButtonTapped,
                          ),
                        );
                      },
                    ),
                    
                //This is my controller with notifier.onLikeButtonTapped method
                 //This is the function accepted by LikeButton , so its limited i can get an object tapped so that i can do a proper request
                      Future<bool> onLikeButtonTapped(bool isLiked) async {
    int likeStatus = 0;

    setLikingStatus(true);
    state = state.copyWith(likeEventResult: const AsyncValue.loading());

    final result = await _recommendedEventsServiceImpl.like(
      LikeRequest(
        eventId: state.eventId,
        userId: int.parse(_preferencesNotifier.getUserID()),
      ),
    );
@zmtzawqlp
Copy link
Member

I think you don't need do as that. A custom widget include your item data and LikeButton will work.

@AfroCyberGuy
Copy link
Author

AfroCyberGuy commented Feb 20, 2024

I think you don't need do as that. A custom widget include your item data and LikeButton will work.

Oww yes yes thank you for your timely response, I think I have logged this as a feature request and not issue. I have it working already but its just a suggestion to enhance LikeButton.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants