AppFlowy icon indicating copy to clipboard operation
AppFlowy copied to clipboard

Add hotkey to reset app scale

Open Trapiz opened this issue 1 year ago • 5 comments

Use the Ctrl+0 or Meta+0 shortcut to reset the app scale to 1

Scale demo.webm

Feature Preview

implements


PR Checklist

  • [x] My code adheres to AppFlowy's Conventions
  • [x] I've listed at least one issue that this PR fixes in the description above.
  • [x] I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • [x] All existing tests are passing.

Trapiz avatar May 21 '24 11:05 Trapiz

A question I do have is whether I should be writing tests for this. I couldn't find any tests that were checking the scaling up or down, so I didn't add a test for resetting the scale. I'm willing to write some tests for scaling and resetting said scale if you feel it's needed to write tests for this

Trapiz avatar May 21 '24 11:05 Trapiz

A question I do have is whether I should be writing tests for this. I couldn't find any tests that were checking the scaling up or down, so I didn't add a test for resetting the scale. I'm willing to write some tests for scaling and resetting said scale if you feel it's needed to write tests for this

It would be great if you could add both tests.

LucasXu0 avatar May 21 '24 11:05 LucasXu0

A question I do have is whether I should be writing tests for this. I couldn't find any tests that were checking the scaling up or down, so I didn't add a test for resetting the scale. I'm willing to write some tests for scaling and resetting said scale if you feel it's needed to write tests for this

It would be great if you could add both tests.

Alright! I'll start looking into writing some tests. I converted the PR to draft for now.

Trapiz avatar May 21 '24 11:05 Trapiz

Hi, @Trapiz. Do you need any help? I can add a sample for your reference.

LucasXu0 avatar May 27 '24 01:05 LucasXu0

Hi, @Trapiz. Do you need any help? I can add a sample for your reference.

I have looked into writing integration tests for this, but ran into the issue that the IntegrationTestWidgetsFlutterBinding binding is registered, and we also need the ScaledWidgetsFlutterBinding binding to be registered to allow scaling. But this is currently not possible to have two bindings registered at the same time. Me and @Xazin already talked about this and he also couldn't find a solution to this problem. I am going to see if I can pull this off with unit tests but I don't think they are going to turn out to be good test cases.

But maybe you have a completely different approach/idea and I would love to see the sample!

Trapiz avatar May 27 '24 07:05 Trapiz

Hi @LucasXu0, a quick follow-up to the comment above, I have looked into writing some unit tests but quickly realized that this would not really be possible. There are really no standalone components to test, and as far as I know, no possibility to trigger key presses either. I feel like with the way that integration tests are currently set up, it's not possible to test this with our current implementation. Do you have any ideas on how to proceed?

Trapiz avatar May 29 '24 12:05 Trapiz

@Trapiz Let me see if I can do that.

You're right. IntegrationTestWidgetsFlutterBuilder will conflict with ScaledWidgetsFlutterBinding. It seems there's no easy way to test the scale feature.

LucasXu0 avatar May 29 '24 13:05 LucasXu0

It's the same with unit test, except it's one of two bindings AutomatedTestWidgetsFlutterBinding or LiveTestWidgetsFlutterBinding.

Xazin avatar May 29 '24 22:05 Xazin