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

Implement custom swipe actions #37

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

albinmedoc
Copy link

-- Work in progress --

I have started to allow specifying the exact tab index when swiping. This allow more customizations for the user.

It would allow the user to swipe from tab 10 to tab 1 in one swipe.

I'm having trouble loading the configuration, and would need some help, the rest should work fine.

A view has two additional configurations:

{
      swipe_back_index: string | number | null | undefined;
      swipe_forward_index: string | number | null | undefined;
}

string: is a path to a tab
number: is the index of a tab
null: disables swipe
undefined: default behaviour (prev/next tab accordingly)

@zanna-37
Copy link
Owner

Thank you very much for your contribution.
I surely can help.

The main thing to discuss here is whether to:

  • Put the custom swipe configuration at the same level of the current config
    • In this case the user needs a way to specify which tab refers to each custom-swipe config.
    • The advantage is that we have all the config in one place. The disadvantage is that the user needs to remember to update the config when changing tab paths.
  • Put the custom swipe configuration at the same level of the "view"s configuration.
    • Advantage is that "related things are near" (views and view-specific swipe config), but the configuration is now split across the file. This is both inconvenient and I guess it would also be harder to code.

What's your opinion?

P.S. I'm trying to adhere to conventional commits. I would appreciate if you could try to follow it principles. Have a look at it or try to mimic my commit messages looking at the history. 😊

@albinmedoc
Copy link
Author

The code is working now.
Both by setting the global configuration and by view. The global overrides the view config.

@albinmedoc
Copy link
Author

I don't have time to write tests for this feature or fix any bugs.
Feel free to edit the code as you likings.

@albinmedoc albinmedoc mentioned this pull request Feb 13, 2023
@zanna-37 zanna-37 linked an issue Feb 13, 2023 that may be closed by this pull request
@zanna-37
Copy link
Owner

Thank you very much! I'll take it from here if you don't have time.

@zanna-37 zanna-37 changed the title Allow specifying exact tab Implement custom swipe actions Feb 13, 2023
@zanna-37 zanna-37 marked this pull request as draft February 13, 2023 13:36
@albinmedoc
Copy link
Author

Thank you.
Just want to mention thats is possible to specify tab by index or path.

I dont know how this works by the built in lovelace? I'm using UI Minimalist.

@NewsGuyTor
Copy link

Really looking forward to this being implemented! Googled this issue and found this PR.

@albinmedoc
Copy link
Author

Thanks @NewsGuyTor!
I have been running this PR for over a month and it works great.

I think the missing piece for this PR to get merged is to add the documentation for this feature.
Currently I don't have time to write it myself. Feel free to do it if you have the time.

@zanna-37
Copy link
Owner

We need to rebase everything but there will be a lot of conflicts. I'm thinking about rewriting this, taking huge inspiration from this PR. I'll add Albin in the commit as co-author as well as in the changelog. However, I'm a bit busy currently but It's on the roadmap with top priority.

@jpoeppelman1
Copy link

Hi all. So, this enhancement would be the best software enhancement known to man kind, so many use cases for the swipe back and forward view index option. I see the branch is still pending and there may be a desire to rewrite. Any way we could get this feature without the rewrite? ;-)

@zanna-37
Copy link
Owner

Any way we could get this feature without the rewrite? ;-)

No, I don't think so. Problem is that the PR works, but I need to make it stable and future-proof.
Since this new feature requires users to change the configuration manually, I need to think of a good config structure in order to leave room for later improvements and actions.

For example, I could allow for arbitrary js execution, not only navigation. But in order to do this I need to sit down and think carefully because once you create the structure it's not very elegant to change it with a breaking change down the road and ask users to comply.

I'm currently busy with work but I haven't forgotten this PR. =)
Hang on tight.

@jpoeppelman1
Copy link

Hi all. I'm okay with using the PR version until we get the refactored version. I'm okay if it breaks in the next release, I'll make the needed changes. So, I'm not a javascript developer, how can I convert the ts file to js when loading as a resource in HA? Any help really appreciated. ;)

@zanna-37
Copy link
Owner

zanna-37 commented Jul 5, 2023

You can have a look at https://github.com/zanna-37/hass-swipe-navigation/blob/main/CONTRIBUTING.md#build or https://github.com/zanna-37/hass-swipe-navigation/blob/main/.github/workflows/build-on-release.yml.

If you don't know what I'm talking about, I discourage you to continue without having a deeper understanding. However, if you're feeling lucky just run scripts/build.sh, you should find the compiled file on dist/swipe-navigation.js.

@jpoeppelman1
Copy link

You can have a look at https://github.com/zanna-37/hass-swipe-navigation/blob/main/CONTRIBUTING.md#build or https://github.com/zanna-37/hass-swipe-navigation/blob/main/.github/workflows/build-on-release.yml.

If you don't know what I'm talking about, I discourage you to continue without having a deeper understanding. However, if you're feeling lucky just run scripts/build.sh, you should find the compiled file on dist/swipe-navigation.js.

Thanks for helping me. I was able to compile the file using the docker method, then took the swipe-navigation.js file from the dist folder, copied it to my-ha-config/www/community/hass-swipe-navigation. I then restart HA and cleared my frontend cache in the iOS companion app, loaded the dashboard, no luck, it did not work. I added "swipe_back_index: security" and it did not honor the path. Below is the structure I used. Any advice?

  • title: ''
    path: security-detail
    swipe_back_index: security
    type: custom:vertical-layout
    badges: []
    cards:

@zanna-37
Copy link
Owner

@jpoeppelman1
Copy link

Just checking in here. How long do you think it will be before we can use this super awesome feature? :-)

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.

Custom swipe actions
4 participants