更新动态卡片

hmxc
小赖 4 years ago
parent 78a12bb0a3
commit 4556db6f8f

@ -169,6 +169,9 @@ class _Community {
String get eventByTopicId => '/user/gambit/listByGambitId'; String get eventByTopicId => '/user/gambit/listByGambitId';
String get newEventList => '/user/gambit/list'; String get newEventList => '/user/gambit/list';
///
String get addEvent => '/user/gambit/writePost';
} }
class _Upload { class _Upload {
@ -180,4 +183,6 @@ class _Upload {
/// ///
String get uploadRepair => '/user/upload/uploadRepair'; String get uploadRepair => '/user/upload/uploadRepair';
String get uploadEvent => '/user/upload/uploadGambit';
} }

@ -0,0 +1,148 @@
import 'dart:io';
import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/utils/network/base_model.dart';
import 'package:akuCommunity/utils/network/net_util.dart';
import 'package:akuCommunity/widget/picker/grid_image_picker.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart';
class AddNewEventPage extends StatefulWidget {
AddNewEventPage({Key key}) : super(key: key);
@override
_AddNewEventPageState createState() => _AddNewEventPageState();
}
class _AddNewEventPageState extends State<AddNewEventPage> {
bool _commentable = true;
List<File> _files = [];
TextEditingController _textEditingController = TextEditingController();
///
_addEvent() async {
VoidCallback cancel = BotToast.showLoading();
final String content = _textEditingController.text;
List<String> imgs;
if (_files.isNotEmpty) {
imgs = await NetUtil().uploadFiles(_files, API.upload.uploadEvent);
}
Map<String, dynamic> params = {
//TODO ID
'gambitId': -1,
'content': content,
'isComment': _commentable ? 1 : 0,
'isPublic': 1,
'imgUrls': imgs,
};
BaseModel baseModel = await NetUtil().post(
API.community.addEvent,
params: params,
showMessage: true,
);
cancel();
if (baseModel.status) {
Get.back(result: true);
}
}
_buildSelectable() {
return MaterialButton(
onPressed: () {
setState(() {
_commentable = !_commentable;
});
},
height: 96.w,
child: Row(
children: [
Icon(
CupertinoIcons.bubble_left,
size: 32.w,
),
8.wb,
'不可评论'.text.size(28.sp).make(),
Spacer(),
AnimatedOpacity(
opacity: _commentable ? 0 : 1,
duration: Duration(milliseconds: 300),
curve: Curves.easeInOutCubic,
child: Icon(
Icons.check_rounded,
color: Colors.black,
size: 40.w,
),
),
],
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
leading: MaterialButton(
padding: EdgeInsets.zero,
onPressed: Get.back,
child: '取消'.text.size(34.sp).make(),
),
leadingWidth: 108.w,
centerTitle: true,
title: '社区'.text.make(),
actions: [
Hero(
tag: 'event_add',
child: MaterialButton(
elevation: 0,
minWidth: 116.w,
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4.w),
),
color: kPrimaryColor,
onPressed: _addEvent,
child: '发表'.text.size(34.sp).make(),
).centered(),
),
32.wb,
],
),
body: ListView(
padding: EdgeInsets.symmetric(horizontal: 64.w, vertical: 32.w),
children: [
TextField(
minLines: 3,
maxLines: 99,
controller: _textEditingController,
decoration: InputDecoration(
contentPadding: EdgeInsets.zero,
border: InputBorder.none,
hintText: '这一刻的想法',
hintStyle: TextStyle(
color: Color(0xFF999999),
fontSize: 34.sp,
),
),
),
GridImagePicker(onChange: (files) => _files = files),
100.hb,
Divider(height: 1.w),
_buildSelectable(),
Divider(height: 1.w),
28.hb,
//TODO
],
).material(color: Colors.white),
);
}
}

@ -1,3 +1,4 @@
import 'package:akuCommunity/ui/community/community_views/add_new_event_page.dart';
import 'package:akuCommunity/ui/community/community_views/my_community_view.dart'; import 'package:akuCommunity/ui/community/community_views/my_community_view.dart';
import 'package:akuCommunity/ui/community/community_views/new_community_view.dart'; import 'package:akuCommunity/ui/community/community_views/new_community_view.dart';
import 'package:akuCommunity/ui/community/community_views/topic/topic_community_view.dart'; import 'package:akuCommunity/ui/community/community_views/topic/topic_community_view.dart';
@ -6,6 +7,7 @@ import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:akuCommunity/widget/buttons/column_action_button.dart'; import 'package:akuCommunity/widget/buttons/column_action_button.dart';
import 'package:akuCommunity/widget/tab_bar/bee_tab_bar.dart'; import 'package:akuCommunity/widget/tab_bar/bee_tab_bar.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart';
class CommunityPage extends StatefulWidget { class CommunityPage extends StatefulWidget {
CommunityPage({Key key}) : super(key: key); CommunityPage({Key key}) : super(key: key);
@ -40,7 +42,7 @@ class _CommunityPageState extends State<CommunityPage>
), ),
], ],
fab: FloatingActionButton( fab: FloatingActionButton(
onPressed: () {}, onPressed: () => Get.to(AddNewEventPage()),
heroTag: 'event_add', heroTag: 'event_add',
child: Icon(Icons.add), child: Icon(Icons.add),
), ),

