showSaveDialog function

void showSaveDialog(
  1. BuildContext context,
  2. NeomGeneratorController controller
)

Implementation

void showSaveDialog(BuildContext context, NeomGeneratorController controller) {
  Alert(
    context: context,
    style: AlertStyle(
        backgroundColor: AppColor.surfaceElevated,
        titleStyle: const TextStyle(color: Colors.white),
        descStyle: const TextStyle(color: Colors.white70)
    ),
    title: GeneratorTranslationConstants.chamberPrefs.tr,
    content: Column(
      children: <Widget>[
        Obx(()=>
            DropdownButton<String>(
              items: AppItemState.values.map((AppItemState itemState) {
                return DropdownMenuItem<String>(
                    value: itemState.name,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: [
                        Text(itemState.name.tr),
                        if(itemState.value != 0) ...[
                          const SizedBox(width: 10),
                          RatingBar(
                            initialRating: itemState.value.toDouble(),
                            minRating: 1,
                            ignoreGestures: true,
                            direction: Axis.horizontal,
                            allowHalfRating: false,
                            itemCount: 5,
                            ratingWidget: RatingWidget(
                              full: AppUtilities.ratingImage(AppAssets.heart),
                              half: AppUtilities.ratingImage(AppAssets.heartHalf),
                              empty: AppUtilities.ratingImage(AppAssets.heartBorder),
                            ),
                            itemPadding: const EdgeInsets.symmetric(horizontal: 1.0),
                            itemSize: 10,
                            onRatingUpdate: (rating) {},
                          ),
                        ]
                      ],
                    )
                );
              }).toList(),
              onChanged: (String? newItemState) {
                controller.setFrequencyState(EnumToString.fromString(AppItemState.values, newItemState!) ?? AppItemState.noState);
              },
              value: CoreUtilities.getItemState(controller.frequencyState.value).name,
              isExpanded: true,
              dropdownColor: AppColor.surfaceElevated,
              style: const TextStyle(color: Colors.white),
              underline: Container(height: 1, color: AppColor.bondiBlue),
            )
        ),
      ],
    ),
    buttons: [
      DialogButton(
        color: AppColor.bondiBlue,
        child: Obx(()=>controller.isLoading.value ? const Center(child: CircularProgressIndicator(color: Colors.white))
            : Text(AppTranslationConstants.add.tr, style: const TextStyle(color: Colors.white, fontSize: 16),
        )),
        onPressed: () async {
          if(controller.frequencyState > 0) {
            await controller.addPreset(context, frequencyPracticeState: controller.frequencyState.value);
            Sint.back();
          } else {
            Sint.snackbar(
                CommonTranslationConstants.appItemPrefs.tr,
                MessageTranslationConstants.selectItemStateMsg.tr,
                snackPosition: SnackPosition.bottom,
                backgroundColor: AppColor.scaffold,
                colorText: Colors.white
            );
          }
        },
      )],
  ).show();
}