showMoreDialog function

Future showMoreDialog(
  1. dynamic context,
  2. EnxController obj
)

Implementation

Future<dynamic> showMoreDialog(context, EnxController obj) {
  return showGeneralDialog(
    context: context,
    barrierDismissible: true,
    barrierLabel: '',
    barrierColor: Colors.black.withOpacity(0.5),
    transitionDuration: const Duration(milliseconds: 300),
    pageBuilder: (context, animation1, animation2) {
      return Container();
    },
    transitionBuilder: (context, animation1, animation2, child) {
      return SlideTransition(
        position: Tween<Offset>(
          begin: const Offset(1.0, 0.0),
          end: Offset.zero,
        ).animate(CurvedAnimation(
          parent: animation1,
          curve: Curves.easeInOut,
        )),
        child: OrientationBuilder(
          builder: (context, orientation) {
            final isPortrait = orientation == Orientation.portrait;
            final widthPercentage = isPortrait ? 0.8 : 0.5;

            return SafeArea(
              child: Scaffold(
                backgroundColor: Colors.transparent,
                body: Row(
                  children: [
                    Expanded(
                      child: GestureDetector(
                        onTap: () => Navigator.pop(context),
                        behavior: HitTestBehavior.opaque,
                      ),
                    ),
                    AnimatedContainer(
                      duration: const Duration(milliseconds: 200),
                      width: MediaQuery.of(context).size.width * widthPercentage,
                      height: MediaQuery.of(context).size.height,
                      decoration: BoxDecoration(
                        color: Colors.white,
                        border: Border.all(width: 3.0),
                        borderRadius: isPortrait
                            ? const BorderRadius.only(
                          topLeft: Radius.circular(15.0),
                          bottomLeft: Radius.circular(15.0),
                        )
                            : const BorderRadius.only(
                          topLeft: Radius.circular(15.0),
                          bottomLeft: Radius.circular(15.0),
                        ),
                      ),
                      child: Column(
                        children: [
                          Expanded(
                            child: ListView(
                              padding: EdgeInsets.zero,
                              children: [
                                for (var item in obj.moreList)
                                  item.isSwitch
                                      ? SwitchListTile(
                                    title: Text(
                                      item.name,
                                      style: TextStyle(
                                          color: Colors.black,
                                          fontWeight: FontWeight.w800,
                                          fontSize: 16.sp),
                                    ),
                                    value: item.status,
                                    activeColor: CustomColors.themeColor,
                                    inactiveTrackColor: Colors.grey,
                                    onChanged: (bool value) {
                                      item.status = value;
                                      obj.updateMoreList(item);
                                      Get.back();
                                    },
                                    secondary: Image.asset(
                                      item.status ? item.activeIcon : item.icon,
                                      width: 30,
                                      height: 30,
                                      package: 'enx_uikit_flutter',
                                    ),
                                  )
                                      : GestureDetector(
                                      behavior: HitTestBehavior.opaque,
                                      onTap: () {
                                        obj.updateMoreList(item);
                                        Get.back();
                                      },
                                      child: Padding(
                                        padding: EdgeInsets.only(left: 15.w, top: 10.w),
                                        child: Row(
                                          crossAxisAlignment: CrossAxisAlignment.center,
                                          children: [
                                            Image.asset(
                                              item.status ? item.activeIcon : item.icon,
                                              width: 40,
                                              height: 40,
                                              package: 'enx_uikit_flutter',
                                            ),
                                            Padding(
                                              padding: EdgeInsets.fromLTRB(15.w, 0, 0, 0),
                                              child: Text(
                                                item.name,
                                                style: TextStyle(
                                                    color: Colors.black,
                                                    fontWeight: FontWeight.w800,
                                                    fontSize: 16.sp),
                                                textAlign: TextAlign.center,
                                              ),
                                            )
                                          ],
                                        ),
                                      )),
                              ],
                            ),
                          ),
                          SizedBox(height: MediaQuery.of(context).padding.bottom),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            );
          },
        ),
      );
    },
  );
}