Merge branch 'laiiihz'

* laiiihz:
  集成jpush
  修复无房产登陆失效问题,话题卡片入口变更
  remove old deprecated community page
hmxc
小赖 4 years ago
commit 1829b3f929

@ -49,6 +49,12 @@ android {
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
manifestPlaceholders = [
JPUSH_PKGNAME : applicationId,
JPUSH_APPKEY : "6a2c6507e3e8b3187ac1c9f9",
JPUSH_CHANNEL : "developer-default",
]
}
signingConfigs {

@ -8,6 +8,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_picker/flutter_picker.dart';
import 'package:fluwx/fluwx.dart';
import 'package:get/get.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
@ -21,6 +22,27 @@ import 'package:akuCommunity/utils/developer_util.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
JPush jpush = new JPush();
jpush.addEventHandler(
//
onReceiveNotification: (Map<String, dynamic> message) async {
print("flutter onReceiveNotification: $message");
},
//
onOpenNotification: (Map<String, dynamic> message) async {
print("flutter onOpenNotification: $message");
},
//
onReceiveMessage: (Map<String, dynamic> message) async {
print("flutter onReceiveMessage: $message");
},
);
jpush.setup(
appKey: "6a2c6507e3e8b3187ac1c9f9",
channel: "developer-default",
production: false,
debug: true, // debug
);
DeveloperUtil.setDev(true);
runApp(MyApp());
}

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

@ -1,168 +0,0 @@
// Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:velocity_x/velocity_x.dart';
// Project imports:
import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/pages/community/note_create_page.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'widget/tab_list.dart';
//TODO CLEAN BOTTOM CODES.
@Deprecated("sh*t community_index need to be cleaned.")
class CommunityIndex extends StatefulWidget {
CommunityIndex({Key key}) : super(key: key);
@override
_CommunityIndexState createState() => _CommunityIndexState();
}
class _CommunityIndexState extends State<CommunityIndex>
with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin {
@override
bool get wantKeepAlive => true;
TabController _tabController;
List tabs = [
{'name': '最新', 'id': 'new'},
{'name': '话题', 'id': 'new'},
{'name': '我的', 'id': 'new'},
];
@override
void initState() {
super.initState();
// Controller
_tabController = TabController(length: tabs.length, vsync: this);
}
void noteCreateRouter() {
NoteCreatePage().to();
}
List<Widget> _listActions() {
return [
FlatButton(
minWidth: 48.w + 27.w * 2,
onPressed: () {},
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Icon(
CupertinoIcons.bell,
size: 48.w,
),
'消息'.text.black.size(20.sp).make(),
],
))
];
}
// AppBar _appBar() {
// return AppBar(
// backgroundColor: Colors.white,
// elevation: 0,
// title: Text("社区"),
// centerTitle: true,
// actions: _listActions(),
// bottom: PreferredSize(
// preferredSize: Size.fromHeight(kToolbarHeight),
// child: Align(
// alignment: Alignment.centerLeft,
// child: TabBar(
// controller: _tabController,
// isScrollable: true,
// indicatorColor: Color(0xffFFd000),
// labelColor: Color(0xff000000),
// unselectedLabelColor: Color(0xFF3A5160).withOpacity(0.5),
// indicatorWeight: 2.0,
// indicatorSize: TabBarIndicatorSize.label,
// labelStyle: TextStyle(
// fontSize: 28.sp,
// color: Color(0xff333333),
// fontWeight: FontWeight.w600,
// ),
// tabs: List.generate(
// tabs.length,
// (index) => Tab(
// text: tabs[index]['name'],
// ),
// ),
// ),
// ),
// ),
// );
// }
FloatingActionButton _floatingActionButton() {
return FloatingActionButton(
backgroundColor: Color(0xffffd000),
child: Icon(
Icons.add,
color: Colors.white,
),
onPressed: noteCreateRouter,
);
}
@override
Widget build(BuildContext context) {
super.build(context);
return BeeScaffold(
title: '社区',
actions: _listActions(),
body: Column(
children: [
Material(
color: kForeGroundColor,
child: PreferredSize(
preferredSize: Size.fromHeight(kToolbarHeight),
child: Align(
alignment: Alignment.centerLeft,
child: TabBar(
indicatorPadding: EdgeInsets.zero,
controller: _tabController,
isScrollable: true,
indicatorColor: Color(0xffFFd000),
indicatorWeight: 2.w,
indicatorSize: TabBarIndicatorSize.label,
unselectedLabelStyle: TextStyle(
color: Color(0xFF333333),
fontSize: 28.sp,
),
labelStyle: TextStyle(
fontSize: 28.sp,
color: Color(0xff333333),
fontWeight: FontWeight.bold,
),
tabs: List.generate(
tabs.length,
(index) => Tab(
text: tabs[index]['name'],
),
),
),
),
),
),
Expanded(
child: TabBarView(
controller: _tabController,
children: List.generate(
tabs.length,
(index) => TabList(index: index),
),
),
),
// _floatingActionButton(),
],
),
fab: _floatingActionButton(),
);
}
}

