getBottomSheetLayoutForCameraGallery method

Widget getBottomSheetLayoutForCameraGallery({
  1. String title = "Choose option",
  2. String camTitle = "Camera",
  3. String galleryTitle = "Gallery",
  4. String cancelTitle = "Cancel",
  5. String? titleFontFamily,
  6. String? camTitleFontFamily,
  7. String? galleryTitleFontFamily,
  8. String? cancelTitleFontFamily,
  9. double? titleFontSize,
  10. double? camTitleFontSize,
  11. double? galleryTitleFontSize,
  12. double? cancelTitleFontSize,
  13. double titlePadding = 16,
  14. double? cancelHorizontalPadding,
  15. double? cancelVerticalPadding,
  16. IconData? camIcon,
  17. IconData? galleryIcon,
  18. bool isTitleCenter = true,
  19. bool isGalleryTitleCenter = true,
  20. bool isCamTitleCenter = true,
  21. Color titleColor = Colors.black,
  22. Color camTitleColor = Colors.black,
  23. Color galleryTitleColor = Colors.black,
  24. Color cancelTitleColor = Colors.black,
  25. Color galleryColor = Colors.black,
  26. Color camColor = Colors.black,
})

Creates a bottom sheet layout for camera/gallery selection.

Displays a modal bottom sheet with options to select camera or gallery, along with a cancel button. The sheet automatically closes when an option is selected.

Parameters:

  • title: Header text for the bottom sheet (defaults to "Choose option").
  • camTitle: Label for camera option (defaults to "Camera").
  • galleryTitle: Label for gallery option (defaults to "Gallery").
  • cancelTitle: Label for cancel button (defaults to "Cancel").
  • titleFontFamily: Font family for title. Defaults to Utils.appConstants.boldFontFamily.
  • camTitleFontFamily: Font family for camera label. Defaults to Utils.appConstants.regularFontFamily.
  • galleryTitleFontFamily: Font family for gallery label. Defaults to Utils.appConstants.regularFontFamily.
  • cancelTitleFontFamily: Font family for cancel button. Defaults to Utils.appConstants.boldFontFamily.
  • titleFontSize: Font size for title. Defaults to Utils.appConstants.textHeaderFontSize.
  • camTitleFontSize: Font size for camera label. Defaults to Utils.appConstants.normalFontSize.
  • galleryTitleFontSize: Font size for gallery label. Defaults to Utils.appConstants.normalFontSize.
  • cancelTitleFontSize: Font size for cancel button. Defaults to Utils.appConstants.normalFontSize.
  • titlePadding: Padding around the title (defaults to 16).
  • cancelHorizontalPadding: Horizontal padding for cancel button.
  • cancelVerticalPadding: Vertical padding for cancel button.
  • camIcon: Icon for camera option (defaults to Icons.camera_alt).
  • galleryIcon: Icon for gallery option (defaults to Icons.photo_library).
  • isTitleCenter: Whether to center the title (defaults to true).
  • isGalleryTitleCenter: Whether to center gallery label (defaults to true).
  • isCamTitleCenter: Whether to center camera label (defaults to true).
  • titleColor: Color for title text (defaults to black).
  • camTitleColor: Color for camera label (defaults to black).
  • galleryTitleColor: Color for gallery label (defaults to black).
  • cancelTitleColor: Color for cancel button text (defaults to black).
  • galleryColor: Color for gallery icon (defaults to black).
  • camColor: Color for camera icon (defaults to black).

Returns a Padding widget containing the bottom sheet layout.

Note: This method only creates the UI. Actual image picking logic should be implemented in the onTap callbacks.

Example:

GlobalBottomSheet.show(
  getBottomSheetLayoutForCameraGallery(
    title: 'Select Image Source',
    camColor: Colors.blue,
    galleryColor: Colors.green,
  )
);

Implementation

Widget getBottomSheetLayoutForCameraGallery(
    {String title = "Choose option",
    String camTitle = "Camera",
    String galleryTitle = "Gallery",
    String cancelTitle = "Cancel",
    String? titleFontFamily,
    String? camTitleFontFamily,
    String? galleryTitleFontFamily,
    String? cancelTitleFontFamily,
    double? titleFontSize,
    double? camTitleFontSize,
    double? galleryTitleFontSize,
    double? cancelTitleFontSize,
    double titlePadding = 16,
    double? cancelHorizontalPadding,
    double? cancelVerticalPadding,
    IconData? camIcon,
    IconData? galleryIcon,
    bool isTitleCenter = true,
    bool isGalleryTitleCenter = true,
    bool isCamTitleCenter = true,
    Color titleColor = Colors.black,
    Color camTitleColor = Colors.black,
    Color galleryTitleColor = Colors.black,
    Color cancelTitleColor = Colors.black,
    Color galleryColor = Colors.black,
    Color camColor = Colors.black}) {
  return Padding(
    padding: EdgeInsets.all(Utils.appConstants.boxPadding),
    child: Container(
        width: Get.width,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: Utils.appConstants.bottomSheetContainerBorderRadius,
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            // Header
            Padding(
              padding: EdgeInsets.all(titlePadding),
              child: Utils.commonWidgets.setText(
                  title,
                  titleFontFamily ?? Utils.appConstants.boldFontFamily,
                  titleColor,
                  titleFontSize ?? Utils.appConstants.textHeaderFontSize,
                  isCenter: isTitleCenter),
            ),
            const Divider(),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                Expanded(
                  child: InkWell(
                    onTap: () async {
                      Get.back(); // Close the bottom sheet
                      // Pick image from camera
                    },
                    child: Column(
                      children: [
                        Icon(
                          camIcon ?? Icons.camera_alt,
                          color: camColor,
                        ),
                        Utils.commonWidgets.setText(
                            camTitle,
                            camTitleFontFamily ??
                                Utils.appConstants.regularFontFamily,
                            camTitleColor,
                            camTitleFontSize ??
                                Utils.appConstants.normalFontSize,
                            isCenter: isCamTitleCenter)
                      ],
                    ),
                  ),
                ),
                Expanded(
                  child: InkWell(
                    onTap: () async {
                      Get.back(); // Close the bottom sheet
                      // Pick image from camera
                    },
                    child: Column(
                      children: [
                        Icon(
                          galleryIcon ?? Icons.photo_library,
                          color: galleryColor,
                        ),
                        Utils.commonWidgets.setText(
                            galleryTitle,
                            galleryTitleFontFamily ??
                                Utils.appConstants.regularFontFamily,
                            galleryTitleColor,
                            galleryTitleFontSize ??
                                Utils.appConstants.normalFontSize,
                            isCenter: isGalleryTitleCenter)
                      ],
                    ),
                  ),
                ),
              ],
            ),
            // Divider line for better separation

            const Divider(),
            // Another divider
            Padding(
              padding:
                  const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  InkWell(
                      onTap: () async {
                        Get.back(); // Close the bottom sheet
                        // Pick image from gallery
                      },
                      child: Utils.commonWidgets.setText(
                          cancelTitle,
                          cancelTitleFontFamily ??
                              Utils.appConstants.boldFontFamily,
                          cancelTitleColor,
                          cancelTitleFontSize ??
                              Utils.appConstants.normalFontSize)),
                ],
              ),
            ),
          ],
        )),
  );
}