guru_sdk/guru_ui/lib/widget/dialog/dialog_utils.dart

323 lines
11 KiB
Dart

import 'package:flutter/material.dart';
import 'package:guru_ui/widget/alerts/dialog_buttons_alert_widget.dart';
import 'package:guru_ui/widget/alerts/dialog_error_picture_alert_widget.dart';
import 'package:guru_ui/widget/alerts/dialog_how_to_play_alert_widget.dart';
import 'package:guru_ui/widget/alerts/dialog_image_single_button_alert_widget.dart';
import 'package:guru_ui/widget/alerts/dialog_label_alert_widget.dart';
import 'package:guru_ui/widget/alerts/dialog_single_input_alert_widget.dart';
import 'package:guru_ui/widget/daily_reward/dialog_daily_reward_gift_collection_widget.dart';
import '../alerts/dialog_image_double_button_alert_widget.dart';
import '../daily_reward/dialog_daily_reward_gift_widget.dart';
import 'dialog_core.dart';
class DialogUtils {
static Future showLabelAlertDialog(BuildContext context,
{required String contentText,
required String cancelText,
required String ackText,
Color? backgroundColor,
TextStyle? contentTextStyle,
TextStyle? cancelTextStyle,
VoidCallback? cancelCallBack,
TextStyle? ackTextStyle,
VoidCallback? ackCallBack,
Color? crossLineColor}) {
return DialogCore.showDialog(
barrierColor: Colors.black.withOpacity(0.8),
barrierDismissible: true,
widget: DialogLabelAlertWidget(
contentText: contentText,
cancelText: cancelText,
ackText: ackText,
backgroundColor: backgroundColor,
contentTextStyle: contentTextStyle,
cancelTextStyle: cancelTextStyle,
cancelCallBack: cancelCallBack,
ackTextStyle: ackTextStyle,
ackCallBack: ackCallBack,
crossLineColor: crossLineColor,
));
}
static Future showButtonsAlertDialog(BuildContext context,
{required String contentText,
required String leftButtonText,
required String rightButtonText,
TextStyle? leftButtonTextStyle,
Color? leftButtonBackgroundColor,
bool? leftButtonShowBorder,
Color? leftButtonBorderColor,
double? leftButtonBorderWidth,
VoidCallback? leftButtonCallBack,
TextStyle? rightButtonTextStyle,
Color? rightButtonBackgroundColor,
bool? rightButtonShowBorder,
Color? rightButtonBorderColor,
double? rightButtonBorderWidth,
VoidCallback? rightButtonCallBack}) {
return DialogCore.showDialog(
barrierColor: Colors.black.withOpacity(0.8),
barrierDismissible: true,
widget: DialogButtonsAlertWidget(
contentText: contentText,
leftButtonText: leftButtonText,
rightButtonText: rightButtonText,
leftButtonTextStyle: leftButtonTextStyle,
leftButtonBackgroundColor: leftButtonBackgroundColor,
leftButtonShowBorder: leftButtonShowBorder,
leftButtonBorderColor: leftButtonBorderColor,
leftButtonBorderWidth: leftButtonBorderWidth,
leftButtonCallBack: leftButtonCallBack,
rightButtonTextStyle: rightButtonTextStyle,
rightButtonBackgroundColor: rightButtonBackgroundColor,
rightButtonShowBorder: rightButtonShowBorder,
rightButtonBorderColor: rightButtonBorderColor,
rightButtonBorderWidth: rightButtonBorderWidth,
rightButtonCallBack: rightButtonCallBack,
));
}
static Future showSingleInputAlertDialog(
BuildContext context, {
required String titleText,
required String buttonText,
Color? backgroundColor,
Image? closeImage,
TextStyle? titleTextStyle,
TextStyle? buttonTextStyle,
Function(String value)? buttonCallback,
Color? buttonBackgroundColor,
VoidCallback? closeCallback,
TextInputType? textInputType,
String? placeholderText,
TextStyle? hintTextStyle,
Color? cursorColor,
}) {
return DialogCore.showDialog(
barrierColor: Colors.black.withOpacity(0.8),
barrierDismissible: true,
widget: DialogSingleInputAlertWidget(
titleText: titleText,
buttonText: buttonText,
backgroundColor: backgroundColor,
closeImage: closeImage,
titleTextStyle: titleTextStyle,
buttonTextStyle: buttonTextStyle,
buttonCallback: buttonCallback,
buttonBackgroundColor: buttonBackgroundColor,
closeCallback: closeCallback,
textInputType: textInputType,
placeholderText: placeholderText,
placeholderTextStyle: hintTextStyle,
cursorColor: cursorColor,
));
}
static Future showErrorPictureAlertDialog(
BuildContext context,
Color? backgroundColor,
VoidCallback? closeCallback,
Image? closeImage,
Image image,
String messageText,
TextStyle? messageStyle,
String buttonText,
TextStyle? buttonTextStyle,
Color? buttonBackgroundColor,
VoidCallback? buttonCallback) {
return DialogCore.showDialog(
barrierColor: Colors.black.withOpacity(0.8),
barrierDismissible: true,
widget: DialogErrorPictureAlertWidget(
image: image,
messageText: messageText,
buttonText: buttonText,
backgroundColor: backgroundColor,
closeCallback: closeCallback,
closeImage: closeImage,
messageStyle: messageStyle,
buttonTextStyle: buttonTextStyle,
buttonBackgroundColor: buttonBackgroundColor,
buttonCallback: buttonCallback,
));
}
static Future showImageSingleButtonAlertDialog(
BuildContext context,
Color? backgroundColor,
String mainTitle,
TextStyle? mainTitleTextStyle,
String subTitle,
TextStyle? subTitleTextStyle,
Image image,
String descriptionText,
TextStyle? descriptionTextStyle,
Color? buttonBackgroundColor,
String buttonText,
Image buttonImage,
TextStyle? buttonTextStyle,
VoidCallback? buttonCallback,
Image? closeImage,
VoidCallback? closeCallback,
) {
return DialogCore.showDialog(
barrierColor: Colors.black.withOpacity(0.8),
barrierDismissible: true,
widget: DialogImageSingleButtonAlertWidget(
mainTitle: mainTitle,
subTitle: subTitle,
image: image,
descriptionText: descriptionText,
buttonText: buttonText,
buttonImage: buttonImage,
backgroundColor: backgroundColor,
mainTitleTextStyle: mainTitleTextStyle,
subTitleTextStyle: subTitleTextStyle,
descriptionTextStyle: descriptionTextStyle,
buttonBackgroundColor: buttonBackgroundColor,
buttonTextStyle: buttonTextStyle,
buttonCallback: buttonCallback,
closeImage: closeImage,
closeCallback: closeCallback,
));
}
static Future showImageDoubleButtonAlertDialog(
BuildContext context,
Color? backgroundColor,
String mainTitle,
TextStyle? mainTitleTextStyle,
String subTitle,
TextStyle? subTitleTextStyle,
Image image,
String descriptionText,
TextStyle? descriptionTextStyle,
Color? upButtonBackgroundColor,
String upButtonText,
Image upButtonImage,
TextStyle? upButtonTextStyle,
VoidCallback? upButtonCallback,
String downButtonText,
TextStyle? downButtonTextStyle,
VoidCallback? downButtonCallback,
Image? closeImage,
VoidCallback? closeCallback,
) {
return DialogCore.showDialog(
barrierColor: Colors.black.withOpacity(0.8),
barrierDismissible: true,
widget: DialogImageDoubleButtonAlertWidget(
mainTitle: mainTitle,
subTitle: subTitle,
image: image,
descriptionText: descriptionText,
backgroundColor: backgroundColor,
mainTitleTextStyle: mainTitleTextStyle,
subTitleTextStyle: subTitleTextStyle,
descriptionTextStyle: descriptionTextStyle,
upButtonBackgroundColor: upButtonBackgroundColor,
upButtonTextStyle: upButtonTextStyle,
upButtonCallback: upButtonCallback,
upButtonText: upButtonText,
upButtonImage: upButtonImage,
downButtonText: downButtonText,
downButtonTextStyle: downButtonTextStyle,
downButtonCallback: downButtonCallback,
closeImage: closeImage,
closeCallback: closeCallback,
));
}
static Future showHowToPlayAlertDialog(
BuildContext context,
Color? backgroundColor,
List<DialogHowToPlayContent> contentList,
Color? indicatorSelectColor,
Color? indicatorUnselectColor,
TextStyle? descriptionTextStyle,
String buttonText,
String lastButtonText,
TextStyle? buttonTextStyle,
Color? buttonBackgroundColor,
VoidCallback? buttonCallback,
) {
return DialogCore.showDialog(
barrierColor: Colors.black.withOpacity(0.8),
barrierDismissible: true,
widget: DialogHowToPlayAlertWidget(
titleText: "How does it work?",
contentList: contentList,
buttonText: buttonText,
lastButtonText: lastButtonText,
backgroundColor: backgroundColor,
indicatorSelectColor: indicatorSelectColor,
indicatorUnselectColor: indicatorUnselectColor,
descriptionTextStyle: descriptionTextStyle,
buttonTextStyle: buttonTextStyle,
buttonBackgroundColor: buttonBackgroundColor,
buttonCallback: buttonCallback,
));
}
static Future showDailyRewardDialog(
BuildContext context,
Color? backgroundColor,
String titleText,
TextStyle? titleTextStyle,
Color? borderColor,
double? borderWidth,
List<GiftConfig> giftList,
Image watchAdImage,
String guideText,
TextStyle? guideTextStyle,
Image? closeImage,
VoidCallback? closeCallback,
) {
return DialogCore.showDialog(
widget: DialogDailyRewardGiftWidget(
backgroundColor: backgroundColor,
titleText: titleText,
titleTextStyle: titleTextStyle,
borderColor: borderColor,
borderWidth: borderWidth,
giftList: giftList,
watchAdImage: watchAdImage,
guideText: guideText,
guideTextStyle: guideTextStyle,
closeImage: closeImage,
closeCallback: closeCallback,
));
}
static Future showDailyRewardCollectionDialog(
BuildContext context,
TextStyle? coinTextStyle,
Image shineImage,
String lottieUrl,
TextStyle? summaryTextStyle,
Color? buttonColor,
TextStyle? buttonTextStyle,
String buttonText,
Widget coinImage,
int coinCount,
String rewardSummary,
VoidCallback? collectionCallback,
) {
return DialogCore.showDialog(
widget: DialogDailyRewardGiftCollectionWidget(
shineImage: shineImage,
buttonText: buttonText,
lottieUrl: lottieUrl,
coinImage: coinImage,
coinCount: coinCount,
rewardSummary: rewardSummary,
coinTextStyle: coinTextStyle,
summaryTextStyle: summaryTextStyle,
buttonColor: buttonColor,
buttonTextStyle: buttonTextStyle,
collectionCallback: collectionCallback,
));
}
}