396 lines
15 KiB
Dart
396 lines
15 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
import 'package:aslan/chatvibe_core/utilities/at_loading_manager.dart';
|
|
import 'package:aslan/chatvibe_data/sources/repositories/user_repository_impl.dart';
|
|
|
|
import 'package:aslan/app_localizations.dart';
|
|
import 'package:aslan/chatvibe_ui/components/appbar/chatvibe_appbar.dart';
|
|
import 'package:aslan/chatvibe_ui/components/at_compontent.dart';
|
|
import 'package:aslan/chatvibe_ui/components/chatvibe_gradient_button.dart';
|
|
import 'package:aslan/chatvibe_ui/components/text/at_text.dart';
|
|
import 'package:aslan/chatvibe_ui/components/at_tts.dart';
|
|
import 'package:aslan/chatvibe_ui/theme/chatvibe_theme.dart';
|
|
import 'package:aslan/chatvibe_core/constants/at_screen.dart';
|
|
import 'package:aslan/chatvibe_core/routes/at_fluro_navigator.dart';
|
|
import 'package:aslan/chatvibe_data/sources/local/user_manager.dart';
|
|
import 'package:aslan/chatvibe_domain/models/res/login_res.dart';
|
|
import 'package:aslan/chatvibe_domain/models/res/at_prop_coupon_list_res.dart';
|
|
import 'package:aslan/chatvibe_features/index/main_route.dart';
|
|
|
|
class CouponSendPage extends StatefulWidget {
|
|
Records? sendCoupon;
|
|
|
|
CouponSendPage({super.key, this.sendCoupon});
|
|
|
|
@override
|
|
_CouponSendPageState createState() => _CouponSendPageState();
|
|
}
|
|
|
|
class _CouponSendPageState extends State<CouponSendPage>
|
|
with SingleTickerProviderStateMixin {
|
|
final TextEditingController _textEditingController = TextEditingController();
|
|
List<ChatVibeUserProfile> users = [];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Stack(
|
|
children: [
|
|
Image.asset(
|
|
"atu_images/index/at_icon_coupon_head_bg.png",
|
|
width: ScreenUtil().screenWidth,
|
|
height: 150.w,
|
|
fit: BoxFit.fill,
|
|
),
|
|
Scaffold(
|
|
backgroundColor: Colors.transparent,
|
|
resizeToAvoidBottomInset: false,
|
|
appBar: ChatVibeStandardAppBar(
|
|
title: ATAppLocalizations.of(context)!.sendUser,
|
|
actions: [],
|
|
),
|
|
body: SafeArea(
|
|
top: false,
|
|
child: Container(
|
|
margin: EdgeInsetsDirectional.only(top: 15.w),
|
|
width: ScreenUtil().screenWidth,
|
|
height: ScreenUtil().screenHeight,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadiusDirectional.only(
|
|
topStart: Radius.circular(35.w),
|
|
),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
SizedBox(height: 10.w),
|
|
Row(
|
|
children: <Widget>[
|
|
SizedBox(width: 10.w),
|
|
Expanded(
|
|
child: searchWidget(
|
|
hint: ATAppLocalizations.of(context)!.searchUserId,
|
|
controller: _textEditingController,
|
|
borderColor: Colors.black12,
|
|
textColor: Colors.grey,
|
|
),
|
|
),
|
|
chatvibeGradientButton(
|
|
text: ATAppLocalizations.of(context)!.search,
|
|
radius: 25,
|
|
textSize: 14.sp,
|
|
textColor: Colors.black,
|
|
gradient: LinearGradient(
|
|
colors: [Colors.transparent, Colors.transparent],
|
|
begin: Alignment.centerLeft,
|
|
end: Alignment.centerRight,
|
|
),
|
|
onPress: () {
|
|
if (_textEditingController.text.isNotEmpty) {
|
|
_searchUser();
|
|
}
|
|
},
|
|
),
|
|
SizedBox(width: 10.w),
|
|
],
|
|
),
|
|
users.isNotEmpty
|
|
? Expanded(
|
|
child: ListView.separated(
|
|
itemBuilder: (context, i) => buildItem(users[i]),
|
|
itemCount: users.length,
|
|
padding: EdgeInsets.zero,
|
|
separatorBuilder:
|
|
(context, i) => Divider(
|
|
height: height(1),
|
|
color: ChatVibeTheme.dividerColor,
|
|
indent: width(28), //25+50+10
|
|
endIndent: width(15),
|
|
),
|
|
),
|
|
)
|
|
: mainEmpty(),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget buildItem(ChatVibeUserProfile data) {
|
|
return Container(
|
|
padding: EdgeInsets.symmetric(vertical: 5.w),
|
|
margin: EdgeInsets.symmetric(horizontal: 25.w),
|
|
child: Row(
|
|
children: [
|
|
GestureDetector(
|
|
onTap: () {
|
|
ATNavigatorUtils.push(
|
|
context,
|
|
"${MainRoute.person}?isMe=${AccountStorage().getCurrentUser()?.userProfile?.id == data.id}&tageId=${data.id}",
|
|
);
|
|
},
|
|
behavior: HitTestBehavior.opaque,
|
|
child: head(url: data.userAvatar ?? "", width: 55.w),
|
|
),
|
|
SizedBox(width: 2.w),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: <Widget>[
|
|
xb(
|
|
data.userSex,
|
|
color:
|
|
data.userSex == 1 ? Colors.blue : Colors.purpleAccent,
|
|
),
|
|
SizedBox(width: 5.w),
|
|
// richText(
|
|
// txt: data.userNickname ?? "",
|
|
// key: (widget as SearchUserList).text,
|
|
// highlight: ChatVibeTheme.primaryColor,
|
|
// defaultColor: Colors.black,
|
|
// ),
|
|
Expanded(
|
|
child: text(
|
|
data.userNickname ?? "",
|
|
fontSize: 15.sp,
|
|
textColor: Colors.black,
|
|
),
|
|
),
|
|
SizedBox(width: 5.w),
|
|
// dj(data.level.toString()),
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
GestureDetector(
|
|
child: Container(
|
|
padding: EdgeInsets.symmetric(vertical: 8.w),
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage(
|
|
(data.hasSpecialId() ?? false)
|
|
? "atu_images/general/at_icon_special_id_bg.png"
|
|
: "atu_images/general/at_icon_id_bg.png",
|
|
),
|
|
fit: BoxFit.fitWidth,
|
|
),
|
|
),
|
|
child: Row(
|
|
textDirection: TextDirection.ltr,
|
|
children: [
|
|
SizedBox(width: 38.w),
|
|
text(
|
|
data.getID(),
|
|
fontSize: 12.sp,
|
|
textColor: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
SizedBox(width: 5.w),
|
|
Image.asset(
|
|
"atu_images/room/at_icon_user_card_copy_id.png",
|
|
width: 12.w,
|
|
height: 12.w,
|
|
),
|
|
SizedBox(width: 8.w),
|
|
],
|
|
),
|
|
),
|
|
onTap: () {
|
|
Clipboard.setData(ClipboardData(text: data.getID()));
|
|
ATTts.show(
|
|
ATAppLocalizations.of(context)!.copiedToClipboard,
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
GestureDetector(
|
|
child: Container(
|
|
alignment: AlignmentDirectional.center,
|
|
width: 55.w,
|
|
height: 25.w,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(22.w)),
|
|
border: Border.all(color: Colors.black12, width: 1.w),
|
|
),
|
|
child: text(
|
|
ATAppLocalizations.of(context)!.send,
|
|
fontSize: 12.sp,
|
|
fontWeight: FontWeight.w600,
|
|
textColor: Colors.black38,
|
|
),
|
|
),
|
|
onTap: () {
|
|
_showSendConfirm(data.id ?? "");
|
|
},
|
|
),
|
|
SizedBox(width: 5.w),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
void _searchUser() async {
|
|
try {
|
|
ATLoadingManager.exhibitOperation();
|
|
users.clear();
|
|
var result = await AccountRepository().searchUser(
|
|
_textEditingController.text,
|
|
);
|
|
users.add(result);
|
|
ATLoadingManager.veilRoutine();
|
|
setState(() {});
|
|
} catch (e) {
|
|
ATLoadingManager.veilRoutine();
|
|
}
|
|
}
|
|
|
|
void _showSendConfirm(String userId) {
|
|
SmartDialog.show(
|
|
tag: "showSendConfirm",
|
|
alignment: Alignment.center,
|
|
animationType: SmartAnimationType.fade,
|
|
builder: (_) {
|
|
return Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 25.w),
|
|
padding: EdgeInsets.symmetric(horizontal: 15.w, vertical: 15.w),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(15.w),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
SizedBox(height: 8.w),
|
|
text(
|
|
ATAppLocalizations.of(context)!.tips,
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.bold,
|
|
textColor: Colors.black,
|
|
),
|
|
SizedBox(height: 10.w),
|
|
netImage(
|
|
url: widget.sendCoupon?.propIcon ?? "",
|
|
width: 78.w,
|
|
height: 78.w,
|
|
),
|
|
SizedBox(height: 15.w),
|
|
text(
|
|
"${widget.sendCoupon?.propName}*${widget.sendCoupon?.propDays}${ATAppLocalizations.of(context)!.days}",
|
|
fontSize: 15.sp,
|
|
fontWeight: FontWeight.w600,
|
|
textColor: Colors.black,
|
|
),
|
|
SizedBox(height: 10.w),
|
|
text(
|
|
maxLines: 3,
|
|
ATAppLocalizations.of(context)!.sendCoupontips,
|
|
fontSize: 15.sp,
|
|
fontWeight: FontWeight.w600,
|
|
textColor: Colors.black54,
|
|
),
|
|
SizedBox(height: 15.w),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 15.w),
|
|
height: height(43),
|
|
alignment: Alignment.center,
|
|
child: Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: GestureDetector(
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
color: Colors.white,
|
|
border: Border.all(
|
|
color: Color(0xffE6E6E6),
|
|
width: 1.w,
|
|
),
|
|
),
|
|
alignment: Alignment.center,
|
|
child: text(
|
|
ATAppLocalizations.of(context)!.cancel,
|
|
fontSize: 14.sp,
|
|
textColor: Colors.black54,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
onTap: () {
|
|
SmartDialog.dismiss(tag: "showSendConfirm");
|
|
},
|
|
),
|
|
),
|
|
SizedBox(width: 15.w),
|
|
Expanded(
|
|
child: GestureDetector(
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Color(0xffC670FF).withOpacity(0.6),
|
|
Color(0xff7726FF).withOpacity(0.6),
|
|
],
|
|
),
|
|
),
|
|
alignment: Alignment.center,
|
|
child: text(
|
|
ATAppLocalizations.of(context)!.confirm,
|
|
fontSize: 14.sp,
|
|
textColor: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
onTap: () {
|
|
ATLoadingManager.exhibitOperation();
|
|
AccountRepository()
|
|
.couponSend(
|
|
widget.sendCoupon?.couponNo ?? "",
|
|
userId,
|
|
)
|
|
.then((result) {
|
|
ATLoadingManager.veilRoutine();
|
|
ATTts.show(
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.operationSuccessful,
|
|
);
|
|
SmartDialog.dismiss(tag: "showSendConfirm");
|
|
})
|
|
.catchError((e) {
|
|
ATLoadingManager.veilRoutine();
|
|
SmartDialog.dismiss(tag: "showSendConfirm");
|
|
});
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 15.w),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|