139 lines
4.0 KiB
Dart
139 lines
4.0 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/cupertino.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/app_localizations.dart';
|
|
import 'package:aslan/chatvibe_ui/components/at_debounce_widget.dart';
|
|
import 'package:aslan/chatvibe_ui/components/at_compontent.dart';
|
|
import 'package:aslan/chatvibe_ui/components/text/at_text.dart';
|
|
import 'package:aslan/chatvibe_core/utilities/at_room_utils.dart';
|
|
import 'package:aslan/chatvibe_data/models/message/at_floating_message.dart';
|
|
import 'package:aslan/main.dart';
|
|
|
|
class InviteRoomDialog extends StatefulWidget {
|
|
ATFloatingMessage msg;
|
|
|
|
InviteRoomDialog(this.msg);
|
|
|
|
@override
|
|
_InviteRoomDialogState createState() => _InviteRoomDialogState();
|
|
}
|
|
|
|
class _InviteRoomDialogState extends State<InviteRoomDialog> {
|
|
Timer? _timer;
|
|
int countdown = 10;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_startTimer();
|
|
}
|
|
|
|
/// 启动倒计时
|
|
void _startTimer() {
|
|
// 计时器(`Timer`)组件的定期(`periodic`)构造函数,创建一个新的重复计时器。
|
|
_timer = Timer.periodic(Duration(seconds: 1), (timer) {
|
|
if (countdown == 0) {
|
|
_cancelTimer();
|
|
SmartDialog.dismiss(tag: "showInviteRoom");
|
|
return;
|
|
}
|
|
countdown--;
|
|
setState(() {});
|
|
});
|
|
}
|
|
|
|
/// 取消倒计时的计时器。
|
|
void _cancelTimer() {
|
|
// 计时器(`Timer`)组件的取消(`cancel`)方法,取消计时器。
|
|
_timer?.cancel();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_timer?.cancel();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
width: ScreenUtil().screenWidth * 0.8,
|
|
padding: EdgeInsets.all(15.w),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(12.w)),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
SizedBox(height: 3.w),
|
|
Row(
|
|
children: [
|
|
Spacer(),
|
|
text("$countdown", textColor: Colors.black87, fontSize: 14.sp),
|
|
SizedBox(width: 3.w),
|
|
GestureDetector(
|
|
child: Image.asset(
|
|
"atu_images/general/at_icon_clear_c.png",
|
|
width: 18.w,
|
|
),
|
|
onTap: () {
|
|
SmartDialog.dismiss(tag: "showInviteRoom");
|
|
},
|
|
),
|
|
],
|
|
),
|
|
netImage(
|
|
url: widget.msg.userAvatarUrl ?? "",
|
|
width: 80.w,
|
|
height: 80.w,
|
|
shape: BoxShape.circle,
|
|
),
|
|
SizedBox(height: 10.w),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: text(
|
|
ATAppLocalizations.of(context)!.inviteGoRoomTips,
|
|
textColor: Colors.black87,
|
|
fontSize: 15.sp,
|
|
maxLines: 5,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 10.w),
|
|
ATDebounceWidget(
|
|
child: Container(
|
|
height: 45.w,
|
|
margin: EdgeInsets.symmetric(horizontal: 35.w),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage("atu_images/room/at_icon_inv_go_btn.png"),
|
|
fit: BoxFit.fill,
|
|
),
|
|
),
|
|
child: text(
|
|
ATAppLocalizations.of(context)!.enterTheRoom,
|
|
textColor: Colors.white,
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
onTap: () {
|
|
SmartDialog.dismiss(tag: "showInviteRoom");
|
|
ATRoomUtils.goRoom(widget.msg.roomId ?? "", navigatorKey.currentState!.context);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _timer {}
|