|
@@ -1,9 +1,13 @@
|
|
|
import 'package:cpt_community/router/page/community_page_router.dart';
|
|
|
+import 'package:cs_resources/generated/l10n.dart';
|
|
|
import 'package:cs_resources/theme/app_colors_theme.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:auto_route/auto_route.dart';
|
|
|
+import 'package:flutter_hooks/flutter_hooks.dart';
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
+import 'package:plugin_platform/engine/image/image_nine_grid.dart';
|
|
|
import 'package:router/ext/auto_router_extensions.dart';
|
|
|
+import 'package:shared/utils/color_utils.dart';
|
|
|
import 'package:widgets/ext/ex_widget.dart';
|
|
|
import 'package:widgets/my_appbar.dart';
|
|
|
import 'package:widgets/my_text_field.dart';
|
|
@@ -27,8 +31,7 @@ class NewsfeedPostPage extends HookConsumerWidget {
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
- // final viewModel = ref.watch(newsfeedPostVmProvider.notifier);
|
|
|
- final state = ref.watch(newsfeedPostVmProvider);
|
|
|
+ final vm = ref.read(newsfeedPostVmProvider.notifier);
|
|
|
|
|
|
return Scaffold(
|
|
|
appBar: MyAppBar.appBar(
|
|
@@ -36,79 +39,233 @@ class NewsfeedPostPage extends HookConsumerWidget {
|
|
|
"Create Post",
|
|
|
backgroundColor: context.appColors.whiteBG,
|
|
|
),
|
|
|
- backgroundColor: context.appColors.backgroundDefault,
|
|
|
+ backgroundColor: ColorUtils.string2Color("#F2F3F6"),
|
|
|
body: Column(
|
|
|
- children: [
|
|
|
- Expanded(
|
|
|
- child: SingleChildScrollView(
|
|
|
- scrollDirection: Axis.vertical,
|
|
|
- physics: const BouncingScrollPhysics(),
|
|
|
- clipBehavior: Clip.none,
|
|
|
- child: Column(
|
|
|
- children: [
|
|
|
- Container(
|
|
|
- width: double.infinity,
|
|
|
- height: 200,
|
|
|
- decoration: BoxDecoration(
|
|
|
- border: Border.all(
|
|
|
- color: Colors.grey,
|
|
|
- width: 1
|
|
|
+ children: [
|
|
|
+ Expanded(
|
|
|
+ child: SingleChildScrollView(
|
|
|
+ scrollDirection: Axis.vertical,
|
|
|
+ physics: const BouncingScrollPhysics(),
|
|
|
+ clipBehavior: Clip.none,
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ // mind textearea
|
|
|
+ Container(
|
|
|
+ margin: const EdgeInsets.only(left:15, right:15,top: 20),
|
|
|
+ child: _buildTextArea(context, ref),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ width: double.infinity,
|
|
|
+ height: 200,
|
|
|
+ color: Colors.white,
|
|
|
+ margin: const EdgeInsets.only(left:15, right:15, top: 20, bottom: 20),
|
|
|
+ padding: const EdgeInsets.all(15),
|
|
|
+ // 选择图片上传 控件
|
|
|
+ child: _buildImageSelectCmp(context, ref,vm),
|
|
|
+ ),
|
|
|
+ ]
|
|
|
+ )
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ // 底部 按钮
|
|
|
+ Container(
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+ Expanded(
|
|
|
+ child: MyButton(
|
|
|
+ text: "Add Card",
|
|
|
+ radius: 0,
|
|
|
+ minHeight: 50,
|
|
|
+ backgroundColor: context.appColors.textPrimary,
|
|
|
+ textColor: Colors.white,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ fontSize: 16,
|
|
|
+ onPressed: (){
|
|
|
+ // Navigator.pop(context);
|
|
|
+ },
|
|
|
),
|
|
|
- borderRadius: BorderRadius.circular(10),
|
|
|
- boxShadow: [
|
|
|
- BoxShadow(
|
|
|
- color: Colors.grey.withOpacity(0.5),
|
|
|
- spreadRadius: 1,
|
|
|
- blurRadius: 1,
|
|
|
- offset: const Offset(0, 3), // changes position of shadow
|
|
|
- ),
|
|
|
- ]
|
|
|
- ),
|
|
|
- child: _buildInputLayout(
|
|
|
- context,
|
|
|
- state,
|
|
|
- 'mind'
|
|
|
),
|
|
|
- ).marginOnly(left:15, right:15, top: 20, bottom: 20),
|
|
|
- Container(
|
|
|
- width: double.infinity,
|
|
|
- height: 200,
|
|
|
- color: Colors.grey,
|
|
|
- ),
|
|
|
- ]
|
|
|
- )
|
|
|
+ ]
|
|
|
+ ),
|
|
|
)
|
|
|
+ ]
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /// textarea
|
|
|
+ Widget _buildTextArea(BuildContext context, WidgetRef ref){
|
|
|
+
|
|
|
+ final state = ref.watch(newsfeedPostVmProvider);
|
|
|
+ final vm = ref.read(newsfeedPostVmProvider.notifier);
|
|
|
+
|
|
|
+ return Container(
|
|
|
+ width: double.infinity,
|
|
|
+ height: 200,
|
|
|
+ padding: const EdgeInsets.all(15),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Colors.white,
|
|
|
+ borderRadius: BorderRadius.circular(5),
|
|
|
+ // boxShadow: [
|
|
|
+ // BoxShadow(
|
|
|
+ // color: Colors.grey.withOpacity(0.5),
|
|
|
+ // spreadRadius: 1,
|
|
|
+ // blurRadius: 1,
|
|
|
+ // offset: const Offset(0, 3), // changes position of shadow
|
|
|
+ // ),
|
|
|
+ // ]
|
|
|
+ ),
|
|
|
+ child: _buildTextAreaLayout(
|
|
|
+ context,
|
|
|
+ ref,
|
|
|
+ 'mind',
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ /// 选择图片上传组件
|
|
|
+ Widget _buildImageSelectCmp(BuildContext context, WidgetRef ref,vm,){
|
|
|
+ final state = ref.watch(newsfeedPostVmProvider);
|
|
|
+ return ImageNineGrid(
|
|
|
+ isSelectEnable: true,
|
|
|
+ maxImages: 10,
|
|
|
+ spacing: 10,
|
|
|
+ aspectRatio: 108 / 80,
|
|
|
+ initialImages: state.imgList,
|
|
|
+ onImagesChanged: (list) {
|
|
|
+ vm.setImgList(list);
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 多行输入框
|
|
|
+ Widget _buildTextAreaLayout(BuildContext context, ref, key){
|
|
|
+ final state = ref.watch(newsfeedPostVmProvider);
|
|
|
+ final vm = ref.read(newsfeedPostVmProvider.notifier);
|
|
|
+ final noteCount = useState(0);
|
|
|
+
|
|
|
+ // return IgnoreKeyboardDismiss(
|
|
|
+ // child: Container(
|
|
|
+ // height: 177,
|
|
|
+ // margin: const EdgeInsets.only(top: 16),
|
|
|
+ // padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 15),
|
|
|
+ // decoration: BoxDecoration(
|
|
|
+ // color: context.appColors.authFiledBG,
|
|
|
+ // borderRadius: const BorderRadius.all(Radius.circular(5)),
|
|
|
+ // ),
|
|
|
+ // child: Stack(
|
|
|
+ // children: [
|
|
|
+ // TextField(
|
|
|
+ // cursorColor: context.appColors.authFiledText,
|
|
|
+ // cursorWidth: 1.5,
|
|
|
+ // autofocus: false,
|
|
|
+ // enabled: true,
|
|
|
+ // focusNode: state.formData["desc"]!['focusNode'],
|
|
|
+ // controller: state.formData["desc"]!['controller'],
|
|
|
+ // decoration: InputDecoration(
|
|
|
+ // isDense: true,
|
|
|
+ // isCollapsed: true,
|
|
|
+ // border: InputBorder.none,
|
|
|
+ // hintText: state.formData["desc"]!['hintText'],
|
|
|
+ // hintStyle: TextStyle(
|
|
|
+ // color: context.appColors.authFiledHint,
|
|
|
+ // fontSize: 16.0,
|
|
|
+ // fontWeight: FontWeight.w500,
|
|
|
+ // ),
|
|
|
+ // ),
|
|
|
+ // style: TextStyle(
|
|
|
+ // color: context.appColors.authFiledText,
|
|
|
+ // fontSize: 16.0,
|
|
|
+ // fontWeight: FontWeight.w500,
|
|
|
+ // ),
|
|
|
+ // textInputAction: TextInputAction.done,
|
|
|
+ // onSubmitted: (value) {
|
|
|
+ // FocusScope.of(context).unfocus();
|
|
|
+ // },
|
|
|
+ // maxLines: null,
|
|
|
+ // expands: true,
|
|
|
+ // onChanged: (text) {
|
|
|
+ // // 当文本改变时,更新字符数量
|
|
|
+ // noteCount.value = text.length;
|
|
|
+ // },
|
|
|
+ // ),
|
|
|
+ // Positioned(
|
|
|
+ // bottom: 0.0,
|
|
|
+ // right: 0.0,
|
|
|
+ // child: Text(
|
|
|
+ // S.current.characters(noteCount.value),
|
|
|
+ // style: TextStyle(
|
|
|
+ // color: context.appColors.textBlack,
|
|
|
+ // fontSize: 15.0,
|
|
|
+ // ),
|
|
|
+ // ),
|
|
|
+ // ),
|
|
|
+ // ],
|
|
|
+ // ),
|
|
|
+ // ),
|
|
|
+ // );
|
|
|
+
|
|
|
+ return Container(
|
|
|
+ child: Stack(
|
|
|
+ children: [
|
|
|
+ TextField(
|
|
|
+ cursorColor: context.appColors.authFiledText,
|
|
|
+ cursorWidth: 1.5,
|
|
|
+ autofocus: false,
|
|
|
+ enabled: true,
|
|
|
+ maxLines: null,
|
|
|
+ focusNode: state.formData[key]!['focusNode'],
|
|
|
+ controller: state.formData[key]!['controller'],
|
|
|
+ decoration: InputDecoration(
|
|
|
+ isDense: true,
|
|
|
+ isCollapsed: true,
|
|
|
+ border: InputBorder.none,
|
|
|
+ hintText: state.formData[key]!['hintText'],
|
|
|
+ hintStyle: TextStyle(
|
|
|
+ color: context.appColors.authFiledHint,
|
|
|
+ fontSize: 16.0,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ style: TextStyle(
|
|
|
+ color: context.appColors.authFiledText,
|
|
|
+ fontSize: 16.0,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ ),
|
|
|
+ textInputAction: TextInputAction.done,
|
|
|
+ onSubmitted: (value) {
|
|
|
+ FocusScope.of(context).unfocus();
|
|
|
+ },
|
|
|
+ expands: true,
|
|
|
+ onChanged: (text) {
|
|
|
+ // 当文本改变时,更新字符数量
|
|
|
+ noteCount.value = text.length;
|
|
|
+ },
|
|
|
),
|
|
|
- Container(
|
|
|
- child: Row(
|
|
|
- children: [
|
|
|
- Expanded(
|
|
|
- child: MyButton(
|
|
|
- text: "Add Card",
|
|
|
- backgroundColor: context.appColors.textPrimary,
|
|
|
- textColor: Colors.white,
|
|
|
- fontWeight: FontWeight.w500,
|
|
|
- fontSize: 16,
|
|
|
- onPressed: (){
|
|
|
- // Navigator.pop(context);
|
|
|
- },
|
|
|
- ),
|
|
|
- ),
|
|
|
- ]
|
|
|
+ Positioned(
|
|
|
+ bottom: 0.0,
|
|
|
+ right: 0.0,
|
|
|
+ child: Text(
|
|
|
+ S.current.characters(noteCount.value),
|
|
|
+ style: TextStyle(
|
|
|
+ color: context.appColors.textBlack,
|
|
|
+ fontSize: 15.0,
|
|
|
+ ),
|
|
|
),
|
|
|
- )
|
|
|
+ ),
|
|
|
]
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
|
|
|
- /// 输入框
|
|
|
+ /// 单行输入框
|
|
|
Widget _buildInputLayout(
|
|
|
BuildContext context,
|
|
|
state,
|
|
|
String key,
|
|
|
{
|
|
|
+ double height = 48,
|
|
|
+ double maxLines = 1,
|
|
|
double marginTop = 0,
|
|
|
bool? showRightIcon = false, //是否展示右侧的布局
|
|
|
Widget? rightWidget, //右侧的布局
|
|
@@ -134,7 +291,7 @@ class NewsfeedPostPage extends HookConsumerWidget {
|
|
|
margin: EdgeInsets.only(top: marginTop),
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
|
|
|
showDivider: false,
|
|
|
- height: 44,
|
|
|
+ height: height,
|
|
|
style: TextStyle(
|
|
|
color: context.appColors.authFiledText,
|
|
|
fontSize: 16.0,
|