alanchan-dev / OmniDateTimePicker

A Flutter DateTime picker package.
MIT License
47 stars 66 forks source link

add actionsBuilder #67

Open IiemB opened 3 months ago

IiemB commented 3 months ago

image

added actionsBuilder to customize the buttons and their actions before returning value from dialogue

example :

showOmniDateTimePicker(
                context: context,
                is24HourMode: true,
                isForce2Digits: true,
                initialDate: DateTime.now(),
                firstDate: DateTime(2020),
                lastDate: DateTime(2025),
                padding: const EdgeInsets.all(12),
                insetPadding: const EdgeInsets.all(12),
                borderRadius: BorderRadius.circular(12),
                actionsBuilder:
                    (onCancelPressed, cancelText, onSavePressed, saveText) => [
                  Expanded(
                    child: OutlinedButton(
                      onPressed: () {
                        // ... others actions
                        onCancelPressed.call();
                      },
                      child: Text(cancelText), // or Other text
                    ),
                  ),
                  const SizedBox(
                    height: 20,
                    child: VerticalDivider(),
                  ),
                  Expanded(
                    child: FilledButton(
                      onPressed: () {
                        // ... others actions
                        onSavePressed.call();
                      },
                      child: Text(saveText), // or Other text
                    ),
                  ),
                ],
              ),
showOmniDateTimeRangePicker(
                context: context,
                is24HourMode: true,
                isForce2Digits: true,
                padding: const EdgeInsets.all(12),
                insetPadding: const EdgeInsets.all(12),
                borderRadius: BorderRadius.circular(12),
                actionsBuilder:
                    (onCancelPressed, cancelText, onSavePressed, saveText) => [
                  Expanded(
                    child: OutlinedButton(
                      onPressed: () {
                        // ... others actions
                        onCancelPressed.call();
                      },
                      child: Text(cancelText), // or Other text
                    ),
                  ),
                  const SizedBox(
                    height: 20,
                    child: VerticalDivider(),
                  ),
                  Expanded(
                    child: FilledButton(
                      onPressed: () {
                        // ... others actions
                        onSavePressed.call();
                      },
                      child: Text(saveText), // or Other text
                    ),
                  ),
                ],
              ),