tarkalabs / tarka-ui-kit-flutter

UI Kit and Design System for building apps with Flutter
https://pub.dev/packages/tarka_ui
MIT License
7 stars 0 forks source link

Improve TUIMobileOverlayMenu #72

Open kalpeshp0310 opened 4 months ago

kalpeshp0310 commented 4 months ago
  1. It does not show the Overlay bottom sheet by itself. Users have to do some ceremonial work to show it as the bottom sheet. To show this overlay as a bottom sheet.
    TUIMobileOverlayMenu(
    title: "title",
    action: () {
    print("tapped");
    },
    menuItems: [
    TUIMenuItem(
      item: TUIMenuItemProperties(
        title: "Item 1",
        style: TUIMenuItemStyle.both,
        state: TUIMenuItemState.unchecked,
      ),
      backgroundDark: true,
    ),
    TUIMenuItem(
      item: TUIMenuItemProperties(
        title: "Item 2",
        style: TUIMenuItemStyle.none,
        state: TUIMenuItemState.unchecked,
      ),
    )
    ],
    )

We have to do this:

showModalBottomSheet(
  context: context,
  shape: const RoundedRectangleBorder(
    borderRadius: BorderRadius.vertical(
      top: Radius.circular(
          20.0), // Adjust the top corner radius here
    ),
  ),
  builder: (BuildContext context) {
    return ClipRRect(
      borderRadius: const BorderRadius.vertical(
        top: Radius.circular(
            20.0), // Match the radius with the shape
      ),
      child: TUIMobileOverlayMenu(
        title: "title",
        action: () {
          print("tapped");
        },
        menuItems: [
          TUIMenuItem(
            item: TUIMenuItemProperties(
              title: "Item 1",
              style: TUIMenuItemStyle.both,
              state: TUIMenuItemState.unchecked,
            ),
            backgroundDark: true,
          ),
          TUIMenuItem(
            item: TUIMenuItemProperties(
              title: "Item 2",
              style: TUIMenuItemStyle.none,
              state: TUIMenuItemState.unchecked,
            ),
          )
        ],
      ),
    );
  },
);

The above code takes care of showing the model, changing its top left and right radius. Also, TUIMobileOverlayMenu assumes that it will be displayed inside the bottom sheet. So it pops from the current stack which dismisses the bottom sheet.

I think we should have a TUI version of the showModalBottomSheet function that removes the above boilerplate code.

  1. Should we rename the callback action to onDismiss?
  2. action is not getting invoked right now. We need to invoke it when the bottom sheet is getting dismissed.
  3. Add support for more buttons.? Right now, only the dismiss (X) button is added by default. It does not allow over header and overlay footer to be used to their full extent.