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

Tab swiping #1656

Merged
merged 7 commits into from
Mar 22, 2024
Merged

Tab swiping #1656

merged 7 commits into from
Mar 22, 2024

Conversation

StarScape
Copy link
Contributor

@StarScape StarScape commented Mar 7, 2024

I haven't actually tested this on a phone yet (just used FF's touch emulation), so I want to make sure and do that before this actually gets merged, but this should be good enough to take a look at.

  • Swiping behavior implemented
  • Click to open copy overlay behavior is preserved
  • Respects tabs that are currently disabled and will not swipe to them

Couple comments/questions below.

Also, there was a test failing on my machine when I ran yarn test:firefox, but looks like that predates my commits.

src/content/popup/popup.ts Outdated Show resolved Hide resolved
src/content/popup/popup.ts Outdated Show resolved Hide resolved
Copy link
Member

@birtles birtles left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks so much for this.

I assume you'll test on iPhone? If so, I can try to test it out on my Android phone.

Unfortunately I'm on parental leave of sorts at the moment so it might take me a bit longer than usual to be able to test it.

Thanks again.

src/content/popup/popup.ts Outdated Show resolved Hide resolved
src/content/popup/popup.ts Outdated Show resolved Hide resolved
src/content/popup/popup.ts Outdated Show resolved Hide resolved
@StarScape
Copy link
Contributor Author

StarScape commented Mar 8, 2024

I assume you'll test on iPhone? If so, I can try to test it out on my Android phone.

Yup, that sounds good. I'll drop a comment here when I've had a chance to test on iPhone.

Unfortunately I'm on parental leave of sorts at the moment so it might take me a bit longer than usual to be able to test it.

That doesn't sound unfortunate to me 🙂. Enjoy your time with your kid(s), no rush at all on my end.

@birtles
Copy link
Member

birtles commented Mar 9, 2024

I assume you'll test on iPhone? If so, I can try to test it out on my Android phone.

Yup, that sounds good. I'll drop a comment here when I've had a chance to test on iPhone.

Great, thank you.

Unfortunately I'm on parental leave of sorts at the moment so it might take me a bit longer than usual to be able to test it.

That doesn't sound unfortunate to me 🙂. Enjoy your time with your kid(s), no rush at all on my end.

Thanks! Yeah, you're right. Not unfortunate at all! Thanks for your understanding!

@StarScape
Copy link
Contributor Author

Hey @birtles, I've gotten around to testing this, but while I can get it to run on the iOS simulator, when I try to run on my actual iPhone (really just wanted to test that the swipe behavior feels right on a touch screen) I get provisioning/signing errors:

image

I'm a bit ignorant of how signing works in the Apple/iOS ecosystem, but I'm guessing the H3RB[...] identifier under "Team" is whatever you have set up under your account. If I try to change "Team" to my own name, I can get through the build setting, but then get this on install.

image

Has the iOS app/extension ever been set up to install from source on any Apple ID except yours? Or, is there a way I can just skip the signing step altogether to run the development version? Again, sorry for my ignorance of Xcode here.

@birtles
Copy link
Member

birtles commented Mar 18, 2024

Hey @birtles, I've gotten around to testing this, but while I can get it to run on the iOS simulator, when I try to run on my actual iPhone (really just wanted to test that the swipe behavior feels right on a touch screen) I get provisioning/signing errors:

Thanks @StarScape! I got in to the office for a brief moment last week where I was able to test the PR on my Android phone but unfortunately the swiping didn't work for me then. I haven't had a chance to debug it yet, however.

I'm really unfamiliar with XCode but I believe @shirakaba has set it up to work on his phone before? Jamie, do you know how any of this works?

@shirakaba
Copy link
Collaborator

shirakaba commented Mar 18, 2024

Heya!

Has the iOS app/extension ever been set up to install from source on any Apple ID except yours? Or, is there a way I can just skip the signing step altogether to run the development version? Again, sorry for my ignorance of Xcode here.

Should be solvable – the Xcode project is not tied to any particular device, but it does default to signing for Brian's team (which is unavoidable – Xcode projects are very clunky for opensource projects), so you'll just need to override the team name to your personal team.

If I try to change "Team" to my own name, I can get through the build setting, but then get this on install.

As mentioned, it's correct to change the team to your personal team while working on it. 👍 Do leave the resulting change to the Xcodeproj uncommitted, though.

As for the error, could you try the top suggestion here? Happy to help until you're unblocked, so just give me another poke if that doesn't resolve it.

@StarScape
Copy link
Contributor Author

@shirakaba Thanks for the guidance! That was an easier fix than I thought (though maybe 'uninstall and reinstall it' should have been more obvious 😅). I was able to get it working and tested on my phone.

it does default to signing for Brian's team (which is unavoidable – Xcode projects are very clunky for opensource projects

Yeah, it seemed a bit clunky, that's why I wanted to check here. Wasn't sure if it was an Xcode limitation or if I had misconfigured something on my end. Thanks again.

@birtles As for the swiping not working on your Android phone, I think the issue might have been that I had the x-distance that needed to be traveled in order for the swipe to register was rather high. When I tested on my iPhone, I could get it to happen, but only if I did a very long and deliberate swipe.

I've knocked the threshold down significantly now. Give it another shot when you get the chance. If it still doesn't work then let me know, we'll need to do some more serious debugging. I don't have a physical Android device handy at the moment, but I should be able to fix any bugs with an emulator.

yarn.lock Outdated Show resolved Hide resolved
@birtles
Copy link
Member

birtles commented Mar 19, 2024

@shirakaba Thank you so much!

@birtles As for the swiping not working on your Android phone, I think the issue might have been that I had the x-distance that needed to be traveled in order for the swipe to register was rather high. When I tested on my iPhone, I could get it to happen, but only if I did a very long and deliberate swipe.

I've knocked the threshold down significantly now. Give it another shot when you get the chance. If it still doesn't work then let me know, we'll need to do some more serious debugging. I don't have a physical Android device handy at the moment, but I should be able to fix any bugs with an emulator.

@StarScape Great, that could well be it. I'll try again on Thursday.

Copy link
Member

@birtles birtles left a comment

Choose a reason for hiding this comment

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

I tried this on my Android phone and it works great. Thank you!

src/content/content.ts Outdated Show resolved Hide resolved
src/content/content.ts Outdated Show resolved Hide resolved
src/content/popup/popup.ts Outdated Show resolved Hide resolved
src/content/popup/swipe.ts Outdated Show resolved Hide resolved
src/content/popup/swipe.ts Outdated Show resolved Hide resolved
StarScape added a commit to StarScape/10ten-ja-reader that referenced this pull request Mar 21, 2024
@StarScape
Copy link
Contributor Author

Alright @birtles, it should (hopefully) be good to go now. Let me know if you'd prefer me squash these down into one commit.

Copy link
Member

@birtles birtles left a comment

Choose a reason for hiding this comment

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

Looks great. I left a few nit comments. If you don't mind, I'll just make those tweaks myself then squash merge it.


const contentContainer = html('div', { class: 'content' });
console.log('Hello1');
Copy link
Member

Choose a reason for hiding this comment

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

Can we drop this? 😅

Suggested change
console.log('Hello1');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lol yeah, sorry that slipped through from some debugging. Thanks for getting this merged, appreciate the patience with the back and forth!

Copy link
Member

Choose a reason for hiding this comment

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

Not at all! Thank you so much for your patience with all my nitpicking!
I'll probably try to get in a few more fixes and then we can release the next version with this included.

const contentContainer = html('div', { class: 'content' });
console.log('Hello1');
onHorizontalSwipe(contentContainer, (direction) => {
console.log('Hello?');
Copy link
Member

Choose a reason for hiding this comment

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

And this?

Suggested change
console.log('Hello?');

Comment on lines 132 to 134
if (options.onSwitchDictionary) {
options.onSwitchDictionary(direction === 'left' ? 'prev' : 'next');
}
Copy link
Member

Choose a reason for hiding this comment

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

I think we can just write:

Suggested change
if (options.onSwitchDictionary) {
options.onSwitchDictionary(direction === 'left' ? 'prev' : 'next');
}
options.onSwitchDictionary?.(direction === 'left' ? 'prev' : 'next');

StarScape and others added 7 commits March 22, 2024 16:29
- Change x-threshold for swipe motion from 150 to 50px
- Move swipe detection code to its own file
- Allow 'prev' parameter for showDictionary function
- Add @stylistic/eslint-plugin-js to handle max-len linting for comments
@birtles birtles enabled auto-merge (squash) March 22, 2024 07:41
@birtles birtles merged commit a534b29 into birchill:main Mar 22, 2024
1 check passed
@birtles
Copy link
Member

birtles commented Mar 22, 2024

@all-contributors please add @StarScape for code

Copy link
Contributor

@birtles

I've put up a pull request to add @StarScape! 🎉

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.

3 participants