647 lines
32 KiB
Dart
647 lines
32 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:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
import 'package:aslan/app_localizations.dart';
|
|
import 'package:aslan/chatvibe_ui/components/appbar/chatvibe_appbar.dart';
|
|
import 'package:aslan/chatvibe_ui/components/at_debounce_widget.dart';
|
|
import 'package:aslan/chatvibe_ui/components/at_compontent.dart';
|
|
import 'package:aslan/chatvibe_ui/components/text/at_text.dart';
|
|
import 'package:aslan/chatvibe_ui/components/at_tts.dart';
|
|
import 'package:aslan/chatvibe_core/routes/at_fluro_navigator.dart';
|
|
import 'package:aslan/chatvibe_core/utilities/at_loading_manager.dart';
|
|
import 'package:aslan/chatvibe_data/sources/local/user_manager.dart';
|
|
import 'package:aslan/chatvibe_managers/user_profile_manager.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:aslan/chatvibe_ui/components/dialog/dialog_base.dart';
|
|
import 'package:aslan/chatvibe_core/constants/at_screen.dart';
|
|
import 'package:aslan/chatvibe_core/routes/at_routes.dart';
|
|
import 'package:aslan/chatvibe_core/utilities/at_pick_utils.dart';
|
|
import 'package:aslan/chatvibe_data/sources/repositories/family_repository_impl.dart';
|
|
|
|
import '../../../chatvibe_domain/usecases/at_accurate_length_limiting_textInput_formatter.dart';
|
|
import '../../../chatvibe_domain/usecases/at_custom_filtering_textinput_formatter.dart';
|
|
import '../../../chatvibe_domain/usecases/at_custom_filtering_textinput_formatter2.dart';
|
|
|
|
class EditFamilyPage extends StatefulWidget {
|
|
String familyId = "";
|
|
|
|
EditFamilyPage(this.familyId);
|
|
|
|
@override
|
|
_EditFamilyPageState createState() => _EditFamilyPageState();
|
|
}
|
|
|
|
class _EditFamilyPageState extends State<EditFamilyPage> {
|
|
TextEditingController familyNameController = TextEditingController();
|
|
TextEditingController familyInfoController = TextEditingController();
|
|
TextEditingController familyAnnouncementController = TextEditingController();
|
|
final int _familyNameMaxLength = 24;
|
|
int _familyNameCurrentLength = 0;
|
|
String familyCover = "";
|
|
final int _familyInfoMaxLength = 80;
|
|
int _familyInfoCurrentLength = 0;
|
|
|
|
final int _familyAnnouncementMaxLength = 80;
|
|
int _familyAnnouncementCurrentLength = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
loadFamilyInfo();
|
|
familyNameController.addListener(() {
|
|
setState(() {
|
|
_familyNameCurrentLength = _getActualCharacterCount(
|
|
familyNameController.text,
|
|
);
|
|
});
|
|
});
|
|
familyInfoController.addListener(() {
|
|
setState(() {
|
|
_familyInfoCurrentLength = _getActualCharacterCount(
|
|
familyInfoController.text,
|
|
);
|
|
});
|
|
});
|
|
|
|
familyAnnouncementController.addListener(() {
|
|
setState(() {
|
|
_familyAnnouncementCurrentLength = _getActualCharacterCount(
|
|
familyAnnouncementController.text,
|
|
);
|
|
});
|
|
});
|
|
}
|
|
|
|
int _getActualCharacterCount(String text) {
|
|
return text.characters.length;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.transparent,
|
|
resizeToAvoidBottomInset: true,
|
|
body: SafeArea(
|
|
top: false,
|
|
child: LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
return SingleChildScrollView(
|
|
padding: EdgeInsets.only(
|
|
bottom: MediaQuery.of(context).viewInsets.bottom,
|
|
),
|
|
child: Stack(
|
|
children: [
|
|
Image.asset(
|
|
"atu_images/family/at_icon_family_head_bg.png",
|
|
fit: BoxFit.fitWidth,
|
|
),
|
|
PositionedDirectional(
|
|
top: 11.w,
|
|
child: ChatVibeStandardAppBar(
|
|
actions: [],
|
|
title: "",
|
|
backButtonColor: Colors.white,
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 212.w),
|
|
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(
|
|
children: [
|
|
SizedBox(height: 12.w),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Container(width: 48.w),
|
|
Spacer(),
|
|
text(
|
|
ATAppLocalizations.of(context)!.editFamily,
|
|
fontSize: 15.sp,
|
|
fontWeight: FontWeight.w600,
|
|
textColor: Colors.white,
|
|
),
|
|
Spacer(),
|
|
ATDebounceWidget(
|
|
child: Container(
|
|
padding: EdgeInsets.all(3.w),
|
|
margin: EdgeInsetsDirectional.only(
|
|
end: 10.w,
|
|
),
|
|
child: text(
|
|
ATAppLocalizations.of(context)!.save,
|
|
fontSize: 15.sp,
|
|
fontWeight: FontWeight.w600,
|
|
textColor: Colors.white,
|
|
),
|
|
),
|
|
onTap: () {
|
|
if (familyNameController.text.isEmpty) {
|
|
ATTts.show(
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.enterFamilyName,
|
|
);
|
|
return;
|
|
}
|
|
_submit();
|
|
},
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 20.w),
|
|
ATDebounceWidget(
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Image.asset(
|
|
"atu_images/family/at_icon_create_family_camer.png",
|
|
height: 85.w,
|
|
),
|
|
familyCover.isNotEmpty
|
|
? netImage(
|
|
url: familyCover,
|
|
fit: BoxFit.cover,
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(8.w),
|
|
),
|
|
width: 85.w,
|
|
height: 85.w,
|
|
)
|
|
: Container(),
|
|
],
|
|
),
|
|
onTap: () {
|
|
ATPickUtils.pickImageProcess(aspectRatio: 1, context, (
|
|
bool success,
|
|
String url,
|
|
) {
|
|
if (success) {
|
|
setState(() {
|
|
familyCover = url;
|
|
});
|
|
}
|
|
});
|
|
},
|
|
),
|
|
SizedBox(height: 10.w),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 10.w),
|
|
text(
|
|
"*",
|
|
textColor: Colors.red,
|
|
fontSize: 13.sp,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
text(
|
|
"${ATAppLocalizations.of(context)!.familyName}:",
|
|
textColor: Colors.white,
|
|
fontSize: 14.sp,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 8.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(1.w), // 边框宽度
|
|
child: Container(
|
|
padding: EdgeInsets.only(
|
|
left: width(12),
|
|
right: width(12),
|
|
),
|
|
alignment: AlignmentDirectional.centerStart,
|
|
height: 45.w,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(7.5.w),
|
|
// 比外圆角小边框宽度
|
|
color: Colors.black87, // 背景色
|
|
),
|
|
child: TextField(
|
|
controller: familyNameController,
|
|
onChanged: (text) {},
|
|
inputFormatters: [
|
|
ATCustomFilteringTextInputFormatter(),
|
|
ATAccurateLengthLimitingTextInputFormatter(
|
|
_familyNameMaxLength,
|
|
),
|
|
],
|
|
decoration: InputDecoration(
|
|
hintText:
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.enterFamilyName,
|
|
hintStyle: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 14.sp,
|
|
),
|
|
contentPadding: EdgeInsets.only(top: 0.w),
|
|
counterText: '',
|
|
isDense: true,
|
|
filled: false,
|
|
focusColor: Colors.transparent,
|
|
hoverColor: Colors.transparent,
|
|
border: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
focusedBorder: InputBorder.none,
|
|
disabledBorder: InputBorder.none,
|
|
errorBorder: InputBorder.none,
|
|
focusedErrorBorder: InputBorder.none,
|
|
suffix: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
SizedBox(width: 3.w),
|
|
text(
|
|
'$_familyNameCurrentLength/$_familyNameMaxLength',
|
|
textColor: Colors.white,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
style: TextStyle(
|
|
fontSize: sp(14),
|
|
color: Colors.white,
|
|
textBaseline: TextBaseline.alphabetic,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 10.w),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 10.w),
|
|
text(
|
|
"${ATAppLocalizations.of(context)!.familyInfo}:",
|
|
textColor: Colors.white,
|
|
fontSize: 14.sp,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 8.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(1.w), // 边框宽度
|
|
child: Stack(
|
|
alignment: AlignmentDirectional.bottomEnd,
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.only(
|
|
top: width(12),
|
|
left: width(12),
|
|
right: width(12),
|
|
),
|
|
alignment: AlignmentDirectional.topStart,
|
|
height: 115.w,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(
|
|
7.5.w,
|
|
),
|
|
// 比外圆角小边框宽度
|
|
color: Colors.black87, // 背景色
|
|
),
|
|
child: TextField(
|
|
controller: familyInfoController,
|
|
onChanged: (text) {},
|
|
inputFormatters: [
|
|
ATCustomFilteringTextInputFormatter2(),
|
|
ATAccurateLengthLimitingTextInputFormatter(
|
|
_familyInfoMaxLength,
|
|
),
|
|
],
|
|
maxLines: 5,
|
|
decoration: InputDecoration(
|
|
hintText:
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.enterFamilyInfo,
|
|
hintStyle: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 14.sp,
|
|
),
|
|
contentPadding: EdgeInsets.only(
|
|
top: 0.w,
|
|
),
|
|
counterText: '',
|
|
isDense: true,
|
|
filled: false,
|
|
focusColor: Colors.transparent,
|
|
hoverColor: Colors.transparent,
|
|
border: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
focusedBorder: InputBorder.none,
|
|
disabledBorder: InputBorder.none,
|
|
errorBorder: InputBorder.none,
|
|
focusedErrorBorder: InputBorder.none,
|
|
suffix: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [SizedBox(width: 3.w)],
|
|
),
|
|
),
|
|
style: TextStyle(
|
|
fontSize: sp(14),
|
|
color: Colors.white,
|
|
textBaseline: TextBaseline.alphabetic,
|
|
),
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
text(
|
|
'$_familyInfoCurrentLength/$_familyInfoMaxLength',
|
|
textColor: Colors.white,
|
|
),
|
|
SizedBox(width: 3.w),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 10.w),
|
|
Row(
|
|
children: [
|
|
SizedBox(width: 10.w),
|
|
text(
|
|
"${ATAppLocalizations.of(context)!.familyAnnouncement}:",
|
|
textColor: Colors.white,
|
|
fontSize: 14.sp,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 8.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(1.w), // 边框宽度
|
|
child: Stack(
|
|
alignment: AlignmentDirectional.bottomEnd,
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.only(
|
|
top: width(12),
|
|
left: width(12),
|
|
right: width(12),
|
|
),
|
|
alignment: AlignmentDirectional.topStart,
|
|
height: 115.w,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(
|
|
7.5.w,
|
|
),
|
|
// 比外圆角小边框宽度
|
|
color: Colors.black87, // 背景色
|
|
),
|
|
child: TextField(
|
|
controller:
|
|
familyAnnouncementController,
|
|
onChanged: (text) {},
|
|
inputFormatters: [
|
|
ATCustomFilteringTextInputFormatter2(),
|
|
ATAccurateLengthLimitingTextInputFormatter(
|
|
_familyAnnouncementMaxLength,
|
|
),
|
|
],
|
|
maxLines: 5,
|
|
decoration: InputDecoration(
|
|
isDense: true,
|
|
filled: false,
|
|
focusColor: Colors.transparent,
|
|
hoverColor: Colors.transparent,
|
|
border: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
focusedBorder: InputBorder.none,
|
|
disabledBorder: InputBorder.none,
|
|
errorBorder: InputBorder.none,
|
|
focusedErrorBorder: InputBorder.none,
|
|
hintText:
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.enterFamilyAnnouncement,
|
|
hintStyle: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 14.sp,
|
|
),
|
|
contentPadding: EdgeInsets.only(
|
|
top: 0.w,
|
|
),
|
|
counterText: '',
|
|
suffix: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [SizedBox(width: 3.w)],
|
|
),
|
|
),
|
|
style: TextStyle(
|
|
fontSize: sp(14),
|
|
color: Colors.white,
|
|
textBaseline: TextBaseline.alphabetic,
|
|
),
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
text(
|
|
'$_familyAnnouncementCurrentLength/$_familyAnnouncementMaxLength',
|
|
textColor: Colors.white,
|
|
),
|
|
SizedBox(width: 3.w),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 15.w),
|
|
ATDebounceWidget(
|
|
debounceTime: Duration(milliseconds: 800),
|
|
child: Container(
|
|
width: 240.w,
|
|
padding: EdgeInsets.symmetric(vertical: 12.w),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(60.w),
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
Color(0xff540001),
|
|
Color(0xffB70508),
|
|
],
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
text(
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.disbandTheFamily,
|
|
fontSize: 15.sp,
|
|
fontWeight: FontWeight.w600,
|
|
textColor: Colors.white,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
onTap: () {
|
|
SmartDialog.show(
|
|
tag: "showConfirmDialog",
|
|
alignment: Alignment.center,
|
|
animationType: SmartAnimationType.fade,
|
|
builder: (_) {
|
|
return MsgDialog(
|
|
title:
|
|
ATAppLocalizations.of(context)!.tips,
|
|
msg:
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.disbandTheFamilyTips,
|
|
btnText:
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.confirm,
|
|
isDark: true,
|
|
onEnsure: () {
|
|
ATLoadingManager.exhibitOperation();
|
|
GroupRepository()
|
|
.familyDisband()
|
|
.then((res) {
|
|
ATLoadingManager.veilRoutine();
|
|
ATTts.show(
|
|
ATAppLocalizations.of(
|
|
context,
|
|
)!.operationSuccessful,
|
|
);
|
|
Provider.of<ChatVibeUserProfileManager>(
|
|
context,
|
|
listen: false,
|
|
).updateFamily(null);
|
|
ATNavigatorUtils.popUntil(
|
|
context,
|
|
ModalRoute.withName(
|
|
ATRoutes.home,
|
|
),
|
|
);
|
|
})
|
|
.catchError((_) {
|
|
ATLoadingManager.veilRoutine();
|
|
});
|
|
},
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
SizedBox(height: 25.w),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void _submit() {
|
|
if (familyCover.isEmpty) {
|
|
familyCover =
|
|
AccountStorage().getCurrentUser()?.userProfile?.userAvatar ?? "";
|
|
}
|
|
ATLoadingManager.exhibitOperation();
|
|
GroupRepository()
|
|
.familyEdit(
|
|
familyCover,
|
|
familyNameController.text,
|
|
familyInfoController.text,
|
|
familyAnnouncementController.text,
|
|
)
|
|
.then((result) {
|
|
ATTts.show(ATAppLocalizations.of(context)!.operationSuccessful);
|
|
ATLoadingManager.veilRoutine();
|
|
ATNavigatorUtils.goBack(context);
|
|
})
|
|
.catchError((_) {
|
|
ATLoadingManager.veilRoutine();
|
|
ATNavigatorUtils.goBack(context);
|
|
});
|
|
}
|
|
|
|
void loadFamilyInfo() {
|
|
ATLoadingManager.exhibitOperation();
|
|
GroupRepository()
|
|
.familyBaseInfo(familyId: widget.familyId)
|
|
.then((result) {
|
|
familyCover = result.familyAvatar ?? "";
|
|
familyNameController.text = result.familyName ?? "";
|
|
familyInfoController.text = result.familyIntro ?? "";
|
|
familyAnnouncementController.text = result.familyNotice ?? "";
|
|
setState(() {});
|
|
ATLoadingManager.veilRoutine();
|
|
})
|
|
.catchError((_) {
|
|
ATLoadingManager.veilRoutine();
|
|
});
|
|
}
|
|
}
|