@ -1,269 +0,0 @@
// Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:flutter_icons/flutter_icons.dart';
import 'package:get/get.dart';
// Project imports:
import 'package:akuCommunity/base/assets_image.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
class NoteCreatePage extends StatefulWidget {
NoteCreatePage({Key key}) : super(key: key);
@override
_NoteCreatePageState createState() => _NoteCreatePageState();
}
class _NoteCreatePageState extends State<NoteCreatePage> {
TextEditingController _noteContent = new TextEditingController();
String hintText = '这一刻的想法...';
bool _isSelect = false;
List<Map<String, dynamic>> _themeList = [
{'title': '选择话题:', 'isSelect': false},
{'title': "#教师节", 'isSelect': false},
{'title': "#快乐植树节", 'isSelect': false},
{'title': "#关爱老人", 'isSelect': false},
{'title': "#运动会", 'isSelect': false},
];
Container _containerTextField() {
return Container(
child: TextFormField(
cursorColor: Color(0xffffc40c),
style: TextStyle(
fontSize: 34.sp,
),
controller: _noteContent,
onChanged: (String value) {},
maxLines: 6,
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.only(
top: 0.w,
bottom: 0.w,
),
hintText: hintText,
border: InputBorder.none, //线
fillColor: Colors.white,
filled: true,
hintStyle: TextStyle(
color: Color(0xff999999),
fontSize: 34.sp,
fontWeight: FontWeight.normal,
),
),
),
);
}
InkWell _containerAddImage() {
return InkWell(
onTap: () {},
child: Container(
width: 196.w,
height: 196.w,
decoration: BoxDecoration(
color: Colors.white,
image: DecorationImage(
image: AssetImage(AssetsImage.IMAGEADD), fit: BoxFit.fill),
),
// child: ,
),
);
}
InkWell _inkWellSelect() {
return InkWell(
onTap: () {
setState(() {
_isSelect = !_isSelect;
});
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 30.w),
decoration: BoxDecoration(
border: Border(
top: BorderSide(color: Color(0xffd8d8d8), width: 1),
bottom: BorderSide(color: Color(0xffd8d8d8), width: 1),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(
AntDesign.message1,
color: Color(0xff333333),
size: 28.sp,
),
SizedBox(width: 10.w),
Text(
'不可评论',
style: TextStyle(
fontSize: 28.sp,
color: Color(0xff333333),
),
),
],
),
_isSelect
? Icon(
AntDesign.check,
color: Color(0xffffd003),
size: 40.sp,
)
: SizedBox(height: 40.sp),
],
),
),
);
}
Wrap _wrapThemeList() {
return Wrap(
spacing: 15.w,
runSpacing: 20.w,
children: _themeList
.asMap()
.keys
.map((index) => index == 0
? Container(
padding: EdgeInsets.only(top: 10.w),
width: 156.w,
alignment: Alignment.centerLeft,
child: Text(
_themeList[index]['title'],
style: TextStyle(
fontSize: 34.sp,
color: Color(0xff333333),
),
),
)
: InkWell(
onTap: () {
_themeList.forEach((item) {
item['isSelect'] = false;
});
setState(() {
_themeList[index]['isSelect'] = true;
});
},
child: Container(
decoration: BoxDecoration(
color: _themeList[index]['isSelect']
? Color(0xfffff8e4)
: Color(0xffffffff),
border: Border.all(
color: _themeList[index]['isSelect']
? Color(0xffffc40c)
: Color(0xff979797),
width: 0.5),
borderRadius: BorderRadius.all(Radius.circular(36))),
padding: EdgeInsets.symmetric(
horizontal: 29.w,
vertical: 13.w,
),
child: Text(
_themeList[index]['title'],
style: TextStyle(
fontSize: 34.sp,
color: _themeList[index]['isSelect']
? Color(0xff333333)
: Color(0xff999999),
),
),
),
))
.toList());
}
@override
Widget build(BuildContext context) {
double _statusHeight = MediaQuery.of(context).padding.top;
return BeeScaffold(
title: '社区',
leading: InkWell(
onTap: () => Get.back(),
child: Container(
padding: EdgeInsets.only(left: 32.w),
alignment: Alignment.center,
child: Text(
'取消',
style: TextStyle(
fontSize: 34.sp,
color: Color(0xff030303),
),
),
),
),
actions: [
Container(
alignment: Alignment.center,
padding: EdgeInsets.only(right: 32.w),
child: InkWell(
onTap: () {},
child: Container(
height: 64.w,
width: 116.w,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Color(0xffffd000),
borderRadius: BorderRadius.all(Radius.circular(4)),
),
child: Text(
'发表',
style: TextStyle(
fontSize: 34.sp,
color: Color(0xff030303),
),
),
),
),
),
],
body: SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height -
kToolbarHeight -
_statusHeight,
color: Colors.white,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
},
child: Container(
padding: EdgeInsets.only(
top: 49.w,
left: 62.w,
right: 62.w,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_containerTextField(),
_containerAddImage(),
SizedBox(height: 202.w),
_inkWellSelect(),
SizedBox(height: 28.w),
_wrapThemeList(),
],
),
),
),
),
),
);
}
}

@ -1,147 +0,0 @@
// Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:flutter_icons/flutter_icons.dart';
import 'package:get/get.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
// Project imports:
import 'package:akuCommunity/pages/community/note_create_page.dart';
import 'package:akuCommunity/routers/page_routers.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'widget/trend_card.dart';
class TopiceDetailPage extends StatefulWidget {
final Bundle bundle;
TopiceDetailPage({Key key, this.bundle}) : super(key: key);
@override
_TopiceDetailPageState createState() => _TopiceDetailPageState();
}
class _TopiceDetailPageState extends State<TopiceDetailPage> {
RefreshController _refreshController =
RefreshController(initialRefresh: false);
ScrollController _controller;
@override
void initState() {
super.initState();
}
void _onRefresh() async {
await Future.delayed(Duration(milliseconds: 1500));
_refreshController.refreshCompleted();
}
void _onLoading() async {
await Future.delayed(Duration(milliseconds: 1500));
if (mounted) setState(() {});
_refreshController.loadComplete();
}
@override
void dispose() {
super.dispose();
_refreshController.dispose();
}
SliverAppBar _sliverAppBar(String imagePath) {
return SliverAppBar(
expandedHeight: 500.w,
pinned: true,
floating: true,
elevation: 0,
backgroundColor: Colors.white,
leading: IconButton(
icon: Icon(AntDesign.left, size: 40.sp),
onPressed: () {
Get.back();
},
),
flexibleSpace: FlexibleSpaceBar(
title: Text('教师节'),
background: Image.asset(
imagePath,
fit: BoxFit.fitHeight,
),
),
);
}
Positioned _positionedFloatActionButton() {
return Positioned(
bottom: 124.w,
right: 32.w,
child: FloatingActionButton(
backgroundColor: Color(0xffffd000),
child: Icon(
Icons.add,
color: Colors.white,
size: 40.sp,
),
onPressed: () {
NoteCreatePage().to();
}));
}
@override
Widget build(BuildContext context) {
double _statusHeight = MediaQuery.of(context).padding.top;
return Scaffold(
body: Stack(
children: [
RefreshConfiguration(
hideFooterWhenNotFull: true,
maxOverScrollExtent: 100 + _statusHeight,
child: SmartRefresher(
controller: _refreshController,
header: ClassicHeader(
height: _statusHeight + 60,
outerBuilder: (child) {
return Container(
padding: EdgeInsets.only(top: _statusHeight),
child: Container(
alignment: Alignment.center,
height: 60,
child: child,
),
);
},
),
footer: ClassicFooter(),
onRefresh: _onRefresh,
onLoading: _onLoading,
enablePullUp: true,
child: CustomScrollView(
controller: _controller,
slivers: [
_sliverAppBar(widget.bundle.getMap('topicMap')['imagePath']),
SliverToBoxAdapter(
child: Container(
color: Colors.white,
child: ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => TrendCard(
name: '秋森',
content: '真的 很喜欢这个小区,保安也非常好',
),
itemCount: 6,
),
),
),
],
),
),
),
_positionedFloatActionButton(),
],
),
);
}
}

