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/tools/sc_room_utils.dart'; import 'package:yumi/shared/business_logic/models/res/sc_index_banner_res.dart'; import 'package:yumi/shared/data_sources/sources/local/user_manager.dart'; import 'package:yumi/modules/wallet/wallet_route.dart'; import 'package:yumi/ui_kit/widgets/banner/index_banner_page.dart'; import 'package:yumi/ui_kit/widgets/countdown_timer.dart'; import 'package:yumi/ui_kit/components/text/sc_text.dart'; import 'package:yumi/app/routes/sc_fluro_navigator.dart'; class SCDialogUtils { static showFirstRechargeDialog(BuildContext context) { SmartDialog.show( tag: "showFirstRecharge", alignment: Alignment.center, animationType: SmartAnimationType.fade, builder: (_) { return Center( child: Stack( alignment: AlignmentDirectional.bottomCenter, children: [ SizedBox( height: 530.w, width: ScreenUtil().screenWidth * 0.86, child: Container( decoration: BoxDecoration( image: DecorationImage( image: AssetImage( "sc_images/index/sc_icon_first_recharge_bg.png", ), fit: BoxFit.fill, ), ), child: Column( children: [ SizedBox(height: 138.w), GestureDetector( child: Row( textDirection: TextDirection.ltr, mainAxisSize: MainAxisSize.min, children: [ Image.asset( "sc_images/index/sc_icon_my_rechage_title.png", height: 25.w, ), Transform.translate( offset: Offset(-3.w, 0), child: text( "${AccountStorage().getCurrentUser()?.userProfile?.firstRechargeAmount}", textColor: Colors.white, fontSize: 14.sp, ), ), ], ), onTap: () { SCRoomUtils.closeAllDialogs(); SCNavigatorUtils.push( context, WalletRoute.recharge, replace: false, ); }, ), SizedBox(height: 55.w), (AccountStorage() .getCurrentUser() ?.userProfile ?.firstRechargeAmount ?? 0) < 0.99 ? Container(height: 60.w) : Stack( alignment: Alignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, spacing: 28.w, children: [ Container( decoration: BoxDecoration( color: Colors.black54, borderRadius: BorderRadius.circular(10.w), ), height: 60.w, width: 60.w, ), Container( decoration: BoxDecoration( color: Colors.black54, borderRadius: BorderRadius.circular(10.w), ), height: 60.w, width: 60.w, ), Container( decoration: BoxDecoration( color: Colors.black54, borderRadius: BorderRadius.circular(10.w), ), height: 60.w, width: 60.w, ), ], ), Image.asset( "sc_images/index/sc_icon_claimed_text.png", width: 70.w, height: 35.w, ), ], ), SizedBox(height: 40.w), (AccountStorage() .getCurrentUser() ?.userProfile ?.firstRechargeAmount ?? 0) < 4.99 ? Container(height: 60.w) : Stack( alignment: Alignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, spacing: 28.w, children: [ Container( decoration: BoxDecoration( color: Colors.black54, borderRadius: BorderRadius.circular(10.w), ), height: 60.w, width: 60.w, ), Container( decoration: BoxDecoration( color: Colors.black54, borderRadius: BorderRadius.circular(10.w), ), height: 60.w, width: 60.w, ), Container( decoration: BoxDecoration( color: Colors.black54, borderRadius: BorderRadius.circular(10.w), ), height: 60.w, width: 60.w, ), ], ), Image.asset( "sc_images/index/sc_icon_claimed_text.png", width: 70.w, height: 35.w, ), ], ), SizedBox(height: 48.w), (AccountStorage() .getCurrentUser() ?.userProfile ?.firstRechargeAmount ?? 0) < 9.99 ? Container(height: 60.w) : Stack( alignment: Alignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, spacing: 28.w, children: [ Container( decoration: BoxDecoration( color: Colors.black54, borderRadius: BorderRadius.circular(10.w), ), height: 60.w, width: 60.w, ), Container( decoration: BoxDecoration( color: Colors.black54, borderRadius: BorderRadius.circular(10.w), ), height: 60.w, width: 60.w, ), Container( decoration: BoxDecoration( color: Colors.black54, borderRadius: BorderRadius.circular(10.w), ), height: 60.w, width: 60.w, ), ], ), Image.asset( "sc_images/index/sc_icon_claimed_text.png", width: 70.w, height: 35.w, ), ], ), ], ), ), ), PositionedDirectional( bottom: 7.w, child: CountdownTimer( expiryDate: DateTime.fromMillisecondsSinceEpoch( AccountStorage() .getCurrentUser() ?.userProfile ?.firstRechargeEndTime ?? 0, ), color: Colors.white, fontSize: 15.sp, ), ), ], ), ); }, ); } 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 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); }, ); } }