363 lines
16 KiB
Dart
363 lines
16 KiB
Dart
import 'dart:ui' as ui;
|
|
|
|
import 'package:carousel_slider/carousel_slider.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_ninepatch_image/flutter_ninepatch_image.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:aslan/app_localizations.dart';
|
|
import 'package:aslan/chatvibe_ui/components/appbar/chatvibe_appbar.dart';
|
|
import 'package:aslan/chatvibe_data/sources/repositories/family_repository_impl.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_domain/models/res/at_family_level_res.dart';
|
|
|
|
class FamilyLevelPage extends StatefulWidget {
|
|
String curentLevel = "0";
|
|
String curentLevelExp = "0";
|
|
|
|
FamilyLevelPage(this.curentLevel, this.curentLevelExp);
|
|
|
|
@override
|
|
_FamilyLevelPageState createState() => _FamilyLevelPageState();
|
|
}
|
|
|
|
class _FamilyLevelPageState extends State<FamilyLevelPage> {
|
|
List<ATFamilyLevelRes> levelList = [];
|
|
ATFamilyLevelRes? currentFamily;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_loadData();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Stack(
|
|
children: [
|
|
Image.asset(
|
|
"atu_images/family/at_icon_family_level_head_bg.png",
|
|
fit: BoxFit.fitWidth,
|
|
),
|
|
Scaffold(
|
|
backgroundColor: Colors.transparent,
|
|
resizeToAvoidBottomInset: false,
|
|
appBar: ChatVibeStandardAppBar(
|
|
title: ATAppLocalizations.of(context)!.familyLevel,
|
|
actions: [],
|
|
backButtonColor: Colors.white,
|
|
),
|
|
body: SafeArea(
|
|
top: false,
|
|
child: Column(
|
|
children: [
|
|
_buildLevelHead(),
|
|
SizedBox(height: 32.w),
|
|
Expanded(
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.only(
|
|
topLeft: Radius.circular(12.w),
|
|
topRight: Radius.circular(12.w),
|
|
),
|
|
child: BackdropFilter(
|
|
filter: ui.ImageFilter.blur(sigmaX: 18, sigmaY: 18),
|
|
child:
|
|
currentFamily != null
|
|
? Container(
|
|
alignment: Alignment.center,
|
|
color: Colors.white10,
|
|
child: Column(
|
|
children: [
|
|
SizedBox(height: 10.w),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(
|
|
horizontal: 10.w,
|
|
),
|
|
width: ScreenUtil().screenWidth,
|
|
height: 105.w,
|
|
child: NinePatchImage(
|
|
imageProvider: AssetImage(
|
|
"atu_images/family/at_icon_family_info_item_bg_${getLevel()}.9.png",
|
|
),
|
|
sliceCachedKey:
|
|
'atu_images/family/at_icon_family_info_item_bg_${getLevel()}.9.png',
|
|
child: Row(
|
|
children: [
|
|
SizedBox(width: 10.w),
|
|
Column(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: [
|
|
SizedBox(height: 10.w),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 3.w),
|
|
text(
|
|
"Lv. ${currentFamily?.level}",
|
|
fontWeight:
|
|
FontWeight.w600,
|
|
fontSize: 15.sp,
|
|
textColor: Colors.white,
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
Image.asset(
|
|
"atu_images/family/at_icon_family_level_exp_tag.png",
|
|
height: 24.w,
|
|
width: 24.w,
|
|
),
|
|
SizedBox(width: 3.w),
|
|
text(
|
|
"${widget
|
|
.curentLevelExp}/${currentFamily
|
|
?.levelExp ?? 0}",
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 8.w),
|
|
Stack(
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white10,
|
|
borderRadius:
|
|
BorderRadius.circular(
|
|
8.w,
|
|
),
|
|
),
|
|
height: 9.w,
|
|
width:
|
|
ScreenUtil()
|
|
.screenWidth *
|
|
0.65,
|
|
),
|
|
widget.curentLevel ==
|
|
currentFamily?.level ?
|
|
Container(
|
|
height: 9.w,
|
|
width: ATRoomUtils
|
|
.collectCurrenProgressProcess(
|
|
int.parse(
|
|
widget.curentLevelExp,
|
|
),
|
|
currentFamily
|
|
?.levelExp ??
|
|
1,
|
|
ScreenUtil()
|
|
.screenWidth *
|
|
0.65,
|
|
),
|
|
decoration: BoxDecoration(
|
|
gradient:
|
|
buildFamilyProgressLinearGradient(
|
|
getLevel(),
|
|
),
|
|
borderRadius:
|
|
BorderRadius.circular(
|
|
8.w,
|
|
),
|
|
),
|
|
):Container(),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
SizedBox(width: 8.w),
|
|
Image.asset(
|
|
"atu_images/family/at_icon_family_level_${currentFamily
|
|
?.level ?? 0}.png",
|
|
height: 75.w,
|
|
),
|
|
SizedBox(width: 10.w),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 15.w),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 13.w),
|
|
text(
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.levelPrivileges,
|
|
fontSize: 15.sp,
|
|
textColor: Colors.white,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsetsDirectional.only(
|
|
start: 15.w,
|
|
top: 15.w,
|
|
bottom: 15.w,
|
|
),
|
|
height: 95.w,
|
|
child: NinePatchImage(
|
|
imageProvider: AssetImage(
|
|
"atu_images/family/at_icon_family_info_item_bg_${getLevel()}.9.png",
|
|
),
|
|
sliceCachedKey:
|
|
'atu_images/family/at_icon_family_info_item_bg_${getLevel()}.9.png',
|
|
child: Padding(
|
|
padding: EdgeInsets.all(15.w),
|
|
child: Column(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: [
|
|
Image.asset(
|
|
"atu_images/family/at_icon_family_role_admin.png",
|
|
height: 32.w,
|
|
),
|
|
SizedBox(height: 6.w),
|
|
text(
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.upToAdmins(
|
|
"${currentFamily?.maxManager ??
|
|
0}",
|
|
),
|
|
fontWeight:
|
|
FontWeight.w600,
|
|
textColor: Colors.white,
|
|
fontSize: 14.sp,
|
|
letterSpacing: 0.1,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(width: 5.w),
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsetsDirectional.only(
|
|
end: 15.w,
|
|
top: 15.w,
|
|
bottom: 15.w,
|
|
),
|
|
height: 95.w,
|
|
child: NinePatchImage(
|
|
imageProvider: AssetImage(
|
|
"atu_images/family/at_icon_family_info_item_bg_${getLevel()}.9.png",
|
|
),
|
|
sliceCachedKey:
|
|
'atu_images/family/at_icon_family_info_item_bg_${getLevel()}.9.png',
|
|
child: Padding(
|
|
padding: EdgeInsets.all(15.w),
|
|
child: Column(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: [
|
|
Image.asset(
|
|
"atu_images/family/at_icon_family_member_tag.png",
|
|
height: 32.w,
|
|
),
|
|
SizedBox(height: 6.w),
|
|
text(
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.upToMembers(
|
|
"${currentFamily?.maxMember ??
|
|
0}",
|
|
),
|
|
letterSpacing: 0.1,
|
|
fontWeight:
|
|
FontWeight.w600,
|
|
textColor: Colors.white,
|
|
maxLines: 2,
|
|
fontSize: 14.sp,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
)
|
|
: Container(),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
int getLevel() {
|
|
int level = 0;
|
|
if (int.parse(currentFamily?.level ?? "0") > 0 &&
|
|
int.parse(currentFamily?.level ?? "0") < 4) {
|
|
level = 1;
|
|
} else if (int.parse(currentFamily?.level ?? "0") > 3 &&
|
|
int.parse(currentFamily?.level ?? "0") < 7) {
|
|
level = 2;
|
|
} else if (int.parse(currentFamily?.level ?? "0") > 6 &&
|
|
int.parse(currentFamily?.level ?? "0") < 10) {
|
|
level = 3;
|
|
} else {
|
|
level = int.parse(currentFamily?.level ?? "0");
|
|
}
|
|
return level;
|
|
}
|
|
|
|
_buildLevelHead() {
|
|
return levelList.isNotEmpty
|
|
? CarouselSlider(
|
|
options: CarouselOptions(
|
|
height: 120.w,
|
|
autoPlay: false,
|
|
initialPage: int.parse(widget.curentLevel),
|
|
enlargeCenterPage: true,
|
|
viewportFraction: 0.40,
|
|
enlargeFactor: 0.40,
|
|
enableInfiniteScroll: false,
|
|
autoPlayAnimationDuration: Duration(milliseconds: 800),
|
|
// 视口分数
|
|
onPageChanged: (index, reason) {
|
|
currentFamily = levelList[index];
|
|
setState(() {});
|
|
},
|
|
),
|
|
items:
|
|
levelList.map((item) {
|
|
return GestureDetector(
|
|
child: Image.asset(
|
|
"atu_images/family/at_icon_family_level_${item.sort ?? 0}.png",
|
|
),
|
|
onTap: () {},
|
|
);
|
|
}).toList(),
|
|
)
|
|
: Container(height: 120.w);
|
|
}
|
|
|
|
void _loadData() {
|
|
GroupRepository()
|
|
.familyLevelConfig()
|
|
.then((res) {
|
|
levelList = res;
|
|
currentFamily = levelList[int.parse(widget.curentLevel)];
|
|
setState(() {});
|
|
})
|
|
.catchError(((e) {}));
|
|
}
|
|
}
|