@ -1,191 +0,0 @@
// Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:pull_to_refresh/pull_to_refresh.dart';
// Project imports:
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/circle_trend.dart';
import 'topic_card.dart';
import 'trend_card.dart';
class TabList extends StatefulWidget {
final int index;
TabList({Key key, this.index}) : super(key: key);
@override
_TabListState createState() => _TabListState();
}
class _TabListState extends State<TabList> with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;
List<Map<String, dynamic>> _circleList = [
{
'title': '今天',
'contentList': <Map<String, dynamic>>[
{
'subtitle': '智慧社区真方便',
'imagePath':
'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1107708528,2478822843&fm=26&gp=0.jpg'
},
{
'subtitle': '打卡成功!每天都要美美哒',
'imagePath':
'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1635278618,744809538&fm=26&gp=0.jpg'
}
]
},
{
'title': '118月',
'contentList': <Map<String, dynamic>>[
{
'subtitle': '健身完毕就去吃火锅,奖励自己一回,偶尔一顿应该没什么吧!',
'imagePath':
'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1771079224,2955282519&fm=26&gp=0.jpg'
},
]
},
{
'title': '217月',
'contentList': <Map<String, dynamic>>[
{
'subtitle': '头疼非常头疼',
'imagePath':
'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2951929786,3989144852&fm=26&gp=0.jpg'
},
]
},
];
List<Map<String, dynamic>> _topicList = [
{
'title': '教师节到啦,你们有什么想对老师说的吗',
'subtitle': '三尺讲台,三寸舌,三寸笔,三千桃李;十年树木,十载风,十载雨,十万栋梁。',
'imagePath': 'assets/example/topic1.png',
'hotNum': '197298'
},
{
'title': '开展全民健身运动,全面建设小康社会',
'subtitle': '生命在于运动,勇创辉煌',
'imagePath': 'assets/example/topic2.png',
'hotNum': '137128'
},
{
'title': '端午品香粽,美味万家颂',
'subtitle': '五月五过端午,包粽子赛龙舟,熏艾草挂荷包,家家户户齐欢乐',
'imagePath': 'assets/example/topic3.png',
'hotNum': '147128'
}
];
List<Map<String, dynamic>> _newsList = [
{
'name': '王管事',
'content': '智慧社区真美丽',
'imageUrl': <String>[
'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=129367535,2478805251&fm=26&gp=0.jpg',
'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=107966910,699677438&fm=26&gp=0.jpg',
'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3011269428,2056805718&fm=26&gp=0.jpg'
],
'isLike': false,
'avatar': Image.asset('assets/example/touxiang1.png'),
},
{
'name': '马泽鹏',
'content': '真的 很喜欢这个小区,保安也非常好',
'imageUrl': <String>[
'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3445658157,2379681095&fm=26&gp=0.jpg',
'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3539674557,3804837870&fm=26&gp=0.jpg',
],
'isLike': true,
'avatar': Image.asset('assets/example/touxiang2.png')
},
{
'name': '王管事',
'content': '智慧城市,共和社会',
'imageUrl': <String>[
'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2446247351,2922660058&fm=26&gp=0.jpg',
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1601274815221&di=3a50314a4d2c7188f6003f67d24177c2&imgtype=0&src=http%3A%2F%2Fimg1.cache.netease.com%2Fcatchpic%2F6%2F62%2F620DAF59053DF902F1D991EDBF14FD26.gif',
],
'isLike': false,
'avatar': Image.asset('assets/example/touxiang3.jpeg')
},
];
RefreshController _refreshController =
RefreshController(initialRefresh: false);
@override
void initState() {
super.initState();
}
void _onRefresh() async {
await Future.delayed(Duration(milliseconds: 1500));
_refreshController.refreshCompleted();
}
void _onLoading() async {
await Future.delayed(Duration(milliseconds: 1500));
if (mounted) setState(() {});
_refreshController.loadComplete();
}
@override
void dispose() {
super.dispose();
_refreshController.dispose();
}
@override
Widget build(BuildContext context) {
super.build(context);
return SmartRefresher(
controller: _refreshController,
header: WaterDropHeader(),
footer: ClassicFooter(),
onRefresh: _onRefresh,
onLoading: _onLoading,
enablePullUp: true,
child: Container(
color: Colors.white,
child: ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => widget.index == 0
? TrendCard(
name: _newsList[index]['name'],
content: _newsList[index]['content'],
imageUrl: _newsList[index]['imageUrl'],
isLike: _newsList[index]['isLike'],
avatar: _newsList[index]['avatar'])
: widget.index == 1
? TopicCard(
title: _topicList[index]['title'],
subtitle: _topicList[index]['subtitle'],
imagePath: _topicList[index]['imagePath'],
hotNum: _topicList[index]['hotNum'],
)
: Container(
margin: EdgeInsets.only(top: 32.w),
child: CircleTrend(
title: _circleList[index]['title'],
contentList: _circleList[index]['contentList'],
),
),
itemCount: widget.index == 0
? _newsList.length
: widget.index == 1
? _topicList.length
: _circleList.length,
),
),
);
}
}

@ -1,128 +0,0 @@
// Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:flutter_icons/flutter_icons.dart';
// Project imports:
import 'package:akuCommunity/pages/community/topice_detail_page.dart';
import 'package:akuCommunity/utils/headers.dart';
class TopicCard extends StatefulWidget {
final String title, subtitle, imagePath, hotNum;
TopicCard({Key key, this.title, this.subtitle, this.imagePath, this.hotNum})
: super(key: key);
@override
_TopicCardState createState() => _TopicCardState();
}
class _TopicCardState extends State<TopicCard> {
TextStyle _textStyleTitle() {
return TextStyle(fontSize: 28.sp, color: Color(0xff333333));
}
TextStyle _textStyleSubtitle() {
return TextStyle(fontSize: 22.sp, color: Color(0xff666666));
}
TextStyle _textStyleHot() {
return TextStyle(fontSize: 22.sp, color: Color(0xff333333));
}
void topiceDetailRouter(String subtitle, String imagePath) {
TopiceDetailPage().to();
}
Row _rowTopic(String title, String subtitle, String imagePath) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image.asset(
imagePath,
height: 160.w,
width: 250.w,
),
SizedBox(width: 12.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 383.w,
height: 80.w,
child: Text(
title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: _textStyleTitle(),
),
),
SizedBox(width: 10.w),
Container(
width: 365.w,
child: Text(
subtitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: _textStyleSubtitle(),
),
),
],
),
],
);
}
Positioned _positionedHot(String hotNum) {
return Positioned(
bottom: 0,
right: 0,
child: Row(
children: [
Icon(
MaterialIcons.whatshot,
color: Color(0xffd4270a),
size: 23.sp,
),
SizedBox(width: 10.w),
Text(
hotNum,
style: _textStyleHot(),
),
],
),
);
}
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
margin: EdgeInsets.only(
left: 32.w,
right: 32.w,
top: 20.w,
),
padding: EdgeInsets.all(20.w),
child: InkWell(
onTap: () {
topiceDetailRouter(
widget.subtitle,
widget.imagePath,
);
},
child: Stack(
children: [
_rowTopic(
widget.title,
widget.subtitle,
widget.imagePath,
),
_positionedHot(widget.hotNum),
],
),
),
);
}
}