@ -35,11 +35,12 @@ class _NewCommunityViewState extends State<NewCommunityView>
itemBuilder: (context, index) { itemBuilder: (context, index) {
final item = items[index] as EventItemModel; final item = items[index] as EventItemModel;
return ChatCard( return ChatCard(
content: item.content,
name: item.createName ?? '', name: item.createName ?? '',
title: item.gambitTitle ?? '', topic: item.gambitTitle ?? '',
contentImg: item.imgUrls, contentImg: item.imgUrls,
date: item.date, date: item.date,
id: item.id, id: item.createId,
headImg: item.headSculptureImgUrl, headImg: item.headSculptureImgUrl,
); );
}, },

@ -60,8 +60,9 @@ class _TopicDetailPageState extends State<TopicDetailPage> {
(context, index) { (context, index) {
final item = items[index] as EventItemModel; final item = items[index] as EventItemModel;
return ChatCard( return ChatCard(
content: item.content,
name: item.createName, name: item.createName,
title: item.gambitTitle, topic: item.gambitTitle,
headImg: item.headSculptureImgUrl, headImg: item.headSculptureImgUrl,
contentImg: item.imgUrls, contentImg: item.imgUrls,
date: item.date, date: item.date,

@ -15,23 +15,25 @@ import 'package:velocity_x/velocity_x.dart';
class ChatCard extends StatefulWidget { class ChatCard extends StatefulWidget {
final String name; final String name;
final String title; final String topic;
final List<ImgModel> headImg; final List<ImgModel> headImg;
final List<ImgModel> contentImg; final List<ImgModel> contentImg;
final DateTime date; final DateTime date;
final bool initLike; final bool initLike;
final String content;
///userID ///userID
final int id; final int id;
ChatCard({ ChatCard({
Key key, Key key,
@required this.name, @required this.name,
@required this.title, @required this.topic,
@required this.headImg, @required this.headImg,
@required this.contentImg, @required this.contentImg,
@required this.date, @required this.date,
this.initLike = false, this.initLike = false,
@required this.id, @required this.id,
@required this.content,
}) : super(key: key); }) : super(key: key);
@override @override
@ -226,9 +228,21 @@ class _ChatCardState extends State<ChatCard> {
children: [ children: [
widget.name.text.size(36.sp).make(), widget.name.text.size(36.sp).make(),
6.hb, 6.hb,
widget.title.text.make(), widget.content.text.make(),
20.hb, 20.hb,
_renderImage(), _renderImage(),
widget.topic.isEmpty
? SizedBox()
: Chip(
label: '#${widget.topic}'.text.size(22.sp).make(),
padding: EdgeInsets.symmetric(
horizontal: 16.w, vertical: 5.w),
labelPadding: EdgeInsets.zero,
backgroundColor: Colors.transparent,
shape: StadiumBorder(
side: BorderSide(),
),
),
Row( Row(
children: [ children: [
BeeDateUtil(widget.date) BeeDateUtil(widget.date)
@ -248,13 +262,13 @@ class _ChatCardState extends State<ChatCard> {
title: '你确定删除吗'.text.isIntrinsic.make(), title: '你确定删除吗'.text.isIntrinsic.make(),
actions: [ actions: [
CupertinoDialogAction( CupertinoDialogAction(
child: '取消'.text.isIntrinsic.make(), child: '取消'.text.black.isIntrinsic.make(),
onPressed: () => Get.back(), onPressed: () => Get.back(),
), ),
CupertinoDialogAction( CupertinoDialogAction(
child: '确定' child: '确定'
.text .text
.color(kPrimaryColor) .color(Colors.orange)
.isIntrinsic .isIntrinsic
.make(), .make(),
onPressed: () => Get.back(result: true), onPressed: () => Get.back(result: true),

@ -12,6 +12,7 @@ import 'package:velocity_x/velocity_x.dart';
// Project imports: // Project imports:
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
//TODO
class BeeImagePicker { class BeeImagePicker {
static Future<File> pick({ static Future<File> pick({
String title, String title,

Loading…
Cancel
Save