diff --git a/circle_app/lib/app/aboutapp/logic.dart b/circle_app/lib/app/aboutapp/logic.dart index b6a46d7..2b3d5cb 100644 --- a/circle_app/lib/app/aboutapp/logic.dart +++ b/circle_app/lib/app/aboutapp/logic.dart @@ -1,5 +1,5 @@ import 'package:dio/dio.dart'; -import 'package:flutter_install_app/flutter_install_app.dart'; +// import 'package:flutter_install_app/flutter_install_app.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; @@ -42,7 +42,7 @@ class AboutappLogic extends GetxController { // SmartDialog.dismiss(); // print(error); // }); - await AppInstaller.installApk(filePath, actionRequired: false); + // await AppInstaller.installApk(filePath, actionRequired: false); } diff --git a/circle_app/lib/app/call_out/logic.dart b/circle_app/lib/app/call_out/logic.dart index f66f695..26af3e4 100644 --- a/circle_app/lib/app/call_out/logic.dart +++ b/circle_app/lib/app/call_out/logic.dart @@ -130,7 +130,7 @@ class Call_outLogic extends GetxController { 'album': myBean, 'content': textEditingController.text, 'interest_id': numbers[0].id, - 'useQueen': isCheck, + 'use_queen': isCheck ? 1 : 0, }); var beandata = BaseResponse.fromJson( diff --git a/circle_app/lib/app/circle/binding.dart b/circle_app/lib/app/circle/binding.dart new file mode 100644 index 0000000..bc5c673 --- /dev/null +++ b/circle_app/lib/app/circle/binding.dart @@ -0,0 +1,10 @@ +import 'package:get/get.dart'; + +import 'logic.dart'; + +class CircleBinding extends Bindings { + @override + void dependencies() { + Get.put(() => CircleLogic()); + } +} diff --git a/circle_app/lib/app/circle/state.dart b/circle_app/lib/app/circle/state.dart index e5abebc..ed2aadf 100644 --- a/circle_app/lib/app/circle/state.dart +++ b/circle_app/lib/app/circle/state.dart @@ -14,7 +14,8 @@ class Lists { int? id; bool? isQueen; User? user; - + Map? interest; + String? create_time; Lists( {this.album, this.chat, this.content, this.id, this.isQueen, this.user}); @@ -28,6 +29,8 @@ class Lists { chat = json['chat'] != null ? new Chat.fromJson(json['chat']) : null; content = json['content']; id = json['id']; + interest = json['interest'] ?? {}; + create_time = json['create_time'] ?? ''; isQueen = json['is_queen']; user = json['user'] != null ? new User.fromJson(json['user']) : null; } @@ -53,12 +56,14 @@ class Lists { class Album { int? type; String? url; + String? create_time; Album({this.type, this.url}); Album.fromJson(Map json) { type = json['type']; url = json['url']; + create_time = json['create_time'] ?? ''; } Map toJson() { diff --git a/circle_app/lib/app/circle/view.dart b/circle_app/lib/app/circle/view.dart index c0de636..98d6720 100644 --- a/circle_app/lib/app/circle/view.dart +++ b/circle_app/lib/app/circle/view.dart @@ -152,14 +152,17 @@ class _CirclePageState extends State fontSize: 18.sp, fontWeight: FontWeight.w600, color: Colors.white, - shadows: [ - Shadow(color: Color(0xffF657FF), offset: Offset(0.0, -1)) + shadows: const [ + Shadow(color: Color(0xffF657FF), offset: Offset(0.0, -1)) ]), ), ), Positioned( right: 0, child: GestureDetector( + onTap: () { + Get.toNamed(AppRoutes.MyCircle,arguments: ''); + }, child: Image.asset( getCircleImage('my_circle'), width: 64.sp, diff --git a/circle_app/lib/app/circle/widgets/info_list_view.dart b/circle_app/lib/app/circle/widgets/info_list_view.dart index b76bbdd..c6bb168 100644 --- a/circle_app/lib/app/circle/widgets/info_list_view.dart +++ b/circle_app/lib/app/circle/widgets/info_list_view.dart @@ -16,7 +16,7 @@ import 'package:get/get.dart'; class InfoListView extends StatefulWidget { // Get.lazyPut(() => ListLogic()); - CircleLogic logic; + var logic; Circle bean; int index; @@ -454,7 +454,19 @@ class _InfoListViewState extends State { Positioned( right: 2.sp, top: 2.sp, - child: Image.asset(getCircleImage('location')), + child:Stack( + alignment: Alignment.center, + children: [ + Image.asset( + getCircleImage('location'), + height: 20.sp, + ), + Text( + lists.user!.city ?? '外星', + style: TextStyle(color: Colors.white, fontSize: 12.sp), + ) + ], + ), height: 18.sp, ), Container( @@ -478,7 +490,7 @@ class _InfoListViewState extends State { ), GestureDetector( onTap: () { - listsLg?.pushMsgPage( + listsLg?.pushHomePage( lists, lists.id.toString()); }, child: ClipOval( @@ -647,7 +659,7 @@ class _InfoListViewState extends State { )), GestureDetector( onTap: () { - listsLg?.pushMsgPage( + listsLg?.pushHomePage( lists, widget.bean.id.toString()); }, child: Image.asset( @@ -762,7 +774,7 @@ class _InfoListViewState extends State { ), GestureDetector( onTap: () { - listsLg?.pushMsgPage( + listsLg?.pushHomePage( lists, widget.bean.id.toString()); }, child: ClipOval( @@ -938,7 +950,7 @@ class _InfoListViewState extends State { )), GestureDetector( onTap: () { - listsLg?.pushMsgPage( + listsLg?.pushHomePage( lists, widget.bean.id.toString()); }, child: Image.asset( diff --git a/circle_app/lib/app/circle/widgets/list_logic.dart b/circle_app/lib/app/circle/widgets/list_logic.dart index 7d21773..dcbe7b3 100644 --- a/circle_app/lib/app/circle/widgets/list_logic.dart +++ b/circle_app/lib/app/circle/widgets/list_logic.dart @@ -48,13 +48,15 @@ class ListLogic extends GetxController { callOutMore = true; loadCallOutListData(_circleId); + } void loadMore() { + if (callOutMore == false) return; loadCallOutListData(_circleId); } - void pushMsgPage(Lists bean,String cicleId) async { + void pushHomePage(Lists bean,String cicleId) async { SharedPreferences prefs = await SharedPreferences.getInstance(); int userId = prefs.getInt("userId")??0; if(bean.user!.id==userId){ @@ -74,6 +76,10 @@ class ListLogic extends GetxController { // } } + void pushMsgPage(Lists bean,String cicleId) async { + + } + @override void onInit() { // TODO: implement onInit diff --git a/circle_app/lib/app/minefragment/view.dart b/circle_app/lib/app/minefragment/view.dart index cc714f7..e48e16a 100644 --- a/circle_app/lib/app/minefragment/view.dart +++ b/circle_app/lib/app/minefragment/view.dart @@ -151,39 +151,45 @@ class MinefragmentPage extends StatelessWidget { } Widget _CircleItemView() { - return Container( - margin: EdgeInsets.only(top: 18), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Image( - image: AssetImage(getHomeImage("mine_circle")), - width: 24, - height: 24, - ), - SizedBox(width: 10), - Text( - "我的圈子", - style: TextStyle(color: Colors.white), - ), - ], - ), - Row( - children: [ - Text( - "加入了3个圈子", - style: TextStyle(color: Colors.white30), - ), - Image( - image: AssetImage(getHomeImage("icon_in")), - width: 24, - height: 24, - ), - ], - ) - ], + return GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + Get.toNamed(AppRoutes.MyCircle,arguments: ''); + }, + child: Container( + margin: EdgeInsets.only(top: 18), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Image( + image: AssetImage(getHomeImage("mine_circle")), + width: 24, + height: 24, + ), + SizedBox(width: 10), + Text( + "我的圈子", + style: TextStyle(color: Colors.white), + ), + ], + ), + Row( + children: [ + Text( + "加入了3个圈子", + style: TextStyle(color: Colors.white30), + ), + Image( + image: AssetImage(getHomeImage("icon_in")), + width: 24, + height: 24, + ), + ], + ) + ], + ), ), ); } diff --git a/circle_app/lib/app/my_circle/binding.dart b/circle_app/lib/app/my_circle/binding.dart new file mode 100644 index 0000000..97127dd --- /dev/null +++ b/circle_app/lib/app/my_circle/binding.dart @@ -0,0 +1,9 @@ +import 'package:circle_app/app/my_circle/logic.dart'; +import 'package:get/get.dart'; + +class My_circleBinding extends Bindings { + @override + void dependencies() { + Get.lazyPut(() => MyCircleLogic()); + } +} diff --git a/circle_app/lib/app/my_circle/logic.dart b/circle_app/lib/app/my_circle/logic.dart new file mode 100644 index 0000000..44bc4a3 --- /dev/null +++ b/circle_app/lib/app/my_circle/logic.dart @@ -0,0 +1,59 @@ +import 'package:circle_app/app/circle/logic.dart'; +import 'package:circle_app/app/circle/state.dart'; +import 'package:circle_app/util/util.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:get/get.dart'; + +import '../../network/api.dart'; +import '../../network/dio_manager.dart'; + +class MyCircleLogic extends GetxController { + PageController pageController = + PageController(initialPage: 1, viewportFraction: 0.8); + InterestsBean circle = InterestsBean(lists: []); + final CircleState state = CircleState(); + int page = 1; + + @override + void onInit() async { + super.onInit(); + var data = await DioManager.instance + .get(url: Api.getMyCircleInterests, params: {"page": page}); + + var bean = BaseResponse.fromJson( + data, (data) => InterestsBean.fromJson(data)); + circle = bean.data!; + update(); + } + + loadMore() async { + page = page++; + var data = await DioManager.instance + .get(url: Api.getMyCircleInterests, params: {"page": page}); + var bean = BaseResponse.fromJson( + data, (data) => InterestsBean.fromJson(data)); + circle = bean.data!; + update(); + } + + outCircle(String interest_id, bool isStatus) async { + var data = await DioManager.instance.post( + url: Api.outCrrcle + interest_id + "/join", + params: {"status": isStatus ? "0" : "1"}); + var bean = BaseResponse.fromJson(data, (data) => data); + if (bean.code == 200) { + circle.lists.forEach((element) { + if (element.id.toString() == interest_id.toString()) { + element.isJoin = !isStatus; + } + }); + } + showToast(bean.msg); + } + + Circle getCircleIndex() { + return circle.lists[state.index]; + } + + +} diff --git a/circle_app/lib/app/my_circle/view.dart b/circle_app/lib/app/my_circle/view.dart new file mode 100644 index 0000000..f77b3e8 --- /dev/null +++ b/circle_app/lib/app/my_circle/view.dart @@ -0,0 +1,383 @@ +import 'package:circle_app/app/circle/logic.dart'; +import 'package:circle_app/app/circle/widgets/info_list_view.dart'; +import 'package:circle_app/app/my_circle/logic.dart'; +import 'package:circle_app/app/select_circle/logic.dart'; +import 'package:circle_app/components/my_app_bar.dart'; +import 'package:circle_app/router/app_routers.dart'; +import 'package:circle_app/util/util.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_swiper/flutter_swiper.dart'; +import 'package:get/get.dart'; + + +class My_circlePage extends StatefulWidget { + My_circlePage({Key? key}) : super(key: key); + @override + _My_circlePageState createState() => _My_circlePageState(); +} + +class _My_circlePageState extends State + with AutomaticKeepAliveClientMixin { + @override + bool get wantKeepAlive => true; + + // 是否需要缓存 + final logic = Get.put(MyCircleLogic()); + + final state = Get.find().state; + + var getContext; + + @override + Widget build(BuildContext context) { + getContext = context; + return Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, + decoration: BoxDecoration( + color: Color(0xFF423055), + image: DecorationImage( + fit: BoxFit.fill, + image: AssetImage(getBaseImage('home_back')))), + child: Scaffold( + backgroundColor: Colors.transparent, + body: SafeArea( + child: GetBuilder(builder: (MyCircleLogic controller) { + return Stack( + children: [ + Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, + child: Column(children: [ + Get.arguments == null ? navigatorItem() : backNavigatorItem(), + // Text(controller.state.msg), + //组件使用 + Expanded( + child: Swiper( + itemBuilder: (BuildContext context, int index) { + var bean = logic.circle.lists[index]; + return InfoListView(index, bean, logic); + }, + index: logic.circle.lists.isNotEmpty ? 0 : controller.state.index, + itemCount: logic.circle.lists.length, + viewportFraction: 0.95, + // scale: 0.9, + loop: false, + onIndexChanged: (index) { + controller.state.index = index; + if (index == logic.circle.lists.length - 1) { + + logic.loadMore(); + controller.update(); + } + }, + // pagination: new SwiperPagination(),//如果不填则不显示指示点 + // control: new SwiperControl(),//如果不填则不显示左右按钮 + )) + ]), + ), + ], + ); + }), + ), + )); + + } + + backNavigatorItem() { + return MyAppBar( + centerTitle: '我的圈子', + ); + } + + navigatorItem() { + List urlList = [ + 'https://p3-passport.byteimg.com/img/user-avatar/eb429d4dbb3c246f580a6f7894f2b246~100x100.awebp', + 'https://p3-passport.byteimg.com/img/user-avatar/eb429d4dbb3c246f580a6f7894f2b246~100x100.awebp', + 'https://p3-passport.byteimg.com/img/user-avatar/eb429d4dbb3c246f580a6f7894f2b246~100x100.awebp' + ]; + List widgets = []; + int index = 0; + urlList.forEach((element) { + widgets.add(Positioned( + left: 15.sp * index, + child: circleWidget(element), + )); + index++; + }); + return Container( + width: Get.width, + padding: EdgeInsets.only(left: 18.sp, right: 18.sp), + height: 44.sp, + child: Stack( + alignment: Alignment.center, + children: [ + Positioned( + left: 0, + child: Container( + + width: 30.sp * widgets.length, + height: 44.sp, + child: Stack( + alignment: Alignment.centerLeft, + children: widgets, + ), + )), + ShaderMask( + shaderCallback: (Rect bounds) { + return const LinearGradient( + begin: Alignment(0.0, -1.0), + end: Alignment.bottomCenter, + colors: [Color(0xff71F3F2), Color(0xffF657FF)], + ).createShader(Offset.zero & bounds.size); + }, + child: Text( + '发现', + style: TextStyle( + fontSize: 18.sp, + fontWeight: FontWeight.w600, + color: Colors.white, + shadows: [ + Shadow(color: Color(0xffF657FF), offset: Offset(0.0, -1)) + ]), + ), + ), + Positioned( + right: 0, + child: GestureDetector( + onTap: () { + Get.toNamed(AppRoutes.MyCircle,arguments: '',preventDuplicates:false); + }, + child: Image.asset( + getCircleImage('my_circle'), + width: 64.sp, + ), + )), + ], + ), + ); + } + + circleWidget(String url, {double width = 30}) { + return GestureDetector( + child: Stack( + alignment: Alignment.center, + children: [ + Image.asset( + getCircleImage('avatar_bg'), + width: width.sp, + ), + ClipOval( + child: Image.network( + url, + width: (width - 1).sp, + height: (width - 1).sp, + fit: BoxFit.fill, + ), + ) + ], + )); + } + + + + void _showTextContentDialog(BuildContext context, String msg) { + showDialog( + context: context, + builder: (BuildContext context) { + return Dialog( + backgroundColor: Colors.transparent, + child: Container( + height: 300.sp, + padding: EdgeInsets.all(1.0), + child: Stack( + children: [ + Container( + decoration: BoxDecoration( + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(10.0), + gradient: LinearGradient( + colors: [Color(0xFFDD3DF4), Color(0xFF30FFD9)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + ), + Container( + margin: EdgeInsets.all(1.sp), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(10.0), + gradient: LinearGradient( + colors: [Color(0xFF4C3E5F), Color(0xFF324140)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + ), + Container( + margin: EdgeInsets.only(top: 24.sp), + child: Column( + children: [ + Container( + margin: EdgeInsets.only( + top: 12.sp, left: 14.sp, right: 14.sp), + alignment: Alignment.center, + child: Text( + msg, + textAlign: TextAlign.center, + style: TextStyle( + color: Color(0xCCF7FAFA), fontSize: 16.sp), + ), + ), + ], + ), + ) + ], + ), + ), + ); + }, + ); + } + + void _showOutCircleDialog( + BuildContext context, CircleLogic controller, Circle bean) { + showDialog( + context: context, + builder: (BuildContext context) { + return Dialog( + backgroundColor: Colors.transparent, + child: Container( + height: 160.sp, + padding: EdgeInsets.all(1.0), + child: Stack( + children: [ + Container( + decoration: BoxDecoration( + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(10.0), + gradient: LinearGradient( + colors: [Color(0xFFDD3DF4), Color(0xFF30FFD9)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + ), + Container( + margin: EdgeInsets.all(1.sp), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(10.0), + gradient: LinearGradient( + colors: [Color(0xFF4C3E5F), Color(0xFF324140)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + ), + Container( + margin: EdgeInsets.only(top: 24.sp), + child: Column( + children: [ + Center( + child: Text( + "提示", + style: + TextStyle(color: Colors.white, fontSize: 16.sp), + ), + ), + Container( + margin: EdgeInsets.only( + top: 12.sp, left: 14.sp, right: 14.sp), + alignment: Alignment.center, + child: Text( + "是否确认退出该圈子。", + textAlign: TextAlign.center, + style: TextStyle( + color: Color(0xCCF7FAFA), fontSize: 16.sp), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + onTap: () { + Navigator.pop(context); + }, + child: Container( + margin: EdgeInsets.only(top: 30.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(17), + gradient: LinearGradient( + colors: [ + Color(0x26FFFFFF), + Color(0x26FFFFFF), + ], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + ), + ), + padding: EdgeInsets.only( + top: 10.sp, + bottom: 10.sp, + left: 52.sp, + right: 52.sp), + child: Text( + "否", + style: TextStyle( + color: Colors.white, + fontSize: 12, + ), + ), + ), + ), + SizedBox(width: 24.sp), + GestureDetector( + onTap: () { + Navigator.pop(context); + logic.outCircle(bean.id.toString(), bean.isJoin); + }, + child: Container( + margin: EdgeInsets.only(top: 24.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(17), + gradient: LinearGradient( + colors: [ + Color(0xFF06F9FA), + Color(0xFFDC5BFD), + ], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + ), + ), + padding: EdgeInsets.only( + top: 10.sp, + bottom: 10.sp, + left: 52.sp, + right: 52.sp), + child: Text( + "是", + style: TextStyle( + color: Colors.white, + fontSize: 12, + ), + ), + ), + ) + ], + ) + ], + ), + ) + ], + ), + ), + ); + }, + ); + } +} + diff --git a/circle_app/lib/app/userinfo/view.dart b/circle_app/lib/app/userinfo/view.dart index 869a0f3..ef5fe81 100644 --- a/circle_app/lib/app/userinfo/view.dart +++ b/circle_app/lib/app/userinfo/view.dart @@ -1,6 +1,7 @@ import 'dart:math'; import 'package:cached_network_image/cached_network_image.dart'; +import 'package:circle_app/app/userinfo/widgets/home_call_out.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -320,7 +321,7 @@ class _MyTabbedScreenState extends State controller: _tabController, children: [ _imageAdapter(controller), - Text("喊话"), + HomeCallOutView(controller.userId), ], ), )) diff --git a/circle_app/lib/app/userinfo/widgets/home_call_out.dart b/circle_app/lib/app/userinfo/widgets/home_call_out.dart new file mode 100644 index 0000000..6650cdb --- /dev/null +++ b/circle_app/lib/app/userinfo/widgets/home_call_out.dart @@ -0,0 +1,662 @@ +import 'dart:ffi'; + +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:circle_app/app/circle/logic.dart'; +import 'package:circle_app/app/circle/state.dart'; +import 'package:circle_app/app/circle/widgets/list_logic.dart'; +import 'package:circle_app/app/circle/widgets/video_item.dart'; +import 'package:circle_app/app/userinfo/widgets/home_call_out_logic.dart'; +import 'package:circle_app/router/app_routers.dart'; +import 'package:circle_app/util/util.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:get/get_core/src/get_main.dart'; +import 'package:get/get.dart'; + +class HomeCallOutView extends StatefulWidget { + // Get.lazyPut(() => ListLogic()); + + String userId; + HomeCallOutView(this.userId, {super.key}); + + @override + State createState() => _HomeCallOutViewState(); +} + +class _HomeCallOutViewState extends State { + List genderList = ['男', '女,' 'MTF', 'FTM', 'CD', '酷儿']; + + List orientationList = [ + '异性恋', + '同性恋', + '双性恋', + '泛性恋', + '无性恋', + '智性恋', + '性单恋' + ]; + + List roleList = ['Sado', 'Maso', 'Dom', 'Sub', 'Switch']; + + HomeCallOutLogic? listsLg; + + @override + void initState() { + // TODO: implement initState + super.initState(); + Get.lazyPut(() => HomeCallOutLogic()); + listsLg = Get.find(); + listsLg?.loadCallOutListData(widget.userId); + } + + @override + void dispose() { + // TODO: implement dispose + super.dispose(); + listsLg?.onClose(); + } + + @override + Widget build(BuildContext context) { + return GetBuilder( + assignId: true, + builder: (listLogic) { + return ClipRRect( + borderRadius: BorderRadius.circular(10.sp), + child: Container( + width: Get.width, + child: Stack( + children: [ + Container( + height: Get.height, + width: Get.width, + margin: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom + 30.sp), + child: RefreshIndicator( + onRefresh: () async { + listLogic.refreshData(); + }, + child: listLogic.lists.isEmpty + ? loaddingWidget(true) + : ListView.builder( + physics: const AlwaysScrollableScrollPhysics(), + scrollDirection: Axis.vertical, + controller: listLogic.scrollController, + itemCount: listLogic.lists.length + 1, + itemBuilder: (context, index) { + if (listLogic.lists.length > index) { + Lists lists = listLogic.lists[index]; + if (lists.isQueen!) { + return vipDynamicItem(lists); + } else { + return normalDynamicItem(lists); + } + } else { + return loaddingWidget( + listLogic.callOutMore); + } + }), + ), + ), + ], + ))); + }, + ); + } + + ///至尊喊话 + vipDynamicItem(Lists lists) { + Text descText = Text( + lists.content!, + style: TextStyle(color: Colors.white, fontSize: 14.sp), + maxLines: 2, + ); + + + double picHeight = 0.0; + + int type = 0; + if (lists.album != null) { + if (lists.album!.isNotEmpty) { + Album info = lists.album!.first!; + type = info.type!; + + if (info.type == 1) { + if (lists.album!.length > 3) { + picHeight = 218.sp; + } else { + picHeight = 109.sp; + } + } else { + picHeight = 140.sp; + } + } + } + double titleHeight = textWidth(lists.interest!['title']); + double widgetHeight = 115.sp + contentHeight(lists.content!) + (picHeight > 0 ? picHeight + 5 : 0); + + return Container( + margin: EdgeInsets.only(top: 10.sp), + width: Get.width, + height: widgetHeight, + decoration: BoxDecoration( + image: DecorationImage( + fit: BoxFit.fill, + image: AssetImage( + getCircleImage('pic_bg'), + ))), + child: Stack(children: [ + Positioned( + left: 0, + top: 2.sp, + child: Image.asset(getCircleImage('vip_say')), + height: 18.sp, + ), + Positioned( + right: 2.sp, + top: 2.sp, + child: Stack( + alignment: Alignment.center, + children: [ + Image.asset( + getCircleImage('location'), + width: titleHeight + 15.sp, + height: 20.sp, + fit: BoxFit.fitWidth, + ), + Text( + lists.interest!['title'], + style: TextStyle(color: Colors.white, fontSize: 12.sp), + ) + ], + ), + ), + Container( + height: widgetHeight, + width: Get.width, + padding: EdgeInsets.only(top: 12.sp, left: 12.sp, right: 12.sp), + child: Column( + children: [ + Container( + height: 72.sp, + child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + child: Stack( + alignment: Alignment.center, + children: [ + Image.asset( + getCircleImage('avatar_bg'), + width: 42.sp, + ), + GestureDetector( + onTap: () { + listsLg?.pushMsgPage(lists, lists.id.toString()); + }, + child: ClipOval( + child: Image.network( + lists.user!.avatar!, + width: 40.sp, + height: 40.sp, + fit: BoxFit.fill, + ), + ), + ) + ], + )), + Expanded( + child: Container( + padding: EdgeInsets.only(left: 8.sp, top: 12.sp), + alignment: Alignment.centerLeft, + height: 72.sp, + child: Column( + children: [ + Row( + children: [ + Text( + lists.user!.nickname!, + style: TextStyle( + color: Colors.white, + fontSize: 18.sp, + fontWeight: FontWeight.w600), + ), + SizedBox( + width: 8.sp, + ), + lists.user!.vip! == 0 + ? Container() + : Image.asset( + getCircleImage('vip'), + width: 36.sp, + ) + ], + ), + SizedBox( + height: 4.sp, + ), + Row( + children: [ + Container( + alignment: Alignment.center, + height: 18.sp, + padding: + EdgeInsets.only(left: 6.sp, right: 6.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(9.sp), + gradient: const LinearGradient( + begin: Alignment(0.25, 0.5), + end: Alignment(0.75, 0.5), + colors: [ + Color(0xff8DFFF8), + Color(0xffB5D3FF) + ])), + child: Text( + '${genderList[lists.user!.gender!]}.${lists.user!.age}.${roleList[lists.user!.role!]}.${orientationList[lists.user!.orientation!]}', + style: TextStyle( + color: Colors.black, + fontSize: 12.sp, + ), + ), + ) + ], + ), + ], + ), + )), + ], + ), + ), + Container( + alignment: Alignment.topLeft, + // margin: EdgeInsets.only(top: 4.sp), + child: descText, + ), + Container( + height: picHeight, + margin: EdgeInsets.only(top: 5.sp), + child: picHeight == 140.sp + ? ClipRRect( + borderRadius: BorderRadius.circular(6.sp), + child: VideoItemWidget(lists.album![0]!.url!)) + : GridView.builder( + itemCount: lists.album!.length, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, //横轴三个子widget + crossAxisSpacing: 8.sp, + mainAxisSpacing: 8.sp, + childAspectRatio: 1.0 //宽高比为1时,子widget + ), + itemBuilder: (contentxt, currentIndex) { + Album album = lists.album![currentIndex]; + return GestureDetector( + onTap: () { + var imgList = []; + for (var element in lists.album!) { + imgList.add(element.url!); + } + Get.toNamed(AppRoutes.Swiper, arguments: { + 'imaglist': imgList, + 'index': currentIndex + }); + }, + child: ClipRRect( + borderRadius: BorderRadius.circular(6.sp), + child: CachedNetworkImage( + imageUrl: album.url!, + errorWidget: (context, url, error) => + Icon(Icons.error), + fit: BoxFit.cover, + ), + ), + ); + }), + ), + Container( + width: Get.width, + margin: EdgeInsets.only(top: 4.sp), + alignment: Alignment.centerLeft, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + lists.create_time!, + style: + TextStyle(color: Colors.white, fontSize: 12.sp), + ), + widget.userId.isNotEmpty + ? Container() + : GestureDetector( + onTap: () { + showTipPiker(lists.id!.toString(), listsLg!.lists.indexOf(lists)); + }, + child: Text('删除',style: TextStyle(color: Colors.red, fontSize: 13.sp),)) + ], + )) + ], + ), + ) + ])); + } + + ///普通图文喊话 + normalDynamicItem(Lists lists) { + Text descText = Text( + lists.content!, + style: TextStyle(color: Colors.white, fontSize: 14.sp), + // maxLines: 2, + ); + + double picHeight = 0.0; + + int type = 0; + if (lists.album != null) { + if (lists.album!.isNotEmpty) { + Album info = lists.album!.first!; + type = info.type!; + + if (info.type == 1) { + if (lists.album!.length > 3) { + picHeight = 218.sp; + } else { + picHeight = 109.sp; + } + } else { + picHeight = 140.sp; + } + } + } + + double titleHeight = textWidth(lists.interest!['title']); + + return Container( + margin: EdgeInsets.only(top: 10.sp), + width: Get.width, + height: picHeight > 0 ? 105.sp + contentHeight(lists.content!) + picHeight : 100.sp + contentHeight(lists.content!), + decoration: BoxDecoration( + image: DecorationImage( + fit: BoxFit.fill, + image: AssetImage( + getCircleImage('normal_bg'), + ))), + child: Stack( + children: [ + Positioned( + right: 2.sp, + top: 2.sp, + child: Stack( + alignment: Alignment.center, + children: [ + Image.asset( + getCircleImage('location'), + width: titleHeight + 15.sp, + height: 20.sp, + fit: BoxFit.fitWidth, + ), + Text( + lists.interest!['title'], + style: TextStyle(color: Colors.white, fontSize: 12.sp), + ) + ], + ), + // height: 18.sp, + ), + Container( + // height: 130.sp + contentHeight(lists.content!) + picHeight, + width: Get.width, + // color: Colors.blue, + padding: EdgeInsets.only(left: 12.sp, right: 12.sp), + child: Column( + children: [ + Container( + height: 72.sp, + child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + child: Stack( + alignment: Alignment.center, + children: [ + Image.asset( + getCircleImage('avatar_bg'), + width: 42.sp, + ), + GestureDetector( + onTap: () {}, + child: ClipOval( + child: Image.network( + lists.user!.avatar!, + width: 40.sp, + height: 40.sp, + fit: BoxFit.fill, + ), + )) + ], + )), + Expanded( + child: Container( + padding: EdgeInsets.only(left: 8.sp, top: 12.sp), + alignment: Alignment.centerLeft, + height: 72.sp, + child: Column( + children: [ + Row( + children: [ + Text( + lists.user!.nickname! ?? '', + style: TextStyle( + color: Colors.white, + fontSize: 18.sp, + fontWeight: FontWeight.w600), + ), + SizedBox( + width: 8.sp, + ), + lists.user!.vip! == 0 + ? Container() + : Image.asset( + getCircleImage('vip'), + width: 36.sp, + ) + ], + ), + SizedBox( + height: 4.sp, + ), + Row( + children: [ + Container( + alignment: Alignment.center, + height: 18.sp, + padding: + EdgeInsets.only(left: 6.sp, right: 6.sp), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(9.sp), + gradient: const LinearGradient( + begin: Alignment(0.25, 0.5), + end: Alignment(0.75, 0.5), + colors: [ + Color(0xff8DFFF8), + Color(0xffB5D3FF) + ])), + child: Text( + '${genderList[lists.user!.gender!]}.${lists.user!.age}.${roleList[lists.user!.role!]}.${orientationList[lists.user!.orientation!]}', + style: TextStyle( + color: Colors.black, + fontSize: 12.sp, + ), + ), + ) + ], + ), + ], + ), + )), + ], + ), + ), + Container( + alignment: Alignment.topLeft, + // margin: EdgeInsets.only(top: 4.sp), + child: descText, + ), + picHeight > 0 + ? Container( + height: picHeight, + alignment: Alignment.centerLeft, + margin: EdgeInsets.only(top: 5.sp), + child: picHeight == 140.sp + ? ClipRRect( + borderRadius: BorderRadius.circular(6.sp), + child: VideoItemWidget(lists.album![0].url!)) + : GridView.builder( + itemCount: lists.album!.length, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, //横轴三个子widget + crossAxisSpacing: 8.sp, + mainAxisSpacing: 8.sp, + childAspectRatio: 1.0 //宽高比为1时,子widget + ), + itemBuilder: (contentxt, currentIndex) { + Album album = lists.album![currentIndex]; + if (album.type == 2) { + return ClipRRect( + borderRadius: + BorderRadius.circular(6.sp), + child: VideoItemWidget(album.url!)); + } + return GestureDetector( + onTap: () { + var imgList = []; + for (var element in lists.album!) { + imgList.add(element.url!); + } + Get.toNamed(AppRoutes.Swiper, arguments: { + 'imaglist': imgList, + 'index': currentIndex + }); + }, + child: ClipRRect( + borderRadius: BorderRadius.circular(6.sp), + child: CachedNetworkImage( + imageUrl: album.url!, + errorWidget: (context, url, error) => + Icon(Icons.error), + fit: BoxFit.cover, + ), + ), + ); + })) + : Container(), + Container( + width: Get.width, + margin: EdgeInsets.only(top: 4.sp), + alignment: Alignment.centerLeft, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + lists.create_time!, + style: + TextStyle(color: Colors.white, fontSize: 12.sp), + ), + widget.userId.isNotEmpty + ? Container() + : GestureDetector( + onTap: () { + showTipPiker(lists.id!.toString(), listsLg!.lists.indexOf(lists)); + }, + child: Text('删除',style: TextStyle(color: Colors.red, fontSize: 13.sp),)) + ], + )) + ], + ), + ) + ], + ), + ); + } + + circleWidget(String url, {double width = 30}) { + return GestureDetector( + child: Stack( + alignment: Alignment.center, + children: [ + Image.asset( + getCircleImage('avatar_bg'), + width: width.sp, + ), + ClipOval( + child: Image.network( + url, + width: (width - 1).sp, + height: (width - 1).sp, + fit: BoxFit.fill, + ), + ) + ], + )); + } + + double contentHeight(String content) { + return calculateTextHeight( + content, 14.sp, FontWeight.w300, Get.width - 64.sp, 100); + } + + double textWidth(value) { + TextPainter painter = TextPainter( + + ///AUTO:华为手机如果不指定locale的时候,该方法算出来的文字高度是比系统计算偏小的。 + locale: WidgetsBinding.instance!.window.locale, + maxLines: 1, + textDirection: TextDirection.ltr, + textScaleFactor: 1, //字体缩放大小 + text: TextSpan( + text: value, + style: TextStyle( + fontSize: 12.sp, + ))); + painter.layout(maxWidth: 350); + return painter.width; + } + + showTipPiker(String callOutId,int index) { + return Get.bottomSheet( + Scaffold( + backgroundColor: Colors.transparent, + body: CupertinoAlertDialog( + content: SingleChildScrollView( + child: ListBody( + children: const [ + Text("是否要删除该喊话?"), + ], + ), + ), + actions: [ + CupertinoDialogAction( + child: const Text("确定",style: TextStyle(color: Colors.red),), + onPressed: () { + Get.back(); + listsLg?.removeData(callOutId,index); + }, + ), + CupertinoDialogAction( + child: const Text("取消"), + onPressed: () { + Get.back(); + }, + ), + ], + ), + ), + isScrollControlled: true, + enableDrag: false, + + ); + } +} diff --git a/circle_app/lib/app/userinfo/widgets/home_call_out_logic.dart b/circle_app/lib/app/userinfo/widgets/home_call_out_logic.dart new file mode 100644 index 0000000..88e356e --- /dev/null +++ b/circle_app/lib/app/userinfo/widgets/home_call_out_logic.dart @@ -0,0 +1,81 @@ +import 'package:circle_app/app/circle/state.dart'; +import 'package:circle_app/common/Widgets/base_tip_widget.dart'; +import 'package:circle_app/common/Widgets/open_vip_tip/view.dart'; +import 'package:circle_app/network/dio_manager.dart'; +import 'package:circle_app/router/app_routers.dart'; +import 'package:circle_app/util/util.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class HomeCallOutLogic extends GetxController { + int callOutPage = 1; + bool isLoad = true; + bool callOutMore = true; + var _userId = ''; + List lists = []; + final ScrollController scrollController = ScrollController(); + + loadCallOutListData(String userId) async { + _userId = userId; + var data = await DioManager.instance.get( + url: "/up-service/${_userId.isEmpty ? 'my/' : 'user/' + userId}/callouts", + params: {"page": callOutPage, "page_size": "20"}); + if (data["code"] == 200) { + List dataList = data["data"]["lists"] ?? []; + if (callOutPage == 1) { + if (lists.isNotEmpty) { + lists.clear(); + } + } + if (dataList.isNotEmpty) { + callOutMore = true; + for (var element in dataList) { + lists.add(Lists.fromJson(element)); + } + callOutPage++; + } + callOutMore = dataList.length == 20; + update(); + } else { + showToast(data["msg"]); + } + } + + void refreshData() { + if (callOutMore == false) return; + callOutPage = 1; + callOutMore = true; + loadCallOutListData(_userId); + + } + + void loadMore() { + loadCallOutListData(_userId); + } + + void pushMsgPage(Lists bean,String cicleId) { + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + scrollController.addListener(() { + if (scrollController.position.pixels == scrollController.position.maxScrollExtent) { + loadMore(); + } + }); + } + + void removeData(String callOutId, int index) async { + var data = await DioManager.instance.delete( + url: "/up-service/callout/${callOutId}",); + if (data['code'] == 200) { + showToast('删除成功'); + lists.removeAt(index); + update(); + } else { + showToast('操作失败'); + } + } +} \ No newline at end of file diff --git a/circle_app/lib/components/func_widget.dart b/circle_app/lib/components/func_widget.dart index 4ccbf85..5156422 100644 --- a/circle_app/lib/components/func_widget.dart +++ b/circle_app/lib/components/func_widget.dart @@ -1,14 +1,13 @@ import 'package:circle_app/util/util.dart'; import 'package:flutter/cupertino.dart'; -Widget bgWidget(BuildContext context,Widget widget) { +Widget bgWidget(BuildContext context, Widget widget) { return Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height, - decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.fill, - image: AssetImage(getBaseImage('home_back')))), - child: widget,); - -} \ No newline at end of file + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, + decoration: BoxDecoration( + image: DecorationImage( + fit: BoxFit.fill, image: AssetImage(getBaseImage('home_back')))), + child: widget, + ); +} diff --git a/circle_app/lib/network/api.dart b/circle_app/lib/network/api.dart index 300e258..8f8cdfe 100644 --- a/circle_app/lib/network/api.dart +++ b/circle_app/lib/network/api.dart @@ -86,4 +86,43 @@ class Api { static const getUrgeStatus = 'up-service/user/'; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // /up-service/my/interests + static const getMyCircleInterests = 'up-service/my/interests'; } \ No newline at end of file diff --git a/circle_app/lib/router/app_pages.dart b/circle_app/lib/router/app_pages.dart index 1fa6404..45baf07 100644 --- a/circle_app/lib/router/app_pages.dart +++ b/circle_app/lib/router/app_pages.dart @@ -9,6 +9,7 @@ import 'package:circle_app/app/call_out/binding.dart'; import 'package:circle_app/app/call_out/view.dart'; import 'package:circle_app/app/chat/binding.dart'; import 'package:circle_app/app/chat/view.dart'; +import 'package:circle_app/app/circle/view.dart'; import 'package:circle_app/app/feedback/binding.dart'; import 'package:circle_app/app/feedback/view.dart'; import 'package:circle_app/app/friendslist/binding.dart'; @@ -22,6 +23,8 @@ import 'package:circle_app/app/minefragment/binding.dart'; import 'package:circle_app/app/minefragment/view.dart'; import 'package:circle_app/app/msg/binding.dart'; import 'package:circle_app/app/msg/view.dart'; +import 'package:circle_app/app/my_circle/binding.dart'; +import 'package:circle_app/app/my_circle/view.dart'; import 'package:circle_app/app/offaccount/binding.dart'; import 'package:circle_app/app/offaccount/view.dart'; import 'package:circle_app/app/photoinfo/binding.dart'; @@ -47,6 +50,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get_navigation/src/routes/get_route.dart'; import '../app/blacklist/view.dart'; +import '../app/circle/binding.dart'; import '../app/splash/view.dart'; import 'app_routers.dart'; @@ -163,5 +167,10 @@ class AppPages { page: () => SplashPage(), binding: SplashBinding(), ), + GetPage( + name: AppRoutes.MyCircle, + page: () => My_circlePage(), + binding: My_circleBinding(), + ), ]; } diff --git a/circle_app/lib/router/app_routers.dart b/circle_app/lib/router/app_routers.dart index acd3a31..af8cce2 100644 --- a/circle_app/lib/router/app_routers.dart +++ b/circle_app/lib/router/app_routers.dart @@ -22,4 +22,5 @@ abstract class AppRoutes { static const Chat = '/chat'; static const SelectCircleActivity = '/user/SelectCircleActivity'; static const SplashActivity = '/user/SplashActivity'; + static const MyCircle = '/myCircle'; } \ No newline at end of file