@ -1,328 +0,0 @@
// Dart imports:
import 'dart:ui';
// Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart';
// Project imports:
import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/extensions/num_ext.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/expandable_text.dart';
import 'package:akuCommunity/widget/views/horizontal_image_view.dart';
class TrendCard extends StatefulWidget {
final String name;
final String content;
final List<String> imageUrl;
final bool isLike;
final Image avatar;
TrendCard(
{Key key,
this.name,
this.content,
this.imageUrl,
this.isLike,
this.avatar})
: super(key: key);
@override
_TrendCardState createState() => _TrendCardState();
}
class _TrendCardState extends State<TrendCard> {
bool _isLike;
@override
void initState() {
super.initState();
_isLike = widget.isLike ?? false;
}
TextStyle _textStyleName() {
return TextStyle(
fontSize: 36.sp,
color: Color(0xff333333),
);
}
TextStyle _textStyleContent() {
return TextStyle(
fontSize: 32.sp,
color: Color(0xff333333),
);
}
TextStyle _textStyleTag() {
return TextStyle(
fontSize: 28.sp,
color: Color(0xff999999),
);
}
void _showDeletDialog() {
showCupertinoDialog(
context: context,
builder: (context) {
return CupertinoAlertDialog(
title: '你确定删除吗?'.text.black.size(34.sp).isIntrinsic.make(),
actions: <Widget>[
CupertinoDialogAction(
child: '取消'.text.black.size(34.sp).isIntrinsic.make(),
onPressed: () {
Get.back();
},
),
CupertinoDialogAction(
child: '确定'
.text
.color(Color(0xFFFF8200))
.size(34.sp)
.isIntrinsic
.make(),
onPressed: () {
Get.back();
},
),
],
);
});
}
Widget _columnCard(String name, String content, Image avatar) {
return Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
children: [
Container(
width: 86.w,
height: 86.w,
child: avatar,
),
SizedBox(width: 9.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(left: 10.w),
child: Text(
name,
style: _textStyleName(),
),
),
SizedBox(height: 6.w),
Container(
padding: EdgeInsets.only(left: 14.w),
child: ExpandableText(
text: content,
maxLines: 2,
style: _textStyleContent(),
expand: false,
),
),
],
),
],
),
SizedBox(height: 20.w),
Padding(
padding: EdgeInsets.only(left: 95.w),
child: Column(
children: [
HorizontalImageView(widget.imageUrl),
SizedBox(height: 20.w),
Stack(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'1分钟前',
style: _textStyleTag(),
),
40.wb,
InkWell(
onTap: () {
_showDeletDialog();
},
child: '删除'.text.black.size(28.sp).make()),
],
),
],
),
],
),
),
],
),
Positioned(
right: 0,
bottom: 0,
child: Builder(
builder: (context) {
return InkWell(
onTap: () => BotToast.showAttachedWidget(
attachedBuilder: (CancelFunc cancelFunc) {
return Material(
child: Container(
decoration: BoxDecoration(
color: Color(0xFFD8D8D8),
borderRadius: BorderRadius.circular(8.w),
),
padding: EdgeInsets.symmetric(
vertical: 15.w, horizontal: 30.w),
width: 363.w,
height: 78.w,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: InkWell(
onTap: () {
_isLike = !_isLike;
cancelFunc();
setState(() {});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
_isLike
? AntDesign.heart
: AntDesign.hearto,
color: _isLike
? Color(0xffff6666)
: Colors.black,
size: 32.w,
),
10.wb,
''
.text
.color(ktextPrimary)
.size(28.sp)
.make(),
],
),
),
),
Expanded(
child: VerticalDivider(
width: 0,
thickness: 1.w,
color: Color(0xFF979797),
),
),
Expanded(
child: InkWell(
onTap: () {},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
CupertinoIcons.ellipses_bubble,
color: Colors.black,
size: 32.w,
),
10.wb,
'评论'
.text
.color(ktextPrimary)
.size(28.sp)
.make(),
],
),
),
),
],
),
),
);
},
preferDirection: PreferDirection.rightCenter,
targetContext: context,
),
child: Icon(
MaterialIcons.more,
color: Color(0xffd8d8d8),
),
);
},
),
),
Positioned(
top: 0,
right: 0,
child: PopupMenuButton<int>(
onSelected: (value) {
switch (value) {
case 0:
BotToast.showText(text: '举报成功');
break;
default:
}
},
padding: EdgeInsets.zero,
icon: Icon(
CupertinoIcons.chevron_down,
size: 25.w,
),
itemBuilder: (context) {
return [
PopupMenuItem(
value: 0,
child: Container(
width: 150.w,
height: 50.w,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
CupertinoIcons.exclamationmark_triangle,
size: 50.w,
),
10.wb,
'举报'.text.black.size(30.sp).make()
],
),
),
)
];
},
),
),
],
);
}
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border(
bottom: BorderSide(
width: 0.5, //
color: Color(0xffe5e5e5), //
),
),
),
padding: EdgeInsets.only(
top: 46.w,
left: 32.w,
bottom: 22.w,
right: 32.w,
),
child: _columnCard(widget.name, widget.content, widget.avatar));
}
}

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

