272 lines
11 KiB
Dart
272 lines
11 KiB
Dart
import 'dart:ui';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/gestures.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
import 'package:aslan/chatvibe_core/constants/at_room_msg_type.dart';
|
|
import 'package:aslan/chatvibe_data/sources/local/user_manager.dart';
|
|
import 'package:aslan/main.dart';
|
|
import 'package:aslan/chatvibe_ui/widgets/room/room_msg_item.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:aslan/app_localizations.dart';
|
|
import 'package:aslan/chatvibe_ui/theme/chatvibe_theme.dart';
|
|
import 'package:aslan/chatvibe_core/routes/at_fluro_navigator.dart';
|
|
import 'package:aslan/chatvibe_managers/app_general_manager.dart';
|
|
import 'package:aslan/chatvibe_managers/rtc_manager.dart';
|
|
import 'package:aslan/chatvibe_managers/rtm_manager.dart';
|
|
import 'package:aslan/chatvibe_features/index/main_route.dart';
|
|
|
|
import '../../../../chatvibe_data/models/enum/at_vip_type.dart';
|
|
import '../../../../chatvibe_domain/models/res/at_room_emoji_res.dart';
|
|
import '../../../components/at_compontent.dart';
|
|
import '../../../components/at_tts.dart';
|
|
|
|
class EmojiTabPage extends StatefulWidget {
|
|
String type;
|
|
|
|
EmojiTabPage(this.type, {super.key});
|
|
|
|
@override
|
|
_EmojiTabPageState createState() => _EmojiTabPageState();
|
|
}
|
|
|
|
class _EmojiTabPageState extends State<EmojiTabPage> {
|
|
PageController _giftPageController = PageController();
|
|
int _index = 0;
|
|
bool isHasPermission = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
if (widget.type == "VIP1-3") {
|
|
if (AccountStorage().getVIP()?.name == ATVIPType.VISCOUNT.name ||
|
|
AccountStorage().getVIP()?.name == ATVIPType.EARL.name ||
|
|
AccountStorage().getVIP()?.name == ATVIPType.MARQUIS.name ||
|
|
AccountStorage().getVIP()?.name == ATVIPType.DUKE.name ||
|
|
AccountStorage().getVIP()?.name == ATVIPType.KING.name ||
|
|
AccountStorage().getVIP()?.name == ATVIPType.EMPEROR.name) {
|
|
isHasPermission = true;
|
|
}
|
|
} else if (widget.type == "VIP4-6") {
|
|
if (AccountStorage().getVIP()?.name == ATVIPType.DUKE.name ||
|
|
AccountStorage().getVIP()?.name == ATVIPType.KING.name ||
|
|
AccountStorage().getVIP()?.name == ATVIPType.EMPEROR.name) {
|
|
isHasPermission = true;
|
|
}
|
|
} else {
|
|
isHasPermission = true;
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Consumer<AppGeneralManager>(
|
|
builder: (context, ref, child) {
|
|
return (ref.emojiByTab[widget.type] ?? []).isEmpty
|
|
? mainEmpty(
|
|
textColor: Colors.white54,
|
|
msg: ATAppLocalizations.of(context)!.noData,
|
|
)
|
|
: Stack(
|
|
children: [
|
|
Column(
|
|
children: [
|
|
Expanded(
|
|
child: PageView.builder(
|
|
controller: _giftPageController,
|
|
onPageChanged: (i) {
|
|
setState(() {
|
|
_index = i;
|
|
});
|
|
},
|
|
itemBuilder: (c, i) {
|
|
var current =
|
|
(ref.emojiByTab[widget.type]!.length - (i * 8));
|
|
int size =
|
|
current > 8
|
|
? 8
|
|
: current % 8 == 0
|
|
? 8
|
|
: current % 8;
|
|
return GridView.builder(
|
|
shrinkWrap: true,
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w),
|
|
physics: NeverScrollableScrollPhysics(),
|
|
gridDelegate:
|
|
SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 4,
|
|
childAspectRatio: 0.9,
|
|
mainAxisSpacing: 5.w,
|
|
crossAxisSpacing: 33.w,
|
|
),
|
|
itemCount: size,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return _emojiItem(
|
|
ref.emojiByTab[widget.type]![(i * 8) + index],
|
|
ref,
|
|
);
|
|
},
|
|
);
|
|
},
|
|
itemCount:
|
|
(ref.emojiByTab[widget.type]!.length / 8).ceil(),
|
|
),
|
|
),
|
|
_indicator(ref),
|
|
SizedBox(height: 10.w),
|
|
],
|
|
),
|
|
isHasPermission ? Container() : Stack(
|
|
alignment: Alignment.bottomCenter,
|
|
children: [
|
|
BackdropFilter(
|
|
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
|
|
child: Container(color: Colors.black38),
|
|
),
|
|
Image.asset(
|
|
widget.type == "VIP1-3"
|
|
? "atu_images/room/at_icon_emoji_vip1_3_bg.png"
|
|
: "atu_images/room/at_icon_emoji_vip4_6_bg.png",
|
|
width: ScreenUtil().screenWidth,
|
|
height: double.infinity,
|
|
fit: BoxFit.fill,
|
|
),
|
|
PositionedDirectional(
|
|
bottom: 15.w,
|
|
child: Container(
|
|
width: ScreenUtil().screenWidth * 0.8,
|
|
child: Text.rich(
|
|
TextSpan(
|
|
children: [
|
|
TextSpan(
|
|
text:
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.exclusiveEmojiWillBeReleasedAfterBecoming,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 12.sp,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
TextSpan(
|
|
text: " ${widget.type}",
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 12.sp,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
TextSpan(
|
|
text: ".",
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 12.sp,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
TextSpan(
|
|
text: ATAppLocalizations.of(context)!.goToUpgrade,
|
|
style: TextStyle(
|
|
decoration: TextDecoration.underline,
|
|
color: Colors.white,
|
|
fontSize: 12.sp,
|
|
decorationColor: Colors.white,
|
|
decorationStyle: TextDecorationStyle.solid,
|
|
decorationThickness: 1.5,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
recognizer:
|
|
TapGestureRecognizer()
|
|
..onTap = () async {
|
|
SmartDialog.dismiss(
|
|
tag: "showRoomEmojiPage",
|
|
);
|
|
ATNavigatorUtils.push(
|
|
navigatorKey.currentState!.context,
|
|
MainRoute.vipList,
|
|
replace: false,
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
int beginTime = 0;
|
|
|
|
Widget _emojiItem(Emojis emoji, AppGeneralManager ref) {
|
|
return GestureDetector(
|
|
child: netImage(
|
|
url: emoji.coverUrl ?? "",
|
|
width: 35.w,
|
|
height: 35.w,
|
|
borderRadius: BorderRadius.all(Radius.circular(5.w)),
|
|
),
|
|
onTap: () {
|
|
if (Provider.of<RealTimeCommunicationManager>(context, listen: false).isOnMai()) {
|
|
int endTime = DateTime.now().millisecondsSinceEpoch;
|
|
if (endTime - beginTime > 5000) {
|
|
beginTime = endTime;
|
|
Msg msg = Msg(
|
|
groupId:
|
|
Provider.of<RealTimeCommunicationManager>(
|
|
context,
|
|
listen: false,
|
|
).currenRoom?.roomProfile?.roomProfile?.roomAccount,
|
|
msg: emoji.coverUrl,
|
|
number: Provider.of<RealTimeCommunicationManager>(
|
|
context,
|
|
listen: false,
|
|
).userOnMaiInIndex(
|
|
AccountStorage().getCurrentUser()?.userProfile?.id ?? "",
|
|
),
|
|
type: ATRoomMsgType.emoticons,
|
|
);
|
|
Provider.of<RtmProvider>(
|
|
context,
|
|
listen: false,
|
|
).sendMsg(msg, addLocal: false);
|
|
Provider.of<RealTimeCommunicationManager>(context, listen: false).starPlayEmoji(msg);
|
|
SmartDialog.dismiss(tag: "showRoomEmojiPage");
|
|
} else {
|
|
ATTts.show(ATAppLocalizations.of(context)!.operationsAreTooFrequent);
|
|
}
|
|
} else {
|
|
ATTts.show(ATAppLocalizations.of(context)!.pleaseGetOnTheMicFirst);
|
|
}
|
|
},
|
|
);
|
|
}
|
|
|
|
_indicator(AppGeneralManager ref) {
|
|
var size = (ref.emojiByTab[widget.type]!.length) / 8;
|
|
var list = <Widget>[];
|
|
for (int i = 0; i < size; i++) {
|
|
list.add(
|
|
Container(
|
|
width: 6.5.w,
|
|
height: 6.5.w,
|
|
margin: EdgeInsets.symmetric(horizontal: 4.w),
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: _index == i ? ChatVibeTheme.primaryColor : Color(0xffDADADA),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
return Row(mainAxisAlignment: MainAxisAlignment.center, children: list);
|
|
}
|
|
}
|