123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- import 'package:flutter/material.dart';
- import 'package:liftmanager/internal/bbs/page/chat_room.dart';
- import 'package:liftmanager/internal/bbs/page/jubao_page.dart';
- import 'package:liftmanager/net/api_service.dart';
- import 'package:liftmanager/res/iconfont.dart';
- import 'package:liftmanager/utils/toast.dart';
- import 'package:liftmanager/widgets/app_bar.dart';
- import 'package:liftmanager/routers/fluro_navigator.dart';
- import 'package:liftmanager/widgets/load_image.dart';
- import 'package:liftmanager/internal/friends/model/near_model.dart';
- import 'package:liftmanager/internal/bbs/bbs_router.dart';
- import '../friends_router.dart';
- import 'package:liftmanager/internal/friends/model/friend_model.dart';
- class NearDetail extends StatefulWidget {
- final NearModel model;
- final Records friendModel;
- const NearDetail({Key key, this.model, this.friendModel}) : super(key: key);
- @override
- State<StatefulWidget> createState() {
- return NearDetailState();
- }
- }
- class NearDetailState extends State<NearDetail> {
- ScrollController _scrollController = new ScrollController();
- String targetUserId;
- int distance;
- String avatarUrl;
- String name;
- void initState() {
- super.initState();
- targetUserId = widget.model != null
- ? widget.model.userId.toString()
- : widget.friendModel.targetUserId;
- distance = widget.model != null ? widget.model.distance : null;
- avatarUrl = widget.model != null
- ? widget.model.avatarUrl
- : widget.friendModel.avatarUrl;
- name = widget.model != null
- ? widget.model.remarks ?? widget.model.name
- : widget.friendModel.remarks ?? widget.friendModel.userName;
- }
- Future createPrivateChatRoom(id) async {
- await NewApiService().createPrivateChatRoom(id.toString(),
- onSuccess: (res) async {
- print(res["room"]);
- String roomId = res["room"];
- await Navigator.push(
- context,
- MaterialPageRoute(
- builder: (_) => ChatDetailPage(
- id: roomId,
- type: 'nearToOne',
- toUserId: id,
- title: name,
- jubaoToUserId: widget.friendModel?.targetUserId,
- ),
- ),
- );
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- @override
- void dispose() {
- _scrollController.dispose();
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- double width = MediaQuery.of(context).size.width;
- return Scaffold(
- appBar: MyAppBar(
- centerTitle: widget.model != null ? "附近的人" : '圈子',
- ),
- body: Container(
- child: Column(children: <Widget>[
- SizedBox(
- height: 10,
- ),
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- SizedBox(width: 10),
- ClipRRect(
- borderRadius: BorderRadius.all(Radius.circular(29)),
- child: LoadNetworkImage(
- avatarUrl,
- width: 57,
- height: 57,
- // alignment: Alignment.centerLeft,
- ),
- ),
- SizedBox(width: 10),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- name ?? "",
- style: TextStyle(
- fontSize: 16,
- color: Colors.black,
- ),
- textAlign: TextAlign.start,
- ),
- if (distance != null)
- Text(
- '距离: $distance 米以内',
- style:
- TextStyle(color: Color(0xff666666), fontSize: 13),
- textAlign: TextAlign.start,
- ),
- ],
- ),
- ),
- ],
- ),
- SizedBox(
- height: 20,
- ),
- Divider(
- height: 0.5,
- thickness: 0.5,
- color: Color(0xffF8F8F8),
- ),
- GestureDetector(
- onTap: () async {
- if (widget.model != null) {
- NavigatorUtils.pushResult(context,
- "${FriendsRouter.remarks}?id=${targetUserId}&remarks=${Uri.encodeComponent(widget.model.remarks ?? '')}",
- (res) {
- setState(() {
- widget.model.remarks = res;
- name = res;
- });
- });
- } else {
- NavigatorUtils.pushResult(context,
- "${FriendsRouter.remarks}?id=${targetUserId}&remarks=${Uri.encodeComponent(widget.friendModel.remarks ?? '')}",
- (res) {
- setState(() {
- widget.friendModel.remarks = res;
- name = res;
- });
- });
- }
- },
- child: Container(
- color: Colors.white,
- height: 50,
- child: Row(
- children: [
- SizedBox(
- width: 10,
- ),
- Text(
- '备注名',
- style: TextStyle(
- color: Color(0xff333333),
- fontSize: 14,
- ),
- ),
- Spacer(),
- Icon(
- Iconfont.gengduo,
- color: Color(0xffcccccc),
- size: 14,
- ),
- SizedBox(
- width: 10,
- ),
- ],
- ),
- ),
- ),
- GestureDetector(
- onTap: () async {
- Navigator.of(context).push(MaterialPageRoute(
- builder: (context) => JuBaoPage(
- toUserId: widget.friendModel.targetUserId,
- )));
- },
- child: Container(
- color: Colors.white,
- height: 50,
- child: Row(
- children: [
- SizedBox(
- width: 10,
- ),
- Text(
- '举报',
- style: TextStyle(
- color: Color(0xff333333),
- fontSize: 14,
- ),
- ),
- Spacer(),
- Icon(
- Iconfont.gengduo,
- color: Color(0xffcccccc),
- size: 14,
- ),
- SizedBox(
- width: 10,
- ),
- ],
- ),
- ),
- ),
- Divider(
- height: 5,
- thickness: 5,
- color: Color(0xffF8F8F8),
- ),
- FlatButton(
- height: 50,
- child: Text(widget.model != null ? "打招呼" : "发消息"),
- textColor: Color(0xff5589FF),
- onPressed: () async {
- if (widget.model != null) {
- createPrivateChatRoom(targetUserId);
- } else {
- if (widget.friendModel.dataTable == 3) {
- await Navigator.push(
- context,
- MaterialPageRoute(
- builder: (_) => ChatDetailPage(
- id: widget.friendModel.sessionid,
- type: 'nearToOne',
- toUserId: widget.friendModel.userId,
- jubaoToUserId: widget.friendModel.targetUserId,
- title: widget.friendModel.remarks ??
- widget.friendModel.userName),
- ),
- );
- }
- }
- },
- ),
- Expanded(
- child: Container(
- color: Color(0xfff8f8f8),
- ),
- )
- ]),
- ),
- );
- }
- }
|