|
@@ -6,6 +6,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
import 'package:sport/bean/login.dart';
|
|
|
import 'package:sport/bean/post_user.dart';
|
|
|
import 'package:sport/bean/user_friend.dart';
|
|
|
+import 'package:sport/bean/user_info.dart';
|
|
|
import 'package:sport/pages/social/chat_page.dart';
|
|
|
import 'package:sport/pages/social/user_detail_page.dart';
|
|
|
import 'package:sport/pages/social/user_friend_add_page.dart';
|
|
@@ -161,18 +162,46 @@ class _PageDetailPage extends StatefulWidget {
|
|
|
}
|
|
|
|
|
|
class _PageDetailState
|
|
|
- extends ViewStateLifecycle<_PageDetailPage, UserFriendModel> {
|
|
|
+ extends ViewStateLifecycle<_PageDetailPage, UserFriendModel>
|
|
|
+ with ChangeNotifier {
|
|
|
TextEditingController _controller;
|
|
|
FocusNode _focusNode;
|
|
|
ValueNotifier<String> _searchValue = ValueNotifier<String>("");
|
|
|
-
|
|
|
+ bool isSeach = false;
|
|
|
_PageDetailState(int type);
|
|
|
-
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
_focusNode = FocusNode();
|
|
|
_controller = new TextEditingController(text: '');
|
|
|
+ // 监听 ...
|
|
|
+ _controller.addListener(() {
|
|
|
+ if (_controller.value.text != "") {
|
|
|
+ if (widget.type == 0) {
|
|
|
+ model.items = model.originItems
|
|
|
+ .where(
|
|
|
+ (element) => element.user.name.indexOf(_controller.text) > -1)
|
|
|
+ .toList();
|
|
|
+ setState(() {
|
|
|
+ isSeach = true;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ model.list = model.originList
|
|
|
+ .where((element) => element.name.indexOf(_controller.text) > -1)
|
|
|
+ .toList();
|
|
|
+ }
|
|
|
+ notifyListeners();
|
|
|
+ } else {
|
|
|
+ if (widget.type == 0) {
|
|
|
+ setState(() {
|
|
|
+ isSeach = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ model.items = model.originItems;
|
|
|
+ model.list = model.originList;
|
|
|
+ notifyListeners();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@override
|
|
@@ -195,88 +224,150 @@ class _PageDetailState
|
|
|
Space(
|
|
|
height: 16.0,
|
|
|
),
|
|
|
- Expanded(
|
|
|
- child: AzListView(
|
|
|
- data: model.items,
|
|
|
- susItemHeight: 200,
|
|
|
- itemCount: model.items.length,
|
|
|
- indexBarData: model.items
|
|
|
- .map((e) => "${e.getSuspensionTag()}")
|
|
|
- .toList(),
|
|
|
- itemBuilder: (BuildContext context, int index) {
|
|
|
- return ListTile(
|
|
|
- leading: Container(
|
|
|
- width: 44,
|
|
|
- height: 44,
|
|
|
- decoration: BoxDecoration(
|
|
|
- shape: BoxShape.rectangle,
|
|
|
- borderRadius: BorderRadius.circular(4.0),
|
|
|
- image: DecorationImage(
|
|
|
- image: CachedNetworkImageProvider(
|
|
|
- model.items[index].user.avatar,
|
|
|
- )),
|
|
|
- ),
|
|
|
- ),
|
|
|
- title: Text("${model.items[index].user.name}"),
|
|
|
- onTap: () {},
|
|
|
- );
|
|
|
- },
|
|
|
- physics: BouncingScrollPhysics(),
|
|
|
- padding: EdgeInsets.zero,
|
|
|
- susItemBuilder: (BuildContext context, int index) {
|
|
|
- return Column(
|
|
|
- children: <Widget>[
|
|
|
- Container(
|
|
|
-// height: 40,
|
|
|
- width: MediaQuery.of(context).size.width,
|
|
|
- padding: EdgeInsets.only(left: 16.0),
|
|
|
-// color: Color(0xFFF3F4F5),
|
|
|
- alignment: Alignment.centerLeft,
|
|
|
- child: Text(
|
|
|
- '${model.items[index].getSuspensionTag()}',
|
|
|
- softWrap: false,
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 14.0,
|
|
|
- color: Color(0xff9999999),
|
|
|
+ isSeach
|
|
|
+ ? model.items.length > 0
|
|
|
+ ? Expanded(
|
|
|
+ child: ListView.builder(
|
|
|
+ itemBuilder: (context, index) => ListTile(
|
|
|
+ leading: InkWell(
|
|
|
+ child: Container(
|
|
|
+ width: 44,
|
|
|
+ height: 44,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ shape: BoxShape.rectangle,
|
|
|
+ borderRadius:
|
|
|
+ BorderRadius.circular(4.0),
|
|
|
+ image: DecorationImage(
|
|
|
+ image: CachedNetworkImageProvider(
|
|
|
+ model.items[index].user.avatar,
|
|
|
+ )),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ onTap: () {
|
|
|
+ NavigatorUtil.goPage(
|
|
|
+ context,
|
|
|
+ (context) => UserDetailPage(
|
|
|
+ PostUser.fromJson({
|
|
|
+ "id":
|
|
|
+ "${model.items[index].user.uid}"
|
|
|
+ })));
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ title:
|
|
|
+ Text("${model.items[index].user.name}"),
|
|
|
+ onTap: () {
|
|
|
+ NavigatorUtil.goPage(
|
|
|
+ context,
|
|
|
+ (context) => ChatPage(
|
|
|
+ UserInfo.fromJson(model
|
|
|
+ .items[index].user
|
|
|
+ .toJson())));
|
|
|
+ },
|
|
|
),
|
|
|
+ itemCount: model.items.length,
|
|
|
),
|
|
|
- ),
|
|
|
- Divider(
|
|
|
- indent: 12.0,
|
|
|
- endIndent: 12.0,
|
|
|
- ),
|
|
|
- ],
|
|
|
- );
|
|
|
- },
|
|
|
- indexBarOptions: IndexBarOptions(
|
|
|
- needRebuild: true,
|
|
|
- ignoreDragCancel: true,
|
|
|
- textStyle: TextStyle(
|
|
|
- color: Color(0xff999999), fontSize: 12.0),
|
|
|
- selectTextStyle: TextStyle(
|
|
|
- fontSize: 20,
|
|
|
- color: Theme.of(context).accentColor),
|
|
|
+ )
|
|
|
+ : _searchNothings()
|
|
|
+ : Expanded(
|
|
|
+ child: AzListView(
|
|
|
+ data: model.items,
|
|
|
+ susItemHeight: 200,
|
|
|
+ itemCount: model.items.length,
|
|
|
+ indexBarData:
|
|
|
+ model.tags.map((e) => "$e").toList(),
|
|
|
+ itemBuilder: (BuildContext context, int index) {
|
|
|
+ return ListTile(
|
|
|
+ leading: InkWell(
|
|
|
+ child: Container(
|
|
|
+ width: 44,
|
|
|
+ height: 44,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ shape: BoxShape.rectangle,
|
|
|
+ borderRadius:
|
|
|
+ BorderRadius.circular(4.0),
|
|
|
+ image: DecorationImage(
|
|
|
+ image: CachedNetworkImageProvider(
|
|
|
+ model.items[index].user.avatar,
|
|
|
+ )),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ onTap: () {
|
|
|
+ NavigatorUtil.goPage(
|
|
|
+ context,
|
|
|
+ (context) => UserDetailPage(
|
|
|
+ PostUser.fromJson({
|
|
|
+ "id":
|
|
|
+ "${model.items[index].user.uid}"
|
|
|
+ })));
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ title:
|
|
|
+ Text("${model.items[index].user.name}"),
|
|
|
+ onTap: () {
|
|
|
+ NavigatorUtil.goPage(
|
|
|
+ context,
|
|
|
+ (context) => ChatPage(UserInfo.fromJson(
|
|
|
+ model.items[index].user.toJson())));
|
|
|
+ },
|
|
|
+ );
|
|
|
+ },
|
|
|
+ physics: BouncingScrollPhysics(),
|
|
|
+ padding: EdgeInsets.zero,
|
|
|
+ susItemBuilder:
|
|
|
+ (BuildContext context, int index) {
|
|
|
+ return Column(
|
|
|
+ children: <Widget>[
|
|
|
+ Container(
|
|
|
+// height: 40,
|
|
|
+ width: MediaQuery.of(context).size.width,
|
|
|
+ padding: EdgeInsets.only(left: 16.0),
|
|
|
+// color: Color(0xFFF3F4F5),
|
|
|
+ alignment: Alignment.centerLeft,
|
|
|
+ child: Text(
|
|
|
+ '${model.items[index].getSuspensionTag()}',
|
|
|
+ softWrap: false,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 14.0,
|
|
|
+ color: Color(0xff9999999),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Divider(
|
|
|
+ indent: 12.0,
|
|
|
+ endIndent: 12.0,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ },
|
|
|
+ indexBarOptions: IndexBarOptions(
|
|
|
+ needRebuild: true,
|
|
|
+ ignoreDragCancel: true,
|
|
|
+ textStyle: TextStyle(
|
|
|
+ color: Color(0xff999999), fontSize: 12.0),
|
|
|
+ selectTextStyle: TextStyle(
|
|
|
+ fontSize: 20,
|
|
|
+ color: Theme.of(context).accentColor),
|
|
|
// downTextStyle: TextStyle(fontSize: 12, color: Theme.of(context).accentColor),
|
|
|
// selectItemDecoration: BoxDecoration(color: Colors.green),
|
|
|
// downItemDecoration:
|
|
|
// BoxDecoration(color: Colors.green),
|
|
|
- indexHintWidth: 33,
|
|
|
- indexHintHeight: 33,
|
|
|
- indexHintDecoration: BoxDecoration(
|
|
|
- image: DecorationImage(
|
|
|
- image: AssetImage(
|
|
|
- "lib/assets/img/friendlist_bg_letter.png"),
|
|
|
- fit: BoxFit.contain,
|
|
|
+ indexHintWidth: 33,
|
|
|
+ indexHintHeight: 33,
|
|
|
+ indexHintDecoration: BoxDecoration(
|
|
|
+ image: DecorationImage(
|
|
|
+ image: AssetImage(
|
|
|
+ "lib/assets/img/friendlist_bg_letter.png"),
|
|
|
+ fit: BoxFit.contain,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ indexHintTextStyle: TextStyle(
|
|
|
+ fontSize: 18.0, color: Colors.white),
|
|
|
+ indexHintAlignment: Alignment.centerRight,
|
|
|
+ indexHintChildAlignment: Alignment(-0.25, 0.0),
|
|
|
+ indexHintOffset: Offset(0, 0),
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
- indexHintTextStyle:
|
|
|
- TextStyle(fontSize: 18.0, color: Colors.white),
|
|
|
- indexHintAlignment: Alignment.centerRight,
|
|
|
- indexHintChildAlignment: Alignment(-0.25, 0.0),
|
|
|
- indexHintOffset: Offset(0, 0),
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
],
|
|
|
)
|
|
|
: EasyRefresh.custom(
|
|
@@ -295,14 +386,19 @@ class _PageDetailState
|
|
|
SliverToBoxAdapter(
|
|
|
child: RequestLoadingWidget(),
|
|
|
),
|
|
|
- SliverList(
|
|
|
- delegate: SliverChildBuilderDelegate(
|
|
|
- (context, index) {
|
|
|
- return _buildItem(model.list[index]);
|
|
|
- },
|
|
|
- childCount: model.list.length,
|
|
|
+ if (model.list.length > 0)
|
|
|
+ SliverList(
|
|
|
+ delegate: SliverChildBuilderDelegate(
|
|
|
+ (context, index) {
|
|
|
+ return _buildItem(model.list[index]);
|
|
|
+ },
|
|
|
+ childCount: model.list.length,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ if (model.list.length <= 0)
|
|
|
+ SliverToBoxAdapter(
|
|
|
+ child: _searchNothings(),
|
|
|
),
|
|
|
- ),
|
|
|
if (model.isError)
|
|
|
SliverToBoxAdapter(
|
|
|
child: RequestErrorWidget(
|
|
@@ -366,11 +462,7 @@ class _PageDetailState
|
|
|
)
|
|
|
: TextSpan(
|
|
|
text: '通过扫码',
|
|
|
- style: Theme.of(context)
|
|
|
- .textTheme
|
|
|
- .bodyText1
|
|
|
- .copyWith(
|
|
|
- color: Theme.of(context).accentColor),
|
|
|
+ style: Theme.of(context).textTheme.bodyText1,
|
|
|
),
|
|
|
TextSpan(
|
|
|
text: "关注了你",
|
|
@@ -435,16 +527,11 @@ class _PageDetailState
|
|
|
? Container(
|
|
|
width: 64,
|
|
|
height: 30,
|
|
|
- margin: _padding,
|
|
|
+// margin: _padding,
|
|
|
alignment: Alignment.center,
|
|
|
- child: Text(
|
|
|
- "已关注",
|
|
|
- strutStyle: fixedLine,
|
|
|
- style: Theme.of(context)
|
|
|
- .textTheme
|
|
|
- .bodyText2
|
|
|
- .copyWith(color: Theme.of(context).accentColor),
|
|
|
- ),
|
|
|
+ child: Text("已关注",
|
|
|
+ strutStyle: fixedLine,
|
|
|
+ style: Theme.of(context).textTheme.bodyText2),
|
|
|
)
|
|
|
: GestureDetector(
|
|
|
child: Container(
|
|
@@ -517,9 +604,27 @@ class _PageDetailState
|
|
|
? Text("已关注",
|
|
|
style:
|
|
|
TextStyle(fontSize: 14.0, color: Color(0xff999999)))
|
|
|
- : Text("关注",
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 14.0, color: Color(0xff999999))),
|
|
|
+ : Container(
|
|
|
+ width: 64,
|
|
|
+ height: 30,
|
|
|
+ margin: _padding,
|
|
|
+ alignment: Alignment.center,
|
|
|
+ child: Text(
|
|
|
+ "关注",
|
|
|
+ strutStyle: fixedLine,
|
|
|
+ style: Theme.of(context)
|
|
|
+ .textTheme
|
|
|
+ .bodyText2
|
|
|
+ .copyWith(color: Theme.of(context).accentColor),
|
|
|
+ ),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.circular(20),
|
|
|
+ border: Border.all(
|
|
|
+ color: Theme.of(context).accentColor,
|
|
|
+ width: .5,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
// Container(
|
|
|
// width: 82,
|
|
|
// height: 30,
|
|
@@ -566,7 +671,7 @@ class _PageDetailState
|
|
|
// });
|
|
|
// }
|
|
|
});
|
|
|
- } else {
|
|
|
+ } else if (flag == null) {
|
|
|
await request(context, () async {
|
|
|
var resp = await model.api
|
|
|
.userFollow(uid: user?.socialInfo?.id)
|
|
@@ -583,39 +688,8 @@ class _PageDetailState
|
|
|
)
|
|
|
],
|
|
|
);
|
|
|
- } else {
|
|
|
-// child = Row(
|
|
|
-// children: <Widget>[
|
|
|
-// CircleAvatar(
|
|
|
-// backgroundImage: userAvatarProvider(user?.socialInfo?.avatar),
|
|
|
-// radius: 22,
|
|
|
-// ),
|
|
|
-// SizedBox(
|
|
|
-// width: 8,
|
|
|
-// ),
|
|
|
-// Expanded(
|
|
|
-// child: Column(
|
|
|
-// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
-// children: <Widget>[
|
|
|
-// Text(
|
|
|
-// "${user?.socialInfo?.name}",
|
|
|
-// style: Theme.of(context)
|
|
|
-// .textTheme
|
|
|
-// .headline3
|
|
|
-// .copyWith(fontWeight: FontWeight.normal),
|
|
|
-// ),
|
|
|
-// SizedBox(
|
|
|
-// height: 5,
|
|
|
-// ),
|
|
|
-// Text(
|
|
|
-// "${DateFormat.formatCreateAt(user?.updatedAt)}在线",
|
|
|
-// style: Theme.of(context).textTheme.bodyText1,
|
|
|
-// ),
|
|
|
-// ],
|
|
|
-// ),
|
|
|
-// ),
|
|
|
-// ],
|
|
|
-// );
|
|
|
+ } else if (widget.type == 4) {
|
|
|
+// child = ListView.separated(itemBuilder: ()=>, itemCount: );
|
|
|
}
|
|
|
// return Column(
|
|
|
// children: <Widget>[
|
|
@@ -736,6 +810,28 @@ class _PageDetailState
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ Widget _searchNothings() {
|
|
|
+ return Column(
|
|
|
+ mainAxisSize: MainAxisSize.min,
|
|
|
+ children: <Widget>[
|
|
|
+ Padding(
|
|
|
+ padding: const EdgeInsets.fromLTRB(0, 50, 0, 0),
|
|
|
+ child: Image.asset("lib/assets/img/emptypage-image-nonetwork.png"),
|
|
|
+ ),
|
|
|
+ Padding(
|
|
|
+ padding: const EdgeInsets.fromLTRB(0, 12, 0, 12),
|
|
|
+ child: Text(
|
|
|
+ "搜索无果",
|
|
|
+ style: Theme.of(context).textTheme.bodyText2,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ SizedBox(
|
|
|
+ height: 100,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
UserFriendModel createModel() => UserFriendModel(widget.type);
|
|
|
}
|