Skip to content

add haptic to creating post#810

Open
ThatOneCalculator wants to merge 1 commit intotunjid:mainfrom
ThatOneCalculator:post-haptic
Open

add haptic to creating post#810
ThatOneCalculator wants to merge 1 commit intotunjid:mainfrom
ThatOneCalculator:post-haptic

Conversation

@ThatOneCalculator
Copy link
Contributor

Very small change that adds a confirmation haptic when making a post :)

@gemini-code-assist
Copy link

Summary of Changes

Hello @ThatOneCalculator, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the user experience by adding a subtle haptic confirmation when a new post is successfully created. This tactile feedback provides an immediate and intuitive response to the user's action, making the interaction feel more complete and engaging.

Highlights

  • Haptic Feedback Integration: Introduced haptic feedback capabilities by importing HapticFeedbackType and LocalHapticFeedback.
  • Haptic Feedback Trigger: Implemented a confirmation haptic feedback (HapticFeedbackType.Confirm) to be triggered when a user successfully creates a post via the Floating Action Button (FAB).
  • Affected Components: The haptic feedback logic was added to both the TopAppBarFab and ComposePostFab composables within the ComposePostFab.kt file.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is a nice, small change that improves the user experience by adding haptic feedback. The implementation is correct, but it introduces some code duplication between TopAppBarFab and ComposePostFab. I've left a couple of comments with suggestions on how to refactor this to improve maintainability. Overall, good work!

Comment on lines 61 to 66
onClick = onClick@{
state.createPostAction()?.let(onCreatePost)
state.createPostAction()?.let {
haptic.performHapticFeedback(HapticFeedbackType.Confirm)
onCreatePost(it)
}
},

Choose a reason for hiding this comment

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

medium

This onClick logic, along with getting the haptic instance on line 49, is duplicated in ComposePostFab. To avoid code duplication and improve maintainability, consider extracting this logic to a common helper function.

Since LocalHapticFeedback.current is a composable call, you could create a private composable function that returns a decorated onClick lambda. For example:

@Composable
private fun rememberHapticClickHandler(action: () -> Unit): () -> Unit {
    val haptic = LocalHapticFeedback.current
    return {
        haptic.performHapticFeedback(HapticFeedbackType.Confirm)
        action()
    }
}

This could then be used in both TopAppBarFab and ComposePostFab to wrap the post creation logic.

Copy link
Owner

Choose a reason for hiding this comment

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

I think this should be opt in, most apps of this sort don't have haptics for like actions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bluesky sort of does (strangely, when you click the compose fab initially, instead of when you post), but I think that haptics like this are good for accessibility and general UX since it's physical confirmation of a successfully completed action -- I think making this optional is totally fine, but my vote would be for it to be on by default rather than off by default :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants