284 lines
11 KiB
Dart
284 lines
11 KiB
Dart
import 'dart:ui' as ui;
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.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_ui/components/text/at_text.dart';
|
|
import 'package:aslan/chatvibe_ui/theme/chatvibe_theme.dart';
|
|
|
|
import 'package:aslan/chatvibe_ui/components/at_compontent.dart';
|
|
import 'package:aslan/chatvibe_ui/components/at_page_list.dart';
|
|
import 'package:aslan/chatvibe_core/constants/at_screen.dart';
|
|
import 'package:aslan/chatvibe_core/utilities/at_date_utils.dart';
|
|
import 'package:aslan/chatvibe_data/sources/repositories/family_repository_impl.dart';
|
|
import 'package:aslan/chatvibe_domain/models/res/at_family_news_list_res.dart';
|
|
|
|
class FamilyNewsPage extends ATPageList {
|
|
String familyId = "";
|
|
String familyAnnouncement = "";
|
|
|
|
@override
|
|
_FamilyNewsPageState createState() =>
|
|
_FamilyNewsPageState(familyId, familyAnnouncement);
|
|
|
|
FamilyNewsPage(this.familyId, this.familyAnnouncement);
|
|
}
|
|
|
|
class _FamilyNewsPageState extends ATPageListState<Records, FamilyNewsPage> {
|
|
String familyId = "";
|
|
String familyAnnouncement = "";
|
|
|
|
_FamilyNewsPageState(this.familyId, this.familyAnnouncement);
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
backgroundColor = Colors.transparent;
|
|
isShowFooter = false;
|
|
padding = EdgeInsets.symmetric(horizontal: 10.w);
|
|
loadData(1);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Stack(
|
|
children: [
|
|
Image.asset(
|
|
"atu_images/family/at_icon_family_head_bg.png",
|
|
fit: BoxFit.fitWidth,
|
|
),
|
|
Scaffold(
|
|
backgroundColor: Colors.transparent,
|
|
resizeToAvoidBottomInset: false,
|
|
appBar: ChatVibeStandardAppBar(
|
|
title: "",
|
|
actions: [],
|
|
backButtonColor: Colors.white,
|
|
),
|
|
body: SafeArea(
|
|
top: false,
|
|
child: Column(
|
|
children: [
|
|
SizedBox(height: 115.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: Container(
|
|
alignment: Alignment.center,
|
|
color: Colors.white10,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
SizedBox(height: 15.w),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
text(
|
|
ATAppLocalizations.of(context)!.familyNews,
|
|
fontSize: 15.sp,
|
|
fontWeight: FontWeight.w600,
|
|
textColor: Colors.white,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 20.w),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 10.w),
|
|
Container(
|
|
height: 22.w,
|
|
width: 4.w,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
Color(0xffC670FF),
|
|
Color(0xff7726FF),
|
|
],
|
|
),
|
|
borderRadius: BorderRadius.circular(2.w),
|
|
),
|
|
),
|
|
SizedBox(width: 10.w),
|
|
text(
|
|
"${ATAppLocalizations.of(context)!.familyAnnouncement}:",
|
|
textColor: Colors.white,
|
|
fontWeight: FontWeight.w600,
|
|
fontSize: 14.sp,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 10.w),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 15.w),
|
|
// 外部容器用于实现渐变边框
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(8.w),
|
|
// 渐变色边框
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
Color(0xffcecece), // 渐变色1
|
|
Color(0xff5b5b5b), // 渐变色2
|
|
Color(0xffcecece), // 渐变色3
|
|
],
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
),
|
|
),
|
|
// 内部留白(边框宽度)
|
|
padding: EdgeInsets.all(0.5.w), // 边框宽度
|
|
child: Stack(
|
|
alignment: AlignmentDirectional.bottomEnd,
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.only(
|
|
top: width(12),
|
|
left: width(12),
|
|
right: width(12),
|
|
bottom: width(12),
|
|
),
|
|
alignment: AlignmentDirectional.topStart,
|
|
height: 125.w,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(
|
|
7.5.w,
|
|
),
|
|
// 比外圆角小边框宽度
|
|
color: Colors.black87, // 背景色
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: text(
|
|
(familyAnnouncement ?? "").isEmpty
|
|
? ATAppLocalizations.of(
|
|
context,
|
|
)!.welcomeToMyFamily
|
|
: familyAnnouncement ?? "",
|
|
fontSize: 14.sp,
|
|
maxLines: 5,
|
|
textColor: Colors.white,
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 20.w),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 10.w),
|
|
Container(
|
|
height: 22.w,
|
|
width: 4.w,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
Color(0xffC670FF),
|
|
Color(0xff7726FF),
|
|
],
|
|
),
|
|
borderRadius: BorderRadius.circular(2.w),
|
|
),
|
|
),
|
|
SizedBox(width: 10.w),
|
|
text(
|
|
"${ATAppLocalizations.of(context)!.familyNotifcations}:",
|
|
textColor: Colors.white,
|
|
fontWeight: FontWeight.w600,
|
|
fontSize: 14.sp,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 20.w),
|
|
Expanded(child: buildList(context)),
|
|
SizedBox(height: 6.w),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget buildItem(Records res) {
|
|
return Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: text(
|
|
res.content ?? "",
|
|
fontSize: 14.sp,
|
|
fontWeight: FontWeight.w600,
|
|
textColor: Colors.white,
|
|
maxLines: 3,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
text(
|
|
ATMDateUtils.formatDateTime2(
|
|
DateTime.fromMillisecondsSinceEpoch(res.createTime ?? 0),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
@override
|
|
builderDivider() {
|
|
return Divider(height: 25.w, thickness: 0.2.w, color: ChatVibeTheme.dividerColor);
|
|
}
|
|
|
|
@override
|
|
empty() {
|
|
return mainEmpty(
|
|
textColor: Colors.white,
|
|
msg: ATAppLocalizations.of(context)!.noData,
|
|
image: Image.asset(
|
|
"atu_images/general/at_icon_loading.png",
|
|
width: 140.w,
|
|
height: 140.w,
|
|
),
|
|
);
|
|
}
|
|
|
|
///加载数据
|
|
@override
|
|
loadPage({
|
|
required int page,
|
|
required Function(List<Records>) onSuccess,
|
|
Function? onErr,
|
|
}) async {
|
|
try {
|
|
var result = await GroupRepository().familyNewsList(
|
|
familyId,
|
|
pageNo: page,
|
|
);
|
|
onSuccess(result.records ?? []);
|
|
} catch (e) {
|
|
if (onErr != null) {
|
|
onErr();
|
|
}
|
|
}
|
|
}
|
|
}
|