showCreatePollingViewDialog function

void showCreatePollingViewDialog(
  1. BuildContext context,
  2. EnxController obj
)

Implementation

void showCreatePollingViewDialog(BuildContext context, EnxController obj) {
  final _formKey = GlobalKey<FormState>();
  final ScrollController _scrollController = ScrollController();
  final FocusNode _focusNode = FocusNode();

  showGeneralDialog(
    context: context,
    barrierColor: Colors.black54, // Semi-transparent barrier
    barrierDismissible: true,
    barrierLabel: 'Create Poll Dialog',
    transitionDuration: const Duration(milliseconds: 300),
    pageBuilder: (context, animation1, animation2) {
      return OrientationBuilder(
        builder: (context, orientation) {
          final isPortrait = orientation == Orientation.portrait;
          final width = isPortrait
              ? MediaQuery.of(context).size.width
              : MediaQuery.of(context).size.width * 0.5;
          final height = MediaQuery.of(context).size.height;

          // Animation setup for right-to-left in landscape
          Offset beginOffset = isPortrait
              ? const Offset(0, 1) // Bottom to top in portrait
              : const Offset(1, 0); // Right to left in landscape
          Offset endOffset = Offset.zero;

          return SafeArea(
            child: SlideTransition(
              position: Tween<Offset>(
                begin: beginOffset,
                end: endOffset,
              ).animate(CurvedAnimation(
                parent: animation1,
                curve: Curves.easeOut,
              )),
              child: Align(
                alignment: isPortrait ? Alignment.center : Alignment.centerRight,
                child: Material(
                  type: MaterialType.transparency,
                  child: Container(
                    width: width,
                    height: height,
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: isPortrait
                          ? BorderRadius.circular(16)
                          : const BorderRadius.only(
                        topLeft: Radius.circular(16),
                        bottomLeft: Radius.circular(16),
                      ),
                      boxShadow: [
                        BoxShadow(
                          color: Colors.black.withOpacity(0.2),
                          blurRadius: 10,
                          spreadRadius: 2,
                        )
                      ],
                    ),
                    padding: EdgeInsets.only(
                      left: 15.0,
                      right: 16.0,
                      top: 16.0,
                      bottom: MediaQuery.of(context).viewInsets.bottom,
                    ),
                    child: SingleChildScrollView(
                      controller: _scrollController,
                      child: _buildLayout(obj, context, _formKey, isPortrait),
                    ),
                  ),
                ),
              ),
            ),
          );
        },
      );
    },
  );
}