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

Opening the keyboard while a sheet animation is running will stop the animation #14

Closed
fujidaiti opened this issue Jan 29, 2024 · 1 comment · Fixed by #189
Closed
Assignees
Labels
bug Something isn't working P1
Milestone

Comments

@fujidaiti
Copy link
Owner

fujidaiti commented Jan 29, 2024

Reproduction code
import 'package:flutter/material.dart';
import 'package:smooth_sheets/smooth_sheets.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Builder(
        builder: (context) {
          return Scaffold(
            body: Center(
              child: FilledButton(
                onPressed: () {
                  Navigator.push(
                    context,
                    ModalSheetRoute(
                      builder: (_) => const SafeArea(
                        bottom: false,
                        child: MySheet(),
                      ),
                    ),
                  );
                },
                child: const Text('Open Sheet'),
              ),
            ),
          );
        },
      ),
    );
  }
}

class MySheet extends StatefulWidget {
  const MySheet({super.key});

  @override
  State<MySheet> createState() => _MySheetState();
}

class _MySheetState extends State<MySheet> {
  late final SheetController controller;

  @override
  void initState() {
    super.initState();
    controller = SheetController();
  }

  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    const minExtent = Extent.pixels(80);

    return ScrollableSheet(
      controller: controller,
      physics: const StretchingSheetPhysics(
        parent: SnappingSheetPhysics(
          snappingBehavior: SnapToNearest(
            snapTo: [minExtent, Extent.proportional(1)],
          ),
        ),
      ),
      initialExtent: minExtent,
      minExtent: minExtent,
      child: SheetContentScaffold(
        body: SizedBox.expand(
          child: SingleChildScrollView(
            child: TextField(
              // keyboardType: TextInputType.none,
              onTap: () {
                controller.animateTo(const Extent.proportional(1));
              },
            ),
          ),
        ),
      ),
    );
  }
}

According to the code above, the sheet should go to fullscreen with animation when the text field is tapped, but actually the sheet stops at an intermediate position.

child: TextField(
  onTap: () {
    controller.animateTo(const Extent.proportional(1));
  },
),
RocketSim_Recording_iPhone_15_6.1_2024-01-30_01.10.59.mp4

Related issues

@fujidaiti fujidaiti self-assigned this Jan 29, 2024
@fujidaiti fujidaiti added the bug Something isn't working label Jan 29, 2024
@fujidaiti fujidaiti removed their assignment Feb 2, 2024
@fujidaiti fujidaiti added this to the v0.3.0 milestone Feb 10, 2024
@fujidaiti fujidaiti self-assigned this Feb 10, 2024
fujidaiti added a commit that referenced this issue Feb 14, 2024
Fixes #22. Unfortunately, there are still some problems related to the
keyboard (e.g. #14) that will be taken care of in a future PR.

Summary:

- Added `SheetExtent.settle`, which causes the sheet to settle into a
stationary position similar to the `goBallistic(0.0)`, but with a
constant (non zero) and relatively high velocity.
- Added `SheetActivity.didFinalizeDimensions`, which is called once in a
frame after all measurement processes for both the content and the
viewport size have been completed.
@fujidaiti fujidaiti removed this from the v0.3.0 milestone Feb 22, 2024
@fujidaiti fujidaiti added the P2 label Feb 24, 2024
@fujidaiti
Copy link
Owner Author

fujidaiti commented Feb 27, 2024

In the meantime, we can avoid this issue by delaying the keyboard opening until the sheet animation is complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant