修复无房产登陆失效问题,话题卡片入口变更

hmxc
小赖 4 years ago
parent ec5a042860
commit d97cc8aa31

@ -47,7 +47,10 @@ class UserDetailModel {
identity = json['identity']; identity = json['identity'];
roomStatus = json['roomStatus']; roomStatus = json['roomStatus'];
nickName = json['nickName']; nickName = json['nickName'];
if (json['estateNames'] != null)
estateNames = json['estateNames'].cast<String>(); estateNames = json['estateNames'].cast<String>();
else
estateNames = [];
if (json['estateNames'] == null) { if (json['estateNames'] == null) {
estateNames = []; estateNames = [];
} }

@ -31,7 +31,9 @@ class UserProvider extends ChangeNotifier {
HiveStore.appBox.put('login', true); HiveStore.appBox.put('login', true);
await updateProfile(); await updateProfile();
await updateUserDetail(); await updateUserDetail();
await setCurrentHouse(_userDetailModel?.estateNames?.first??''); await setCurrentHouse((_userDetailModel?.estateNames?.isEmpty ?? true)
? ''
: _userDetailModel?.estateNames?.first);
notifyListeners(); notifyListeners();
} }

@ -45,17 +45,7 @@ class _EventDetailPageState extends State<EventDetailPage> {
: ListView( : ListView(
children: [ children: [
ChatCard( ChatCard(
initLike: _model.isLike == 1, model:_model,
name: _model.createName,
topic: _model.gambitTitle,
headImg: _model.headSculptureImgUrl,
contentImg: _model.imgUrls,
date: _model.date,
id: _model.id,
content: _model.content,
themeId: _model.id,
comments: _model.gambitThemeCommentVoList,
likeNames: _model.likeNames,
hideLine: true, hideLine: true,
canTap: false, canTap: false,
), ),

@ -45,17 +45,7 @@ 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, model: item,
name: item.createName ?? '',
topic: item.gambitTitle ?? '',
contentImg: item.imgUrls,
date: item.date,
id: item.createId,
headImg: item.headSculptureImgUrl,
themeId: item.id,
initLike: item.isLike == 1,
comments: item.gambitThemeCommentVoList,
likeNames: item.likeNames,
onDelete: () { onDelete: () {
_refreshController.callRefresh(); _refreshController.callRefresh();
}, },

@ -64,20 +64,10 @@ 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(
initLike: item.isLike == 1, model:item,
themeId: item.id,
content: item.content,
name: item.createName,
topic: item.gambitTitle,
headImg: item.headSculptureImgUrl,
contentImg: item.imgUrls,
date: item.date,
id: item.createId,
onDelete: () { onDelete: () {
_refreshController.callRefresh(); _refreshController.callRefresh();
}, },
comments: item.gambitThemeCommentVoList,
likeNames: item.likeNames,
); );
}, },
childCount: items.length, childCount: items.length,

@ -1,4 +1,5 @@
// Flutter imports: // Flutter imports:
import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/model/community/event_item_model.dart'; import 'package:akuCommunity/model/community/event_item_model.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -11,7 +12,6 @@ import 'package:velocity_x/velocity_x.dart';
// Project imports: // Project imports:
import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/provider/user_provider.dart';
import 'package:akuCommunity/ui/community/community_views/event_detail_page.dart'; import 'package:akuCommunity/ui/community/community_views/event_detail_page.dart';
import 'package:akuCommunity/utils/bee_date_util.dart'; import 'package:akuCommunity/utils/bee_date_util.dart';
@ -21,42 +21,18 @@ import 'package:akuCommunity/widget/picker/bee_image_preview.dart';
import 'package:akuCommunity/widget/views/bee_grid_image_view.dart'; import 'package:akuCommunity/widget/views/bee_grid_image_view.dart';
class ChatCard extends StatefulWidget { class ChatCard extends StatefulWidget {
final String name; final EventItemModel model;
final String topic;
final List<ImgModel> headImg;
final List<ImgModel> contentImg;
final DateTime date;
final bool initLike;
final String content;
///userID
final int id;
final int themeId;
final VoidCallback onDelete; final VoidCallback onDelete;
final List<GambitThemeCommentVoList> comments;
final List<LikeNames> likeNames;
final bool hideLine; final bool hideLine;
final bool canTap; final bool canTap;
ChatCard({ ChatCard({
Key key, Key key,
@required this.name, @required this.model,
@required this.topic,
@required this.headImg,
@required this.contentImg,
@required this.date,
@required this.initLike,
@required this.id,
@required this.content,
@required this.themeId,
this.onDelete, this.onDelete,
@required this.comments,
this.hideLine = false, this.hideLine = false,
@required this.likeNames,
this.canTap = true, this.canTap = true,
}) : super(key: key); }) : super(key: key);
@ -65,23 +41,22 @@ class ChatCard extends StatefulWidget {
} }
class _ChatCardState extends State<ChatCard> { class _ChatCardState extends State<ChatCard> {
bool _like = false;
bool get _isMyself { bool get _isMyself {
final userProvider = Provider.of<UserProvider>(context, listen: false); final userProvider = Provider.of<UserProvider>(context, listen: false);
return (userProvider?.userInfoModel?.id ?? -1) == widget.id; return (userProvider?.userInfoModel?.id ?? -1) == widget.model.id;
} }
String get firstHead { String get firstHead {
if (widget.headImg == null || widget.headImg.isEmpty) if (widget.model.headSculptureImgUrl == null ||
widget.model.headSculptureImgUrl.isEmpty)
return ''; return '';
else else
return widget.headImg.first.url; return widget.model.headSculptureImgUrl.first.url;
} }
_renderImage() { _renderImage() {
if (widget.contentImg.isEmpty) return SizedBox(); if (widget.model.imgUrls.isEmpty) return SizedBox();
if (widget.contentImg.length == 1) if (widget.model.imgUrls.length == 1)
return MaterialButton( return MaterialButton(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
@ -91,7 +66,7 @@ class _ChatCardState extends State<ChatCard> {
), ),
onPressed: () { onPressed: () {
Get.to( Get.to(
BeeImagePreview.path(path: widget.contentImg.first.url), BeeImagePreview.path(path: widget.model.imgUrls.first.url),
opaque: false, opaque: false,
); );
}, },
@ -101,17 +76,17 @@ class _ChatCardState extends State<ChatCard> {
maxWidth: 300.w, maxWidth: 300.w,
), ),
child: Hero( child: Hero(
tag: widget.contentImg.first.url, tag: widget.model.imgUrls.first.url,
child: FadeInImage.assetNetwork( child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(widget.contentImg.first.url), image: API.image(widget.model.imgUrls.first.url),
), ),
), ),
), ),
); );
else else
return BeeGridImageView( return BeeGridImageView(
urls: widget.contentImg.map((e) => e.url).toList()); urls: widget.model.imgUrls.map((e) => e.url).toList());
} }
_buildMoreButton() { _buildMoreButton() {
@ -150,15 +125,16 @@ class _ChatCardState extends State<ChatCard> {
cancel(); cancel();
await NetUtil().get( await NetUtil().get(
API.community.like, API.community.like,
params: {'themeId': widget.themeId}, params: {'themeId': widget.model.id},
showMessage: true, showMessage: true,
); );
setState(() { setState(() {
_like = !_like; widget.model.isLike =
(widget.model.isLike == 1) ? 0 : 1;
}); });
}, },
child: [ child: [
_like widget.model.isLike == 1
? Icon(Icons.favorite, ? Icon(Icons.favorite,
size: 30.w, color: Colors.red) size: 30.w, color: Colors.red)
: Icon(Icons.favorite_border, size: 30.w), : Icon(Icons.favorite_border, size: 30.w),
@ -221,7 +197,7 @@ class _ChatCardState extends State<ChatCard> {
children: [ children: [
Icon(Icons.favorite_border_rounded, size: 24.w), Icon(Icons.favorite_border_rounded, size: 24.w),
14.wb, 14.wb,
...widget.likeNames ...widget.model.likeNames
.map((e) => e.name.text.make()) .map((e) => e.name.text.make())
.toList() .toList()
.sepWidget(separate: ','.text.make()), .sepWidget(separate: ','.text.make()),
@ -233,20 +209,47 @@ class _ChatCardState extends State<ChatCard> {
_renderComment() { _renderComment() {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: widget.comments.map((e) { children: widget.model.gambitThemeCommentVoList.map((e) {
StringBuffer buffer = StringBuffer(); StringBuffer buffer = StringBuffer();
buffer.write(e.createName); buffer.write(e.createName);
if (e.parentName != null) buffer.write('回复${e.parentName}'); if (e.parentName != null) buffer.write('回复${e.parentName}');
buffer.write(':${e.content}'); buffer.write(':${e.content}');
return InkWell( return InkWell(
child: buffer.toString().text.make(), child: buffer.toString().text.make(),
onTap: () {}, onTap: () {
addComment();
},
); );
}).toList(), }).toList(),
); );
} }
addComment() {} addComment() async {
FocusNode node = FocusNode();
node.requestFocus();
Get.bottomSheet(
Row(
children: [
TextField(
focusNode: node,
decoration: InputDecoration(
border: OutlineInputBorder(),
isDense: true,
),
).p(16.w).expand(),
16.wb,
MaterialButton(
color: kPrimaryColor,
onPressed: () {},
minWidth: 64.w,
child: '发送'.text.make(),
),
16.wb,
],
).material(color: Colors.white),
barrierColor: Colors.transparent,
);
}
_renderLikeAndComment() { _renderLikeAndComment() {
return Material( return Material(
@ -258,23 +261,20 @@ class _ChatCardState extends State<ChatCard> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
widget.likeNames.isEmpty ? SizedBox() : _renderLike(), widget.model.likeNames.isEmpty ? SizedBox() : _renderLike(),
(widget.likeNames.isNotEmpty && widget.comments.isNotEmpty) (widget.model.likeNames.isNotEmpty &&
widget.model.gambitThemeCommentVoList.isNotEmpty)
? Divider(height: 1.w, thickness: 1.w) ? Divider(height: 1.w, thickness: 1.w)
: SizedBox(), : SizedBox(),
widget.comments.isEmpty ? SizedBox() : _renderComment(), widget.model.gambitThemeCommentVoList.isEmpty
? SizedBox()
: _renderComment(),
], ],
), ),
), ),
); );
} }
@override
void initState() {
super.initState();
_like = widget.initLike ?? false;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DecoratedBox( return DecoratedBox(
@ -290,7 +290,7 @@ class _ChatCardState extends State<ChatCard> {
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
onPressed: widget.canTap onPressed: widget.canTap
? () { ? () {
Get.to(EventDetailPage(themeId: widget.themeId)); Get.to(EventDetailPage(themeId: widget.model.id));
} }
: null, : null,
child: Row( child: Row(
@ -311,15 +311,18 @@ class _ChatCardState extends State<ChatCard> {
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
widget.name.text.black.size(36.sp).make(), widget.model.createName.text.black.size(36.sp).make(),
6.hb, 6.hb,
widget.content.text.black.make(), widget.model.content.text.black.make(),
20.hb, 20.hb,
_renderImage(), _renderImage(),
widget.topic?.isEmpty ?? true widget.model.gambitTitle?.isEmpty ?? true
? SizedBox() ? SizedBox()
: Chip( : Chip(
label: '#${widget.topic}'.text.size(22.sp).make(), label: '#${widget.model.gambitTitle}'
.text
.size(22.sp)
.make(),
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: 16.w, vertical: 5.w), horizontal: 16.w, vertical: 5.w),
labelPadding: EdgeInsets.zero, labelPadding: EdgeInsets.zero,
@ -331,7 +334,7 @@ class _ChatCardState extends State<ChatCard> {
Row( Row(
children: [ children: [
64.hb, 64.hb,
BeeDateUtil(widget.date) BeeDateUtil(widget.model.date)
.timeAgo .timeAgo
.text .text
.size(28.sp) .size(28.sp)
@ -365,7 +368,7 @@ class _ChatCardState extends State<ChatCard> {
if (result == true) { if (result == true) {
await NetUtil().get( await NetUtil().get(
API.community.deleteMyEvent, API.community.deleteMyEvent,
params: {'themeId': widget.themeId}, params: {'themeId': widget.model.id},
showMessage: true, showMessage: true,
); );
if (widget.onDelete != null) widget.onDelete(); if (widget.onDelete != null) widget.onDelete();

Loading…
Cancel
Save