| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:easy_refresh/easy_refresh.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:keyboard/base/base_view.dart';
- import 'package:get/get.dart';
- import 'package:keyboard/module/character/content/character_group_content_controller.dart';
- import 'package:keyboard/resource/string.gen.dart';
- import '../../../data/bean/character_info.dart';
- import '../../../resource/assets.gen.dart';
- class CharacterGroupContentView
- extends BaseView<CharacterGroupContentController> {
- const CharacterGroupContentView({super.key});
- @override
- backgroundColor() => const Color(0xFFF4F2FB);
- @override
- Widget buildBody(BuildContext context) {
- return
- Column(
- children: [
- SizedBox(
- height: 8.w,
- ),
- Expanded(
- child: Obx(() {
- return EasyRefresh(
- controller: controller.refreshController,
- header: const ClassicHeader(),
- footer: ClassicFooter(
- showMessage: false,
- noMoreText: StringName.noMoreData,
- failedText: StringName.loadFailed,
- processedText: StringName.loadCompleted,
- processingText: StringName.loading,
- ),
- onRefresh: null,
- // onRefresh: controller.refreshData,
- onLoad: controller.loadMoreData,
- child: ListView.separated(
- padding: EdgeInsets.zero,
- itemCount: controller.characterList.length,
- itemBuilder: (context, index) {
- return _buildListItem(
- characterInfo: controller.characterList[index],
- );
- },
- separatorBuilder: (BuildContext context, int index) {
- return SizedBox(
- width: double.infinity,
- height: 10.h,
- child: Container(color: const Color(0xFFF4F2FB)),
- );
- },
- ),
- );
- }),
- ),
- ],
- );
- }
- Widget _buildListItem({required CharacterInfo characterInfo}) {
- return GestureDetector(
- onTap: () {
- controller.itemButtonClick(characterInfo);
- },
- child: Container(
- margin: EdgeInsets.symmetric(horizontal: 16.w),
- padding: EdgeInsets.all(14.r),
- decoration: ShapeDecoration(
- color: Colors.white,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(12.r),
- ),
- ),
- child: Row(
- children: [
- _buildAvatar(imageUrl: characterInfo.imageUrl),
- SizedBox(width: 8.w),
- _buildCharacterInfo(characterInfo),
- _buildActionButton(characterInfo),
- ],
- ),
- ),
- );
- }
- /// 角色头像
- Widget _buildAvatar({required String? imageUrl}) {
- return Container(
- width: 60.r,
- height: 60.r,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(8),
- gradient: LinearGradient(
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- colors: [Color(0xffebe6ff), Color(0xffffe6fe)],
- ),
- ),
- child: CachedNetworkImage(
- imageUrl: imageUrl ?? "",
- width: 60.r,
- height: 60.r,
- fit: BoxFit.cover,
- ),
- );
- }
- /// 构建角色信息,包括名称、VIP标识和描述
- Widget _buildCharacterInfo(CharacterInfo characterInfo) {
- return Expanded(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Text(
- characterInfo.name ?? "",
- style: TextStyle(
- color: Colors.black.withAlpha(204),
- fontSize: 15.sp,
- fontWeight: FontWeight.w500,
- ),
- ),
- SizedBox(width: 4.w),
- characterInfo.isVip == true
- ? Assets.images.iconCharacterVip.image(
- width: 38.w,
- height: 16.h,
- )
- : Container(),
- ],
- ),
- Text(
- characterInfo.description ?? "",
- softWrap: true,
- style: TextStyle(
- color: Colors.black.withAlpha(153),
- fontSize: 12.sp,
- fontWeight: FontWeight.w400,
- ),
- ),
- ],
- ),
- );
- }
- /// 按钮
- Widget _buildActionButton(CharacterInfo characterInfo) {
- return InkWell(
- onTap: () {
- controller.itemButtonClick(characterInfo);
- },
- child: Container(
- width: 72.w,
- height: 28.h,
- margin: EdgeInsets.only(left: 8.w),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(50.r),
- gradient:
- characterInfo.isAdd == true
- ? null
- : const LinearGradient(
- colors: [Color(0xFF7D46FC), Color(0xFFBC87FF)],
- begin: Alignment.topLeft,
- end: Alignment.bottomRight,
- ),
- color: characterInfo.isAdd == true ? const Color(0xFFEDE8FF) : null,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- if (characterInfo.isLock == true && characterInfo.isVip == true)
- Padding(
- padding: EdgeInsets.only(right: 2.w),
- child: Assets.images.iconCharacterLock.image(
- width: 18.r,
- height: 18.r,
- ), // 锁定图标
- ),
- Text(
- characterInfo.isLock == true && characterInfo.isVip == true
- ? StringName.characterUnlock
- : characterInfo.isAdd == true
- ? StringName.characterAdded
- : StringName.characterAdd,
- style: TextStyle(
- color:
- characterInfo.isAdd == true
- ? const Color(0xFF7D46FC)
- : Colors.white,
- fontSize: 14.sp,
- fontWeight: FontWeight.w500,
- ),
- ),
- ],
- ),
- ),
- );
- }
- }
|