140 lines
4.6 KiB
Dart
140 lines
4.6 KiB
Dart
import 'dart:math';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
import 'package:yumi/app_localizations.dart';
|
|
import 'package:yumi/ui_kit/components/sc_debounce_widget.dart';
|
|
import 'package:yumi/ui_kit/theme/socialchat_theme.dart';
|
|
import 'package:yumi/shared/business_logic/models/res/sc_index_banner_res.dart';
|
|
|
|
import 'package:yumi/ui_kit/widgets/banner/index_banner_page.dart';
|
|
import 'package:yumi/ui_kit/widgets/first_recharge/first_recharge_dialog.dart';
|
|
import 'package:yumi/ui_kit/components/text/sc_text.dart';
|
|
|
|
class SCDialogUtils {
|
|
static Future<void> showFirstRechargeDialog(
|
|
BuildContext context, {
|
|
bool forceRefresh = false,
|
|
}) {
|
|
return FirstRechargeDialog.showFromRemote(
|
|
context,
|
|
forceRefresh: forceRefresh,
|
|
);
|
|
}
|
|
|
|
static void showDynamicCommentOptDialog(
|
|
BuildContext context, {
|
|
Function? reportCallback,
|
|
Function? deleteCallback,
|
|
}) {
|
|
SmartDialog.dismiss(tag: "showDynamicCommentOptDialog");
|
|
SmartDialog.show(
|
|
tag: "showDynamicCommentOptDialog",
|
|
alignment: Alignment.bottomCenter,
|
|
animationType: SmartAnimationType.fade,
|
|
builder: (_) {
|
|
return SafeArea(
|
|
top: false,
|
|
child: Container(
|
|
padding: EdgeInsets.symmetric(vertical: 10.w),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.only(
|
|
topLeft: Radius.circular(10.w),
|
|
topRight: Radius.circular(10.w),
|
|
),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
spacing: 3.w,
|
|
children: [
|
|
if (reportCallback != null)
|
|
SCDebounceWidget(
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
child: text(
|
|
SCAppLocalizations.of(context)!.report,
|
|
textColor: Colors.black,
|
|
fontSize: 15.sp,
|
|
),
|
|
),
|
|
onTap: () {
|
|
reportCallback.call();
|
|
SmartDialog.dismiss(tag: "showDynamicCommentOptDialog");
|
|
},
|
|
),
|
|
if (reportCallback != null)
|
|
Divider(
|
|
color: SocialChatTheme.dividerColor,
|
|
thickness: 0.5,
|
|
height: 10.w,
|
|
),
|
|
if (deleteCallback != null)
|
|
SCDebounceWidget(
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
child: text(
|
|
SCAppLocalizations.of(context)!.delete,
|
|
textColor: Colors.black,
|
|
fontSize: 15.sp,
|
|
),
|
|
),
|
|
onTap: () {
|
|
deleteCallback.call();
|
|
SmartDialog.dismiss(tag: "showDynamicCommentOptDialog");
|
|
},
|
|
),
|
|
if (deleteCallback != null)
|
|
Divider(
|
|
color: SocialChatTheme.dividerColor,
|
|
thickness: 0.5,
|
|
height: 10.w,
|
|
),
|
|
SCDebounceWidget(
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
child: text(
|
|
SCAppLocalizations.of(context)!.cancel,
|
|
textColor: Colors.black,
|
|
fontSize: 15.sp,
|
|
),
|
|
),
|
|
onTap: () {
|
|
SmartDialog.dismiss(tag: "showDynamicCommentOptDialog");
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
static void showBannerDialog(
|
|
BuildContext context,
|
|
List<SCIndexBannerRes> banners,
|
|
) {
|
|
if (banners.isEmpty) {
|
|
return;
|
|
}
|
|
SCIndexBannerRes banner;
|
|
if (banners.length > 1) {
|
|
int index = Random().nextInt(banners.length);
|
|
banner = banners[index];
|
|
} else {
|
|
banner = banners.first;
|
|
}
|
|
|
|
SmartDialog.show(
|
|
tag: "showBannerDialog",
|
|
alignment: Alignment.center,
|
|
animationType: SmartAnimationType.fade,
|
|
builder: (_) {
|
|
return IndexBannerPage(banner);
|
|
},
|
|
);
|
|
}
|
|
}
|