278 lines
11 KiB
Dart
278 lines
11 KiB
Dart
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/chatvibe_ui/components/at_debounce_widget.dart';
|
|
import 'package:aslan/chatvibe_ui/components/at_compontent.dart';
|
|
import 'package:marquee/marquee.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:aslan/chatvibe_ui/components/text/at_text.dart';
|
|
import 'package:aslan/chatvibe_core/utilities/at_path_utils.dart';
|
|
import 'package:aslan/chatvibe_domain/models/res/login_res.dart';
|
|
import 'package:aslan/app_localizations.dart';
|
|
import 'package:aslan/chatvibe_data/sources/local/user_manager.dart';
|
|
import 'package:aslan/chatvibe_managers/user_profile_manager.dart';
|
|
import 'package:aslan/chatvibe_ui/widgets/headdress/headdress_widget.dart';
|
|
|
|
///荣耀墙
|
|
class HonorPage extends StatefulWidget {
|
|
String tageId = "";
|
|
|
|
HonorPage(this.tageId);
|
|
|
|
@override
|
|
_HonorPageState createState() => _HonorPageState();
|
|
}
|
|
|
|
class _HonorPageState extends State<HonorPage> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Consumer<ChatVibeUserProfileManager>(
|
|
builder: (context, ref, child) {
|
|
if (widget.tageId == AccountStorage().getCurrentUser()?.userProfile?.id) {
|
|
return (AccountStorage()
|
|
.getCurrentUser()
|
|
?.userProfile
|
|
?.wearHonor
|
|
?.isNotEmpty ??
|
|
false)
|
|
? Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: SingleChildScrollView(
|
|
child: GridView.builder(
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 4, // 每行2个
|
|
childAspectRatio: 1, // 宽高比
|
|
mainAxisSpacing: 5,
|
|
crossAxisSpacing: 5,
|
|
),
|
|
padding: EdgeInsets.all(10),
|
|
itemCount:
|
|
AccountStorage()
|
|
.getCurrentUser()
|
|
?.userProfile
|
|
?.wearHonor
|
|
?.length ??
|
|
0,
|
|
itemBuilder: (context, index) {
|
|
return _buildItem(
|
|
AccountStorage()
|
|
.getCurrentUser()!
|
|
.userProfile!
|
|
.wearHonor![index],
|
|
);
|
|
},
|
|
),
|
|
),
|
|
)
|
|
: mainEmpty(
|
|
msg: ATAppLocalizations.of(context)!.noData,
|
|
textColor: Colors.white,
|
|
);
|
|
} else {
|
|
return (ref.userProfile?.wearHonor?.isNotEmpty ?? false)
|
|
? Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: SingleChildScrollView(
|
|
child: GridView.builder(
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 4, // 每行2个
|
|
childAspectRatio: 1, // 宽高比
|
|
mainAxisSpacing: 5,
|
|
crossAxisSpacing: 5,
|
|
),
|
|
padding: EdgeInsets.all(10),
|
|
itemCount: ref.userProfile?.wearHonor?.length,
|
|
itemBuilder: (context, index) {
|
|
return _buildItem(ref.userProfile!.wearHonor![index]);
|
|
},
|
|
),
|
|
),
|
|
)
|
|
: mainEmpty(
|
|
msg: ATAppLocalizations.of(context)!.noData,
|
|
textColor: Colors.white,
|
|
);
|
|
}
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _buildItem(WearBadge wearBadge) {
|
|
return ATDebounceWidget(
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage(getBadgeLevelLabBG(wearBadge.badgeLevel ?? 1)),
|
|
fit: BoxFit.fill,
|
|
),
|
|
),
|
|
alignment: Alignment.topCenter,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
SizedBox(height: 25.w),
|
|
Container(
|
|
margin: EdgeInsetsDirectional.only(start: 12.w, end: 5.w),
|
|
child: netImage(
|
|
url: wearBadge.selectUrl ?? "",
|
|
height: 35.w,
|
|
fit: BoxFit.contain,
|
|
),
|
|
),
|
|
SizedBox(height: 7.w),
|
|
Container(
|
|
margin: EdgeInsetsDirectional.only(start: 8.w),
|
|
constraints: BoxConstraints(maxWidth: 70.w, maxHeight: 16.w),
|
|
child:
|
|
(wearBadge.badgeName?.length ?? 0) > 8
|
|
? Marquee(
|
|
text: wearBadge.badgeName ?? "",
|
|
style: TextStyle(
|
|
fontSize: 10.sp,
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
decoration: TextDecoration.none,
|
|
),
|
|
scrollAxis: Axis.horizontal,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
blankSpace: 40.0,
|
|
velocity: 40.0,
|
|
pauseAfterRound: Duration(seconds: 1),
|
|
accelerationDuration: Duration(seconds: 1),
|
|
accelerationCurve: Curves.easeOut,
|
|
decelerationDuration: Duration(milliseconds: 550),
|
|
decelerationCurve: Curves.easeOut,
|
|
)
|
|
: Text(
|
|
wearBadge.badgeName ?? "",
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(
|
|
fontSize: 10.sp,
|
|
color: Colors.white,
|
|
decoration: TextDecoration.none,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
onTap: () {
|
|
SmartDialog.show(
|
|
tag: "showPropsDetail",
|
|
alignment: Alignment.center,
|
|
animationType: SmartAnimationType.fade,
|
|
builder: (_) {
|
|
return Stack(
|
|
children: [
|
|
Container(
|
|
width: 220.w,
|
|
height: 150.w,
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage(
|
|
"atu_images/index/at_icon_honor_detail_bg.png",
|
|
),
|
|
fit: BoxFit.fill,
|
|
),
|
|
),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 10.w),
|
|
Expanded(
|
|
child:
|
|
wearBadge.animationUrl != null &&
|
|
ATPathUtils.fileTypeIsPicOperation(
|
|
wearBadge.animationUrl ?? "",
|
|
)
|
|
? netImage(
|
|
url: wearBadge.animationUrl ?? "",
|
|
height: 35.w,
|
|
fit: BoxFit.contain,
|
|
)
|
|
: (ATPathUtils.fetchFileExtensionFunction(
|
|
wearBadge.animationUrl ?? "",
|
|
).toLowerCase() ==
|
|
".svga"
|
|
? SVGAHeadwearWidget(
|
|
height: 35.w,
|
|
resource:
|
|
wearBadge.animationUrl ?? "",
|
|
)
|
|
: netImage(
|
|
url: wearBadge.animationUrl ?? "",
|
|
height: 35.w,
|
|
fit: BoxFit.contain,
|
|
)),
|
|
),
|
|
SizedBox(width: 10.w),
|
|
],
|
|
),
|
|
SizedBox(height: 15.w),
|
|
Container(
|
|
margin: EdgeInsetsDirectional.symmetric(
|
|
horizontal: 8.w,
|
|
),
|
|
alignment: AlignmentDirectional.center,
|
|
child: text(
|
|
textAlign: TextAlign.center,
|
|
maxLines: 2,
|
|
wearBadge.badgeName ?? "",
|
|
fontSize: 14.sp,
|
|
fontWeight: FontWeight.bold,
|
|
textColor: CupertinoColors.white,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Positioned(
|
|
right: 15.w,
|
|
top: 10.w,
|
|
child: GestureDetector(
|
|
child: Icon(
|
|
Icons.close,
|
|
size: 20.w,
|
|
color: Color(0xFFF8E090),
|
|
),
|
|
onTap: () {
|
|
SmartDialog.dismiss(tag: "showPropsDetail");
|
|
},
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
String getBadgeLevelLabBG(num badgeLevel) {
|
|
if (badgeLevel == 1) {
|
|
return "atu_images/person/at_icon_honor_item_c_bg.png";
|
|
} else if (badgeLevel == 2) {
|
|
return "atu_images/person/at_icon_honor_item_b_bg.png";
|
|
} else if (badgeLevel == 3) {
|
|
return "atu_images/person/at_icon_honor_item_a_bg.png";
|
|
} else if (badgeLevel == 4) {
|
|
return "atu_images/person/at_icon_honor_item_s_bg.png";
|
|
}
|
|
return "atu_images/person/at_icon_honor_item_c_bg.png";
|
|
}
|
|
}
|