@ -45,17 +45,7 @@ class _EventDetailPageState extends State<EventDetailPage> {
: ListView(
children: [
ChatCard(
initLike: _model.isLike == 1,
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,
model:_model,
hideLine: true,
canTap: false,
),

@ -45,17 +45,7 @@ class NewCommunityViewState extends State<NewCommunityView>
itemBuilder: (context, index) {
final item = items[index] as EventItemModel;
return ChatCard(
content: item.content,
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,
model: item,
onDelete: () {
_refreshController.callRefresh();
},

@ -64,20 +64,10 @@ class _TopicDetailPageState extends State<TopicDetailPage> {
(context, index) {
final item = items[index] as EventItemModel;
return ChatCard(
initLike: item.isLike == 1,
themeId: item.id,
content: item.content,
name: item.createName,
topic: item.gambitTitle,
headImg: item.headSculptureImgUrl,
contentImg: item.imgUrls,
date: item.date,
id: item.createId,
model:item,
onDelete: () {
_refreshController.callRefresh();
},
comments: item.gambitThemeCommentVoList,
likeNames: item.likeNames,
);
},
childCount: items.length,

@ -1,4 +1,5 @@
// Flutter imports:
import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/model/community/event_item_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -11,7 +12,6 @@ import 'package:velocity_x/velocity_x.dart';
// Project imports:
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:akuCommunity/provider/user_provider.dart';
import 'package:akuCommunity/ui/community/community_views/event_detail_page.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';
class ChatCard extends StatefulWidget {
final String name;
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 EventItemModel model;
final VoidCallback onDelete;
final List<GambitThemeCommentVoList> comments;
final List<LikeNames> likeNames;
final bool hideLine;
final bool canTap;
ChatCard({
Key key,
@required this.name,
@required this.topic,
@required this.headImg,
@required this.contentImg,
@required this.date,
@required this.initLike,
@required this.id,
@required this.content,
@required this.themeId,
@required this.model,
this.onDelete,
@required this.comments,
this.hideLine = false,
@required this.likeNames,
this.canTap = true,
}) : super(key: key);
@ -65,23 +41,22 @@ class ChatCard extends StatefulWidget {
}
class _ChatCardState extends State<ChatCard> {
bool _like = false;
bool get _isMyself {
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 {
if (widget.headImg == null || widget.headImg.isEmpty)
if (widget.model.headSculptureImgUrl == null ||
widget.model.headSculptureImgUrl.isEmpty)
return '';
else
return widget.headImg.first.url;
return widget.model.headSculptureImgUrl.first.url;
}
_renderImage() {
if (widget.contentImg.isEmpty) return SizedBox();
if (widget.contentImg.length == 1)
if (widget.model.imgUrls.isEmpty) return SizedBox();
if (widget.model.imgUrls.length == 1)
return MaterialButton(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
padding: EdgeInsets.zero,
@ -91,7 +66,7 @@ class _ChatCardState extends State<ChatCard> {
),
onPressed: () {
Get.to(
BeeImagePreview.path(path: widget.contentImg.first.url),
BeeImagePreview.path(path: widget.model.imgUrls.first.url),
opaque: false,
);
},
@ -101,17 +76,17 @@ class _ChatCardState extends State<ChatCard> {
maxWidth: 300.w,
),
child: Hero(
tag: widget.contentImg.first.url,
tag: widget.model.imgUrls.first.url,
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(widget.contentImg.first.url),
image: API.image(widget.model.imgUrls.first.url),
),
),
),
);
else
return BeeGridImageView(
urls: widget.contentImg.map((e) => e.url).toList());
urls: widget.model.imgUrls.map((e) => e.url).toList());
}
_buildMoreButton() {
@ -150,15 +125,16 @@ class _ChatCardState extends State<ChatCard> {
cancel();
await NetUtil().get(
API.community.like,
params: {'themeId': widget.themeId},
params: {'themeId': widget.model.id},
showMessage: true,
);
setState(() {
_like = !_like;
widget.model.isLike =
(widget.model.isLike == 1) ? 0 : 1;
});
},
child: [
_like
widget.model.isLike == 1
? Icon(Icons.favorite,
size: 30.w, color: Colors.red)
: Icon(Icons.favorite_border, size: 30.w),
@ -221,7 +197,7 @@ class _ChatCardState extends State<ChatCard> {
children: [
Icon(Icons.favorite_border_rounded, size: 24.w),
14.wb,
...widget.likeNames
...widget.model.likeNames
.map((e) => e.name.text.make())
.toList()
.sepWidget(separate: ','.text.make()),
@ -232,17 +208,49 @@ class _ChatCardState extends State<ChatCard> {
_renderComment() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: widget.comments.map((e) {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: widget.model.gambitThemeCommentVoList.map((e) {
StringBuffer buffer = StringBuffer();
buffer.write(e.createName);
if (e.parentName != null) buffer.write('回复${e.parentName}');
buffer.write(':${e.content}');
return buffer.toString().text.make();
return InkWell(
child: buffer.toString().text.make(),
onTap: () {
addComment();
},
);
}).toList(),
);
}
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() {
return Material(
borderRadius: BorderRadius.circular(8.w),
@ -253,23 +261,20 @@ class _ChatCardState extends State<ChatCard> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
widget.likeNames.isEmpty ? SizedBox() : _renderLike(),
(widget.likeNames.isNotEmpty && widget.comments.isNotEmpty)
widget.model.likeNames.isEmpty ? SizedBox() : _renderLike(),
(widget.model.likeNames.isNotEmpty &&
widget.model.gambitThemeCommentVoList.isNotEmpty)
? Divider(height: 1.w, thickness: 1.w)
: SizedBox(),
widget.comments.isEmpty ? SizedBox() : _renderComment(),
widget.model.gambitThemeCommentVoList.isEmpty
? SizedBox()
: _renderComment(),
],
),
),
);
}
@override
void initState() {
super.initState();
_like = widget.initLike ?? false;
}
@override
Widget build(BuildContext context) {
return DecoratedBox(
@ -285,7 +290,7 @@ class _ChatCardState extends State<ChatCard> {
padding: EdgeInsets.zero,
onPressed: widget.canTap
? () {
Get.to(EventDetailPage(themeId: widget.themeId));
Get.to(EventDetailPage(themeId: widget.model.id));
}
: null,
child: Row(
@ -306,15 +311,18 @@ class _ChatCardState extends State<ChatCard> {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
widget.name.text.black.size(36.sp).make(),
widget.model.createName.text.black.size(36.sp).make(),
6.hb,
widget.content.text.black.make(),
widget.model.content.text.black.make(),
20.hb,
_renderImage(),
widget.topic?.isEmpty ?? true
widget.model.gambitTitle?.isEmpty ?? true
? SizedBox()
: Chip(
label: '#${widget.topic}'.text.size(22.sp).make(),
label: '#${widget.model.gambitTitle}'
.text
.size(22.sp)
.make(),
padding: EdgeInsets.symmetric(
horizontal: 16.w, vertical: 5.w),
labelPadding: EdgeInsets.zero,
@ -326,7 +334,7 @@ class _ChatCardState extends State<ChatCard> {
Row(
children: [
64.hb,
BeeDateUtil(widget.date)
BeeDateUtil(widget.model.date)
.timeAgo
.text
.size(28.sp)
@ -360,7 +368,7 @@ class _ChatCardState extends State<ChatCard> {
if (result == true) {
await NetUtil().get(
API.community.deleteMyEvent,
params: {'themeId': widget.themeId},
params: {'themeId': widget.model.id},
showMessage: true,
);
if (widget.onDelete != null) widget.onDelete();

@ -609,6 +609,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.4"
jpush_flutter:
dependency: "direct main"
description:
name: jpush_flutter
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.3"
js:
dependency: transitive
description:

@ -95,6 +95,7 @@ dependencies:
git:
url: http://192.168.2.201:8099/aku_fe/power_logger.git
flutter_rating_bar: ^3.2.0+1
jpush_flutter: ^0.6.3
dev_dependencies:
flutter_test:

Loading…
Cancel
Save