Browse Source

UI修改0115:1415

dart3_last
fff 1 week ago
parent
commit
f79e83848a
  1. 162
      lib/address/address_map_page.dart
  2. 12
      lib/address/edit_address_page.dart
  3. 16
      lib/base_state.dart
  4. 7
      lib/community/community_child_list.dart
  5. 62
      lib/community/community_child_page.dart
  6. 29
      lib/community/community_course.dart
  7. 51
      lib/community/community_details.dart
  8. 10
      lib/community/community_list.dart
  9. 23
      lib/community/community_view/class_details.dart
  10. 234
      lib/community/community_view/community_dynamic.dart
  11. 33
      lib/community/community_view/course_banner.dart
  12. 1
      lib/community/community_view/home_class.dart
  13. 4
      lib/community/headlines/activity_top_list.dart
  14. 30
      lib/community/headlines/article_list.dart
  15. 14
      lib/community/headlines/article_page.dart
  16. 32
      lib/community/headlines/headlines_banner.dart
  17. 2
      lib/community/headlines/headlines_collection.dart
  18. 56
      lib/community/headlines/headlines_column_details.dart
  19. 38
      lib/community/new_community_details.dart
  20. 1
      lib/community/order_page.dart
  21. 7
      lib/community/photo_view_gallery_screen.dart
  22. 17
      lib/community/release_dynamic.dart
  23. 6
      lib/community/report/report_notice.dart
  24. 60
      lib/community/report/report_page.dart
  25. 2
      lib/community/report/report_success.dart
  26. 121
      lib/community/share_trends.dart
  27. 16
      lib/constant.dart
  28. 2
      lib/data/article.dart
  29. 6
      lib/data/article.g.dart
  30. 32
      lib/data/vip_card.dart
  31. 9
      lib/home/activity_list_page.dart
  32. 314
      lib/home/founder_story_page.dart
  33. 47
      lib/home/guide_page.dart
  34. 59
      lib/home/help_farmers/help_farmers_page.dart
  35. 72
      lib/home/home_page.dart
  36. 6
      lib/home/home_view/activity_list.dart
  37. 2
      lib/home/home_view/brand_view.dart
  38. 17
      lib/home/home_view/coupon.dart
  39. 1
      lib/home/home_view/discount_zone.dart
  40. 49
      lib/home/home_view/featured_acticvity.dart
  41. 7
      lib/home/home_view/founder_store.dart
  42. 2
      lib/home/home_view/happy_help_farmers.dart
  43. 27
      lib/home/home_view/home_banner.dart
  44. 10
      lib/home/home_view/home_integral_store.dart
  45. 8
      lib/home/home_view/home_recommend_goods.dart
  46. 11
      lib/home/home_view/hot_article.dart
  47. 72
      lib/home/home_view/quick_order.dart
  48. 1
      lib/home/home_view/shortcut_operation.dart
  49. 11
      lib/home/home_view/sign_view.dart
  50. 3
      lib/home/home_view/top_selling_list.dart
  51. 1
      lib/home/home_view/union_entry.dart
  52. 1
      lib/home/home_view/welfare_core.dart
  53. 16
      lib/home/huixiang_brand_page.dart
  54. 30
      lib/home/huixiang_view/huixiang_banner.dart
  55. 1
      lib/home/huixiang_view/origin_info.dart
  56. 23
      lib/home/points_mall_page.dart
  57. 12
      lib/home/points_mall_view/point_mall_user.dart
  58. 5
      lib/home/points_mall_view/points_goods_title.dart
  59. 3
      lib/home/points_mall_view/points_goods_view.dart
  60. 27
      lib/home/points_mall_view/points_mall_banner.dart
  61. 6
      lib/home/trading_card_page.dart
  62. 32
      lib/home/welfare_exchange.dart
  63. 58
      lib/home/welfare_page.dart
  64. 9
      lib/im/SocketClient.dart
  65. 1
      lib/im/add_friend.dart
  66. 506
      lib/im/chat_details_page.dart
  67. 18
      lib/im/chat_friend_group.dart
  68. 12
      lib/im/chat_setting.dart
  69. 127
      lib/im/contact_share.dart
  70. 4
      lib/im/database/hx_database.dart
  71. 4
      lib/im/database/message.dart
  72. 37
      lib/im/im_search.dart
  73. 29
      lib/im/im_view/friend_groip_list.dart
  74. 187
      lib/im/im_view/im_page.dart
  75. 36
      lib/im/im_view/on_chat_msg_instance.dart
  76. 119
      lib/integral/integral_detailed_page.dart
  77. 48
      lib/integral/integral_page.dart
  78. 51
      lib/integral/intergra_view/integral_vip.dart
  79. 34
      lib/integral_store/integral_store_details_page.dart
  80. 4
      lib/login/captcha/block_puzzle_captcha.dart
  81. 83
      lib/login/login_page.dart
  82. 78
      lib/login/new_login_page.dart
  83. 54
      lib/main.dart
  84. 74
      lib/main_page.dart
  85. 8
      lib/message/main_message_page.dart
  86. 14
      lib/message/real_time_info_page.dart
  87. 23
      lib/message/system_details.dart
  88. 169
      lib/message/system_message.dart
  89. 24
      lib/message/system_notice.dart
  90. 8
      lib/mine/coupon_page.dart
  91. 5
      lib/mine/coupons_page.dart
  92. 16
      lib/mine/fans_page.dart
  93. 10
      lib/mine/follow_page.dart
  94. 23
      lib/mine/invitation_record.dart
  95. 10
      lib/mine/manage_address_page.dart
  96. 10
      lib/mine/mine_card_invalid_page.dart
  97. 12
      lib/mine/mine_greenery.dart
  98. 57
      lib/mine/mine_page.dart
  99. 162
      lib/mine/mine_shop_details.dart
  100. 66
      lib/mine/mine_shop_page.dart
  101. Some files were not shown because too many files have changed in this diff Show More

162
lib/address/address_map_page.dart

@ -9,6 +9,7 @@ import 'package:geolocator/geolocator.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/location.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/request_permission.dart';
import 'package:permission_handler/permission_handler.dart' as PH;
import 'package:shared_preferences/shared_preferences.dart';
@ -46,10 +47,12 @@ class _AddressMapPage extends State<AddressMapPage> {
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context, token: value.getString('token')),
});
apiService = ApiService(
Dio(),
context: context,
token: SharedInstance.instance.token,
);
LocationInstance.getInstance().startLocation(context, (Position? result) {
print("event: $result");
if (result?.latitude != null && result?.longitude != null) {
@ -62,8 +65,7 @@ class _AddressMapPage extends State<AddressMapPage> {
heading: 0,
speed: 0,
speedAccuracy: 0);
LocationInstance.getInstance()
.getAddress(result.latitude, result.longitude)
LocationInstance.getInstance().getAddress(result.latitude, result.longitude)
?.then((value) {
if (value != null) {
city = value.city ?? "";
@ -242,158 +244,22 @@ class _AddressMapPage extends State<AddressMapPage> {
},
heightRatioWithWidth: 0.82,
);
});
},
);
}
// BMFMapController? _mapController;
// BMFCoordinate? bmfCoordinate;
// void onMapCreated(BMFMapController controller) {
// controller.setMapRegionDidChangeCallback(callback: (status) {
// BMFMapStatus bmfMapStatus = status;
// print("status: ${bmfMapStatus.toMap()}");
// if (bmfCoordinate?.longitude == status.targetGeoPt?.longitude &&
// bmfCoordinate?.latitude == status.targetGeoPt?.latitude) {
// if ((DateTime.now().millisecondsSinceEpoch - time) > 1000) {
// center = status.targetGeoPt;
// searchPoi(center);
// time = DateTime.now().millisecondsSinceEpoch;
// }
// } else {
// bmfCoordinate = status.targetGeoPt;
// }
// });
//
// setState(() {
// _mapController = controller;
// _mapController?.showUserLocation(true);
// _loadCustomData();
// addMarker();
// });
// }
Position? latLng;
// BMFMarker? bmfMarker;
// addMarker() {
// bmfMarker?.updateIsLockedToScreen(
// true,
// BMFPoint(
// (Platform.isIOS
// ? MediaQuery.of(context).size.width
// : window.physicalSize.width) /
// 2,
// (Platform.isIOS
// ? MediaQuery.of(context).size.height
// : window.physicalSize.height) /
// 4));
// }
saveLatLng(Position? latLng) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString("latitude", "${latLng?.latitude}");
await prefs.setString("longitude", "${latLng?.longitude}");
SharedInstance.instance.saveLatLng(latLng);
}
// getLatLng() async {
// SharedPreferences.getInstance().then((value) => {
// setState(() {
// _mapController?.updateMapOptions(
// BMFMapOptions(
// center: BMFCoordinate(
// double.tryParse("${value.getString("latitude")}") ?? 0,
// double.tryParse("${value.getString("longitude")}") ?? 0,
// ),
// zoomLevel: 15,
// showZoomControl: false,
// showMapScaleBar: false,
// rotateEnabled: false,
// ),
// );
// })
// });
// }
//
// BMFMapWidget? map;
// BMFCoordinate? center = BMFCoordinate(30.553111, 114.342366);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
searchWidget(),
// Expanded(
// child: Stack(
// children: [
// Container(
// child: BMFMapWidget(
// mapOptions: BMFMapOptions(
// center: BMFCoordinate(30.553111, 114.342366),
// zoomLevel: 15,
// showZoomControl: false,
// showMapScaleBar: false,
// rotateEnabled: false,
// ),
// onBMFMapCreated: onMapCreated,
// // onCameraMoveEnd: (cameraPosition) {
// // center = cameraPosition.target;
// // searchPoi(center);
// // },
// // onCameraMove: (cameraPosition) {
// // center = cameraPosition.target;
// // setState(() {});
// // },
// // markers: [Marker(position: center)].toSet(),
// // touchPoiEnabled: true,
// // scrollGesturesEnabled: true,
// // customStyleOptions: _customStyleOptions,
// // gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
// // Factory<OneSequenceGestureRecognizer>(
// // () => EagerGestureRecognizer())
// // ].toSet(),
// ),
// ),
// // Center(
// // child: IgnorePointer(
// // child: Container(
// // margin: EdgeInsets.only(bottom: 44.h),
// // child: Image.asset(
// // "assets/image/icon_address_location.webp",
// // width: 66.w,
// // height: 75.h,
// // ),
// // ),
// // ),
// // ),
// Positioned(
// right: 17,
// bottom: 16,
// child: InkWell(
// onTap: () {
// startLocation();
// },
// child: Container(
// width: 32,
// height: 32,
// padding: EdgeInsets.all(8),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(16),
// color: Colors.white,
// ),
// child: Image.asset(
// "assets/image/icon_address_location_action.webp",
// width: 16.w,
// height: 16.h,
// ),
// ),
// ),
// ),
// ],
// ),
// flex: 1,
// ),
Expanded(
child: Container(
child: ListView.separated(
@ -464,14 +330,16 @@ class _AddressMapPage extends State<AddressMapPage> {
padding: EdgeInsets.fromLTRB(10, 6, 16, 6),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(4)),
borderRadius: BorderRadius.all(
Radius.circular(4),
),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
),
],
),
child: Row(

12
lib/address/edit_address_page.dart

@ -5,6 +5,7 @@ import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/address.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -32,11 +33,11 @@ class _EditAddressPage extends State<EditAddressPage> {
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context, token: value.getString('token')),
queryAddress(),
});
context: context,
token: SharedInstance.instance.token,
);
queryAddress();
}
Address? preAddress;
@ -45,8 +46,7 @@ class _EditAddressPage extends State<EditAddressPage> {
preAddress = Address.fromJson(widget.arguments);
nameController.text = "${preAddress?.username}";
mobileController.text = "${preAddress?.phone}";
addressController.text =
"${preAddress?.province}${preAddress?.city}${preAddress?.area}";
addressController.text = "${preAddress?.province}${preAddress?.city}${preAddress?.area}";
houseNumberController.text = "${preAddress?.addressStr}";
setState(() {});
}

16
lib/base_state.dart

@ -1,7 +1,9 @@
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:huixiang/utils/bridge.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:shared_preferences/shared_preferences.dart';
abstract class BaseState<T extends StatefulWidget> extends State<T>
@ -41,16 +43,16 @@ abstract class BaseState<T extends StatefulWidget> extends State<T>
pushRoute() async {
String startIntent = await Bridge.getStartIntent();
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
print("intent:$startIntent");
String pushData = "";
if (startIntent != null && startIntent != "") {
if (startIntent.isNotEmpty) {
pushData = startIntent;
} else {
pushData = sharedPreferences.getString("pushData") ?? "";
pushData = SharedInstance.instance.pushData;
}
if (pushData == null || pushData == "") return;
Map<String, dynamic> pushMap = jsonDecode(pushData);
if (pushData.isEmpty) return;
Map<String, dynamic>? pushMap = jsonDecode(pushData);
if (pushMap != null) {
String routeName = "";
Map<String, dynamic> params = {};
@ -108,8 +110,8 @@ abstract class BaseState<T extends StatefulWidget> extends State<T>
params["id"] = pushMap["info"];
break;
}
sharedPreferences.setString("pushData", "");
print("xgPushClickAction: routeName: $routeName");
SharedInstance.instance.savePushData();
debugPrint("xgPushClickAction: routeName: $routeName");
if (routeName != "") {
Navigator.of(context).pushNamed(routeName, arguments: params);
}

7
lib/community/community_child_list.dart

@ -1,8 +1,10 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/comunity_comment.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
@ -33,6 +35,11 @@ class _CommunityChildList extends State<CommunityChildList> {
@override
void initState() {
super.initState();
apiService = ApiService(
Dio(),
context: context,
token: SharedInstance.instance.token,
);
_onRefresh();
}

62
lib/community/community_child_page.dart

@ -9,6 +9,7 @@ import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/comunity_comment.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:huixiang/view_widget/no_data_view.dart';
@ -65,7 +66,7 @@ class CommunityChildPageState extends State<CommunityChildPage>
}
///
queryCommunity(String? searchKey) async {
Future queryCommunity({String? searchKey}) async {
if (!isRefresh) {
isRefresh = true;
return;
@ -74,14 +75,12 @@ class CommunityChildPageState extends State<CommunityChildPage>
return;
}
isLoadingData = true;
if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance();
userId = value.getString('userId');
userId = SharedInstance.instance.userId;
apiService = ApiService(Dio(),
context: context,
token: value.getString("token"),
showLoading: false);
}
token: SharedInstance.instance.token,
showLoading: false,
);
if (isLoadMore) {
pageNum += 1;
isLoadMore = false;
@ -103,7 +102,8 @@ class CommunityChildPageState extends State<CommunityChildPage>
});
refreshController.refreshCompleted();
if (baseData?.isSuccess ?? false) {
if (baseData?.data?.list?.isNotEmpty ?? false)
if (baseData?.data?.list?.isNotEmpty ?? false) {
if (searchKey != null) {
articles.forEach((element) {
if (element.id == searchKey) {
element.content = jsonEncode(baseData?.data?.list?[0].subjectInfo);
@ -119,9 +119,35 @@ class CommunityChildPageState extends State<CommunityChildPage>
element.likes = baseData?.data?.list?[0].likes;
element.comments = baseData?.data?.list?[0].comments;
this.isRefresh = false;
}
});
setState(() {});
} else {
if (pageNum == 1) {
articles.clear();
}
baseData!.data!.list!.forEach((element) {
var article = Article();
article.id = element.id;
article.content = jsonEncode(element.subjectInfo);
article.mainTitle = element.subject;
article.followed = element.selfFollow;
article.liked = element.selfLike;
article.authorHeadImg = element.memberInfo?.avatar;
article.authorName = element.memberInfo?.nickname;
article.location = element.location;
article.createTime = element.createTime;
article.author = element.memberInfo?.mid;
article.viewers = element.viewers;
article.likes = element.likes;
article.comments = element.comments;
articles.add(article);
});
if ((int.tryParse(baseData.data!.total ?? "0") ?? 0) < (pageNum * 10)) {
refreshController.loadNoData();
}
}
}
}
isLoadingData = false;
@ -131,7 +157,7 @@ class CommunityChildPageState extends State<CommunityChildPage>
Widget build(BuildContext context) {
super.build(context);
return FutureBuilder(
future: queryCommunity(null),
future: queryCommunity(),
builder: (context, position) {
return Stack(
alignment: Alignment.bottomRight,
@ -139,7 +165,7 @@ class CommunityChildPageState extends State<CommunityChildPage>
SmartRefresher(
controller: refreshController,
enablePullDown: true,
enablePullUp: (articles.length == 0) ? false:true,
enablePullUp: articles.isNotEmpty,
physics: BouncingScrollPhysics(),
header: MyHeader(),
footer: CustomFooter(
@ -152,7 +178,7 @@ class CommunityChildPageState extends State<CommunityChildPage>
isLoadMore = true;
setState(() {});
},
child: (articles.length == 0)
child: (articles.isEmpty)
? NoDataView(
src: "assets/image/guan_zhu.webp",
isShowBtn: false,
@ -173,11 +199,10 @@ class CommunityChildPageState extends State<CommunityChildPage>
userId: userId,
isList: true,
exitFull: () {
// setState(() {
// onRefresh();
// });
queryCommunity(articles[position].id);
queryCommunity(searchKey: articles[position].id);
},
removalDynamic: () {
queryCommunity().then((value) => setState(() {}));
},
),
onTap: () {
@ -188,12 +213,9 @@ class CommunityChildPageState extends State<CommunityChildPage>
"userId": userId,
},
).then((value) {
// onRefresh();
// setState(() {});
queryCommunity(articles[position].id);
queryCommunity(searchKey: articles[position].id);
});
// setState(() {});
},
);
},

29
lib/community/community_course.dart

@ -14,6 +14,7 @@ import 'package:huixiang/data/page.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/event_type.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
@ -57,32 +58,26 @@ class _CommunityCourse extends State<CommunityCourse>
setState(() {});
}
});
if (apiService == null) {
SharedPreferences.getInstance().then((value) {
apiService = ApiService(
apiService ??= ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
);
_onRefresh();
});
}
}
///banner
queryCourseBanner() async {
if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
apiService ??= ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
);
}
BaseData<PageInfo<BannerData>>? baseData = await apiService?.queryBanner({
"model": {"type": "COURSE_BANNER"},
}).catchError((onError) {
refreshController.refreshFailed();
return BaseData<PageInfo<BannerData>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
bannerData.clear();
@ -122,6 +117,7 @@ class _CommunityCourse extends State<CommunityCourse>
refreshController.refreshFailed();
refreshController.loadFailed();
}
return BaseData<PageInfo<Course>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
if (categoryId == "") {
@ -144,8 +140,10 @@ class _CommunityCourse extends State<CommunityCourse>
///
collectionList() async {
BaseListData<CollectClass>? baseData =
await apiService?.collectList().catchError((onError) {});
BaseListData<CollectClass>? baseData = await apiService?.collectList()
.catchError((onError) {
return BaseListData<CollectClass>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
setState(() {
collectList.clear();
@ -160,8 +158,9 @@ class _CommunityCourse extends State<CommunityCourse>
///
collectCourse(collectId) async {
BaseListData<Course>? baseData =
await apiService?.collect(collectId).catchError((error) {});
BaseListData<Course>? baseData = await apiService?.collect(collectId).catchError((error) {
return BaseListData<Course>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
setState(() {
if (!collectMap.containsKey(collectId)) {

51
lib/community/community_details.dart

@ -1,5 +1,6 @@
import 'dart:ui';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@ -10,15 +11,16 @@ import 'package:huixiang/data/member_comment.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:huixiang/view_widget/tips_dialog.dart';
import 'package:huixiang/web/web_view/comment_list.dart';
import 'package:huixiang/web/web_view/input_comment.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../view_widget/classic_header.dart';
import '../view_widget/my_footer.dart';
class CommunityDetails extends StatefulWidget {
final Map<String, dynamic> arguments;
@ -113,6 +115,11 @@ class _CommunityDetails extends State<CommunityDetails>
emojiShowing = false;
});
});
apiService = ApiService(
Dio(),
context: context,
token: SharedInstance.instance.token,
);
_queryMemberCommentList(true);
queryDetails(businessId);
}
@ -153,11 +160,10 @@ class _CommunityDetails extends State<CommunityDetails>
///
queryDetails(id) async {
SharedPreferences value = await SharedPreferences.getInstance();
BaseData<Article>? baseData =
await apiService?.informationInfo(id).catchError((onError) {
BaseData<Article>? baseData = await apiService?.informationInfo(id).catchError((onError) {
debugPrint(onError.toString());
refreshController.refreshFailed();
return BaseData<Article>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
setState(() {
@ -233,9 +239,7 @@ class _CommunityDetails extends State<CommunityDetails>
exitFull: () {
setState(() {});
},
userId: widget.arguments != null
? widget.arguments["userId"]
: widget.arguments["mid"],
userId: widget.arguments["userId"] ?? widget.arguments["mid"],
itemCount: 3,
isDetails: true,
heightFun: (height) {
@ -308,9 +312,10 @@ class _CommunityDetails extends State<CommunityDetails>
////
_queryInformationLikes() async {
BaseData? baseData = await apiService
?.informationLikes("${businessId}")
.catchError((onError) {});
BaseData? baseData = await apiService?.informationLikes("${businessId}")
.catchError((onError) {
return BaseData()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
commentKey.currentState?.setState(() {});
setState(() {
@ -321,8 +326,6 @@ class _CommunityDetails extends State<CommunityDetails>
article?.likes = likes + 1;
article?.liked = !(article?.liked ?? false);
});
} else {
// SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}
}
@ -333,7 +336,9 @@ class _CommunityDetails extends State<CommunityDetails>
"parentId": parenId,
"relationalId": businessId,
"relationalType": 4
}).catchError((error) {});
}).catchError((error) {
return BaseData()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
CommentListState? state = commentKey.currentState as CommentListState?;
state?.queryMemberCommentList();
@ -346,8 +351,7 @@ class _CommunityDetails extends State<CommunityDetails>
///
_toComment() {
if (commentKey.currentContext == null) return;
RenderBox? firstRenderBox =
commentKey.currentContext?.findRenderObject() as RenderBox?;
RenderBox? firstRenderBox = commentKey.currentContext?.findRenderObject() as RenderBox?;
Offset? first = firstRenderBox?.localToGlobal(Offset.zero);
scrollController.animateTo(
(first?.dy ?? 0) +
@ -373,7 +377,9 @@ class _CommunityDetails extends State<CommunityDetails>
SmartDialog.show(
builder: (ctx) => Tips(() {
delComment(memberComment);
}));
},
),
);
}
///
@ -398,17 +404,18 @@ class _CommunityDetails extends State<CommunityDetails>
SmartDialog.showLoading(
msg: S.current.zhengzaijiazai,
);
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
BaseData<PageInfo<MemberComment>>? baseData =
await apiService?.memberCommentList({
BaseData<PageInfo<MemberComment>>? baseData = await apiService?.memberCommentList({
"pageNum": 1,
"pageSize": 100,
"relationalId": businessId,
"relationalType": 4,
}).catchError((error) {});
}).catchError((error) {
return BaseData<PageInfo<MemberComment>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
commentTotal = baseData!.data?.size;
memberList = baseData!.data?.list ?? [];
memberList = baseData.data?.list ?? [];
contentHeight();
if (mounted) setState(() {});
SmartDialog.dismiss();

10
lib/community/community_list.dart

@ -7,6 +7,7 @@ import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/comunity_comment.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/border_text.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/icon_text.dart';
@ -38,11 +39,8 @@ class _CommunityList extends State<CommunityList> {
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
if(apiService != null)
apiService = ApiService(Dio(),
context: context, token: value.getString("token")),
});
context: context, token: SharedInstance.instance.token);
}
////
@ -53,8 +51,6 @@ class _CommunityList extends State<CommunityList> {
SmartDialog.showToast(isFollow ? "关注成功" : "取关成功",
alignment: Alignment.center);
setState(() {});
} else {
SmartDialog.showToast("${baseData?.msg}", alignment: Alignment.center);
}
}
@ -65,8 +61,6 @@ class _CommunityList extends State<CommunityList> {
widget.exitFull?.call();
SmartDialog.showToast("删除成功", alignment: Alignment.center);
setState(() {});
} else {
// SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}
}

23
lib/community/community_view/class_details.dart

@ -13,6 +13,8 @@ import 'package:huixiang/data/course_details.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/share_dialog.dart';
import 'package:huixiang/view_widget/tips_dialog.dart';
import 'package:huixiang/web/web_view/comment_list.dart';
import 'package:huixiang/web/web_view/input_comment.dart';
@ -21,7 +23,6 @@ import 'package:sharesdk_plugin/sharesdk_defines.dart';
import 'package:sharesdk_plugin/sharesdk_interface.dart';
import 'package:sharesdk_plugin/sharesdk_map.dart';
import '../../view_widget/share_dialog.dart';
class ClassDetails extends StatefulWidget {
final Map<String, dynamic> arguments;
@ -62,23 +63,18 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver {
super.initState();
WidgetsBinding.instance.addObserver(this);
commentFocus.addListener(_focusNodeListener);
if (apiService == null) {
SharedPreferences.getInstance().then((value) {
apiService = ApiService(
apiService ??= ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
);
courseDetails(widget.arguments["id"]);
queryChapterList(widget.arguments["id"]);
});
}
}
///
queryChapterList(courseId) async {
BaseListData<Chapter>? baseData =
await apiService?.catalogList(courseId).catchError((onError) {
BaseListData<Chapter>? baseData = await apiService?.catalogList(courseId).catchError((onError) {
return BaseListData<Chapter>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
@ -86,8 +82,7 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver {
chapterList.clear();
chapterList.addAll(baseData!.data ?? []);
chapterIndex = 0;
ClassDetailsVideoState? state =
videoKey.currentState as ClassDetailsVideoState?;
ClassDetailsVideoState? state = videoKey.currentState as ClassDetailsVideoState?;
state?.initVideo(chapterList[chapterIndex].content?.fileUrl);
// initVideo(chapterList[chapterIndex].content.fileUrl);
});
@ -97,8 +92,10 @@ class _ClassDetails extends State<ClassDetails> with WidgetsBindingObserver {
///
courseDetails(id) async {
BaseData<CourseDetails>? baseData =
await apiService?.course(id).catchError((error) {});
BaseData<CourseDetails>? baseData = await apiService?.course(id)
.catchError((error) {
return BaseData<CourseDetails>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
setState(() {
course = baseData!.data;

234
lib/community/community_view/community_dynamic.dart

@ -1,14 +1,17 @@
import 'dart:convert';
import 'package:chewie/chewie.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/article.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:chewie/src/chewie_progress_colors.dart' as chewie;
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/border_text.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/round_button.dart';
@ -35,7 +38,7 @@ class CommunityDynamic extends StatefulWidget {
CommunityDynamic(
this.article,
this.commentType, {
Key? key,
super.key,
this.itemCount = 9,
this.heightFun,
this.isDetails = false,
@ -43,7 +46,7 @@ class CommunityDynamic extends StatefulWidget {
this.exitFull,
this.userId,
this.isList = false,
}) : super(key: key);
});
@override
State<StatefulWidget> createState() {
@ -56,13 +59,17 @@ class _CommunityDynamic extends State<CommunityDynamic> {
double height = 0;
ApiService? apiService;
late VideoPlayerController videoPlayerController;
late ChewieController chewieAudioController;
VideoPlayerController? videoPlayerController;
ChewieController? chewieAudioController;
late Chewie chewies;
@override
void initState() {
super.initState();
apiService = ApiService(Dio(),
context: context,
token: SharedInstance.instance.token,
);
initVideo();
}
@ -78,10 +85,11 @@ class _CommunityDynamic extends State<CommunityDynamic> {
} else {
videoPlayerController = VideoPlayerController.networkUrl(
Uri.parse(cnt["video"]),
)..initialize().then((value) {
);
videoPlayerController!.initialize().then((value) {
chewieAudioController = ChewieController(
videoPlayerController: videoPlayerController,
aspectRatio: videoPlayerController.value.aspectRatio,
videoPlayerController: videoPlayerController!,
aspectRatio: videoPlayerController!.value.aspectRatio,
//
autoPlay: false,
//
@ -97,7 +105,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
),
autoInitialize: true,
);
chewieAudioController.addListener(_fullScreenListener);
chewieAudioController!.addListener(_fullScreenListener);
if (mounted) setState(() {});
});
}
@ -106,34 +114,36 @@ class _CommunityDynamic extends State<CommunityDynamic> {
////
_vipFollow(followId, isFollow) async {
BaseData? baseData = await apiService?.follow(followId ?? "");
BaseData? baseData = await apiService?.follow(followId ?? "").catchError((onError) {
return BaseData<dynamic>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
widget.exitFull?.call();
SmartDialog.showToast(isFollow ? "关注成功" : "取关成功",
alignment: Alignment.center);
SmartDialog.showToast(
isFollow ? "关注成功" : "取关成功",
alignment: Alignment.center,
);
setState(() {});
} else {
SmartDialog.showToast("${baseData?.msg}", alignment: Alignment.center);
}
}
///
_deleteDynamic(id) async {
BaseData? baseData = await apiService?.deleteTrend(id);
BaseData? baseData = await apiService?.deleteTrend(id).catchError((onError) {
return BaseData<dynamic>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
widget.removalDynamic?.call();
widget.exitFull?.call();
SmartDialog.showToast("删除成功", alignment: Alignment.center);
setState(() {});
} else {
// SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}
}
////
_queryInformationLikes(isLikes) async {
BaseData? baseData = await apiService
?.informationLikes("${widget.article?.id}")
.catchError((onError) {});
BaseData<dynamic>? baseData = await apiService?.informationLikes("${widget.article?.id}").catchError((onError) {
return BaseData<dynamic>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
widget.exitFull?.call();
setState(() {});
@ -141,11 +151,15 @@ class _CommunityDynamic extends State<CommunityDynamic> {
}
goPersonalPage() async {
await Navigator.of(context).pushNamed('/router/personal_page', arguments: {
"memberId": (widget.article?.author == widget.userId)
? "0"
: widget.article?.author,
});
if (widget.article?.author == null || widget.article?.author == widget.userId) {
return;
}
await Navigator.of(context).pushNamed(
'/router/personal_page',
arguments: {
"memberId": widget.article?.author,
},
);
widget.exitFull?.call();
}
@ -159,7 +173,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
alignment: Alignment.topCenter,
padding: EdgeInsets.only(
left: 16.w,
top: 16.h,
top: 16,
right: 16.w,
),
decoration: BoxDecoration(
@ -188,16 +202,6 @@ class _CommunityDynamic extends State<CommunityDynamic> {
children: [
GestureDetector(
onTap: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => PhotoViewGalleryScreen(
// images: [(widget?.article?.authorHeadImg ?? "").isEmpty?
// "https://lmg.jj20.com/up/allimg/tx30/09041130358711081.jpg":widget?.article?.authorHeadImg
// ], //list
// index: 0, //index
// ),
// ));
goPersonalPage();
},
child: MImage(
@ -220,10 +224,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
Text(
widget.article?.authorName ?? "",
style: TextStyle(
fontSize:
MediaQuery.of(context).size.width >= 650
? 12.sp
: 15.sp,
fontSize: 15.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF1A1A1A),
),
@ -231,10 +232,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
Text(
widget.article?.createTime ?? "",
style: TextStyle(
fontSize:
MediaQuery.of(context).size.width >= 650
? 10.sp
: 13.sp,
fontSize: 13.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF808080),
),
@ -261,11 +259,10 @@ class _CommunityDynamic extends State<CommunityDynamic> {
},
child: (widget.commentType == 0)
? Container(
width: 56.w,
height: 25.h,
alignment: Alignment.center,
child: RoundButton(
height: 25.h,
height: 28,
backgroup: (widget.article?.followed ?? false)
? Color(0xFFE6E6E6)
: Color(0xFF32A060),
@ -276,6 +273,9 @@ class _CommunityDynamic extends State<CommunityDynamic> {
? S.of(context).yiguanzhu
: S.of(context).guanzhu,
radius: 20,
padding: EdgeInsets.symmetric(
horizontal: 10,
),
icons: Icon(
(widget.article?.followed ?? false)
? Icons.check
@ -285,7 +285,8 @@ class _CommunityDynamic extends State<CommunityDynamic> {
: Colors.white,
size: 15,
),
))
),
)
: Padding(
padding: EdgeInsets.all(20),
child: Icon(
@ -302,7 +303,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
),
widget.isList
? Text(
widget.article?.mainTitle ?? "",
widget.article?.mainTitle?.trim() ?? "",
maxLines: 5,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@ -312,7 +313,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
),
)
: Text(
widget.article?.mainTitle ?? "",
widget.article?.mainTitle?.trim() ?? "",
style: TextStyle(
color: Color(0xFF1A1A1A),
fontWeight: MyFontWeight.regular,
@ -325,7 +326,10 @@ class _CommunityDynamic extends State<CommunityDynamic> {
),
if (widget.article?.location != "")
Padding(
padding: EdgeInsets.only(bottom: 7),
padding: EdgeInsets.only(
top: 7,
bottom: widget.isList ? 0 : 12,
),
child: Row(
children: [
Icon(
@ -357,14 +361,12 @@ class _CommunityDynamic extends State<CommunityDynamic> {
),
if (!widget.isDetails)
Container(
// padding: EdgeInsets.only(bottom: 16),
padding: EdgeInsets.only(bottom: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Container(
padding: EdgeInsets.only(bottom: 16.h),
child: Row(
children: [
SvgPicture.asset(
@ -387,10 +389,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
],
),
),
),
Expanded(
child: Container(
padding: EdgeInsets.only(bottom: 16.h),
child: Row(
children: [
SvgPicture.asset(
@ -411,7 +410,8 @@ class _CommunityDynamic extends State<CommunityDynamic> {
),
),
],
))),
),
),
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
@ -423,8 +423,6 @@ class _CommunityDynamic extends State<CommunityDynamic> {
widget.article?.liked ?? false);
});
},
child: Container(
padding: EdgeInsets.only(bottom: 16.h),
child: Row(
children: [
(widget.article?.liked ?? false)
@ -454,9 +452,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
),
),
),
),
if ((widget.article?.author != (widget.userId ?? "")) &&
widget.commentType == 0)
if (widget.commentType == 0)
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
@ -468,9 +464,8 @@ class _CommunityDynamic extends State<CommunityDynamic> {
child: Container(
padding: EdgeInsets.only(
top: 3.h,
bottom: 16.h,
),
alignment: Alignment.center,
alignment: Alignment.centerRight,
// color: Colors.red,
child: Icon(
Icons.more_horiz,
@ -486,7 +481,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
),
),
Container(
height: 16.h,
height: 16,
color: Color(0xFFF7F7F7),
),
],
@ -534,7 +529,8 @@ class _CommunityDynamic extends State<CommunityDynamic> {
print("share!$state");
});
});
});
},
);
}
String buildShareUrl() {
@ -552,8 +548,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
cnt["images"] != null &&
cnt["images"].length > 0) {
if (cnt["images"].length == 1) {
itemWidget = Container(
child: InkWell(
itemWidget = InkWell(
onTap: () {
// ImagePickers.previewImages(subjectInfo.images,0);
Navigator.push(
@ -566,24 +561,24 @@ class _CommunityDynamic extends State<CommunityDynamic> {
),
);
},
child: Container(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.width / 1.5,
),
child: MImage(
cnt["images"][0],
fit: BoxFit.contain,
radius: BorderRadius.circular(2),
height: MediaQuery.of(context).size.width / 1.5,
errorSrc: "assets/image/default_2_1.webp",
fadeSrc: "assets/image/default_2_1.webp",
)),
),
),
);
} else {
itemWidget = GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount:
(cnt["images"].length == 2 || cnt["images"].length == 4)
? 2
: 3,
crossAxisSpacing: 12.w,
mainAxisSpacing: 12.w,
crossAxisCount: (cnt["images"].length == 2 || cnt["images"].length == 4) ? 2 : 3,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
childAspectRatio: 1,
),
padding: EdgeInsets.zero,
@ -618,14 +613,12 @@ class _CommunityDynamic extends State<CommunityDynamic> {
itemCount: cnt["images"].length,
);
}
} else if (cnt["type"] == "video" &&
cnt["video"] != null &&
cnt["video"].isNotEmpty) {
} else if (cnt["type"] == "video" && cnt["video"] != null && cnt["video"].isNotEmpty) {
itemWidget = videoWidget(
MediaQuery.of(context).size.width - 32,
videoPlayerController != null
? (MediaQuery.of(context).size.width - 32) /
videoPlayerController.value.aspectRatio
videoPlayerController!.value.aspectRatio
: MediaQuery.of(context).size.width / 2,
cnt["video"].replaceAll(".mp4", "_poster.jpg"),
);
@ -636,7 +629,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
height: 16.h,
height: 16,
),
itemWidget,
],
@ -646,11 +639,11 @@ class _CommunityDynamic extends State<CommunityDynamic> {
@override
void dispose() {
super.dispose();
chewieAudioController.pause();
chewieAudioController.dispose();
chewieAudioController?.pause();
chewieAudioController?.dispose();
videoPlayerController.pause();
videoPlayerController.dispose();
videoPlayerController?.pause();
videoPlayerController?.dispose();
}
Widget videoWidget(double width, double height, src) {
@ -664,7 +657,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
width: width,
height: height,
child: chewies = Chewie(
controller: chewieAudioController,
controller: chewieAudioController!,
),
)
: Container(
@ -683,7 +676,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
child: MImage(
src,
aspectRatio: videoPlayerController != null
? videoPlayerController.value.aspectRatio
? videoPlayerController!.value.aspectRatio
: (width / 7 * 5),
fit: BoxFit.cover,
errorSrc: "assets/image/default_2_1.webp",
@ -704,7 +697,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
}
Future<void> _fullScreenListener() async {
if (!chewieAudioController.isFullScreen) {
if (!(chewieAudioController?.isFullScreen ?? false)) {
Future.delayed(Duration(seconds: 1), () {
widget.exitFull?.call();
});
@ -793,19 +786,22 @@ class _CommunityDynamic extends State<CommunityDynamic> {
return buildBottomSheetWidget(context);
},
backgroundColor: Colors.transparent,
context: context);
context: context,
);
}
Widget buildBottomSheetWidget(BuildContext context) {
return Container(
padding: EdgeInsets.all(16),
decoration: new BoxDecoration(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(25.0),
topRight: const Radius.circular(25.0))),
topRight: const Radius.circular(25.0),
),
),
child: Container(
height: 130.h,
height: ("${widget.article?.author ?? ""}" == "${SharedInstance.instance.userId}") ? 145.h : 100.h,
child: Column(
children: [
GestureDetector(
@ -845,7 +841,8 @@ class _CommunityDynamic extends State<CommunityDynamic> {
),
],
),
)),
),
),
Container(
margin: EdgeInsets.symmetric(vertical: 12),
height: 1.h,
@ -855,8 +852,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
behavior: HitTestBehavior.translucent,
onTap: () {
setState(() {
Navigator.of(context)
.popAndPushNamed('/router/report_page', arguments: {
Navigator.of(context).popAndPushNamed('/router/report_page', arguments: {
"userName": widget.article?.authorName ?? "",
"authorId": widget.article?.author ?? "",
});
@ -889,7 +885,50 @@ class _CommunityDynamic extends State<CommunityDynamic> {
],
),
),
)
),
if (("${widget.article?.author ?? ""}" == "${SharedInstance.instance.userId}")) ...[
Container(
margin: EdgeInsets.symmetric(
vertical: 12,
),
height: 1.h,
color: Color(0xFFF7F7F7),
),
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
Navigator.of(context).pop();
showDeleteDialog();
},
child: Container(
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: 5.h),
child: Row(
children: [
SizedBox(
width: 4.w,
),
SvgPicture.asset(
"assets/svg/ju_b.svg",
width: 20,
height: 20,
),
SizedBox(
width: 15.w,
),
Text(
S.of(context).shanchu,
style: TextStyle(
fontSize: 17.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF1A1A1A),
),
),
],
),
),
),
],
],
),
),
@ -908,4 +947,5 @@ class _CommunityDynamic extends State<CommunityDynamic> {
widget.heightFun?.call(height);
print("height: $height");
}
}

33
lib/community/community_view/course_banner.dart

@ -22,11 +22,10 @@ class CourseBanner extends StatefulWidget {
}
class _CourseBanner extends State<CourseBanner> {
ApiService? apiService;
final RefreshController refreshController = RefreshController();
List<BannerData> bannerData = [];
@override
Widget build(BuildContext context) {
return Container(
@ -76,20 +75,26 @@ class _CourseBanner extends State<CourseBanner> {
bannerClick(BannerData bannerData) async {
switch (bannerData.contentType) {
case 1:
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": bannerData.content});
Navigator.of(context).pushNamed(
'/router/integral_store_page',
arguments: {"goodsId": bannerData.content},
);
break;
case 2:
Navigator.of(context)
.pushNamed('/router/web_page', arguments: {
Navigator.of(context).pushNamed(
'/router/web_page',
arguments: {
"activityId": bannerData.content,
});
},
);
break;
case 3:
Navigator.of(context)
.pushNamed('/router/web_page', arguments: {
Navigator.of(context).pushNamed(
'/router/web_page',
arguments: {
"articleId": bannerData.content,
});
},
);
break;
case 4:
String? router = bannerData.content;
@ -106,10 +111,12 @@ class _CourseBanner extends State<CourseBanner> {
}
break;
case 5:
Navigator.of(context)
.pushNamed('/router/class_details', arguments: {
Navigator.of(context).pushNamed(
'/router/class_details',
arguments: {
"id": bannerData.content,
});
},
);
break;
case 7:
String? router = bannerData.content;

1
lib/community/community_view/home_class.dart

@ -21,7 +21,6 @@ class HomeClass extends StatefulWidget {
}
class _HomeClass extends State<HomeClass> {
ApiService? apiService;
Position? latLng;
final TextEditingController editingController = TextEditingController();

4
lib/community/headlines/activity_top_list.dart

@ -1,8 +1,6 @@
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/article.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -19,8 +17,6 @@ class ActivityTopList extends StatefulWidget {
}
class _ActivityTopList extends State<ActivityTopList> {
ApiService? apiService;
Position? latLng;
final TextEditingController editingController = TextEditingController();

30
lib/community/headlines/article_list.dart

@ -4,6 +4,7 @@ import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/article.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -28,10 +29,10 @@ class _ArticleList extends State<ArticleList> {
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context, token: value.getString("token")),
});
context: context,
token: SharedInstance.instance.token,
);
}
@override
@ -53,7 +54,8 @@ class _ArticleList extends State<ArticleList> {
fontWeight: MyFontWeight.semi_bold,
color: Colors.black,
),
)),
),
),
ListView.builder(
padding: EdgeInsets.zero,
itemCount: widget.articles.length,
@ -76,7 +78,8 @@ class _ArticleList extends State<ArticleList> {
},
),
],
));
),
);
}
Widget articleItem(Article articles, position) {
@ -125,21 +128,6 @@ class _ArticleList extends State<ArticleList> {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Expanded(
// child: Text(
// widget.articles != null
// ? widget.articles[position]?.author?.name ?? ""
// : "",
// overflow: TextOverflow.ellipsis,
// maxLines: 1,
// style: TextStyle(
// fontSize: 12.sp,
// fontWeight: MyFontWeight.medium,
// color: Color(0xFF8E8E8E),
// ),
// ),
// ),
// SizedBox(width: 8.w),
Image.asset(
"assets/image/browse.webp",
width: 14,
@ -171,7 +159,7 @@ class _ArticleList extends State<ArticleList> {
),
),
],
)
),
],
),
),

14
lib/community/headlines/article_page.dart

@ -1,3 +1,4 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@ -14,6 +15,7 @@ import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/event_type.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:huixiang/view_widget/store_title_tab.dart';
@ -60,6 +62,10 @@ class _ArticlePage extends State<ArticlePage>
setState(() {});
}
});
apiService = ApiService(Dio(),
context: context,
token: SharedInstance.instance.token,
);
queryArticleList(false);
queryArticleList(true);
queryHeadlinesBanner();
@ -78,6 +84,7 @@ class _ArticlePage extends State<ArticlePage>
"model": {"type": "INFORMATION"},
}).catchError((onError) {
refreshController.refreshFailed();
return BaseData<PageInfo<BannerData>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
bannerData.clear();
@ -108,6 +115,7 @@ class _ArticlePage extends State<ArticlePage>
}).catchError((onError) {
refreshController.refreshFailed();
refreshController.loadFailed();
return BaseData<PageInfo<Article>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
refreshController.refreshCompleted();
@ -139,8 +147,7 @@ class _ArticlePage extends State<ArticlePage>
///
queryHeadlinesList() async {
BaseListData<Headlines>? baseData =
await apiService?.headlinesList().catchError((onError) {
BaseListData<Headlines>? baseData = await apiService?.headlinesList().catchError((onError) {
return BaseListData<Headlines>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
@ -248,7 +255,8 @@ class _ArticlePage extends State<ArticlePage>
fontWeight: MyFontWeight.semi_bold,
color: Colors.black,
),
)),
),
),
///
HeadlinesCollection(headlines, articles),

32
lib/community/headlines/headlines_banner.dart

@ -22,7 +22,7 @@ class HeadlinesBanner extends StatefulWidget {
}
class _HeadlinesBanner extends State<HeadlinesBanner> {
ApiService? apiService;
final RefreshController refreshController = RefreshController();
List<BannerData> bannerData = [];
@ -73,20 +73,26 @@ class _HeadlinesBanner extends State<HeadlinesBanner> {
bannerClick(BannerData bannerData) async {
switch (bannerData.contentType) {
case 1:
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": bannerData.content});
Navigator.of(context).pushNamed(
'/router/integral_store_page',
arguments: {"goodsId": bannerData.content},
);
break;
case 2:
Navigator.of(context)
.pushNamed('/router/web_page', arguments: {
Navigator.of(context).pushNamed(
'/router/web_page',
arguments: {
"activityId": bannerData.content,
});
},
);
break;
case 3:
Navigator.of(context)
.pushNamed('/router/web_page', arguments: {
Navigator.of(context).pushNamed(
'/router/web_page',
arguments: {
"articleId": bannerData.content,
});
},
);
break;
case 4:
String? router = bannerData.content;
@ -103,10 +109,12 @@ class _HeadlinesBanner extends State<HeadlinesBanner> {
}
break;
case 5:
Navigator.of(context)
.pushNamed('/router/class_details', arguments: {
Navigator.of(context).pushNamed(
'/router/class_details',
arguments: {
"id": bannerData.content,
});
},
);
break;
case 7:
String? router = bannerData.content;

2
lib/community/headlines/headlines_collection.dart

@ -21,7 +21,7 @@ class HeadlinesCollection extends StatefulWidget {
}
class _HeadlinesCollection extends State<HeadlinesCollection> {
ApiService? apiService;
Position? latLng;
final TextEditingController editingController = TextEditingController();

56
lib/community/headlines/headlines_column_details.dart

@ -1,3 +1,4 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:huixiang/data/headlines_details.dart';
import 'package:huixiang/generated/l10n.dart';
@ -8,6 +9,7 @@ import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_footer.dart';
@ -39,13 +41,19 @@ class _HeadlinesColumnDetails extends State<HeadlinesColumnDetails>
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
apiService = ApiService(Dio(),
context: context,
token: SharedInstance.instance.token,
);
_onRefresh();
}
///
queryHeadlinesDetails(id) async {
BaseData<HeadlinesDetails>? baseData =
await apiService?.headlinesDetails(id).catchError((error) {});
BaseData<HeadlinesDetails>? baseData = await apiService?.headlinesDetails(id)
.catchError((error) {
return BaseData<HeadlinesDetails>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
setState(() {
headlinesListDetails = baseData!.data;
@ -66,6 +74,7 @@ class _HeadlinesColumnDetails extends State<HeadlinesColumnDetails>
}).catchError((onError) {
refreshController.refreshFailed();
refreshController.loadFailed();
return BaseData<PageInfo<Article>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
refreshController.refreshCompleted();
@ -239,10 +248,8 @@ class _HeadlinesColumnDetails extends State<HeadlinesColumnDetails>
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"简介:",
@ -272,7 +279,7 @@ class _HeadlinesColumnDetails extends State<HeadlinesColumnDetails>
color: Colors.black,
),
),
)
),
],
),
SizedBox(height: 3.h),
@ -293,8 +300,7 @@ class _HeadlinesColumnDetails extends State<HeadlinesColumnDetails>
S.of(context).gengduo,
style: TextStyle(
fontSize: 12.sp,
fontWeight:
MyFontWeight.regular,
fontWeight: MyFontWeight.regular,
color: Colors.black,
),
),
@ -325,10 +331,12 @@ class _HeadlinesColumnDetails extends State<HeadlinesColumnDetails>
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
Navigator.of(context)
.pushNamed('/router/web_page', arguments: {
Navigator.of(context).pushNamed(
'/router/web_page',
arguments: {
"articleId": articles[position].id
});
},
);
int viewers = articles[position].viewers ?? 0;
articles[position].viewers = (viewers + 1);
setState(() {});
@ -378,8 +386,7 @@ class _HeadlinesColumnDetails extends State<HeadlinesColumnDetails>
children: [
Expanded(
child: Container(
height:
MediaQuery.of(context).size.width >= 650 ? 133.h : 105,
height: MediaQuery.of(context).size.width >= 650 ? 133.h : 105,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
@ -407,24 +414,12 @@ class _HeadlinesColumnDetails extends State<HeadlinesColumnDetails>
fontWeight: MyFontWeight.regular,
color: Color(0xFF353535),
),
)),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Expanded(
// child: Text(
// articles?.author?.name ?? "",
// overflow: TextOverflow.ellipsis,
// maxLines: 1,
// style: TextStyle(
// fontSize: 12.sp,
// fontWeight: MyFontWeight.medium,
// color: Color(0xFF8E8E8E),
// ),
// ),
// ),
// SizedBox(width: 8),
Image.asset(
"assets/image/browse.webp",
width: 14,
@ -439,7 +434,8 @@ class _HeadlinesColumnDetails extends State<HeadlinesColumnDetails>
fontWeight: MyFontWeight.regular,
color: Color(0xFF8D8D8D),
),
)),
),
),
Expanded(
child: Text(
articles.createTime?.split(":")[0] ?? "",
@ -449,7 +445,7 @@ class _HeadlinesColumnDetails extends State<HeadlinesColumnDetails>
color: Color(0xFF8D8D8D),
),
),
)
),
],
),
],

38
lib/community/new_community_details.dart

@ -1,6 +1,7 @@
import 'dart:convert';
import 'dart:ui';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -13,6 +14,7 @@ import 'package:huixiang/data/page.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:huixiang/view_widget/round_button.dart';
@ -66,15 +68,15 @@ class _NewCommunityDetails extends State<NewCommunityDetails>
userId = widget.arguments?["userId"];
WidgetsBinding.instance.addObserver(this);
commentFocus.addListener(_focusNodeListener);
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token);
queryDetails(commentsId);
}
///
queryDetails(id) async {
SharedPreferences value = await SharedPreferences.getInstance();
BaseData<Article>? baseData =
await apiService?.informationInfo(id).catchError((onError) {
BaseData<Article>? baseData = await apiService?.informationInfo(id).catchError((onError) {
debugPrint(onError.toString());
return BaseData<Article>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
setState(() {
@ -90,8 +92,6 @@ class _NewCommunityDetails extends State<NewCommunityDetails>
SmartDialog.showToast(isFollow ? "关注成功" : "取关成功",
alignment: Alignment.center);
setState(() {});
} else {
// SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}
}
@ -436,7 +436,8 @@ class _NewCommunityDetails extends State<NewCommunityDetails>
height: MediaQuery.of(context).size.width,
errorSrc: "assets/image/default_2_1.webp",
fadeSrc: "assets/image/default_2_1.webp",
)),
),
),
);
} else {
itemWidget = GridView.builder(
@ -520,9 +521,10 @@ class _NewCommunityDetails extends State<NewCommunityDetails>
////
_queryInformationLikes() async {
BaseData? baseData = await apiService
?.informationLikes("${commentsId}")
.catchError((onError) {});
BaseData? baseData = await apiService?.informationLikes("${commentsId}")
.catchError((onError) {
return BaseData()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
commentKey.currentState?.setState(() {});
setState(() {
@ -533,8 +535,6 @@ class _NewCommunityDetails extends State<NewCommunityDetails>
article?.likes = likes + 1;
article?.liked = !(article?.liked ?? false);
});
} else {
SmartDialog.showToast("${baseData?.msg}", alignment: Alignment.center);
}
}
@ -545,7 +545,9 @@ class _NewCommunityDetails extends State<NewCommunityDetails>
"parentId": parenId,
"relationalId": commentsId,
"relationalType": 4
}).catchError((error) {});
}).catchError((error) {
return BaseData()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
CommentListState? state = commentKey.currentState as CommentListState?;
state?.queryMemberCommentList();
@ -585,7 +587,9 @@ class _NewCommunityDetails extends State<NewCommunityDetails>
SmartDialog.show(
builder: (ctx) => Tips(() {
delComment(memberComment);
}));
},
),
);
}
///
@ -606,14 +610,14 @@ class _NewCommunityDetails extends State<NewCommunityDetails>
///
_queryMemberCommentList() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
BaseData<PageInfo<MemberComment>>? baseData =
await apiService?.memberCommentList({
BaseData<PageInfo<MemberComment>>? baseData = await apiService?.memberCommentList({
"pageNum": 1,
"pageSize": 100,
"relationalId": commentsId,
"relationalType": 4,
}).catchError((error) {});
}).catchError((error) {
return BaseData<PageInfo<MemberComment>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
commentTotal = baseData?.data?.size;
memberList = baseData?.data?.list ?? [];

1
lib/community/order_page.dart

@ -29,6 +29,7 @@ class _OrderPage extends State<OrderPage> with SingleTickerProviderStateMixin,Au
@override
Widget build(BuildContext context) {
super.build(context);
return DefaultTabController(
length: 4,
child: Scaffold(

7
lib/community/photo_view_gallery_screen.dart

@ -21,18 +21,19 @@ class PhotoViewGalleryScreen extends StatefulWidget {
}
class _PhotoViewGalleryScreenState extends State<PhotoViewGalleryScreen> {
int currentIndex=0;
int currentIndex = 0;
@override
void initState() {
// TODO: implement initState
currentIndex = widget.index;
super.initState();
currentIndex=widget.index;
}
File fileFromDocsDir(String filename) {
String pathName = p.join(ImgCachePath.instance.path, filename);
return File(pathName);
}
@override
Widget build(BuildContext context) {
return Scaffold(

17
lib/community/release_dynamic.dart

@ -8,6 +8,7 @@ import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/address.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:image_pickers/image_pickers.dart';
@ -38,14 +39,12 @@ class _ReleaseDynamic extends State<ReleaseDynamic> {
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
showLoading: false,
);
});
}
@override
@ -238,7 +237,8 @@ class _ReleaseDynamic extends State<ReleaseDynamic> {
isDestructiveAction: true,
),
);
});
},
);
}
///
@ -272,7 +272,8 @@ class _ReleaseDynamic extends State<ReleaseDynamic> {
isDestructiveAction: true,
),
);
});
},
);
}
Widget addImageItem() {
@ -440,7 +441,8 @@ class _ReleaseDynamic extends State<ReleaseDynamic> {
),
],
),
)),
),
),
addressController.text == ""
? Container()
: GestureDetector(
@ -469,7 +471,8 @@ class _ReleaseDynamic extends State<ReleaseDynamic> {
height: 5,
)
],
));
),
);
}
}

6
lib/community/report/report_notice.dart

@ -14,7 +14,7 @@ class ReportNotice extends StatefulWidget {
}
class _ReportNotice extends State<ReportNotice> {
ApiService? apiService;
int checkIndex = 0;
@override
@ -35,7 +35,9 @@ class _ReportNotice extends State<ReportNotice> {
body: Container(
width: double.infinity,
color: Color(0xFFFFFFFFF),
padding: EdgeInsets.only(left: 16, top: 10, right: 16),
padding: EdgeInsets.only(
left: 16, top: 10, right: 16,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,

60
lib/community/report/report_page.dart

@ -1,10 +1,11 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -32,13 +33,20 @@ class _ReportPage extends State<ReportPage> {
super.initState();
userName = widget.arguments?['userName'];
authorId = widget.arguments?['authorId'];
apiService = ApiService(
Dio(),
context: context,
token: SharedInstance.instance.token,
);
}
report() async {
BaseData? baseData = await apiService?.complaint({
"content": checkIndex == 9 ? editingController.text : textCon,
"informationId": authorId,
}).catchError((onError) {});
}).catchError((onError) {
return BaseData()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
Navigator.of(context).popAndPushNamed('/router/report_success');
} else {
@ -70,12 +78,16 @@ class _ReportPage extends State<ReportPage> {
Container(
width: double.infinity,
color: Color(0XFFFFFFFF),
padding: EdgeInsets.only(bottom: 4, left: 16, right: 16),
padding: EdgeInsets.only(
bottom: 4,
left: 16,
right: 16,
),
child: Text.rich(
TextSpan(
children: [
TextSpan(
text:S.of(context).jubao,
text: S.of(context).jubao,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
@ -108,8 +120,11 @@ class _ReportPage extends State<ReportPage> {
Container(
width: double.infinity,
height: 186.h,
margin:
EdgeInsets.only(right: 16, left: 40, bottom: 100),
margin: EdgeInsets.only(
right: 16,
left: 40,
bottom: 100,
),
decoration: new BoxDecoration(
color: Color(0xFFF7F7F7),
borderRadius: BorderRadius.circular(4.0),
@ -137,7 +152,8 @@ class _ReportPage extends State<ReportPage> {
),
),
),
))
),
)
],
),
),
@ -164,12 +180,16 @@ class _ReportPage extends State<ReportPage> {
color: Color(0xFF3C425C),
),
),
)),
),
),
Expanded(
child: GestureDetector(
onTap: () {
if(checkIndex == 9 && editingController.text == ""){
SmartDialog.showToast("请输入举报原因", alignment: Alignment.center);
if (checkIndex == 9 && editingController.text == "") {
SmartDialog.showToast(
"请输入举报原因",
alignment: Alignment.center,
);
return;
}
report();
@ -191,10 +211,12 @@ class _ReportPage extends State<ReportPage> {
),
),
),
))
),
),
],
),
))
),
),
],
),
),
@ -204,7 +226,11 @@ class _ReportPage extends State<ReportPage> {
Widget reportContent() {
return Container(
width: double.infinity,
padding: EdgeInsets.only(left: 16, right: 16, top: 20),
padding: EdgeInsets.only(
left: 16,
right: 16,
top: 20,
),
child: Column(
children: [
content("色情低俗", 1),
@ -241,7 +267,8 @@ class _ReportPage extends State<ReportPage> {
),
content("其他", 9),
],
));
),
);
}
var checkIndex = 0;
@ -287,9 +314,10 @@ class _ReportPage extends State<ReportPage> {
fontWeight: MyFontWeight.regular,
),
),
)
),
],
),
));
),
);
}
}

2
lib/community/report/report_success.dart

@ -15,7 +15,7 @@ class ReportSuccess extends StatefulWidget {
}
class _ReportSuccess extends State<ReportSuccess> {
ApiService? apiService;
int checkIndex = 0;
@override

121
lib/community/share_trends.dart

@ -10,6 +10,7 @@ import 'package:huixiang/data/article.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:flutter/cupertino.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../generated/l10n.dart';
import '../../utils/font_weight.dart';
@ -27,7 +28,7 @@ class ShareTrends extends StatefulWidget {
}
}
class _ShareTrends extends State<ShareTrends>{
class _ShareTrends extends State<ShareTrends> {
ApiService? apiService;
bool topSetting = false;
final TextEditingController textController = TextEditingController();
@ -42,17 +43,14 @@ class _ShareTrends extends State<ShareTrends>{
///
queryDetails(id) async {
SharedPreferences value = await SharedPreferences.getInstance();
if (apiService == null)
apiService = ApiService(
Dio(),
apiService ??= ApiService(Dio(),
context: context,
token: value.getString("token"),
showLoading: true
token: SharedInstance.instance.token,
showLoading: true,
);
BaseData<Article>? baseData =
await apiService?.informationInfo(id).catchError((onError) {
BaseData<Article>? baseData = await apiService?.informationInfo(id).catchError((onError) {
debugPrint(onError.toString());
return BaseData<Article>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
setState(() {
@ -65,34 +63,13 @@ class _ShareTrends extends State<ShareTrends>{
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFFF9FAF7),
// appBar: MyAppBar(
// title:"转发",
// titleColor: Colors.black,
// titleSize: 18.sp,
// background: Colors.white,
// leading: false,
// leadingColor: Colors.black,
// actions: [
// Container(
// alignment: Alignment.center ,
// color: Color(0xFF32A060),
// margin:EdgeInsets.only(right: 16.w) ,
// child: Text(
// S.of(context).fabu,
// style: TextStyle(
// color: Colors.white,
// fontSize:12.sp,
// fontWeight: MyFontWeight.regular,
// ),
// ),
// )
// ],
// ),
body: Container(
child: Column(
children: [
Container(
padding:EdgeInsets.only(top: MediaQuery.of(context).padding.top+11.h,bottom:14.w),
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top + 11.h, bottom: 14.w,
),
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
@ -101,19 +78,26 @@ class _ShareTrends extends State<ShareTrends>{
Expanded(
child: Container(
alignment: Alignment.center,
margin: EdgeInsets.only(left:60.w,),
margin: EdgeInsets.only(
left: 60.w,
),
child: Text(
"转发",
style: TextStyle(
color: Colors.black,
fontSize:17.sp,
fontSize: 17.sp,
fontWeight: MyFontWeight.regular,
),
),)),
),
),
),
Container(
alignment: Alignment.center ,
margin:EdgeInsets.only(right: 16.w) ,
padding: EdgeInsets.symmetric(horizontal: 16.w,vertical: 3.h),
alignment: Alignment.center,
margin: EdgeInsets.only(right: 16.w),
padding: EdgeInsets.symmetric(
horizontal: 16.w,
vertical: 3.h,
),
decoration: BoxDecoration(
color: Color(0xFF32A060),
borderRadius: BorderRadius.circular(10.5),
@ -122,7 +106,7 @@ class _ShareTrends extends State<ShareTrends>{
S.of(context).fabu,
style: TextStyle(
color: Colors.white,
fontSize:12.sp,
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
@ -130,12 +114,12 @@ class _ShareTrends extends State<ShareTrends>{
],
),
),
Expanded(child:
Container(
Expanded(
child: Container(
margin: EdgeInsets.symmetric(vertical: 14.h),
width: double.infinity,
color: Colors.white,
padding: EdgeInsets.only(left: 20.w,right: 16.w),
padding: EdgeInsets.only(left: 20.w, right: 16.w),
child: Column(
children: [
Container(
@ -145,15 +129,17 @@ class _ShareTrends extends State<ShareTrends>{
),
margin: EdgeInsets.only(top: 30.w),
child: Container(
margin: EdgeInsets.only(left:16.w,right: 10.w,),
margin: EdgeInsets.only(
left: 16.w,
right: 10.w,
),
alignment: Alignment.topLeft,
child: TextField(
textInputAction:TextInputAction.send,
onEditingComplete: () {
},
textInputAction: TextInputAction.send,
onEditingComplete: () {},
maxLines: 8,
minLines: 1,
focusNode:commentFocus,
focusNode: commentFocus,
controller: textController,
decoration: InputDecoration(
border: InputBorder.none,
@ -168,12 +154,12 @@ class _ShareTrends extends State<ShareTrends>{
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
onTap: () {
Navigator.of(context).pushNamed(
'/router/scan_web',
arguments: {
"result": widget.arguments?["shareUrl"],
"title":"一心回乡",
"title": "一心回乡",
},
);
},
@ -182,16 +168,25 @@ class _ShareTrends extends State<ShareTrends>{
color: Color(0xFFF2F2F2),
borderRadius: BorderRadius.circular(6),
),
padding: EdgeInsets.only(top: 8.h,bottom: 8.h,left: 8.w,right: 10.w),
padding: EdgeInsets.only(
top: 8.h,
bottom: 8.h,
left: 8.w,
right: 10.w,
),
margin: EdgeInsets.only(top: 12.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if(article?.content != null && article!.content!.contains("images\":[\"") || (article?.coverImg ?? "")!= "")
if (article?.content != null &&
article!.content!
.contains("images\":[\"") ||
(article?.coverImg ?? "") != "")
MImage(
article?.content != null &&
article!.content!.contains("images\":[\"")
article!.content!
.contains("images\":[\"")
? jsonDecode(article!.content!)["images"][0]
: article?.coverImg ?? "",
radius: BorderRadius.circular(2),
@ -201,26 +196,32 @@ class _ShareTrends extends State<ShareTrends>{
errorSrc: "assets/image/default_2_1.webp",
fadeSrc: "assets/image/default_2_1.webp",
),
if(article?.content != null || article?.coverImg != null)
SizedBox(width: 7.w,),
Expanded(child: Text(
if (article?.content != null ||
article?.coverImg != null)
SizedBox(
width: 7.w,
),
Expanded(
child: Text(
article?.mainTitle ?? "",
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xFF4D4D4D),
fontSize:14.sp,
fontSize: 14.sp,
height: 1.4.h,
fontWeight: MyFontWeight.regular,
),
),),
),
),
],
),
)),
),
),
],
),
),
)
),
],
),
),

16
lib/constant.dart

@ -7,24 +7,26 @@ const String chatImageHost = "http://skk8mlm5b.hn-bkt.clouddn.com/";
/// socket的host和port端口
//47.93.216.24:9090 线 192.168.10.200/192.168.10.129:9090
const String socketHost = kDebugMode ? '192.168.10.200' : '47.93.216.24';
const String socketHost = kReleaseMode ? '192.168.10.200' : '47.93.216.24';
const int socketPort = 9090;
const ipBaseUrl = "http://whois.pconline.com.cn";
///
const localMiniBaseUrl = "http://192.168.10.54:8765/app/"; ///
// const localMiniBaseUrl = "http://192.168.10.54:8765/app/"; ///
///线
/// app接口的请求地址
const localMiniBaseUrl = "https://pos.api.yixinhuixiang.com/app/";
const serviceMiniBaseUrl = "https://pos.api.yixinhuixiang.com/app/";
///线
/// app接口的请求地址
const localBaseUrl = "http://192.168.10.54:8766/app/"; ///
// const localBaseUrl = "http://192.168.10.54:8766/app/"; ///
///线
const localBaseUrl = "https://pos.platform.yixinhuixiang.com/app/";
const serviceBaseUrl = "https://pos.platform.yixinhuixiang.com/app/";
///线
/// 线
/// list进行分组
Map<S, List<T>> groupBy<S, T>(Iterable<T> values, S Function(T) key) {
var map = <S, List<T>>{};
@ -61,16 +63,16 @@ Map<String, T> groupItem<S, T>(Map<S, List<T>> values, {int Function(T)? key}) {
///
T max<T>(Iterable<T> list, int Function(T) key) {
late T tt;
T? tt;
for (T t in list) {
if (tt == null) {
tt = t;
}
if (key(tt) < key(t)) {
if (key(tt!) < key(t)) {
tt = t;
}
}
return tt;
return tt!;
}
extension ListExtension<S, T> on Iterable<T> {

2
lib/data/article.dart

@ -16,7 +16,7 @@ class Article {
dynamic viceTitle;
String? content = '';
String? coverImg = '';
Author? author;
dynamic author;
int? type = 0;
int? likes = 0;
int? viewers = 0;

6
lib/data/article.g.dart

@ -18,9 +18,7 @@ Article _$ArticleFromJson(Map<String, dynamic> json) => Article()
..viceTitle = json['viceTitle']
..content = json['content'] as String?
..coverImg = json['coverImg'] as String?
..author = json['author'] == null
? null
: Author.fromJson(json['author'] as Map<String, dynamic>)
..author = json['author']
..type = (json['type'] as num?)?.toInt()
..likes = (json['likes'] as num?)?.toInt()
..viewers = (json['viewers'] as num?)?.toInt()
@ -53,7 +51,7 @@ Map<String, dynamic> _$ArticleToJson(Article instance) => <String, dynamic>{
'viceTitle': instance.viceTitle,
'content': instance.content,
'coverImg': instance.coverImg,
'author': instance.author?.toJson(),
'author': instance.author,
'type': instance.type,
'likes': instance.likes,
'viewers': instance.viewers,

32
lib/data/vip_card.dart

@ -1,3 +1,5 @@
import 'dart:ui';
import 'package:huixiang/data/store.dart';
import 'package:json_annotation/json_annotation.dart';
@ -5,39 +7,69 @@ part 'vip_card.g.dart';
@JsonSerializable(explicitToJson: true)
class VipCard {
@JsonKey()
String? id = '';
@JsonKey()
String? createTime = '';
@JsonKey()
dynamic createUser;
@JsonKey()
String? updateTime = '';
@JsonKey()
String? updateUser = '';
@JsonKey()
String? mid = '';
@JsonKey()
String? openid = '';
@JsonKey()
String? nickname = '';
@JsonKey()
String? headimg = '';
@JsonKey()
String? balance = '';
@JsonKey()
String? realRecharge = '';
@JsonKey()
String? sex = '';
@JsonKey()
bool? status = false;
@JsonKey()
bool? onCredit = false;
@JsonKey()
String? loginTime = '';
@JsonKey()
int? loginNum = 0;
@JsonKey()
String? tenantCode = '';
@JsonKey()
int? source = 0;
@JsonKey()
String? expendAmount = '';
@JsonKey()
int? buyTimes = 0;
@JsonKey()
dynamic lastBuyTime;
@JsonKey(name: "vip_no")
dynamic vipNo;
@JsonKey()
dynamic expireTime;
@JsonKey()
int? integral = 0;
@JsonKey()
int? level = 0;
@JsonKey()
dynamic vipRegStore;
@JsonKey()
String? tenantName = '';
@JsonKey()
String? tenantLogo = '';
@JsonKey()
List<Store>? storeList = [];
VipCard();
Color color = Color(0xFF32A060);
factory VipCard.fromJson(Map<String, dynamic> json) => _$VipCardFromJson(json);
Map<String, dynamic> toJson() => _$VipCardToJson(this);

9
lib/home/activity_list_page.dart

@ -7,6 +7,7 @@ import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/event_type.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:keframe/keframe.dart';
@ -39,9 +40,7 @@ class _ActivityListPage extends State<ActivityListPage>
List<Activity>? activityList;
queryActivity() async {
final SharedPreferences value = await SharedPreferences.getInstance();
apiService =
ApiService(Dio(), context: context, token: value.getString('token'));
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token);
BaseData<PageInfo<Activity>>? baseData = await apiService?.informationList({
"pageNum": 1,
"pageSize": 10,
@ -50,7 +49,7 @@ class _ActivityListPage extends State<ActivityListPage>
"state": 1
}).catchError((error) {
_refreshController.refreshFailed();
return Future.value(null);
return BaseData<PageInfo<Activity>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
_refreshController.refreshCompleted();
@ -92,7 +91,7 @@ class _ActivityListPage extends State<ActivityListPage>
Navigator.of(context).pushNamed(
'/router/web_page',
arguments: {
"activityId": activityList![position].id
"activityId": activityList![position].id,
},
);
},

314
lib/home/founder_story_page.dart

@ -33,7 +33,9 @@ class _FounderStoryPage extends State<FounderStoryPage> {
children: [
Container(
// margin: EdgeInsets.only(bottom: 20),
padding: EdgeInsets.only(left: 32.w, right: 32.w, top: 24.h),
padding: EdgeInsets.only(
left: 32.w, right: 32.w, top: 24.h,
),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
@ -41,7 +43,8 @@ class _FounderStoryPage extends State<FounderStoryPage> {
color: Colors.black.withAlpha(12),
offset: Offset(0, 2),
blurRadius: 14,
spreadRadius: 0,)
spreadRadius: 0,
),
],
),
child: Column(
@ -55,9 +58,13 @@ class _FounderStoryPage extends State<FounderStoryPage> {
SizedBox(
height: 16,
),
Text("关于创始人",
Text(
"关于创始人",
style: TextStyle(
fontSize: 24.sp, color: Color(0xff565656))),
fontSize: 24.sp,
color: Color(0xff565656),
),
),
SizedBox(
height: 18.h,
),
@ -75,8 +82,10 @@ class _FounderStoryPage extends State<FounderStoryPage> {
color: Color(0xFF1A1A1A),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
height: 1.5),
)),
height: 1.5,
),
),
),
Padding(
padding: EdgeInsets.only(top: 50.h),
child: Align(
@ -103,8 +112,10 @@ class _FounderStoryPage extends State<FounderStoryPage> {
color: Color(0xFF1A1A1A),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
height: 1.5.h),
)),
height: 1.5.h,
),
),
),
Image.asset(
"assets/image/icon_story_2.webp",
alignment: Alignment.centerRight,
@ -132,7 +143,9 @@ class _FounderStoryPage extends State<FounderStoryPage> {
style: TextStyle(
fontSize: 24.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xff565656))),
color: Color(0xff565656),
),
),
SizedBox(
height: 20,
),
@ -149,7 +162,9 @@ class _FounderStoryPage extends State<FounderStoryPage> {
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xff565656))),
color: Color(0xff565656),
),
),
),
_textWidget("2019年,在武汉成立湖北海峡姐妹餐饮有限公司。"
"成为百年川椒火锅(光谷店)运营方,通过“素食煮义”和“蔬食之力”推广有机永续美好生活,"
@ -169,7 +184,9 @@ class _FounderStoryPage extends State<FounderStoryPage> {
style: TextStyle(
fontSize: 24.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xff565656))),
color: Color(0xff565656),
),
),
SizedBox(
height: 26.h,
),
@ -205,7 +222,8 @@ class _FounderStoryPage extends State<FounderStoryPage> {
color: Colors.black.withAlpha(12),
offset: Offset(0, 2),
blurRadius: 14,
spreadRadius: 0)
spreadRadius: 0,
),
],
),
child: RichText(
@ -217,8 +235,10 @@ class _FounderStoryPage extends State<FounderStoryPage> {
color: Colors.white,
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
height: 1.5.h),
)),
height: 1.5.h,
),
),
),
),
Padding(
padding: EdgeInsets.only(
@ -233,11 +253,14 @@ class _FounderStoryPage extends State<FounderStoryPage> {
SizedBox(
height: 27.h,
),
Text("传递理念",
Text(
"传递理念",
style: TextStyle(
fontSize: 24.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xff565656))),
color: Color(0xff565656),
),
),
SizedBox(
height: 20.h,
),
@ -264,108 +287,6 @@ class _FounderStoryPage extends State<FounderStoryPage> {
],
),
),
// Container(
// // margin: EdgeInsets.only(bottom: 20),
// // padding: EdgeInsets.all(16),
// decoration: BoxDecoration(
// color: Colors.white,
// boxShadow: [
// BoxShadow(
// color: Colors.black.withAlpha(12),
// offset: Offset(0, 2),
// blurRadius: 14,
// spreadRadius: 0)
// ],
// ),
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Padding(
// padding: EdgeInsets.all(16),
// child: Text("评论 (58) 喜欢 (58)",
// style: TextStyle(
// fontSize: 16,
// fontWeight: FontWeight.bold,
// color: Color(0xff1A1A1A))),
// ),
// SizedBox(
// height: 600,
// child: ListView.builder(
// itemCount: 6,
// scrollDirection: Axis.vertical,
// physics: BouncingScrollPhysics(),
// itemBuilder: (context, position) {
// return _commentItem(position);
// },
// ),
// ),
// ],
// ),
// ),
// SizedBox(
// height: 12,
// ),
// Container(
// padding: EdgeInsets.all(16),
// decoration: BoxDecoration(
// color: Colors.white,
// boxShadow: [
// BoxShadow(
// color: Colors.black.withAlpha(12),
// offset: Offset(0, 2),
// blurRadius: 14,
// spreadRadius: 0)
// ],
// borderRadius: new BorderRadius.only(
// topLeft: Radius.circular(8.0),
// topRight: Radius.circular(8.0),
// ),
// ),
// child: Row(
// children: [
// Expanded(
// flex: 1,
// child: Container(
// decoration: new BoxDecoration(
// color: Color(0xffF2F2F2),
// borderRadius: BorderRadius.circular(2.0)),
// child: Column(
// children: [
// Container(
// margin: const EdgeInsets.fromLTRB(4, 0, 4, 0),
// alignment: Alignment.topLeft,
// child: TextField(
// maxLines: 8,
// minLines: 1,
// decoration: InputDecoration(
// border: InputBorder.none,
// hintText: "留下您精彩的评论吧~",
// hintStyle: TextStyle(
// fontSize: 14,
// color: Color(0xffCDCCCC),
// ),
// ),
// ),
// ),
// ],
// ),
// ),
// ),
// Padding(
// padding: EdgeInsets.only(left: 20, right: 20),
// child: Text(
// "发送",
// style: TextStyle(
// fontSize: 16,
// fontWeight: FontWeight.bold,
// color: Color(0XFF1A1A1A)),
// ),
// ),
// Image.asset("assets/image/icon_like_h.webp")
// ],
// ),
// ),
],
),
),
@ -382,7 +303,10 @@ class _FounderStoryPage extends State<FounderStoryPage> {
children: [
Text(
"",
style: TextStyle(fontSize: 10.sp, color: Color(0xff32A060)),
style: TextStyle(
fontSize: 10.sp,
color: Color(0xff32A060),
),
),
SizedBox(
width: 5.w,
@ -392,7 +316,10 @@ class _FounderStoryPage extends State<FounderStoryPage> {
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Colors.black))),
color: Colors.black,
),
),
),
],
),
);
@ -421,23 +348,11 @@ class _FounderStoryPage extends State<FounderStoryPage> {
style: TextStyle(
fontSize: 18.sp,
fontWeight: MyFontWeight.light,
color: Colors.white),
)
color: Colors.white,
),
),
],
),
// CircleAvatar(
// radius: 100,
// backgroundImage: Image.asset(img),
// child: Container(
// alignment: Alignment.center,
// child: Text(
// text,
// style: TextStyle(
// fontSize: 18,
// fontWeight: FontWeight.w300,
// color: Colors.white),
// )),
// ),
),
Container(
width: 73.w,
@ -446,136 +361,13 @@ class _FounderStoryPage extends State<FounderStoryPage> {
painter: MyPainter(
lineColor: Color(0xff32A060),
width: 2.w,
isDividerRound: true),
isDividerRound: true,
),
),
),
)
],
),
);
}
// Widget _commentItem(var position) {
// return Container(
// child: Column(
// children: [
// Padding(
// padding: EdgeInsets.all(16),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// ClipOval(
// child: Image.network(
// "https://t7.baidu.com/it/u=2841334870,333581502&fm=193&f=GIF",
// fit: BoxFit.cover,
// width: 40,
// height: 40,
// ),
// clipBehavior: Clip.hardEdge,
// ),
// SizedBox(
// width: 12,
// ),
// Expanded(
// child: Container(
// height: 60,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text.rich(
// TextSpan(children: [
// TextSpan(
// text: "张三",
// style: TextStyle(
// fontWeight: FontWeight.bold,
// fontSize: 14,
// color: Colors.black),
// ),
// ]),
// textDirection: TextDirection.ltr,
// ),
// Text(
// "2021.04.12 12:12",
// overflow: TextOverflow.ellipsis,
// maxLines: 2,
// style: TextStyle(
// fontSize: 12,
// color: Color(0xff808080),
// ),
// ),
// ],
// ),
// ),
// flex: 1,
// ),
// Container(
// alignment: Alignment.topRight,
// child: Row(
// children: [
// Image.asset(
// "assets/image/icon_like.webp",
// width: 16,
// height: 16,
// ),
// Text(
// "58",
// style:
// TextStyle(fontSize: 12, color: Color(0xff1A1A1A)),
// ),
// ],
// ),
// ),
// ],
// ),
// ),
// Padding(
// padding: EdgeInsets.only(left: 68, right: 16),
// child: Text(
// "文本,是指书面语言的表现形式,从文学角度说,通常是具有完整、系统含义(Mess…",
// style: TextStyle(fontSize: 14, color: Color(0xff1A1A1A)),
// ),
// ),
// SizedBox(
// height: 12,
// ),
// Container(
// width: double.infinity,
// margin: EdgeInsets.only(left: 68, right: 16),
// decoration: new BoxDecoration(
// color: Color(0xffF2F2F2),
// borderRadius: BorderRadius.circular(2.0),
// ),
// child: Padding(
// padding: EdgeInsets.only(left: 4, top: 4, bottom: 4),
// child: Text(
// "文本,是指书面语言的表现形式文本,是指、",
// style: TextStyle(fontSize: 12, color: Color(0xff808080)),
// ),
// ),
// ),
// if (position == 5)
// Container(
// height: 63,
// decoration: BoxDecoration(
// color: Color(0xffF2F2F2),
// boxShadow: [
// BoxShadow(
// color: Colors.black.withAlpha(12),
// offset: Offset(0, 2),
// blurRadius: 14,
// spreadRadius: 0)
// ],
// ),
// margin: EdgeInsets.only(top: 30),
// alignment: Alignment.center,
// child: Text(
// "-已显示全部评论-",
// style: TextStyle(fontSize: 14, color: Color(0xff353535)),
// ),
// ),
// ],
// ),
// );
// }
}

47
lib/home/guide_page.dart

@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/utils/constant.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/border_text.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -27,24 +28,9 @@ class _GuidePage extends State<GuidePage> {
}
isLogin() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
if (sharedPreferences.getBool("isShowPrivacyPolicy") == null ||
!(sharedPreferences.getBool("isShowPrivacyPolicy") ?? false)) {
if (!SharedInstance.instance.isShowPrivacyPolicy) {
showAlertDialog();
}
// if (sharedPreferences.containsKey('token') &&
// sharedPreferences.getString("token") != null &&
// sharedPreferences.getString("token") != "") {
// Navigator.of(context).popAndPushNamed('/router/main_page');
// } else {
// initController();
//
// apiService = ApiService(Dio(), context: context);
// isShowLogin = true;
// setState(() {});
// }
}
@override
@ -70,7 +56,9 @@ class _GuidePage extends State<GuidePage> {
color: Colors.white,
child: Center(
child: Container(
margin: EdgeInsets.only(top: 120.h, left: 19.w, right: 19.w),
margin: EdgeInsets.only(
top: 120.h, left: 19.w, right: 19.w,
),
child: Stack(
children: [
Column(
@ -164,7 +152,9 @@ class _GuidePage extends State<GuidePage> {
color: Colors.white,
child: Center(
child: Container(
margin: EdgeInsets.only(top: 120.h, left: 19.w, right: 19.w),
margin: EdgeInsets.only(
top: 120.h, left: 19.w, right: 19.w,
),
child: Stack(
children: [
Column(
@ -478,7 +468,8 @@ class _GuidePage extends State<GuidePage> {
child: Column(
children: [
Text.rich(
TextSpan(children: [
TextSpan(
children: [
TextSpan(
text: S.of(context).yinsizhengce1,
style: TextStyle(
@ -497,11 +488,11 @@ class _GuidePage extends State<GuidePage> {
),
recognizer: TapGestureRecognizer()
..onTap = () {
Navigator.of(context)
.popAndPushNamed('/router/treaty_page');
Navigator.of(context).popAndPushNamed('/router/treaty_page');
},
),
]),
],
),
),
10.d,
Text(
@ -557,9 +548,7 @@ class _GuidePage extends State<GuidePage> {
textColor: Colors.white,
fontSize: 12.sp,
callback: () {
SharedPreferences.getInstance().then((value) {
value.setBool("isShowPrivacyPolicy", true);
});
SharedInstance.instance.showPrivacyPolicy();
SharesdkPlugin.uploadPrivacyPermissionStatus(
1,
(success) {
@ -591,14 +580,12 @@ class _GuidePage extends State<GuidePage> {
}
toNext() {
SharedPreferences.getInstance().then((value) {
value.setBool("isFirst", false);
String? token = value.getString("token");
if (token?.isEmpty ?? true) {
SharedInstance.instance.setFirst();
String token = SharedInstance.instance.token;
if (token.isEmpty) {
Navigator.of(context).popAndPushNamed('/router/new_login_page');
} else {
Navigator.of(context).popAndPushNamed('/router/main_page');
}
});
}
}

59
lib/home/help_farmers/help_farmers_page.dart

@ -9,6 +9,7 @@ import 'package:huixiang/data/good_list.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/home/help_farmers/farmers_tab.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shimmer/shimmer.dart';
@ -38,20 +39,18 @@ class _HelpFarmersPage extends State<HelpFarmersPage> {
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context,
token: value.getString('token'),
showLoading: true),
queryConfig(),
});
token: SharedInstance.instance.token,
showLoading: true,
);
queryConfig();
}
///
queryConfig() async {
try {
BaseListData<Farmers>? baseData =
await apiService?.getConfig().catchError((error) {
BaseListData<Farmers>? baseData = await apiService?.getConfig().catchError((error) {
networkStatus = -1;
refreshController.refreshFailed();
return BaseListData<Farmers>()..isSuccess = false;
@ -224,7 +223,9 @@ class _HelpFarmersPage extends State<HelpFarmersPage> {
isShowBtn: false,
text: "当前分类暂无商品",
fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h, left: 60.w, right: 60.w),
margin: EdgeInsets.only(
top: 120.h, left: 60.w, right: 60.w,
),
)
: StaggeredGrid.count(
crossAxisCount: 2,
@ -260,7 +261,7 @@ class _HelpFarmersPage extends State<HelpFarmersPage> {
offset: Offset(0, 2),
blurRadius: 4,
spreadRadius: 0,
)
),
],
color: Colors.white,
),
@ -298,12 +299,13 @@ class _HelpFarmersPage extends State<HelpFarmersPage> {
),
),
Padding(
padding: EdgeInsets.only(left: 10.w, bottom: 12.h),
padding: EdgeInsets.only(
left: 10.w, bottom: 12.h,
),
child: Row(
children: [
Text(
AppUtils.calculateDouble(
double.tryParse("${goodList.price}") ?? 0),
AppUtils.calculateDouble(double.tryParse("${goodList.price}") ?? 0),
style: TextStyle(
fontSize: 24.sp,
fontFamily: 'APPHT',
@ -313,7 +315,9 @@ class _HelpFarmersPage extends State<HelpFarmersPage> {
),
Container(
margin: EdgeInsets.only(left: 8.w),
padding: EdgeInsets.symmetric(vertical: 3.h, horizontal: 9.w),
padding: EdgeInsets.symmetric(
vertical: 3.h, horizontal: 9.w,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
boxShadow: [
@ -355,8 +359,9 @@ class _HelpFarmersPage extends State<HelpFarmersPage> {
offset: Offset(0, 1),
blurRadius: 12,
spreadRadius: 0,
)
]),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -372,7 +377,9 @@ class _HelpFarmersPage extends State<HelpFarmersPage> {
Row(
children: [
Padding(
padding: EdgeInsets.only(left: 6.w, bottom: 5.h, top: 12.h),
padding: EdgeInsets.only(
left: 6.w, bottom: 5.h, top: 12.h,
),
child: Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
@ -387,7 +394,9 @@ class _HelpFarmersPage extends State<HelpFarmersPage> {
),
),
Padding(
padding: EdgeInsets.only(left: 12.w, bottom: 5.h, top: 12.h),
padding: EdgeInsets.only(
left: 12.w, bottom: 5.h, top: 12.h,
),
child: Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
@ -402,7 +411,9 @@ class _HelpFarmersPage extends State<HelpFarmersPage> {
),
),
Padding(
padding: EdgeInsets.only(left: 12.w, bottom: 5.h, top: 12.h),
padding: EdgeInsets.only(
left: 12.w, bottom: 5.h, top: 12.h,
),
child: Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
@ -417,7 +428,9 @@ class _HelpFarmersPage extends State<HelpFarmersPage> {
),
),
Padding(
padding: EdgeInsets.only(left: 12.w, bottom: 5.h, top: 12.h),
padding: EdgeInsets.only(
left: 12.w, bottom: 5.h, top: 12.h,
),
child: Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
@ -457,8 +470,9 @@ class _HelpFarmersPage extends State<HelpFarmersPage> {
),
),
Padding(
padding:
EdgeInsets.only(top: 7.h, left: 10.w, bottom: 8.h),
padding: EdgeInsets.only(
top: 7.h, left: 10.w, bottom: 8.h,
),
child: Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8),
@ -509,7 +523,8 @@ class _HelpFarmersPage extends State<HelpFarmersPage> {
),
);
},
)),
),
),
],
),
);

72
lib/home/home_page.dart

@ -6,8 +6,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_swiper_view/flutter_swiper_view.dart';
import 'package:get/get.dart';
import 'package:get/utils.dart';
import 'package:huixiang/data/activity_pos.dart';
import 'package:huixiang/data/article.dart';
import 'package:huixiang/data/banner.dart';
@ -20,6 +18,7 @@ import 'package:huixiang/data/goods_category.dart';
import 'package:huixiang/data/home_rank.dart';
import 'package:huixiang/data/login_info.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/data/user_info.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/home/home_view/discount_zone.dart';
import 'package:huixiang/home/home_view/home_recommend_goods.dart';
@ -31,19 +30,18 @@ import 'package:huixiang/home/points_mall_view/points_goods_view.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/event_type.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/activity_coupons.dart';
import 'package:huixiang/view_widget/activity_poster.dart';
import 'package:huixiang/view_widget/channel_dialog.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/invite_success_dialog.dart';
import 'package:huixiang/view_widget/request_permission.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../data/user_info.dart';
import '../utils/flutter_utils.dart';
import '../view_widget/channel_dialog.dart';
import '../view_widget/custom_image.dart';
import 'home_view/happy_help_farmers.dart';
import 'home_view/shortcut_operation.dart';
@ -99,29 +97,20 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
setState(() {});
}
});
if (apiService == null) {
SharedPreferences.getInstance().then((value) {
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
);
_onRefresh(isFirstIn: true);
});
}
if (showInvite) {
inviteShowAlertDialog(widget.invite, widget.interviewCouponList?[0]);
showInvite = false;
}
if ((widget.invite?.isNotEmpty ?? false) ||
(widget.interviewCouponList?.isNotEmpty ?? false)) {
if ((widget.invite?.isNotEmpty ?? false) || (widget.interviewCouponList?.isNotEmpty ?? false)) {
showInvite = true;
}
//
// if (widget.firstLoginCouponList != null && widget.firstLoginCouponList.length > 0)
// showNew = true;
}
///
@ -138,14 +127,11 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
///
posterShowAlertDialog(ActivityPos? activityPos, firstLoginCouponList) {
var today = DateTime.now().day;
SharedPreferences.getInstance().then((value) {
if (value.getInt("today") == today &&
(value.getString("ActivityPosCode") ?? "")
.contains("${activityPos?.code}_${value.getString("userId")};"))
if (SharedInstance.instance.today == today && (SharedInstance.instance.ActivityPosCode).contains("${activityPos?.code}_${SharedInstance.instance.userId};"))
return;
value.setString("ActivityPosCode",
"${(value.getString("ActivityPosCode") ?? "")}${activityPos?.code}_${value.getString("userId")};");
value.setInt("today", today);
SharedInstance.instance.saveActivityPosCode("${SharedInstance.instance.ActivityPosCode}${activityPos?.code}_${SharedInstance.instance.userId};");
SharedInstance.instance.saveToday(today);
//
showDialog(
context: context,
@ -153,7 +139,6 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
return ActivityPoster(activityPos, firstLoginCouponList);
},
);
});
}
///
@ -309,7 +294,7 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
// apiService = ApiService(
// Dio(),
// context: context,
// token: value.getString("token"),
// token: SharedInstance.instance.token,
// );
// }
// BaseData<List<MsgStats>>? baseData = await apiService?.stats().catchError((onError) {});
@ -337,22 +322,16 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
///
queryWiped(memberCouponId) async {
if (apiService == null) {
SharedPreferences.getInstance().then((value) {
apiService = ApiService(
apiService ??= ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
);
});
}
BaseData? baseData = await apiService?.wiped(memberCouponId).catchError((onError) {
return BaseData()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
SmartDialog.showToast("核销成功", alignment: Alignment.center);
} else {
SmartDialog.showToast("${baseData?.msg}", alignment: Alignment.center);
}
}
@ -556,18 +535,26 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
bannerClick(BannerData bannerData) async {
switch (bannerData.contentType) {
case 1:
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": bannerData.content});
Navigator.of(context).pushNamed(
'/router/integral_store_page',
arguments: {
"goodsId": bannerData.content,
},
);
break;
case 2:
Navigator.of(context).pushNamed('/router/web_page', arguments: {
Navigator.of(context).pushNamed(
'/router/web_page', arguments: {
"activityId": bannerData.content,
});
},
);
break;
case 3:
Navigator.of(context).pushNamed('/router/web_page', arguments: {
Navigator.of(context).pushNamed(
'/router/web_page', arguments: {
"articleId": bannerData.content,
});
},
);
break;
case 4:
String? router = bannerData.content;
@ -599,7 +586,8 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
Map map = jsonDecode(params);
Navigator.of(context).pushNamed(
router.substring(0, router.indexOf("?")),
arguments: map);
arguments: map,
);
break;
}
}

6
lib/home/home_view/activity_list.dart

@ -8,6 +8,7 @@ import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/event_type.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
@ -41,8 +42,7 @@ class _ActivityList extends State<ActivityList>
List<Activity>? activityList;
queryActivity() async {
final SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(Dio(), context: context, token: value.getString('token'));
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token);
BaseData<PageInfo<Activity>>? baseData = await apiService?.informationList({
"pageNum": 1,
"pageSize": 10,
@ -51,7 +51,7 @@ class _ActivityList extends State<ActivityList>
"state": 1
}).catchError((error) {
_refreshController.refreshFailed();
return Future.value(null);
return BaseData<PageInfo<Activity>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
_refreshController.refreshCompleted();

2
lib/home/home_view/brand_view.dart

@ -72,7 +72,7 @@ class _BrandView extends State<BrandView> {
),
);
},
itemCount: widget.brandData.length ?? 0,
itemCount: widget.brandData.length,
),
);
}

17
lib/home/home_view/coupon.dart

@ -7,6 +7,7 @@ import 'package:huixiang/data/coupon.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/receive_success.dart';
@ -29,15 +30,12 @@ class _CouponView extends State<CouponView> {
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(
Dio(),
context: context,
token: value.getString('token'),
),
queryCoupon(),
});
token: SharedInstance.instance.token,
);
queryCoupon();
}
queryCoupon() async {
@ -48,7 +46,7 @@ class _CouponView extends State<CouponView> {
"searchKey": "",
"state": 0
}).catchError((onError) {
return Future.value(null);
return BaseData<PageInfo<Coupon>>()..isSuccess = false;
});
coupons.clear();
if (baseData?.isSuccess ?? false) {
@ -78,7 +76,7 @@ class _CouponView extends State<CouponView> {
itemBuilder: (context, position) {
return couponItem(coupons[position]);
},
itemCount:coupons == null ? 0 : coupons.length,
itemCount: coupons.length,
),
),
],
@ -271,7 +269,8 @@ class _CouponView extends State<CouponView> {
receiveCoupon(couponId) async {
BaseData? baseData = await apiService?.receiveCoupon(couponId).catchError((onError) {
return Future.value(null);});
return BaseData()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
queryCoupon();
showAlertDialog();

1
lib/home/home_view/discount_zone.dart

@ -18,7 +18,6 @@ class DiscountZone extends StatefulWidget {
}
class _DiscountZone extends State<DiscountZone> {
ApiService? apiService;
@override
void initState() {

49
lib/home/home_view/featured_acticvity.dart

@ -6,6 +6,7 @@ import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -29,8 +30,7 @@ class _FeaturedActivity extends State<FeaturedActivity> {
List<Activity>? activityList;
queryActivity() async {
final SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(Dio(), context: context, token: value.getString('token'));
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token);
BaseData<PageInfo<Activity>>? baseData = await apiService?.informationList({
"pageNum": 1,
"pageSize": 10,
@ -38,7 +38,8 @@ class _FeaturedActivity extends State<FeaturedActivity> {
"type": 1,
"state": 1
}).catchError((error) {
return Future.value(null);});
return BaseData<PageInfo<Activity>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
activityList = baseData?.data?.list ?? [];
if (activityList!.length == 1)
@ -70,8 +71,10 @@ class _FeaturedActivity extends State<FeaturedActivity> {
if (activityList?.isNotEmpty ?? false)
GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/web_page',
arguments: {"activityId": activityList?[0].id});
Navigator.of(context).pushNamed(
'/router/web_page',
arguments: {"activityId": activityList?[0].id},
);
},
child: Container(
child: stackItem(18.sp, activityList?[0]),
@ -98,8 +101,10 @@ class _FeaturedActivity extends State<FeaturedActivity> {
children: [
GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/web_page',
arguments: {"activityId": activityList?[1].id});
Navigator.of(context).pushNamed(
'/router/web_page',
arguments: {"activityId": activityList?[1].id},
);
},
child: Container(
child: stackItem(12.sp, activityList?[1]),
@ -118,31 +123,6 @@ class _FeaturedActivity extends State<FeaturedActivity> {
),
),
),
// SizedBox(
// height: 5,
// ),
// GestureDetector(
// onTap: () {
// Navigator.of(context).pushNamed('/router/web_page',
// arguments: {"activityId": activityList[2].id});
// },
// child: Container(
// child: stackItem(12.sp, activityList[2]),
// margin: EdgeInsets.symmetric(horizontal: 5.w),
// width: (MediaQuery.of(context).size.width - 42) / 2,
// height: 190.h / 2,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(4),
// color: Colors.blue,
// image: DecorationImage(
// image: NetworkImage(
// activityList[2].coverImg,
// ),
// fit: BoxFit.fill,
// ),
// ),
// ),
// ),
],
),
),
@ -232,8 +212,9 @@ class _FeaturedActivity extends State<FeaturedActivity> {
),
Spacer()
],
)
),
],
));
),
);
}
}

7
lib/home/home_view/founder_store.dart

@ -32,8 +32,7 @@ class _FounderStore extends State<FounderStore> {
),
GestureDetector(
onTap: () {
Navigator.of(context)
.pushNamed('/router/founder_story_page');
Navigator.of(context).pushNamed('/router/founder_story_page');
},
child: founderStore(),
),
@ -44,7 +43,9 @@ class _FounderStore extends State<FounderStore> {
Widget founderStore() {
return Container(
margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 22.h, bottom: 28.h),
margin: EdgeInsets.only(
left: 16.w, right: 16.w, top: 22.h, bottom: 28.h,
),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(

2
lib/home/home_view/happy_help_farmers.dart

@ -13,14 +13,12 @@ class HappyHelpFarmers extends StatefulWidget {
}
class _HappyHelpFarmers extends State<HappyHelpFarmers> {
ApiService? apiService;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(

27
lib/home/home_view/home_banner.dart

@ -75,18 +75,26 @@ class _HomeBanner extends State<HomeBanner> {
bannerClick(BannerData bannerData) async {
switch (bannerData.contentType) {
case 1:
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": bannerData.content});
Navigator.of(context).pushNamed(
'/router/integral_store_page',
arguments: {"goodsId": bannerData.content},
);
break;
case 2:
Navigator.of(context).pushNamed('/router/web_page', arguments: {
Navigator.of(context).pushNamed(
'/router/web_page',
arguments: {
"activityId": bannerData.content,
});
},
);
break;
case 3:
Navigator.of(context).pushNamed('/router/web_page', arguments: {
Navigator.of(context).pushNamed(
'/router/web_page',
arguments: {
"articleId": bannerData.content,
});
},
);
break;
case 4:
String? router = bannerData.content;
@ -105,9 +113,12 @@ class _HomeBanner extends State<HomeBanner> {
}
break;
case 5:
Navigator.of(context).pushNamed('/router/class_details', arguments: {
Navigator.of(context).pushNamed(
'/router/class_details',
arguments: {
"id": bannerData.content,
});
},
);
break;
case 7:
String? router = bannerData.content;

10
lib/home/home_view/home_integral_store.dart

@ -45,7 +45,9 @@ class _HomeIntegralStore extends State<HomeIntegralStore> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(padding: EdgeInsets.only(left: 16,bottom: 10),child: Text(
Padding(
padding: EdgeInsets.only(left: 16,bottom: 10),
child: Text(
S.of(context).dajiadouzaiduihuan,
textAlign: TextAlign.end,
style: TextStyle(
@ -85,8 +87,10 @@ class _HomeIntegralStore extends State<HomeIntegralStore> {
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": widget.gooods[index].id});
Navigator.of(context).pushNamed(
'/router/integral_store_page',
arguments: {"goodsId": widget.gooods[index].id},
);
},
child: buildItem(widget.gooods[index]),
);

8
lib/home/home_view/home_recommend_goods.dart

@ -1,8 +1,10 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:huixiang/data/home_rank.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/app_util.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:huixiang/utils/font_weight.dart';
@ -25,6 +27,11 @@ class _HomeRecommendGoods extends State<HomeRecommendGoods> {
@override
void initState() {
apiService = ApiService(
Dio(),
context: context,
token: SharedInstance.instance.token,
);
super.initState();
}
@ -145,4 +152,5 @@ class _HomeRecommendGoods extends State<HomeRecommendGoods> {
),
);
}
}

11
lib/home/home_view/hot_article.dart

@ -29,8 +29,7 @@ class _HotArticle extends State<HotArticle> {
imgPath: "assets/image/icon_today_video.webp",
moreText: S.of(context).chakangengduo,
onTap: () {
Navigator.of(context)
.pushNamed('/router/hot_article_page');
Navigator.of(context).pushNamed('/router/hot_article_page');
},
),
hotList(),
@ -43,9 +42,7 @@ class _HotArticle extends State<HotArticle> {
return Container(
child: ListView.builder(
shrinkWrap: true,
itemCount: widget.articles != null
? ((widget.articles.length > 3) ? 3 : widget.articles.length)
: 0,
itemCount: ((widget.articles.length > 3) ? 3 : widget.articles.length),
physics: NeverScrollableScrollPhysics(),
scrollDirection: Axis.vertical,
padding: EdgeInsets.symmetric(vertical: 12.h),
@ -56,7 +53,9 @@ class _HotArticle extends State<HotArticle> {
height: position == 0 ? 247.h : 96.h,
margin: EdgeInsets.symmetric(vertical: 6.h, horizontal: 16.w),
child: HotArticleItem(
article: widget.articles[position], isHot: position == 0),
article: widget.articles[position],
isHot: position == 0,
),
),
);
},

72
lib/home/home_view/quick_order.dart

@ -10,6 +10,7 @@ import 'package:huixiang/utils/location.dart';
import 'package:huixiang/data/store.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/border_text.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/item_title.dart';
@ -36,6 +37,10 @@ class _QuickOrder extends State<QuickOrder> {
@override
void initState() {
apiService = ApiService(Dio(),
context: context,
token: SharedInstance.instance.token,
showLoading: false);
super.initState();
getLatLng();
startLocation();
@ -60,44 +65,30 @@ class _QuickOrder extends State<QuickOrder> {
}
getLatLng() async {
SharedPreferences.getInstance().then(
(value) => {
apiService = ApiService(Dio(),
context: context,
token: value.getString('token'),
showLoading: false),
if (value.containsKey("latitude") &&
value.containsKey("longitude") )
{
token: SharedInstance.instance.token,
showLoading: false);
if (SharedInstance.instance.latitude.isNotEmpty && SharedInstance.instance.longitude.isNotEmpty) {
latLng = Position(
latitude: double.tryParse(value.getString("latitude") ??"")!,
longitude: double.tryParse(value.getString("longitude") ?? "")!,
latitude: double.tryParse(SharedInstance.instance.latitude)!,
longitude: double.tryParse(SharedInstance.instance.longitude)!,
timestamp: DateTime.now(),
accuracy: 0,
altitude: 0,
heading: 0,
speed: 0,
speedAccuracy: 0
),
);
queryStore(
value.getString("latitude"),
value.getString("longitude"),
SharedInstance.instance.latitude,
SharedInstance.instance.longitude,
editingController.text,
),
setState(() {
// _mapController?.updateMapOptions(
// BMFMapOptions(
// center: latLng,
// zoomLevel: 15,
// ));
})
}
else
{
queryStore("", "", editingController.text),
}
},
);
setState(() {});
} else {
queryStore("", "", editingController.text);
}
}
startLocation() async {
@ -125,11 +116,6 @@ class _QuickOrder extends State<QuickOrder> {
"${latLng?.latitude}",
"${latLng?.longitude}",
editingController.text);
// _mapController?.updateMapOptions(BMFMapOptions(
// center: value,
// zoomLevel: 15,
// )
// );
return r;
});
}
@ -137,12 +123,10 @@ class _QuickOrder extends State<QuickOrder> {
}
saveLatLng(Position latLng, province, city, district) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString("latitude", "${latLng.latitude}");
await prefs.setString("longitude", "${latLng.longitude}");
if (province != null) await prefs.setString("province", province);
if (city != null) await prefs.setString("city", city);
if (district != null) await prefs.setString("district", district);
SharedInstance.instance.saveLatLng(latLng);
if (province != null) SharedInstance.instance.setProvince(province);
if (city != null) SharedInstance.instance.setCity(city);
if (district != null) SharedInstance.instance.setDistrict(district);
}
@override
@ -267,14 +251,6 @@ class _QuickOrder extends State<QuickOrder> {
),
),
),
// Text(
// store?.remark ??"",
// style: TextStyle(
// fontSize: 10.sp,
// fontWeight: MyFontWeight.medium,
// color: Color(0xFF868686),
// ),
// ),
SizedBox(
height: 5,
),
@ -386,7 +362,7 @@ class _QuickOrder extends State<QuickOrder> {
//
// http://miniscan.lotus-wallet.com/placeorder?tenant_code=1194&table_id=1669609340031467520&store_id=1637659387134738432
var result = await Navigator.of(context).pushNamed('/router/qr_scan');
if (result == null || result !is String || (result as String).isEmpty) {
if (result == null || result is String || (result as String).isEmpty) {
return;
}
// String result = await scanner.scan();
@ -394,9 +370,7 @@ class _QuickOrder extends State<QuickOrder> {
String tableId = uri.queryParameters["tableId"] ?? uri.queryParameters["table_id"] ?? "";
String tenantCode = uri.queryParameters["tenantCode"] ?? uri.queryParameters["tenant_code"] ?? "";
String shopId = uri.queryParameters["shopId"] ?? uri.queryParameters["store_id"] ?? "";
if (tableId != "" &&
tenantCode != "" &&
shopId != "") {
if (tableId != "" && tenantCode != "" && shopId != "") {
Navigator.of(context).pushNamed(
'/router/store_order',
arguments: {

1
lib/home/home_view/shortcut_operation.dart

@ -16,7 +16,6 @@ class ShortcutOperation extends StatefulWidget {
}
class _ShortcutOperation extends State<ShortcutOperation> {
ApiService? apiService;
@override
void initState() {

11
lib/home/home_view/sign_view.dart

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:huixiang/view_widget/login_tips_dialog.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -27,21 +28,16 @@ class SignView extends StatelessWidget {
imgPath: "assets/image/icon_today_task.webp",
moreText: S.of(context).renwuzhongxin,
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString('token') == null ||
value.getString('token') == "") {
if (SharedInstance.instance.token.isEmpty) {
LoginTipsDialog().show(context);
} else {
Navigator.of(context).pushNamed('/router/integral_page');
}
});
},
),
InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString('token') == null ||
value.getString('token') == "") {
if (SharedInstance.instance.token.isEmpty) {
LoginTipsDialog().show(context);
} else {
Navigator.of(context).pushNamed('/router/integral_page')
@ -49,7 +45,6 @@ class SignView extends StatelessWidget {
if (value != null) setSigned(value),
});
}
});
},
child: signIn(context),
),

3
lib/home/home_view/top_selling_list.dart

@ -1,9 +1,11 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:huixiang/data/good_list.dart';
import 'package:huixiang/data/home_rank.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/app_util.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:huixiang/utils/font_weight.dart';
@ -26,6 +28,7 @@ class _TopSellingList extends State<TopSellingList> {
@override
void initState() {
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token);
super.initState();
}

1
lib/home/home_view/union_entry.dart

@ -17,7 +17,6 @@ class UnionEntry extends StatefulWidget {
}
class _UnionEntry extends State<UnionEntry> {
ApiService? apiService;
@override
void initState() {

1
lib/home/home_view/welfare_core.dart

@ -13,7 +13,6 @@ class WelfareCore extends StatefulWidget {
}
class _WelfareCore extends State<WelfareCore> {
ApiService? apiService;
@override
void initState() {

16
lib/home/huixiang_brand_page.dart

@ -13,6 +13,7 @@ import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/event_type.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/store_title_tab.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
@ -28,8 +29,7 @@ class BrandPage extends StatefulWidget {
}
}
class _BrandPage extends State<BrandPage>
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
class _BrandPage extends State<BrandPage> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
final ScrollController scrollController = ScrollController();
final RefreshController refreshController = RefreshController();
@ -45,17 +45,16 @@ class _BrandPage extends State<BrandPage>
msg: S.current.zhengzaijiazai,
);
final SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString('token'),
token: SharedInstance.instance.token,
);
BaseData<BrandData>? baseData =
await apiService?.queryHome().catchError((error) {
refreshController.refreshFailed();
return Future.value(null);
return BaseData<BrandData>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
brandData = baseData!.data;
@ -67,22 +66,21 @@ class _BrandPage extends State<BrandPage>
"model": {"type": "BRAND_APP"},
}).catchError((error) {
refreshController.refreshFailed();
return Future.value(null);
return BaseData<PageInfo<BannerData>>()..isSuccess = false;
});
bannerData.clear();
bannerData.addAll(banner?.data?.records ?? []);
BaseData? brand = await apiService?.queryHomeBrand().catchError((error) {
refreshController.refreshFailed();
return Future.value(null);
return BaseData()..isSuccess = false;
});
if (brand?.isSuccess ?? false) {
brands.clear();
globaKeys.clear();
brands.addAll((brand!.data["brandList"] as List<dynamic>?)
?.map((e) => Brand.fromJson(e))
.toList() ??
[]);
.toList() ?? []);
founder = Founder.fromJson(brand.data["founder"]);
brands.forEach((element) {
globaKeys.add(GlobalKey());

30
lib/home/huixiang_view/huixiang_banner.dart

@ -69,20 +69,26 @@ class _HuiXiangBanner extends State<HuiXiangBanner> {
bannerClick(BannerData bannerData) async {
switch (bannerData.contentType) {
case 1:
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": bannerData.content});
Navigator.of(context).pushNamed(
'/router/integral_store_page',
arguments: {"goodsId": bannerData.content},
);
break;
case 2:
Navigator.of(context)
.pushNamed('/router/web_page', arguments: {
Navigator.of(context).pushNamed(
'/router/web_page',
arguments: {
"activityId": bannerData.content,
});
},
);
break;
case 3:
Navigator.of(context)
.pushNamed('/router/web_page', arguments: {
Navigator.of(context).pushNamed(
'/router/web_page',
arguments: {
"articleId": bannerData.content,
});
},
);
break;
case 4:
String? router = bannerData.content;
@ -99,10 +105,12 @@ class _HuiXiangBanner extends State<HuiXiangBanner> {
}
break;
case 5:
Navigator.of(context)
.pushNamed('/router/class_details', arguments: {
Navigator.of(context).pushNamed(
'/router/class_details',
arguments: {
"id": bannerData.content,
});
},
);
break;
case 7:
String? router = bannerData.content;

1
lib/home/huixiang_view/origin_info.dart

@ -308,4 +308,5 @@ class _OriginInfo extends State<OriginInfo> {
),
);
}
}

23
lib/home/points_mall_page.dart

@ -18,6 +18,7 @@ import 'package:huixiang/home/points_mall_view/points_mall_banner.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/event_type.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
@ -68,6 +69,8 @@ class _PointsMallPage extends State<PointsMallPage>
List<BannerData> bannerData = [];
queryUser() async {
client ??= ApiService(Dio(), context: context, token: SharedInstance.instance.token, showLoading: false);
BaseData<PageInfo<BannerData>>? banner = await client?.queryBanner({
"model": {"type": "CREDIT_INDEX"},
}).catchError((onError) {
@ -82,11 +85,9 @@ class _PointsMallPage extends State<PointsMallPage>
BaseData<UserInfo>? baseData = await client?.queryInfo().catchError((onError) {
return BaseData<UserInfo>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
if ((baseData?.isSuccess ?? false) && baseData?.data != null) {
userInfo = baseData!.data;
SharedPreferences.getInstance().then((value) => {
value.setString('user', jsonEncode(baseData.data)),
});
SharedInstance.instance.saveUser(baseData.data!);
}
}
@ -95,8 +96,7 @@ class _PointsMallPage extends State<PointsMallPage>
msg: S.current.zhengzaijiazai,
);
final SharedPreferences value = await SharedPreferences.getInstance();
client = ApiService(Dio(), context: context, token: value.getString('token'), showLoading: false);
client = ApiService(Dio(), context: context, token: SharedInstance.instance.token, showLoading: false);
await queryUser();
@ -221,11 +221,12 @@ class _PointsMallPage extends State<PointsMallPage>
}
_toDetails(index) async {
await Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": goods[index].id});
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
String? token = sharedPreferences.getString("token");
if (token?.isNotEmpty ?? false) queryUser();
await Navigator.of(context).pushNamed(
'/router/integral_store_page',
arguments: {"goodsId": goods[index].id},
);
String token = SharedInstance.instance.token;
if (token.isNotEmpty) queryUser();
}
@override

12
lib/home/points_mall_view/point_mall_user.dart

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/user_info.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -22,13 +23,12 @@ class _PointMallUser extends State<PointMallUser> {
Widget build(BuildContext context) {
return InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
Navigator.of(context).pushNamed('/router/new_login_page',
arguments: {"login": "login"});
if (SharedInstance.instance.token.isEmpty) {
Navigator.of(context).pushNamed(
'/router/new_login_page',
arguments: {"login": "login"},
);
}
});
},
child: Container(
margin: EdgeInsets.all(16),

5
lib/home/points_mall_view/points_goods_title.dart

@ -23,8 +23,8 @@ class PointsGoodsTitle extends StatefulWidget {
}
}
class _PointsGoodsTitle extends State<PointsGoodsTitle>
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin{
class _PointsGoodsTitle extends State<PointsGoodsTitle> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin{
var _itemText = S.current.morenpaixu;
List<String> sortString = [
S.current.morenpaixu,
@ -39,6 +39,7 @@ class _PointsGoodsTitle extends State<PointsGoodsTitle>
@override
Widget build(BuildContext context) {
super.build(context);
return Container(
margin: EdgeInsets.only(top:24.h),
child: Column(

3
lib/home/points_mall_view/points_goods_view.dart

@ -20,6 +20,7 @@ class PointGoods extends StatefulWidget {
}
class _PointGoods extends State<PointGoods> {
String pointPrice(Goods goods) {
if (goods.oneBean != "0") {
return "${goods.oneBean}印章";
@ -96,7 +97,7 @@ class _PointGoods extends State<PointGoods> {
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
),
],
color: Colors.white,
),

27
lib/home/points_mall_view/points_mall_banner.dart

@ -73,20 +73,24 @@ class _PointMallBanner extends State<PointMallBanner> {
bannerClick(BannerData bannerData) async {
switch (bannerData.contentType) {
case 1:
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": bannerData.content});
Navigator.of(context).pushNamed(
'/router/integral_store_page',
arguments: {"goodsId": bannerData.content},
);
break;
case 2:
Navigator.of(context)
.pushNamed('/router/web_page', arguments: {
Navigator.of(context).pushNamed(
'/router/web_page', arguments: {
"activityId": bannerData.content,
});
},
);
break;
case 3:
Navigator.of(context)
.pushNamed('/router/web_page', arguments: {
Navigator.of(context).pushNamed(
'/router/web_page', arguments: {
"articleId": bannerData.content,
});
},
);
break;
case 4:
String? router = bannerData.content;
@ -103,10 +107,11 @@ class _PointMallBanner extends State<PointMallBanner> {
}
break;
case 5:
Navigator.of(context)
.pushNamed('/router/class_details', arguments: {
Navigator.of(context).pushNamed(
'/router/class_details', arguments: {
"id": bannerData.content,
});
},
);
break;
case 7:
String? router = bannerData.content;

6
lib/home/trading_card_page.dart

@ -5,6 +5,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -29,11 +30,8 @@ class _TradingCardPage extends State<TradingCardPage> {
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), context: context, token: value.getString("token"));
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token);
queryUserBalance();
});
}
@override

32
lib/home/welfare_exchange.dart

@ -13,6 +13,7 @@ import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_footer.dart';
@ -54,25 +55,20 @@ class _WelfareExchange extends State<WelfareExchange>
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context,
token: value.getString("token"),
showLoading: false),
creditGoods(),
});
token: SharedInstance.instance.token,
showLoading: false);
creditGoods();
}
queryUser() async {
BaseData<UserInfo>? baseData =
await apiService?.queryInfo().catchError((onError) {
BaseData<UserInfo>? baseData = await apiService?.queryInfo().catchError((onError) {
return BaseData<UserInfo>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
userInfo = baseData!.data;
SharedPreferences.getInstance().then((value) => {
value.setString('user', jsonEncode(baseData.data)),
});
if ((baseData?.isSuccess ?? false) && baseData!.data != null) {
userInfo = baseData.data;
SharedInstance.instance.saveUser(baseData.data!);
}
}
@ -82,11 +78,9 @@ class _WelfareExchange extends State<WelfareExchange>
SmartDialog.showLoading(
msg: S.current.zhengzaijiazai,
);
final SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(Dio(),
context: context,
token: value.getString('token'),
token: SharedInstance.instance.token,
showLoading: false);
await queryUser();
@ -106,8 +100,7 @@ class _WelfareExchange extends State<WelfareExchange>
gooods.addAll(goodsData?.data?.list ?? []);
}
BaseData<PageInfo<GoodsCategory>>? dataCategory =
await apiService?.goodsCategory({
BaseData<PageInfo<GoodsCategory>>? dataCategory = await apiService?.goodsCategory({
"current": 1,
"map": {},
"model": {"pageNum": 1, "pageSize": 20, "searchKey": ""},
@ -135,8 +128,7 @@ class _WelfareExchange extends State<WelfareExchange>
"pageSize": 100,
"state": 1
};
BaseData<PageInfo<Goods>>? pageGoods =
await apiService?.creditGoods(param).catchError((onError) {
BaseData<PageInfo<Goods>>? pageGoods = await apiService?.creditGoods(param).catchError((onError) {
refreshController.loadFailed();
refreshController.refreshFailed();
return BaseData<PageInfo<Goods>>()..isSuccess = false;
@ -465,7 +457,7 @@ class _WelfareExchange extends State<WelfareExchange>
Widget pointList() {
return Container(
child: (goods?.isEmpty ?? true)
child: (goods.isEmpty)
? NoDataView(
src: "assets/image/xiao_fei.webp",
isShowBtn: false,

58
lib/home/welfare_page.dart

@ -14,6 +14,7 @@ import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
@ -51,16 +52,12 @@ class _WelfarePage extends State<WelfarePage> {
@override
void initState() {
super.initState();
if (apiService == null) {
SharedPreferences.getInstance().then((value) {
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
);
_onRefresh();
});
}
}
queryGoods() async {
@ -73,11 +70,10 @@ class _WelfarePage extends State<WelfarePage> {
"pageSize": 100,
"state": 1
};
BaseData<PageInfo<Goods>>? pageGoods =
await apiService?.creditGoods(param).catchError((onError) {
BaseData<PageInfo<Goods>>? pageGoods = await apiService?.creditGoods(param).catchError((onError) {
refreshController.loadFailed();
refreshController.refreshFailed();
return Future.value(null);
return BaseData<PageInfo<Goods>>()..isSuccess = false;
});
SmartDialog.dismiss();
if (pageGoods?.isSuccess ?? false) {
@ -98,9 +94,7 @@ class _WelfarePage extends State<WelfarePage> {
"searchKey": "",
"state": 0
}).catchError((onError) {
SmartDialog.showToast(AppUtils.dioErrorTypeToString(onError.type),
alignment: Alignment.center);
return Future.value(null);
return BaseData<PageInfo<Coupon>>()..isSuccess = false;
});
coupons.clear();
coupon.clear();
@ -160,7 +154,8 @@ class _WelfarePage extends State<WelfarePage> {
Expanded(
child: Container(
color: Colors.white,
))
),
)
],
),
Scaffold(
@ -219,7 +214,7 @@ class _WelfarePage extends State<WelfarePage> {
benefitExchange(),
],
),
)
),
// activityTask(),
],
),
@ -445,8 +440,7 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
SizedBox(
@ -457,8 +451,7 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 24.sp,
fontWeight: MyFontWeight.semi_bold,
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
],
@ -488,8 +481,7 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 22.sp,
fontWeight: MyFontWeight.semi_bold,
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
],
@ -520,8 +512,7 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 26.sp,
fontWeight: MyFontWeight.semi_bold,
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
],
@ -552,8 +543,7 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
SizedBox(
@ -566,8 +556,7 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 24.sp,
fontWeight: FontWeight.bold,
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
],
@ -591,8 +580,7 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 30.sp,
fontWeight: MyFontWeight.semi_bold,
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
SizedBox(
@ -603,8 +591,7 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.semi_bold,
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
],
@ -693,7 +680,9 @@ class _WelfarePage extends State<WelfarePage> {
///
receiveCoupon(couponId) async {
couponIndex = swiperIndex;
BaseData? baseData = await apiService?.receiveCoupon(couponId);
BaseData? baseData = await apiService?.receiveCoupon(couponId).catchError((error){
return BaseData()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
queryCoupon();
showAlertDialog();
@ -805,7 +794,7 @@ class _WelfarePage extends State<WelfarePage> {
Icons.keyboard_arrow_right,
color: Color(0xFF4D4D4D),
size: 20,
)
),
],
),
),
@ -833,8 +822,7 @@ class _WelfarePage extends State<WelfarePage> {
//Widget之间间距
mainAxisSpacing: 16.w,
//Widget宽高比例 0.59
childAspectRatio: 200 /
(285 / 2 + (285 / 2) * AppUtils.textScale(context)),
childAspectRatio: 200 / (285 / 2 + (285 / 2) * AppUtils.textScale(context)),
),
itemBuilder: (context, index) {
return GestureDetector(
@ -847,7 +835,7 @@ class _WelfarePage extends State<WelfarePage> {
child: exchangeItem(goods[index]),
);
},
)
),
],
),
);
@ -865,7 +853,7 @@ class _WelfarePage extends State<WelfarePage> {
offset: Offset(0, 2),
blurRadius: 4,
spreadRadius: 0,
)
),
],
),
child: Stack(

9
lib/im/SocketClient.dart

@ -12,18 +12,17 @@ import 'package:huixiang/im/database/message.dart';
import 'package:huixiang/im/out/auth.pb.dart';
import 'package:huixiang/im/out/message.pb.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
class SocketClient {
Socket? _socket;
SharedPreferences? _shared;
Timer? timer;
bool get heartbeatActive => timer != null && timer!.isActive;
connect() async {
_shared = await SharedPreferences.getInstance();
if (_socket != null) {
reconnect();
@ -50,11 +49,9 @@ class SocketClient {
Message message = Message.fromJson(messageMap);
if (callbacks[dataResult.from] != null) {
callbacks[dataResult.from]?.call(message);
/// user conversation callback
}
callbacks[userId]?.call(message);
/// user self conversation list callback
});
});
@ -66,7 +63,7 @@ class SocketClient {
debugPrint("socket-listen-down: down");
});
authRequest(_shared?.getString("token") ?? "");
authRequest(SharedInstance.instance.token);
heartbeat();
}).catchError((error) {
@ -257,5 +254,5 @@ class SocketClient {
return true;
}
String get userId => _shared?.getString("userId") ?? "";
String get userId => SharedInstance.instance.userId;
}

1
lib/im/add_friend.dart

@ -17,7 +17,6 @@ class AddFriend extends StatefulWidget {
}
class _AddFriend extends State<AddFriend> {
ApiService? apiService;
@override
void initState() {

506
lib/im/chat_details_page.dart

@ -1,29 +1,30 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:ui';
import 'package:dio/dio.dart';
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:huixiang/constant.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/im_user.dart';
import 'package:huixiang/data/user_info.dart';
import 'package:huixiang/im/database/message.dart';
import 'package:huixiang/im/out/message.pb.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/data/im_user.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:image_pickers/image_pickers.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../community/release_dynamic.dart';
import '../../generated/l10n.dart';
@ -31,8 +32,7 @@ import '../../utils/font_weight.dart';
import '../utils/flutter_utils.dart';
import '../view_widget/custom_image.dart';
import '../view_widget/request_permission.dart';
import 'im_view/on_chat_message.dart';
import 'im_view/on_chat_msg_instance.dart';
class ChatDetailsPage extends StatefulWidget {
final Map<String, dynamic>? arguments;
@ -46,43 +46,39 @@ class ChatDetailsPage extends StatefulWidget {
}
class _ChatDetailsPage extends State<ChatDetailsPage>
with WidgetsBindingObserver
implements OnChatMessage {
with WidgetsBindingObserver {
ApiService? apiService;
List<Medias> mediaPaths = [];
int selectCount = 9;
int dynamicType = 0;
final TextEditingController chatController = TextEditingController();
bool emojiShowing = false;
double keyboard = -1;
bool needShowSmiley = false;
bool needHideSmiley = false;
bool isKeyBoardShow = false;
bool emojiShowing = false;
bool moreShow = false;
bool needShowMore = false;
bool needHideMore = false;
double keyboard = -1;
var commentFocus = FocusNode();
String hintText = "输入消息内容...";
UserInfo? userInfo;
final OnChatMessage? _tempOnChatMessage = OnChatMsgInstance.instance.onChatMessage;
// final OnChatMessage? _tempOnChatMessage = OnChatMsgInstance.instance.onChatMessage;
final ScrollController scrollController = ScrollController();
GlobalKey<AnimatedListState> animatedListKey = GlobalKey<AnimatedListState>();
String tex = "";
String selfUserId = "";
ImUser? _toUser;
late String conversation;
List<String> imageUrl = [];
@override
void onMessage(txt) {
// SmartDialog.showToast("聊天 $txt", alignment: Alignment.center);
}
double inputWidgetHeight = 95;
double dynamicInputHeight = 0;
RefreshController refreshController = RefreshController();
List<Message> messages = [];
int page = 0;
loadMessageList() async {
selfUserId = (await SharedPreferences.getInstance()).getString("userId") ?? "";
selfUserId = SharedInstance.instance.userId;
debugPrint("selfUserId: $selfUserId _toUser?.mid: ${_toUser?.mid} ");
conversation = conversationId(selfUserId, _toUser?.mid);
ImUser? imUser = await hxDatabase.queryImUserById(conversation);
@ -95,9 +91,10 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
await refresh();
socketClient.addCallback(_toUser?.mid ?? '', (Message message) {
messages.insert(0, message);
if (message.msgType == MsgType.VIDEO.value || message.msgType == MsgType.IMAGE.value) {
imageUrl.add(message.attach);
messages.add(message);
animatedListKey.currentState?.insertItem(messages.length - 1);
if ((message.msgType == MsgType.VIDEO.value || message.msgType == MsgType.IMAGE.value) && (message.attach?.isNotEmpty ?? false)) {
imageUrl.add(message.attach!);
}
messageShowTime().then((value) {
refreshState();
@ -107,66 +104,69 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
messageImageUrl();
refreshState();
jumpToBottom();
// refreshState();
// jumpToBottom();
}
Future refresh() async {
Future<double> refresh() async {
List<Message>? messagePage = await hxDatabase.queryUList(conversation, page: page + 1, pageSize: 10);
debugPrint("refresh-message-list: ${messagePage?.length ?? ''} page: $page");
if (messagePage?.isEmpty ?? true) {
refreshController.loadNoData();
return;
refreshController.refreshCompleted();
return 0;
} else {
refreshController.loadComplete();
refreshController.refreshCompleted();
page += 1;
}
double height = 0;
await Future.forEach(messagePage!, (element) async {
height += await chatDetailsItemHeight(element);
});
if (scrollController.hasClients) {
debugPrint("refresh-message-height: ${height} page: $page");
scrollController.position.restoreOffset(height, initialRestore: true);
}
if (page == 1) {
messages = messagePage!;
messages.addAll(messagePage.reversed.toList());
animatedListKey.currentState?.insertAllItems(0, messagePage.length);
} else {
messages.addAll(messagePage!);
messages.insertAll(0, messagePage.reversed.toList());
animatedListKey.currentState?.insertAllItems(0, messagePage.length, duration: 300.milliseconds);
}
await messageShowTime();
return Future.value();
return height;
}
///
messageImageUrl() {
imageUrl = messages.where((e) => e.msgType == MsgType.VIDEO.value || e.msgType == MsgType.IMAGE.value).map((e) => e.attach).toList();
imageUrl = messages.where((e) => (e.msgType == MsgType.VIDEO.value || e.msgType == MsgType.IMAGE.value) && (e.attach?.isNotEmpty ?? false)).map((e) => "${e.attach}").toList();
}
Future messageShowTime() async {
List<Message>? messagePages = await hxDatabase.queryTList(conversation);
for (var value in messages) {
Message? message = messagePages?.firstWhere((element) => value.id == element.id);
Message? message = messagePages?.firstWhere((element) => value.id == element.id, orElse: () => messages.first);
value.showTime = message != null;
}
}
SharedPreferences? sharedPre;
///
queryUser() async {
sharedPre = await SharedPreferences.getInstance();
if (apiService == null)
apiService = ApiService(Dio(), context: context, token: sharedPre?.getString("token"));
if ((sharedPre?.containsKey('user') ?? false) &&
sharedPre?.getString('user') != null &&
sharedPre?.getString('user') != "") {
userInfo = UserInfo.fromJson(jsonDecode(sharedPre!.getString('user')!));
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token);
userInfo = UserInfo.fromJson(jsonDecode(SharedInstance.instance.userJson));
if (userInfo?.phone?.isNotEmpty ?? false) {
setState(() {});
return;
}
}
BaseData<UserInfo>? baseData = await apiService?.queryInfo().catchError((onError) {});
if (baseData?.isSuccess ?? false) {
BaseData<UserInfo>? baseData = await apiService?.queryInfo().catchError((onError) {
return BaseData<UserInfo>()..isSuccess = false;
});
if ((baseData?.isSuccess ?? false) && baseData?.data != null) {
setState(() {
userInfo = baseData!.data;
});
SharedPreferences.getInstance().then((value) => {
value.setString('user', jsonEncode(baseData!.data)),
});
SharedInstance.instance.saveUser(baseData!.data!);
}
}
@ -174,75 +174,93 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
if (mounted) setState(() {});
}
late StreamSubscription<bool> keyboardSubscription;
@override
void initState() {
super.initState();
_toUser = widget.arguments?["toUser"];
OnChatMsgInstance.instance.onChatMessage = this;
// OnChatMsgInstance.instance.onChatMessage = this;
WidgetsBinding.instance.addObserver(this);
commentFocus.addListener(_focusNodeListener);
queryUser();
loadMessageList();
}
void jumpToBottom() {
Future.delayed(const Duration(milliseconds: 100), () {
scrollController.position.jumpTo(0);
});
scrollController.addListener(() {
debugPrint("scrollController-onChange: ${scrollController.position.pixels}");
if (messages.length >= 10 && scrollController.position.pixels < -80) {
if (!loading) {
loading = true;
refresh().then((value) => loading = false);
}
}
});
void didChangeMetrics() {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
isKeyBoardShow = MediaQuery.of(context).viewInsets.bottom > 0;
if (MediaQuery.of(context).viewInsets.bottom == 0) {
var keyboardVisibilityController = KeyboardVisibilityController();
keyboardSubscription = keyboardVisibilityController.onChange.listen((bool visible) {
isKeyBoardShow = visible;
debugPrint("keyboardVisibility-onChange: ${isKeyBoardShow}");
if (isKeyBoardShow) {
FocusScope.of(context).requestFocus(FocusNode());
if (mounted) if (!emojiShowing) if (!moreShow)
setState(() {
hintText = "请输入消息内容...";
isKeyBoardShow = false;
});
if (!emojiShowing && !moreShow) {
chatController.clear();
}
} else {
if (mounted)
setState(() {
isKeyBoardShow = true;
});
inputWidgetHeight = 95;
}
});
if (needShowSmiley && window.viewInsets.bottom <= 0.1) {
needShowSmiley = false;
setState(() {
emojiShowing = true;
jumpToBottom();
// if (needShowSmiley && !visible) {
// needShowSmiley = false;
// setState(() {
// emojiShowing = true;
// });
// }
// if (needHideSmiley && visible) {
// needHideSmiley = false;
// setState(() {
// emojiShowing = false;
// });
// }
// if (needShowMore && !visible) {
// needShowMore = false;
// setState(() {
// moreShow = true;
// });
// }
// if (needHideMore && visible) {
// needHideMore = false;
// setState(() {
// moreShow = false;
// });
// }
});
}
if (needHideSmiley && window.viewInsets.bottom > 0.1) {
needHideSmiley = false;
setState(() {
emojiShowing = false;
});
bool loading = false;
void jumpToBottom() {
Future.delayed(const Duration(milliseconds: 400), () {
if (scrollController.hasClients && scrollController.position.pixels != scrollController.position.maxScrollExtent) {
scrollController.position.animateTo(scrollController.position.maxScrollExtent, duration: 250.milliseconds, curve: Curves.easeInOut);
}
if (needShowMore && window.viewInsets.bottom <= 0.1) {
needShowMore = false;
setState(() {
moreShow = true;
});
}
if (needHideMore && window.viewInsets.bottom > 0.1) {
needHideMore = false;
setState(() {
moreShow = false;
});
@override
void didChangeMetrics() {
super.didChangeMetrics();
dynamicInputHeight = MediaQuery.of(context).viewInsets.bottom;
if (dynamicInputHeight > 0 && dynamicInputHeight > keyboard) {
keyboard = dynamicInputHeight;
}
}
@override
void dispose() {
super.dispose();
OnChatMsgInstance.instance.onChatMessage = _tempOnChatMessage;
// OnChatMsgInstance.instance.onChatMessage = _tempOnChatMessage;
keyboardSubscription.cancel();
WidgetsBinding.instance.removeObserver(this);
commentFocus.removeListener(_focusNodeListener);
scrollController.dispose();
@ -260,39 +278,51 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
///
_onTextFieldTap() {
if (emojiShowing) {
needHideSmiley = true;
emojiShowing = false;
}
if (moreShow) {
needHideMore = true;
moreShow = false;
}
}
///
_onSmileyTap() {
if (!emojiShowing && commentFocus.hasFocus && isKeyBoardShow) {
needShowSmiley = true;
commentFocus.unfocus();
} else {
setState(() {
emojiShowing = !emojiShowing;
isKeyBoardShow = emojiShowing;
if (isKeyBoardShow && commentFocus.hasFocus) {
commentFocus.unfocus();
}
if (moreShow) {
moreShow = false;
});
}
if (emojiShowing) {
if (inputWidgetHeight == 95) {
inputWidgetHeight += (keyboard == -1 ? 270 : keyboard);
jumpToBottom();
}
} else {
inputWidgetHeight = 95;
}
setState(() {});
}
///
_onMoreTap() {
if (!moreShow && commentFocus.hasFocus && isKeyBoardShow) {
needShowMore = true;
commentFocus.unfocus();
} else {
setState(() {
moreShow = !moreShow;
isKeyBoardShow = moreShow;
if (isKeyBoardShow && commentFocus.hasFocus) {
commentFocus.unfocus();
}
if (emojiShowing) {
emojiShowing = false;
});
}
if (moreShow) {
if (inputWidgetHeight == 95) {
inputWidgetHeight += (keyboard == -1 ? 167 : keyboard);
jumpToBottom();
}
} else {
inputWidgetHeight = 95;
}
setState(() {});
}
////
@ -330,7 +360,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
String fileUrl = await qiniu.uploadFile(apiService!, path);
socketClient.sendMessage(_toUser?.mid ?? '', fileUrl, attach: path, msgType: galleryMode == GalleryMode.image ? 2 : 4).then((value) {
Message message = value;
messages.insert(0, message);
messages.add(message);
animatedListKey.currentState?.insertItem(messages.length - 1);
chatController.clear();
messageShowTime().then((value) {
refreshState();
@ -394,7 +425,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
String fileUrl = await qiniu.uploadFile(apiService!, path);
socketClient.sendMessage(_toUser?.mid ?? '', fileUrl, attach: path, msgType: 2).then((value) {
Message message = value;
messages.insert(0, message);
messages.add(message);
animatedListKey.currentState?.insertItem(messages.length - 1);
chatController.clear();
messageShowTime().then((value) {
refreshState();
@ -485,29 +517,21 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
}
@override
Widget build(BuildContext context) {
double h = MediaQuery.of(context).viewInsets.bottom;
if (h > 0) {
jumpToBottom();
if (keyboard < h) {
keyboard = h;
// setState(() {});
}
}
Widget build(BuildContext ctx) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
setState(() {
needShowSmiley = false;
emojiShowing = false;
isKeyBoardShow = emojiShowing;
isKeyBoardShow = false;
moreShow = false;
isKeyBoardShow = moreShow;
});
inputWidgetHeight = 95;
FocusScope.of(context).requestFocus(FocusNode());
// jumpToBottom();
},
child: Scaffold(
// resizeToAvoidBottomInset: false,
resizeToAvoidBottomInset: true,
backgroundColor: Color(0xFFF6F6F6),
appBar: MyAppBar(
title: _toUser?.nickname,
@ -515,11 +539,16 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
titleSize: 17.sp,
leading: true,
leadingColor: Colors.black,
toolbarHeight: kToolbarHeight,
action: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () async {
await Navigator.of(context).pushNamed('/router/chat_setting',
arguments: {"userId": _toUser?.mid});
await Navigator.of(context).pushNamed(
'/router/chat_setting',
arguments: {
"userId": _toUser?.mid,
},
);
page = 0;
refresh().then((value) {
refreshState();
@ -536,32 +565,11 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
),
),
body: Container(
height: MediaQuery.of(context).size.height - kToolbarHeight - MediaQuery.of(context).padding.top - MediaQuery.of(context).viewInsets.bottom,
child: Column(
children: [
Expanded(
child: SmartRefresher(
enablePullDown: false,
enablePullUp: true,
header: MyHeader(),
footer: CustomFooter(
loadStyle: LoadStyle.ShowWhenLoading,
builder: (BuildContext context, LoadStatus? mode) {
return SizedBox();
},
),
reverse: true,
scrollController: scrollController,
controller: refreshController,
onRefresh: () {
debugPrint("");
},
onLoading: () {
refresh().then((value) {
refreshState();
});
},
child: chatDetailsList(),
),
flex: 1,
),
input(),
@ -574,30 +582,68 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
///
Widget chatDetailsList() {
return ListView.builder(
itemCount: messages.length,
reverse: true,
padding: EdgeInsets.zero,
itemBuilder: (context, position) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
setState(() {
if (emojiShowing) {
emojiShowing = !emojiShowing;
}
if (moreShow) {
moreShow = !moreShow;
}
});
FocusScope.of(context).requestFocus(FocusNode());
},
child: chatDetailsItem(position),
);
return AnimatedList(
key: animatedListKey,
initialItemCount: messages.length,
controller: scrollController,
physics: BouncingScrollPhysics()..frictionFactor(0.8),
itemBuilder: (context, position, animation) {
return chatDetailsItem(position);
},
);
}
Future<double> chatDetailsItemHeight(Message message) async {
bool isSelf = message.fromId == selfUserId;
bool isText = message.msgType == 1;
bool isImage = message.msgType == 2;
double itemHeight = 32.0;
if (message.showTime) {
itemHeight += 10.sp;
}
if (!isSelf && isText) {
itemHeight += 10.h;
double itemWidth = MediaQuery.of(context).size.width - 92.w - 44;
double textH = textHeight(message.content, 17.sp, 1.2, itemWidth) + 12;
itemHeight += textH > 44 ? textH : 44;
}
if (isSelf && isText) {
itemHeight += 10.h;
double itemWidth = MediaQuery.of(context).size.width - 88.w - 44;
if (message.state == 3) {
itemWidth -= 20;
itemWidth -= 12.w;
}
double textH = textHeight(message.content, 17.sp, 1.2, itemWidth) + 12;
itemHeight += textH > 44 ? textH : 44;
}
if (!isSelf && isImage) {
itemHeight += 10.h;
Size size = await fetchImageSize(message);
itemHeight += size.height;
}
if (isSelf && isImage) {
itemHeight += 10.h;
Size size = await fetchImageSize(message);
itemHeight += size.height;
}
return itemHeight;
}
textHeight(text, fontSize, height, width) {
final TextPainter textPainter = TextPainter(
text: TextSpan(
text: text,
style: TextStyle(
fontSize: fontSize,
height: height,
),
),
textDirection: TextDirection.ltr,
)..layout(minWidth: 0, maxWidth: width);
return textPainter.height;
}
Widget chatDetailsItem(position) {
bool isSelf = messages[position].fromId == selfUserId;
bool isText = messages[position].msgType == 1;
@ -626,6 +672,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
style: TextStyle(
color: Color(0xFFA29E9E),
fontSize: 10.sp,
height: 1.0,
fontWeight: MyFontWeight.regular,
),
),
@ -662,6 +709,10 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (_toUser?.mid?.isEmpty ?? true) {
"用户信息错误".toast;
return;
}
Navigator.of(context).pushNamed(
'/router/personal_page',
arguments: {
@ -673,8 +724,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
child: MImage(
_toUser?.avatar ?? '',
isCircle: true,
height: 44.h,
width: 44.h,
height: 44,
width: 44,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.webp",
fadeSrc: "assets/image/default_1.webp",
@ -705,7 +756,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
),
key: _buttonKey,
padding: EdgeInsets.symmetric(
vertical: 8.h,
vertical: 6,
horizontal: 12.w,
),
child: Text(
@ -783,14 +834,14 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
),
key: _buttonKey,
padding: EdgeInsets.symmetric(
vertical: 8.h,
vertical: 6,
horizontal: 12.w,
),
child: Text(
tex = messages[position].content,
textAlign: TextAlign.left,
style: TextStyle(
height: 1.2.h,
height: 1.2,
color: Colors.white,
fontSize: 17.sp,
fontWeight: MyFontWeight.medium,
@ -809,7 +860,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
Navigator.of(context).pushNamed(
'/router/personal_page',
arguments: {
"memberId": "0",
"memberId": selfUserId,
"inletType": 1,
},
);
@ -817,8 +868,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
child: MImage(
userInfo?.headimg ?? "",
isCircle: true,
height: 44.h,
width: 44.h,
height: 44,
width: 44,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.webp",
fadeSrc: "assets/image/default_1.webp",
@ -831,7 +882,9 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
/// not self image
if (!isSelf && isImage)
Padding(
padding: EdgeInsets.only(left: 17.w, right: 39.w, top: 20.h),
padding: EdgeInsets.only(
left: 17.w, right: 39.w, top: 10.h,
),
child: Row(
children: [
MImage(
@ -851,19 +904,23 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
showMessageMenu(context, _buttonKey, messages[position]);
},
onTap: () {
if (imageUrl.contains(messages[position].attach)) {
ImagePickers.previewImages(imageUrl, imageUrl.indexOf(messages[position].attach));
if (imageUrl.contains(messages[position].attach) && (messages[position].attach?.isNotEmpty ?? false)) {
ImagePickers.previewImages(imageUrl, imageUrl.indexOf(messages[position].attach!));
}
},
child: FutureBuilder(
future: fetchImageSize(messages[position]),
key: _buttonKey,
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting ||
snapshot.hasError) {
if (messages[position].attach?.isEmpty ?? true) {
return SizedBox(
width: 180.w,
height: 200.h,
);
}
if (snapshot.connectionState == ConnectionState.waiting || snapshot.hasError) {
return Image.file(
File(messages[position].attach),
File(messages[position].attach!),
width: 180.w,
height: 200.h,
alignment: Alignment.centerLeft,
@ -871,7 +928,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
);
} else {
return Image.file(
File(messages[position].attach),
File(messages[position].attach!),
width: snapshot.data.width,
height: snapshot.data.height,
alignment: Alignment.centerLeft,
@ -892,7 +949,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
padding: EdgeInsets.only(
left: 39.w,
right: 17.w,
top: 20.h,
top: 10.h,
),
child: Row(
children: [
@ -902,17 +959,23 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
showMessageMenu(context, _buttonKey, messages[position]);
},
onTap: () {
if (imageUrl.contains(messages[position].attach)) {
ImagePickers.previewImages(imageUrl, imageUrl.indexOf(messages[position].attach));
if (imageUrl.contains(messages[position].attach) && (messages[position].attach?.isNotEmpty ?? false)) {
ImagePickers.previewImages(imageUrl, imageUrl.indexOf(messages[position].attach!));
}
},
child: FutureBuilder (
future: fetchImageSize(messages[position]),
key: _buttonKey,
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (messages[position].attach?.isEmpty ?? true) {
return SizedBox(
width: 180.w,
height: 200.h,
);
}
if (snapshot.connectionState == ConnectionState.waiting || snapshot.hasError) {
return Image.file(
File(messages[position].attach),
File(messages[position].attach!),
width: 180.w,
height: 200.h,
alignment: Alignment.centerRight,
@ -920,7 +983,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
);
} else {
return Image.file(
File(messages[position].attach),
File(messages[position].attach!),
width: snapshot.data.width,
height: snapshot.data.height,
alignment: Alignment.centerRight,
@ -1038,11 +1101,10 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
GestureDetector(
onTap: () async {
await hxDatabase.deleteByMsgId("${message.id}");
int index = messages.indexOf(message);
messages.remove(message);
animatedListKey.currentState?.removeItem(index, (context, animation) {return Container();});
Navigator.pop(context);
if (mounted) {
setState(() {});
}
},
child: Column(
children: [
@ -1083,20 +1145,23 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
}
Future<Size> fetchImageSize(Message message) async {
String imageLocalPath = message.attach;
String? imageLocalPath = message.attach;
String imageUrl = message.content;
debugPrint("$imageLocalPath");
debugPrint("$imageUrl");
File file = File(imageLocalPath);
if (imageLocalPath?.isEmpty ?? true) {
return Future.value(Size.zero);
}
File file = File(imageLocalPath!);
if (!(await file.exists())) {
await qiniu.downloadFile(imageUrl, savePath: imageLocalPath);
}
Size size = Size.zero;
if (sharedPre != null) {
String? sizeStr = sharedPre!.getString(imageLocalPath);
String? sizeStr = SharedInstance.instance.getSize(imageLocalPath);
if (sizeStr != null && sizeStr != "") {
Map<String, dynamic> sizeMap = jsonDecode(sizeStr);
size = Size(sizeMap["width"], sizeMap["height"]);
@ -1104,7 +1169,6 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
return size;
}
}
}
Completer<Size> completer = Completer();
Image.file(file)
@ -1118,7 +1182,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
"width": size.width,
"height": size.height,
};
sharedPre?.setString(imageLocalPath, jsonEncode(sizeMap));
SharedInstance.instance.setSize(imageLocalPath, jsonEncode(sizeMap));
completer.complete(size);
}));
return completer.future;
@ -1141,7 +1205,9 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
Widget input() {
return Container(
color: Color(0xFFFDFCFC),
padding: EdgeInsets.only(top: 14.h, bottom: 15.h),
// duration: 400.milliseconds,
height: inputWidgetHeight,
padding: EdgeInsets.only(top: 14, bottom: 15),
child: Column(
children: [
///
@ -1171,11 +1237,11 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
if (commentText.trim() == "") {
return;
}
socketClient
.sendMessage(_toUser?.mid ?? '', commentText)
socketClient.sendMessage(_toUser?.mid ?? '', commentText)
.then((value) {
Message message = value;
messages.insert(0, message);
messages.add(message);
animatedListKey.currentState?.insertItem(messages.length - 1);
chatController.clear();
messageShowTime().then((value) {
refreshState();
@ -1203,14 +1269,13 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
behavior: HitTestBehavior.opaque,
onTap: () {
_onSmileyTap();
jumpToBottom();
},
child: Container(
padding: EdgeInsets.only(left: 15.w, right: 8.w),
child: Image.asset(
"assets/image/icon_chat_emo.webp",
height: 26.h,
width: 26.h,
height: 26,
width: 26,
),
),
),
@ -1218,27 +1283,25 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
behavior: HitTestBehavior.opaque,
onTap: () {
_onMoreTap();
jumpToBottom();
},
child: Container(
padding: EdgeInsets.only(left: 8.w, right: 19.w),
child: Image.asset(
"assets/image/chat_more.webp",
height: 26.h,
width: 26.h,
height: 26,
width: 26,
),
),
),
],
),
SizedBox(
height: 16.h,
height: 16,
),
///
Offstage(
offstage: !emojiShowing,
child: SizedBox(
if (emojiShowing)
Container(
height: keyboard == -1 ? 270 : keyboard,
width: MediaQuery.of(context).size.width,
child: EmojiPicker(
@ -1246,12 +1309,12 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
config: Config(
emojiViewConfig: EmojiViewConfig(
columns: 7,
emojiSizeMax: 32 * (Platform.isIOS ? 1.10 : 1.0),
emojiSizeMax: 28 * (Platform.isIOS ? 1.10 : 1.0),
verticalSpacing: 0,
horizontalSpacing: 0,
backgroundColor: const Color(0xFFF2F2F2),
gridPadding: EdgeInsets.zero,
recentsLimit: 28,
recentsLimit: 35,
replaceEmojiOnLimitExceed: false,
noRecents: Text(
"最近使用",
@ -1274,17 +1337,22 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
categoryIcons: const CategoryIcons(),
tabIndicatorAnimDuration: Duration(milliseconds: 0),
),
checkPlatformCompatibility: true,
bottomActionBarConfig: const BottomActionBarConfig(
backgroundColor: Colors.transparent,
buttonIconColor: Colors.blue,
showBackspaceButton: true,
showSearchViewButton: false,
),
swapCategoryAndBottomBar: false,
checkPlatformCompatibility: true,
),
),
),
///
Offstage(
offstage: !moreShow,
child: Container(
height: keyboard == -1 ? 167.h : keyboard,
if (moreShow)
Container(
height: keyboard == -1 ? 167 : keyboard,
child: Column(
children: [
Container(
@ -1383,7 +1451,6 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
],
),
),
),
],
),
);
@ -1394,4 +1461,5 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
debugPrint(tex);
Clipboard.setData(ClipboardData(text: tex));
}
}

18
lib/im/chat_friend_group.dart

@ -1,19 +1,15 @@
import 'dart:ui';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/social_info.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:huixiang/view_widget/my_tab.dart';
import '../../generated/l10n.dart';
import '../view_widget/my_tab.dart';
import 'im_view/custom_underline_tabIndicator.dart';
import 'im_view/friend_groip_list.dart';
@ -56,11 +52,13 @@ class _ChatFriendGroup extends State<ChatFriendGroup>
///(///)
querySocialInfo() async {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(Dio(),
context: context, token: value.getString("token"), showLoading: false);
context: context, token: SharedInstance.instance.token, showLoading: false,
);
BaseData<SocialInfo>? baseData = await apiService?.socialInfo().catchError((onError) {});
BaseData<SocialInfo>? baseData = await apiService?.socialInfo().catchError((onError) {
return BaseData<SocialInfo>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
setState(() {
infoNumber = baseData!.data;

12
lib/im/chat_setting.dart

@ -1,13 +1,11 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/im/database/message.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:flutter/cupertino.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../utils/font_weight.dart';
import '../main.dart';
import '../data/im_user.dart';
@ -34,11 +32,9 @@ class _ChatSetting extends State<ChatSetting> {
}
void initData() async {
selfUserId = (await SharedPreferences.getInstance()).getString("userId") ?? "";
selfUserId = SharedInstance.instance.userId;
imUser = await hxDatabase.queryImUserById(widget.arguments?["userId"]);
setState(() {
});
setState(() {});
}
@override

127
lib/im/contact_share.dart

@ -1,14 +1,7 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:flutter/cupertino.dart';
import '../../utils/font_weight.dart';
class ContactsShare extends StatefulWidget {
final Map<String, dynamic>? arguments;
@ -22,7 +15,6 @@ class ContactsShare extends StatefulWidget {
}
class _ContactsShare extends State<ContactsShare> {
ApiService? apiService;
final TextEditingController searchController = TextEditingController();
int searchIndex = 0;
@ -43,33 +35,41 @@ class _ContactsShare extends State<ContactsShare> {
titleColor: Colors.black,
),
body: Container(
margin: EdgeInsets.only(top:14.h),
margin: EdgeInsets.only(top: 14.h),
color: Colors.white,
child:SingleChildScrollView(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
},
child:Column(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
contactSearch(),
Padding(
padding: EdgeInsets.only(left: 17.w,bottom:24.h),
child: Text("最近联系(0)",
padding: EdgeInsets.only(
left: 17.w, bottom: 24.h,
),
child: Text(
"最近联系(0)",
style: TextStyle(
fontSize: 17.sp,
color: Color(0xFF0D0D0D),
fontWeight: MyFontWeight.regular,
)),
),
),
),
recentList(),
Padding(
padding: EdgeInsets.only(left: 17.w,bottom:24.h),
child: Text("我的关注(0)",
padding: EdgeInsets.only(
left: 17.w,
bottom: 24.h,
),
child: Text(
"我的关注(0)",
style: TextStyle(
fontSize: 17.sp,
color: Color(0xFF0D0D0D),
@ -79,7 +79,9 @@ class _ContactsShare extends State<ContactsShare> {
),
mineFollowList(),
],
)),)
),
),
),
),
);
}
@ -87,7 +89,9 @@ class _ContactsShare extends State<ContactsShare> {
Widget contactSearch() {
return Container(
width: double.infinity,
margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 4.h, bottom: 16.h),
margin: EdgeInsets.only(
left: 16.w, right: 16.w, top: 4.h, bottom: 16.h,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6.w),
color: Color(0xFFF9FAF7),
@ -111,24 +115,25 @@ class _ContactsShare extends State<ContactsShare> {
fontSize: 12.sp,
color: Color(0xFFB3B3B3),
fontWeight: MyFontWeight.regular,
)),
),
),
],
),
TextField(
textInputAction: TextInputAction.search,
enableInteractiveSelection: true,
onEditingComplete: () {
},
onEditingComplete: () {},
controller: searchController,
cursorHeight: 25.h,
decoration: InputDecoration(
contentPadding: EdgeInsets.only(top: 7.h, bottom: 9.h,left:5.w),
contentPadding: EdgeInsets.only(
top: 7.h, bottom: 9.h, left: 5.w,
),
border: InputBorder.none,
),
)
],
)
),
);
}
@ -142,48 +147,47 @@ class _ContactsShare extends State<ContactsShare> {
onTap: () {},
child: recentItem(),
);
});
},
);
}
Widget recentItem() {
return Container(
margin: EdgeInsets.only(bottom: 14.h),
padding: EdgeInsets.only(left: 16.w,right: 14.w),
child:Column(
padding: EdgeInsets.only(
left: 16.w, right: 14.w,
),
child: Column(
children: [
Row(
children: [
// MImage(
// "",
// isCircle: true,
// width: 44,
// height: 44,
// fit: BoxFit.cover,
// errorSrc: "assets/image/default_1.webp",
// fadeSrc: "assets/image/default_1.webp",
// ),
Image.asset(
"assets/image/fuka_zj.webp",
height:44,
width:44,
height: 44,
width: 44,
),
SizedBox(
width: 10.w,
),
SizedBox(width: 10.w,),
Text("张五",
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF1A1A1A),
fontWeight: MyFontWeight.bold,
)),
),
),
],
),
Container(
height: 1.h,
width: double.infinity,
color: Color(0xFFF7F7F7),
margin: EdgeInsets.only(left:54.w,top: 10.h),
margin: EdgeInsets.only(
left: 54.w, top: 10.h,
),
)
],
)
),
);
}
@ -197,48 +201,47 @@ class _ContactsShare extends State<ContactsShare> {
onTap: () {},
child: recentItem(),
);
});
},
);
}
Widget mineFollowItem() {
return Container(
margin: EdgeInsets.only(bottom: 14.h),
padding: EdgeInsets.only(left: 16.w,right: 14.w),
child:Column(
padding: EdgeInsets.only(
left: 16.w, right: 14.w,
),
child: Column(
children: [
Row(
children: [
// MImage(
// "",
// isCircle: true,
// width: 44,
// height: 44,
// fit: BoxFit.cover,
// errorSrc: "assets/image/default_1.webp",
// fadeSrc: "assets/image/default_1.webp",
// ),
Image.asset(
"assets/image/fuka_zj.webp",
height:44,
width:44,
height: 44,
width: 44,
),
SizedBox(
width: 10.w,
),
SizedBox(width: 10.w,),
Text("小王",
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF1A1A1A),
fontWeight: MyFontWeight.bold,
)),
),
),
],
),
Container(
height: 1.h,
width: double.infinity,
color: Color(0xFFF7F7F7),
margin: EdgeInsets.only(left:54.w,top: 10.h),
)
margin: EdgeInsets.only(
left: 54.w, top: 10.h,
),
),
],
)
),
);
}
}

4
lib/im/database/hx_database.dart

@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:huixiang/constant.dart';
import 'package:huixiang/im/database/message.dart';
import 'package:huixiang/im/database/migration.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sqflite/sqflite.dart';
@ -38,8 +39,7 @@ class HxDatabase {
_dbIsOpen() async {
if (db == null || !db!.isOpen) {
var sp = await SharedPreferences.getInstance();
open(key: sp.getString("userId"));
open(key: SharedInstance.instance.userId);
}
}

4
lib/im/database/message.dart

@ -19,11 +19,11 @@ class Message {
String toId;
String replyId;
String? replyId;
String content;
String attach;
String? attach;
int msgType;

37
lib/im/im_search.dart

@ -2,7 +2,9 @@ import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/constant.dart';
import 'package:huixiang/data/base_list_data.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../data/im_user.dart';
@ -33,9 +35,7 @@ class _ImSearch extends State<ImSearch> {
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
selfUserId = value.getString("userId") ?? "";
});
selfUserId = SharedInstance.instance.userId;
}
///
@ -47,13 +47,10 @@ class _ImSearch extends State<ImSearch> {
///
queryImSearch(keyword) async {
if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(Dio(),
apiService ??= ApiService(Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
showLoading: false);
}
BaseListData<ImUser>? baseData =
await apiService?.memberSearch(keyword).catchError((onError) {
return BaseListData<ImUser>()..isSuccess = false;
@ -175,26 +172,32 @@ class _ImSearch extends State<ImSearch> {
setState(() {
searchUserIndex = position;
});
String memberId = searchUser[searchUserIndex].mid ?? "";
if (memberId.isEmpty) {
"用户信息错误".toast;
return;
}
if (memberId == selfUserId) {
return;
}
Navigator.of(context).pushNamed(
'/router/personal_page',
arguments: {
"memberId": (searchUser[searchUserIndex]
.mid ??
"") ==
selfUserId
? "0"
: searchUser[searchUserIndex].mid,
"memberId": memberId,
"inletType": 0
});
},
);
FocusScope.of(context)
.requestFocus(FocusNode());
},
child: imSearchItem(searchUser[position]),
);
},
))
),
)
],
)),
),
),
],
),
),

29
lib/im/im_view/friend_groip_list.dart

@ -1,15 +1,13 @@
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/follow.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/data/im_user.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../retrofit/retrofit_api.dart';
import 'package:huixiang/im/database/message.dart';
@ -54,30 +52,12 @@ class _FriendGroupList extends State<FriendGroupList> {
super.dispose();
}
// loadMessageList() async {
// SharedPreferences shared = await SharedPreferences.getInstance();
// String userId = shared.getString("userId");
// messages = await hxDatabase.queryList(userId);
// messages.forEach((element) {
// debugPrint("messages: ${element.toJson()}");
// });
// userIds = messages
// .map((e) => e.toId != userId ? e.toId : e.fromId)
// .toSet().where((element) => element != userId)
// .toList();
// if (mounted) {
// setState(() {});
// }
//
// }
///
queryFollowList() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
apiService ??= ApiService(
Dio(),
context: context,
token: sharedPreferences.getString("token"),
token: SharedInstance.instance.token,
showLoading: false,
);
@ -104,11 +84,10 @@ class _FriendGroupList extends State<FriendGroupList> {
///
queryMutualFollowList() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
apiService ??= ApiService(
Dio(),
context: context,
token: sharedPreferences.getString("token"),
token: SharedInstance.instance.token,
showLoading: false,
);
@ -163,7 +142,7 @@ class _FriendGroupList extends State<FriendGroupList> {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (list![position].mid == sharedPreferences.getString("userId")) {
if (list![position].mid == SharedInstance.instance.userId) {
SmartDialog.showToast("不能跟自己聊天", alignment: Alignment.center);
return;
}

187
lib/im/im_view/im_page.dart

@ -1,6 +1,7 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/constant.dart';
import 'package:huixiang/data/base_list_data.dart';
@ -10,6 +11,7 @@ import 'package:huixiang/im/database/message.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:huixiang/view_widget/round_button.dart';
@ -60,38 +62,31 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
@override
void dispose() {
super.dispose();
OnChatMsgInstance.instance.onChatMessage = null;
// OnChatMsgInstance.instance.onChatMessage = null;
socketClient.removeCallback(socketClient.userId);
}
@override
void initState() {
super.initState();
OnChatMsgInstance.instance.onChatMessage = this;
// OnChatMsgInstance.instance.onChatMessage = this;
initSocketClient();
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), token: value.getString("token"), context: context);
apiService = ApiService(Dio(), token: SharedInstance.instance.token, context: context);
queryMsgStats();
});
}
initSocketClient() async {
SharedPreferences shared = await SharedPreferences.getInstance();
selfUserId = shared.getString("userId") ?? '';
selfUserId = SharedInstance.instance.userId;
socketClient.addCallback(selfUserId, (Message message) {
if (conversationIds.contains(message.conversationId)) {
conversationIds.remove(message.conversationId);
}
conversationIds.insert(insertIndex, message.conversationId);
lastMessageMap[message.conversationId] = message;
listenerRefresh(message);
});
loadMessageList();
}
@ -149,7 +144,7 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
/// update imuser info by mids
queryImUserInfo(userIds) async {
List<ImUser> contacts = (await hxDatabase.queryImUser(userIds)) ?? [];
if (contacts?.isEmpty ?? true) {
if (contacts.isEmpty) {
await queryMemberInfo(userIds);
return;
} else {
@ -166,10 +161,11 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
.mGroupItem();
List<String> topConversationIds = [], notTopUserIds = [];
contactMap.forEach((key, value) {
if (value.isTop == 1)
if (value.isTop == 1) {
topConversationIds.add(key);
else
} else {
notTopUserIds.add(key);
}
});
insertIndex = topConversationIds.length;
this.conversationIds = topConversationIds..addAll(notTopUserIds);
@ -178,8 +174,6 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
/// update one conversation last message ,and update conversation sort
void updateLastMessage(String conversationId) async {
Message? message = await hxDatabase.lastMessage(conversationId);
debugPrint(
"lastmessage: $conversationId ${message?.content} ${message?.toJson()}");
if (message != null) {
lastMessageMap[conversationId] = message;
await sortConversation(lastMessageMap);
@ -205,10 +199,7 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
BaseListData<ImUser>? baseData = await apiService?.memberInfoByIds({
"mids": mids,
}).catchError((error) {
SmartDialog.showToast(
AppUtils.dioErrorTypeToString(error.type),
alignment: Alignment.center,
);
return BaseListData<ImUser>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
if (baseData!.data?.isNotEmpty ?? false) {
@ -222,25 +213,17 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
});
refreshState();
}
} else {
if (baseData?.msg?.isNotEmpty ?? false) {
SmartDialog.showToast(baseData?.msg ?? '', alignment: Alignment.center);
}
}
}
///App消息
queryMsgStats() async {
if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
apiService ??= ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
);
}
BaseListData<MsgStats>? baseData =
await apiService?.stats().catchError((error) {
BaseListData<MsgStats>? baseData = await apiService?.stats().catchError((error) {
return BaseListData<MsgStats>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
@ -304,9 +287,7 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context)
.pushNamed('/router/chat_friend_group')
.then((value) {
Navigator.of(context).pushNamed('/router/chat_friend_group').then((value) {
_refresh();
});
},
@ -337,9 +318,7 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
footer: CustomFooter(
loadStyle: LoadStyle.ShowWhenLoading,
builder: (BuildContext context, LoadStatus? mode) {
return (messages.length == 0)
? Container()
: MyFooter(mode);
return (messages.length == 0) ? Container() : MyFooter(mode);
},
),
controller: _refreshController,
@ -367,7 +346,8 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
"assets/image/icon_system_message_new.webp",
S.of(context).xitongxiaoxi,
((msgNumber["2"] ?? 0) + (msgNumber["3"] ?? 0))
.toString()),
.toString(),
),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
@ -434,7 +414,7 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
});
},
child: Container(
margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 16.h),
margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 8.h),
padding: EdgeInsets.symmetric(vertical: 10.h),
decoration: BoxDecoration(
color: Color(0xFFFDFCFC),
@ -465,64 +445,15 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
);
}
bool _isDelEnter = false;
Map<String, ScrollController> idsController = {};
String? lastScrollId;
double lastScrollOffset = 0;
bool _isScrollOpen = false;
///
Widget chatList() {
return ListView(
padding: EdgeInsets.only(top: 8.h),
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
children: conversationIds.map((e) {
ScrollController scrollController;
if (idsController.containsKey(e))
scrollController = idsController[e] ?? ScrollController();
else {
scrollController = ScrollController();
idsController[e] = scrollController;
}
scrollController.addListener(() {
if (scrollController.offset > 0) {
if (lastScrollId != null && lastScrollId != e)
idsController[lastScrollId]?.jumpTo(0);
if (lastScrollOffset < scrollController.offset) {
scrollController
.jumpTo(scrollController.position.maxScrollExtent);
_isScrollOpen = true;
} else if (lastScrollOffset > scrollController.offset &&
_isScrollOpen) {
scrollController.jumpTo(0);
}
lastScrollId = e;
// scrollController.animateTo(
// lastScrollOffset == scrollController.position.maxScrollExtent
// ? 0
// : scrollController.position.maxScrollExtent,
// duration: Duration(milliseconds: 100),
// curve: Curves.ease);
lastScrollOffset = scrollController.offset;
} else {
if (lastScrollId == e) {
setState(() {
_isDelEnter = false;
_isScrollOpen = false;
});
}
}
});
int position = conversationIds.indexOf(e);
return SingleChildScrollView(
physics: BouncingScrollPhysics(),
controller: scrollController,
scrollDirection: Axis.horizontal,
child: Row(
children: [
GestureDetector(
behavior: HitTestBehavior.opaque,
return InkWell(
onTap: () {
Navigator.of(context).pushNamed(
'/router/chat_details_page',
@ -535,68 +466,49 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
_refresh();
});
},
child: chatItem(conversationIds[position]),
),
GestureDetector(
child: Container(
color: Colors.red,
alignment: Alignment.center,
padding:
EdgeInsets.symmetric(vertical: 25.h, horizontal: 14.w),
child: Text(
_isDelEnter && lastScrollId == e
? "删除并清空"
: S.of(context).shanchu,
style: TextStyle(
color: Colors.white,
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
),
),
onTap: () async {
// showDelDialog(conversationIds[position]);
if (_isDelEnter) {
await hxDatabase.deleteByUser(conversationIds[position]);
lastScrollId = null;
_refresh();
} else {
Future.delayed(Duration(milliseconds: 100), () {
idsController[lastScrollId]?.animateTo(
idsController[lastScrollId]!.position.maxScrollExtent,
duration: Duration(milliseconds: 100),
curve: Curves.ease);
});
}
setState(() {
_isDelEnter = !_isDelEnter;
});
},
),
],
),
child: chatItem(e),
);
}).toList(),
);
}
Widget chatItem(conversationId) {
return Container(
return Slidable(
key: ValueKey(conversationId),
direction: Axis.horizontal,
closeOnScroll: true,
endActionPane: ActionPane(
dragDismissible: true,
extentRatio: 0.25,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context) async {
await hxDatabase.deleteByUser(conversationId);
_refresh();
},
backgroundColor: Color(0xFFFE4A49),
foregroundColor: Colors.white,
autoClose: true,
label: S.of(context).shanchu,
),
],
),
child: Container(
padding: EdgeInsets.only(
left: 16.w,
right: 17.w,
bottom: 18.h,
top: 8.h,
bottom: 8.h,
),
width: MediaQuery.of(context).size.width,
child: Row(
children: [
MImage(
!contactMap.containsKey(conversationId)
? ""
: contactMap[conversationId]?.avatar ?? "",
!contactMap.containsKey(conversationId) ? "" : contactMap[conversationId]?.avatar ?? "",
isCircle: true,
height: 54.h,
width: 54.h,
height: 54,
width: 54,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.webp",
fadeSrc: "assets/image/default_1.webp",
@ -680,6 +592,7 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
),
],
),
),
);
}

36
lib/im/im_view/on_chat_msg_instance.dart

@ -1,20 +1,20 @@
import 'on_chat_message.dart';
class OnChatMsgInstance{
factory OnChatMsgInstance() => _getInstance();
static OnChatMsgInstance get instance => _getInstance();
static OnChatMsgInstance? _instance;
OnChatMessage? onChatMessage;
OnChatMsgInstance._internal();
static OnChatMsgInstance _getInstance(){
if(_instance == null){
_instance = OnChatMsgInstance._internal();
}
return _instance!;
}
}
// class OnChatMsgInstance{
// factory OnChatMsgInstance() => _getInstance();
//
// static OnChatMsgInstance get instance => _getInstance();
//
// static OnChatMsgInstance? _instance;
//
// OnChatMessage? onChatMessage;
//
// OnChatMsgInstance._internal();
//
// static OnChatMsgInstance _getInstance(){
// if(_instance == null){
// _instance = OnChatMsgInstance._internal();
// }
// return _instance!;
// }
// }

119
lib/integral/integral_detailed_page.dart

@ -9,14 +9,15 @@ import 'package:huixiang/data/user_bill.dart';
import 'package:huixiang/data/user_info.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:huixiang/view_widget/my_tab.dart';
import 'package:huixiang/view_widget/no_data_view.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../view_widget/no_data_view.dart';
class IntegralDetailedPage extends StatefulWidget {
final arguments;
@ -70,25 +71,28 @@ class _IntegralDetailedPage extends State<IntegralDetailedPage>
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context, token: value.getString("token")),
userInfo = UserInfo.fromJson(jsonDecode(value.getString('user') ?? "")),
queryDetail(widget.arguments["titleType"] == 1 ? "" : "bill_cate_point_get", widget.arguments["titleType"] == 1 ?"BILL_TYPE_BEAN_ADD" :""),
});
context: context, token: SharedInstance.instance.token);
userInfo = UserInfo.fromJson(jsonDecode(SharedInstance.instance.userJson));
queryDetail(widget.arguments["titleType"] == 1 ? "" : "bill_cate_point_get",
widget.arguments["titleType"] == 1 ?"BILL_TYPE_BEAN_ADD" :"");
}
queryDetail(category,type) async {
BaseData<PageInfo<UserBill>>? baseData = await apiService?.queryBillInfo({
"current": current,
"model": {"category": category, "title": widget.arguments["titleType"] == 1 ? "":"bill_title_point", "type": type},
"model": {
"category": category,
"title": widget.arguments["titleType"] == 1 ? "":"bill_title_point",
"type": type,
},
"order": "descending",
"size": 10,
"sort": "id"
}).catchError((onError) {
refreshController.loadFailed();
refreshController.refreshFailed();
return Future.value(null);
return BaseData<PageInfo<UserBill>>()..isSuccess = false;
});
if (current == 1) userBill.clear();
if (baseData?.isSuccess ?? false) {
@ -127,6 +131,7 @@ class _IntegralDetailedPage extends State<IntegralDetailedPage>
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
body: NestedScrollView(
headerSliverBuilder: (context, inner) {
@ -181,14 +186,16 @@ class _IntegralDetailedPage extends State<IntegralDetailedPage>
style: TextStyle(
color: Colors.white,
fontWeight: MyFontWeight.medium,
fontSize: 48.sp),
fontSize: 48.sp,
),
),
Text(
widget.arguments["titleType"] == 1 ? "我的印章" : S.of(context).wodejifenzhi,
style: TextStyle(
color: Color(0xFFF2F2F2),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular),
fontWeight: MyFontWeight.regular,
),
),
],
),
@ -211,13 +218,18 @@ class _IntegralDetailedPage extends State<IntegralDetailedPage>
indicatorSize: TabBarIndicatorSize.label,
labelColor: Colors.white,
labelStyle: TextStyle(
fontSize: 16.sp, fontWeight: MyFontWeight.medium),
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
),
unselectedLabelStyle: TextStyle(
fontSize: 16.sp, fontWeight: MyFontWeight.medium),
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
),
indicatorColor: Colors.white,
unselectedLabelColor: Color(0xFFE6E6E6),
),
)),
),
),
),
];
},
@ -243,8 +255,9 @@ class _IntegralDetailedPage extends State<IntegralDetailedPage>
text: "当前暂无记录哦~",
fontSize: 16.sp,
margin: EdgeInsets.all(60.h),
):ListView.builder(
itemCount: userBill != null ? userBill.length : 0,
)
: ListView.builder(
itemCount: userBill.length,
padding: EdgeInsets.only(top: 8, bottom: 8),
itemBuilder: (context, position) {
return Container(
@ -259,8 +272,9 @@ class _IntegralDetailedPage extends State<IntegralDetailedPage>
offset: Offset(0, 2),
blurRadius: 3,
spreadRadius: 0,
)
]),
),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
@ -273,25 +287,29 @@ class _IntegralDetailedPage extends State<IntegralDetailedPage>
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(padding: EdgeInsets.only(bottom: 8.h),
Padding(
padding: EdgeInsets.only(bottom: 8.h),
child: Text(
userBill[position].type ?? "",
// S.of(context).qiandao,
style: TextStyle(
color: Colors.black,
fontSize: 14.sp,
fontWeight: FontWeight.bold),
fontWeight: FontWeight.bold,
),
),),
Text(
userBill[position].createTime ?? "",
style: TextStyle(
color: Color(0xFF4D4D4D),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular),
)
fontWeight: MyFontWeight.regular,
),
),
],
),
)),
),
),
Container(
margin: EdgeInsets.only(top: 2.h),
child: Text(
@ -300,61 +318,12 @@ class _IntegralDetailedPage extends State<IntegralDetailedPage>
color: Color(0xFF4D4D4D),
fontSize: 14.sp,
fontFamily: 'JDZhengHT',
fontWeight: MyFontWeight.regular),
fontWeight: MyFontWeight.regular,
),
),
),
)
],
)
// Row(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Image.asset(
// "assets/image/icon_intergral_sign.webp",
// width: 36.w,
// height: 34.h,
// ),
// SizedBox(
// width: 15,
// ),
// Expanded(
// child: Container(
// // height: 34.h,
// alignment: Alignment.centerLeft,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// userBill[position].type ?? "",
// // S.of(context).qiandao,
// style: TextStyle(
// color: Colors.black,
// fontSize: 12.sp,
// fontWeight: FontWeight.w400),
// ),
// Text(
// userBill[position].createTime ?? "",
// style: TextStyle(
// color: Color(0xFF727272),
// fontSize: 10.sp,
// fontWeight: MyFontWeight.regular),
// )
// ],
// ),
// )),
// Container(
// margin: EdgeInsets.only(top: 2.h),
// child: Text(
// "${tabController.index == 0 ? "+" : "-"}${double.tryParse(userBill[position].number ?? "0").toInt().toString()}",
// style: TextStyle(
// color: Color(0xFF727272),
// fontSize: 12.sp,
// fontWeight: MyFontWeight.regular),
// ),
// )
// ],
// ),
),
);
},
),

48
lib/integral/integral_page.dart

@ -15,6 +15,7 @@ import 'package:huixiang/integral/intergra_view/in_for_points.dart';
import 'package:huixiang/integral/intergra_view/integral_vip.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:huixiang/view_widget/my_footer.dart';
@ -43,22 +44,17 @@ class _IntegralPage extends State<IntegralPage> {
final RefreshController refreshController = RefreshController();
querySignInfo() async {
// SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai);
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
showLoading: false,
);
userInfo = UserInfo.fromJson(jsonDecode(value.getString("user") ?? ""));
userInfo = UserInfo.fromJson(jsonDecode(SharedInstance.instance.userJson));
BaseListData<Rank>? rankData =
await apiService?.rankList().catchError((onError) {
SmartDialog.showToast(AppUtils.dioErrorTypeToString(onError.type),
alignment: Alignment.center);
BaseListData<Rank>? rankData = await apiService?.rankList().catchError((onError) {
refreshController.refreshFailed();
return BaseListData<Rank>()..isSuccess = false;
});
if (rankData?.isSuccess ?? false) {
ranks.clear();
@ -69,13 +65,12 @@ class _IntegralPage extends State<IntegralPage> {
}
if (ranks.length > 0) {
rankLevel = (ranks.indexWhere(
(element) => element.id == userInfo?.memberRankVo?.id) +
1);
rankLevel = (ranks.indexWhere((element) => element.id == userInfo?.memberRankVo?.id) + 1);
}
BaseData<SignInfo>? baseData =
await apiService?.signInInfo().catchError((onError) {});
BaseData<SignInfo>? baseData = await apiService?.signInInfo().catchError((onError) {
return BaseData<SignInfo>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
signInfo = baseData!.data;
refreshController.refreshCompleted();
@ -89,20 +84,6 @@ class _IntegralPage extends State<IntegralPage> {
color: Colors.white,
child: Stack(
children: [
// Positioned(
// child: Container(
// height: 122.h + kToolbarHeight + MediaQuery.of(context).padding.top,
// decoration: BoxDecoration(
// image: DecorationImage(
// fit: BoxFit.fill,
// image: AssetImage("assets/image/jifen.webp"),
// ),
// ),
// ),
// top: 0,
// left: 0,
// right: 0,
// ),
Container(
decoration: BoxDecoration(
image: DecorationImage(
@ -186,7 +167,8 @@ class _IntegralPage extends State<IntegralPage> {
0] ??
0)
: 0)
.toString()),
.toString(),
),
///
InForPoints(signInfo, _signIn),
@ -215,13 +197,17 @@ class _IntegralPage extends State<IntegralPage> {
SmartDialog.showLoading(
msg: S.of(context).zhengzaijiazai,
);
BaseData? baseData = await apiService?.signIn().catchError((onError) {});
BaseData? baseData = await apiService?.signIn().catchError((onError) {
return BaseData()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
setState(() {});
SmartDialog.show(
builder: (ctx) => SignInWidget(
"${(signInfo?.signInList?.length ?? 0) + 1}",
"${signInfo?.rewardList?[(signInfo?.signInList?.length ?? 0)]}"));
"${signInfo?.rewardList?[(signInfo?.signInList?.length ?? 0)]}",
),
);
} else {
SmartDialog.dismiss();
}

51
lib/integral/intergra_view/integral_vip.dart

@ -24,12 +24,13 @@ class IntegralVip extends StatefulWidget {
}
class _IntegralVip extends State<IntegralVip> {
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(vertical: 16.h,horizontal: 16.w),
padding: EdgeInsets.symmetric(
vertical: 16.h,horizontal: 16.w,
),
child: Row(
children: [
MImage(
@ -96,52 +97,6 @@ class _IntegralVip extends State<IntegralVip> {
],
),
),
// Container(
// width: 2.w,
// height: 32.h,
// color: Color(0xFFFFFFFF),
// ),
// Expanded(
// flex: 1,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Text(
// (widget?.signInfo?.rank?.rankName != null)
// ? "${widget.signInfo.rank.rankName.replaceAll("会员", "")}"
// : "",
// style: TextStyle(
// fontWeight: MyFontWeight.medium,
// fontSize: 21.sp,
// color: Colors.white,
// ),
// ),
// SizedBox(
// height: 6.h,
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Text(
// S.of(context).wodehuiyuandengji,
// style: TextStyle(
// fontSize: 12.sp,
// fontWeight: MyFontWeight.regular,
// color: Color(0xFFF2F2F2),
// ),
// ),
// // Icon(
// // Icons.keyboard_arrow_right,
// // color: Colors.white,
// // size: 15,
// // ),
// ],
// ),
// ],
// ),
// ),
],
),
);

34
lib/integral_store/integral_store_details_page.dart

@ -12,6 +12,7 @@ import 'package:huixiang/data/user_info.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_footer.dart';
@ -42,15 +43,12 @@ class _IntegralStoreDetailsPage extends State<IntegralStoreDetailsPage> {
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), context: context, token: value.getString("token"));
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token);
queryGoodsById();
if (value.getString('user') != null) {
points = UserInfo.fromJson(jsonDecode(value.getString('user')!)).points;
happyBean = UserInfo.fromJson(jsonDecode(value.getString('user')!)).happyBean;
if (SharedInstance.instance.userJson.isNotEmpty) {
points = UserInfo.fromJson(jsonDecode(SharedInstance.instance.userJson)).points;
happyBean = UserInfo.fromJson(jsonDecode(SharedInstance.instance.userJson)).happyBean;
}
});
}
Goods? goods;
@ -58,7 +56,9 @@ class _IntegralStoreDetailsPage extends State<IntegralStoreDetailsPage> {
///
queryGoodsById() async {
BaseData<Goods>? baseData = await apiService?.creditGoodsById(widget.arguments?["goodsId"] ?? "")
.catchError((onError) {});
.catchError((onError) {
return BaseData<Goods>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
setState(() {
goods = baseData?.data;
@ -77,7 +77,7 @@ class _IntegralStoreDetailsPage extends State<IntegralStoreDetailsPage> {
}
refreshController.refreshCompleted();
});
}else {
} else {
refreshController.refreshFailed();
}
}
@ -175,9 +175,7 @@ class _IntegralStoreDetailsPage extends State<IntegralStoreDetailsPage> {
color: (payType > 0)
? Color(0xFF32A060)
: Color(0xFFD8D8D8),
borderRadius: BorderRadius.circular(
45
),
borderRadius: BorderRadius.circular(45),
),
alignment: Alignment.center,
child: Text(
@ -200,8 +198,9 @@ class _IntegralStoreDetailsPage extends State<IntegralStoreDetailsPage> {
//1-2-3-
toExchangeOrder() async {
await Navigator.of(context)
.pushNamed('/router/exchange_order_page', arguments: {
await Navigator.of(context).pushNamed(
'/router/exchange_order_page',
arguments: {
"goodsId": goods?.id,
"name": goods?.name,
"money": goods?.money,
@ -216,9 +215,10 @@ class _IntegralStoreDetailsPage extends State<IntegralStoreDetailsPage> {
: (goods?.canDelivery ?? false)
? 2
: 3,
});
var shared = await SharedPreferences.getInstance();
points = UserInfo.fromJson(jsonDecode(shared.getString('user') ?? "")).points;
},
);
points = UserInfo.fromJson(jsonDecode(SharedInstance.instance.userJson)).points;
setState(() {});
}

4
lib/login/captcha/block_puzzle_captcha.dart

@ -151,7 +151,9 @@ class _BlockPuzzleCaptchaPageState extends State<BlockPuzzleCaptchaPage>
ApiService apiIpService = ApiService(Dio(), context: context);
CaptchaData baseData = await apiIpService.captchaGet({
"captchaType": "blockPuzzle",
}).catchError((onError) {});
}).catchError((onError) {
return CaptchaData();
});
debugPrint("ClickWordCaptchaModel: ${baseData.toJson()}");

83
lib/login/login_page.dart

@ -17,6 +17,7 @@ import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/event_type.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/border_text.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:photo_view/photo_view.dart';
@ -62,16 +63,10 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
String? areaCode;
isLogin() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
if (sharedPreferences.getBool("isShowPrivacyPolicy") == null ||
!(sharedPreferences.getBool("isShowPrivacyPolicy") ?? false)) {
if (!SharedInstance.instance.isShowPrivacyPolicy) {
showAlertDialog();
}
if (sharedPreferences.containsKey('token') &&
sharedPreferences.getString("token") != null &&
sharedPreferences.getString("token") != "") {
if (SharedInstance.instance.token.isNotEmpty) {
Navigator.of(context).popAndPushNamed('/router/main_page');
} else {
initController();
@ -133,8 +128,7 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
changeAlpha = (offset / (height - chaHeight) * (255)).toInt();
changeAlpha = (changeAlpha > 255 ? 255 : changeAlpha);
changeAlpha = (changeAlpha < 0 ? 0 : changeAlpha);
alpha = (initAlpha + offset / (height - chaHeight) * (255 - initAlpha))
.toInt();
alpha = (initAlpha + offset / (height - chaHeight) * (255 - initAlpha)).toInt();
alpha = (alpha > 255 ? 255 : alpha);
alpha = (alpha < 0 ? 0 : alpha);
});
@ -204,9 +198,7 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
Color statusInviteLineColor = Color(0xFF32A060);
_sendCode() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
if (!sharedPreferences.containsKey("isShowPrivacyPolicy") ||
!(sharedPreferences.getBool("isShowPrivacyPolicy") ?? false)) {
if (!SharedInstance.instance.isShowPrivacyPolicy) {
showAlertDialog();
return;
}
@ -223,10 +215,12 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
return;
}
if (_sendCodeStatus == 0) {
client
?.sendVerify(
{"areaCode": areaCode, "mobile": mobile, "verification": ""})
.then((value) => {
client?.sendVerify({
"areaCode": areaCode, "mobile": mobile, "verification": "",
}).catchError((error) {
SmartDialog.showToast("$error", alignment: Alignment.center);
return BaseData<dynamic>()..isSuccess = false;
}).then((value) => {
if (value.isSuccess ?? false)
{_sendCodeStatus = 1, countdown()}
else
@ -237,10 +231,6 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
alignment: Alignment.center),
refresh()
}
})
.catchError((error) {
SmartDialog.showToast("$error", alignment: Alignment.center);
return Future.value(null);
});
}
}
@ -279,9 +269,7 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
scrollToTop();
return;
}
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
if (!sharedPreferences.containsKey("isShowPrivacyPolicy") ||
!(sharedPreferences.getBool("isShowPrivacyPolicy") ?? false)) {
if (!SharedInstance.instance.isShowPrivacyPolicy) {
showAlertDialog();
return;
}
@ -327,12 +315,9 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
SmartDialog.showLoading(
msg: S.of(context).zhengzaijiazai,
);
BaseData<LoginInfo>? value =
await client?.memberLogin(param).catchError((error) {
BaseData<LoginInfo>? value = await client?.memberLogin(param).catchError((error) {
print(error.message);
SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type),
alignment: Alignment.center);
return Future.value(null);
return BaseData<LoginInfo>()..isSuccess = false;
});
// SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai);
Future.delayed(Duration(seconds: 2), () {
@ -346,7 +331,8 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
"invite": invite,
"interviewCouponList": value.data?.interviewCouponList,
"firstLoginCouponList": value.data?.firstLoginCouponList
});
},
);
SmartDialog.dismiss();
} else {
SmartDialog.showToast("${value?.msg}", alignment: Alignment.center);
@ -356,13 +342,7 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
saveUserJson(userJson) {
var userEntity = UserEntity.fromJson(userJson);
SharedPreferences.getInstance().then((value) => {
value.setString('userJson', jsonEncode(userJson)),
value.setString('token', "${userEntity.token}"),
value.setString('userId', "${userEntity.userId}"),
value.setString('nick', "${userEntity.name}"),
value.setString('mobile', "${userEntity.mobile}"),
});
SharedInstance.instance.saveUserInfo(userEntity);
}
late AnimationController animatedContainer;
@ -402,8 +382,7 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
}
animationStart() {
animatedContainer =
AnimationController(vsync: this, duration: Duration(seconds: 10));
animatedContainer = AnimationController(vsync: this, duration: Duration(seconds: 10));
animation = AlignmentTween(begin: alignmentBegin, end: alignmentEnd)
.animate(animatedContainer);
@ -458,8 +437,7 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
secondChild: uiPage(),
firstCurve: Curves.easeInQuart,
secondCurve: Curves.easeInQuart,
crossFadeState:
isShowLogin ? CrossFadeState.showSecond : CrossFadeState.showFirst,
crossFadeState: isShowLogin ? CrossFadeState.showSecond : CrossFadeState.showFirst,
duration: Duration(milliseconds: Platform.isIOS ? 1000 : 1000),
);
}
@ -1052,21 +1030,19 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
),
SizedBox(
height: 208.h,
)
),
],
),
);
}
scrollToTop() {
RenderBox? renderBox =
loginKey.currentContext?.findRenderObject() as RenderBox?;
RenderBox? renderBox = loginKey.currentContext?.findRenderObject() as RenderBox?;
var screenHeight = MediaQuery.of(context).size.height;
var scrollHeight = screenHeight * 1.47;
var height = scrollHeight - (renderBox?.size.height ?? 0);
var chaHeight = screenHeight - (renderBox?.size.height ?? 0);
scrollController?.animateTo(height - chaHeight,
duration: Duration(milliseconds: 500), curve: Curves.ease);
scrollController?.animateTo(height - chaHeight, duration: Duration(milliseconds: 500), curve: Curves.ease);
}
showAlertDialog() {
@ -1108,7 +1084,8 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
),
),
Text.rich(
TextSpan(children: [
TextSpan(
children: [
TextSpan(
text: S.of(context).yinsizhengce1,
style: TextStyle(
@ -1126,11 +1103,11 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
color: Color(0xff32A060)),
recognizer: TapGestureRecognizer()
..onTap = () {
Navigator.of(context)
.popAndPushNamed('/router/treaty_page');
Navigator.of(context).popAndPushNamed('/router/treaty_page');
},
),
]),
],
),
),
SizedBox(
height: 5.h,
@ -1191,9 +1168,7 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
textColor: Colors.white,
fontSize: 12.sp,
callback: () {
SharedPreferences.getInstance().then((value) {
value.setBool("isShowPrivacyPolicy", true);
});
SharedInstance.instance.showPrivacyPolicy();
SharesdkPlugin.uploadPrivacyPermissionStatus(
1,
(success) => {
@ -1217,7 +1192,7 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
],
),
],
)
),
],
);
},

78
lib/login/new_login_page.dart

@ -8,21 +8,23 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/channels.dart';
import 'package:huixiang/data/examine_instance.dart';
import 'package:huixiang/data/user_entity.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/event_type.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/border_text.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sharesdk_plugin/sharesdk_interface.dart';
import '../main.dart';
import 'captcha/block_puzzle_captcha.dart';
class NewLoginPage extends StatefulWidget {
@ -63,18 +65,12 @@ class _NewLoginPage extends State<NewLoginPage> {
}
queryChannels() async {
BaseData<Channels>? baseData =
await apiService?.appChannels().catchError((error) {
print(error.message);
SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type),
alignment: Alignment.center);
BaseData<Channels>? baseData = await apiService?.appChannels().catchError((error) {
return BaseData<Channels>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
channelsList = baseData!.data;
setState(() {});
} else {
SmartDialog.showToast("${baseData?.msg}", alignment: Alignment.center);
}
}
@ -121,9 +117,7 @@ class _NewLoginPage extends State<NewLoginPage> {
}
_sendCode() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
if (!sharedPreferences.containsKey("isShowPrivacyPolicy") ||
!(sharedPreferences.getBool("isShowPrivacyPolicy") ?? false)) {
if (!SharedInstance.instance.isShowPrivacyPolicy) {
showAlertDialog();
return;
}
@ -131,14 +125,18 @@ class _NewLoginPage extends State<NewLoginPage> {
if (mobile == "") {
mobileStatus = 2;
mobileErrorText = S.of(context).qingshurushoujihao;
SmartDialog.showToast(S.of(context).qingshurushoujihao,
alignment: Alignment.center);
SmartDialog.showToast(
S.of(context).qingshurushoujihao,
alignment: Alignment.center,
);
setState(() {});
return;
}
if (!checkStatus) {
SmartDialog.showToast(S.of(context).gouxuanxieyi,
alignment: Alignment.center);
SmartDialog.showToast(
S.of(context).gouxuanxieyi,
alignment: Alignment.center,
);
return;
}
if (_sendCodeStatus == 0) {
@ -171,15 +169,15 @@ class _NewLoginPage extends State<NewLoginPage> {
}
_login() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
if (!sharedPreferences.containsKey("isShowPrivacyPolicy") ||
!(sharedPreferences.getBool("isShowPrivacyPolicy") ?? false)) {
if (!SharedInstance.instance.isShowPrivacyPolicy) {
showAlertDialog();
return;
}
if (!checkStatus) {
SmartDialog.showToast(S.of(context).gouxuanxieyi,
alignment: Alignment.center);
SmartDialog.showToast(
S.of(context).gouxuanxieyi,
alignment: Alignment.center,
);
return;
}
var mobile = _controllerPhone.text;
@ -189,12 +187,6 @@ class _NewLoginPage extends State<NewLoginPage> {
setState(() {});
return;
}
// if (mobile.length != 11) {
// mobileStatus = 2;
// mobileErrorText = S.of(context).phone_error;
// setState(() {});
// return;
// }
var code = _controllerCode.text;
if (code == "") {
@ -221,16 +213,12 @@ class _NewLoginPage extends State<NewLoginPage> {
msg: S.of(context).zhengzaijiazai,
);
BaseData? value = await apiService?.memberLogin(param).catchError((error) {
print(error.message);
SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type),
alignment: Alignment.center);
return Future.value(null);
return BaseData()..isSuccess = false;
});
// SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai);
if (value?.isSuccess ?? false) {
var userInfo = value!.data;
ExamineInstance.instance.isExamine =
userInfo.authInfo?.account == "13800138000";
ExamineInstance.instance.isExamine = userInfo.authInfo?.account == "13800138000";
saveUserJson(userInfo.authInfo?.toJson());
eventBus.fire(EventType(3));
@ -249,28 +237,20 @@ class _NewLoginPage extends State<NewLoginPage> {
saveUserJson(userJson) {
var userEntity = UserEntity.fromJson(userJson);
SharedPreferences.getInstance().then((value) => {
value.setString('userJson', jsonEncode(userJson)),
value.setString('token', "${userEntity.token}"),
value.setString('userId', "${userEntity.userId}"),
value.setString('nick', "${userEntity.name}"),
value.setString('mobile', "${userEntity.mobile}"),
});
SharedInstance.instance.saveUserInfo(userEntity);
}
isLogin() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
if (sharedPreferences.getBool("isShowPrivacyPolicy") == null ||
!(sharedPreferences.getBool("isShowPrivacyPolicy") ?? false)) {
if (!SharedInstance.instance.isShowPrivacyPolicy) {
showAlertDialog();
}
if (sharedPreferences.containsKey('token') &&
sharedPreferences.getString("token") != null &&
sharedPreferences.getString("token") != "") {
ExamineInstance.instance.isExamine =
sharedPreferences.getString("mobile") == "13800138000";
if (SharedInstance.instance.token.isNotEmpty) {
ExamineInstance.instance.isExamine = SharedInstance.instance.mobile == "13800138000";
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
Navigator.of(context).popAndPushNamed('/router/main_page');
});
} else {
apiService = ApiService(Dio(), context: context);
initController();
@ -935,9 +915,7 @@ class _NewLoginPage extends State<NewLoginPage> {
textColor: Colors.white,
fontSize: 12.sp,
callback: () {
SharedPreferences.getInstance().then((value) {
value.setBool("isShowPrivacyPolicy", true);
});
SharedInstance.instance.showPrivacyPolicy();
SharesdkPlugin.uploadPrivacyPermissionStatus(
1,
(success) => {

54
lib/main.dart

@ -79,6 +79,7 @@ import 'package:huixiang/union/union_details_page.dart';
import 'package:huixiang/union/union_select_city.dart';
import 'package:huixiang/utils/ImgCachePath.dart';
import 'package:huixiang/utils/qiniu.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/vip/user_vip_service_page.dart';
import 'package:huixiang/web/web_page.dart';
import 'package:huixiang/web/web_turntable_activity.dart';
@ -141,7 +142,8 @@ import 'order/invoices_manage/invoices_title_info.dart';
void main() async {
if (Platform.isAndroid) {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.transparent));
SystemUiOverlayStyle(statusBarColor: Colors.transparent),
);
}
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([
@ -157,24 +159,14 @@ void main() async {
locale = Locale.fromSubtags(languageCode: 'zh', countryCode: 'CH');
}
ImgCachePath();
// initSdk();
bool isFirst = sharedPreferences.getBool("isFirst") ?? true;
initShared();
SharedInstance.instance.init(sharedPreferences);
runApp(MyApp(locale, isFirst));
// FlutterBugly.postCatchedException((){
// });
// FlutterBugly.init(androidAppId: "204f207673",iOSAppId: "8bb92ba0f6");
}
// final XgFlutterPlugin xgFlutterPlugin = XgFlutterPlugin();
late HxDatabase hxDatabase;
late SharedPreferences sharedPreferences;
initShared() async {
sharedPreferences = await SharedPreferences.getInstance();
}
initDatabase(String userId) async {
hxDatabase = HxDatabase();
@ -199,11 +191,8 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
builder: (
BuildContext context,
Widget? child,
) =>
GetMaterialApp(
builder: (BuildContext context, Widget? child,) {
return GetMaterialApp(
debugShowCheckedModeBanner: false,
title: Platform.isAndroid
? (ExamineInstance.instance.isExamine ? "海峡姐妹" : "")
@ -211,10 +200,11 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.blue,
// fontFamily: 'JDZhengHT',
brightness: Brightness.light,
textTheme: TextTheme(
button: TextStyle(fontSize: 24.sp),
bodyText1: TextStyle(fontSize: 12.sp),
bodyText2: TextStyle(fontSize: 16.sp),
labelMedium: TextStyle(fontSize: 16.sp),
labelSmall: TextStyle(fontSize: 16.sp),
labelLarge: TextStyle(fontSize: 16.sp),
),
),
localeResolutionCallback: (locale, supportedLocales) {
@ -228,25 +218,19 @@ class MyApp extends StatelessWidget {
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
localeListResolutionCallback:
(List<Locale>? locales, Iterable<Locale> supportedLocales) {
localeListResolutionCallback: (List<Locale>? locales, Iterable<Locale> supportedLocales) {
Locale? locale;
if (locales?.isNotEmpty ?? false) {
print("locale: ${locales![0]}");
if (locales[0].countryCode == "TW") {
locale =
Locale.fromSubtags(languageCode: 'zh', countryCode: 'TW');
locale = Locale.fromSubtags(languageCode: 'zh', countryCode: 'TW');
} else if (locales[0].countryCode == "US") {
locale =
Locale.fromSubtags(languageCode: 'en', countryCode: 'US');
locale = Locale.fromSubtags(languageCode: 'en', countryCode: 'US');
} else {
locale =
Locale.fromSubtags(languageCode: 'zh', countryCode: 'CH');
locale = Locale.fromSubtags(languageCode: 'zh', countryCode: 'CH');
}
}
return appLocale ??
locale ??
Locale.fromSubtags(languageCode: 'zh', countryCode: 'CH');
return appLocale ?? locale ?? Locale.fromSubtags(languageCode: 'zh', countryCode: 'CH');
},
supportedLocales: S.delegate.supportedLocales,
home: (isFirst) ? GuidePage() : NewLoginPage(),
@ -263,8 +247,7 @@ class MyApp extends StatelessWidget {
if (pageContentBuilder != null) {
final Route route = CupertinoPageRoute(
builder: (context) {
return pageContentBuilder(context,
arguments: settings.arguments);
return pageContentBuilder(context, arguments: settings.arguments);
},
settings: settings,
);
@ -279,7 +262,8 @@ class MyApp extends StatelessWidget {
settings: settings,
);
},
),
);
},
);
}
}

74
lib/main_page.dart

@ -23,10 +23,10 @@ import 'package:huixiang/utils/event_type.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/native_event_handler.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/update_dialog.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sharesdk_plugin/sharesdk_interface.dart';
import 'package:sharesdk_plugin/sharesdk_register.dart';
import 'package:tpns_flutter_plugin/android/xg_android_api.dart';
@ -102,11 +102,9 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
String userId = value.getString("userId") ?? "";
String userId = SharedInstance.instance.userId;
initDatabase(userId);
connectSocket();
});
pageController = PageController(
initialPage:
@ -268,9 +266,7 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
MyNativeEventHandler(
(String title, String message, String customContent, int type) {
print("xgPushClickAction2: $customContent");
SharedPreferences.getInstance().then((value) {
value.setString("pushData", customContent);
});
SharedInstance.instance.savePushData(pushData: customContent);
},
),
);
@ -291,16 +287,14 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
? (event["actionType"] == 0)
: (event["xg"]["msgtype"] == 1) &&
event[Platform.isAndroid ? "customMessage" : "custom"] != null) {
SharedPreferences.getInstance().then((value) {
value.setString("pushData",
event[Platform.isAndroid ? "customMessage" : "custom"]);
});
SharedInstance.instance.savePushData(pushData: event[Platform.isAndroid ? "customMessage" : "custom"]);
if ((ModalRoute.of(context)?.isActive ?? false) &&
(ModalRoute.of(context)?.isCurrent ?? false)) {
pushRoute();
} else {
Navigator.of(context)
.pushNamedAndRemoveUntil('/router/main_page', (route) => false);
Navigator.of(context).pushNamedAndRemoveUntil(
'/router/main_page', (route) => false,
);
}
}
return event;
@ -329,9 +323,7 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
}
pushRoute() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
if (sharedPreferences.getString("token") == null ||
sharedPreferences.getString("token") == "") return;
if (SharedInstance.instance.token.isEmpty) return;
String? startIntent;
if (Platform.isAndroid) startIntent = await Bridge.getStartIntent();
print("intent:${startIntent ?? ''}");
@ -340,7 +332,7 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
pushData = startIntent;
// pushData = """{"typed":1,"info":"1420304936817655808"}""";
} else {
pushData = sharedPreferences.getString("pushData") ?? "";
pushData = SharedInstance.instance.pushData;
}
if (pushData == "") return;
Map<String, dynamic>? pushMap = jsonDecode(pushData);
@ -401,7 +393,7 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
params["id"] = pushMap["info"];
break;
}
sharedPreferences.setString("pushData", "");
SharedInstance.instance.savePushData();
print("xgPushClickAction: routeName: $routeName");
if (routeName != "") {
Navigator.of(context).pushNamed(routeName, arguments: params);
@ -410,27 +402,27 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
}
queryUserInfo() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
if (sharedPreferences.getString("token") == null ||
sharedPreferences.getString("token") == "") return;
BaseData<UserInfo> baseDate = await ApiService(
if (SharedInstance.instance.token.isEmpty) return;
BaseData<UserInfo>? baseDate = await ApiService(
Dio(),
context: context,
token: sharedPreferences.getString('token'),
).queryInfo().catchError((onError) {});
sharedPreferences.setString('user', jsonEncode(baseDate.data));
token: SharedInstance.instance.token,
).queryInfo().catchError((onError) {
return BaseData<UserInfo>()..isSuccess = false;
});
if ((baseDate?.isSuccess ?? false) && baseDate?.data != null) {
SharedInstance.instance.saveUser(baseDate!.data!);
//
String? mobile = baseDate.data?.phone;
if (mobile != null && mobile != "") {
xgFlutterPlugin.setAccount(mobile, AccountType.PHONE_NUMBER);
// xgFlutterPlugin.unbindWithIdentifier(identify: mobile, bindType: XGBindType.account)
xgFlutterPlugin.bindWithIdentifier(
identify: mobile,
bindType: XGBindType.account,
);
}
}
}
requestPermission() async {
if (!await Permission.storage.isGranted) {
@ -440,24 +432,23 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
///app自动更新
appAutoUpdate() async {
SharedPreferences value = await SharedPreferences.getInstance();
if (apiService == null) {
apiService = ApiService(
apiService ??= ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
);
}
PackageInfo packageInfo = await PackageInfo.fromPlatform();
BaseData<AppUpdate>? baseData =
await apiService?.appVersion().catchError((onError) {});
BaseData<AppUpdate>? baseData = await apiService?.appVersion().catchError((onError) {
return BaseData<AppUpdate>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
// baseData.data.appLastVersion = "2.0.17";
// baseData.data.appLastVersionUp = "1.0.1";
if (AppUtils.versionCompare(
packageInfo.version, "${baseData?.data?.appLastVersion}") &&
AppUtils.versionCompare(value.getString("appLastVersion") ?? "1.0.0",
"${baseData?.data?.appLastVersion}")) {
packageInfo.version,
"${baseData?.data?.appLastVersion}",
) && AppUtils.versionCompare(
SharedInstance.instance.appLastVersion ?? "1.0.0",
"${baseData?.data?.appLastVersion}",
)) {
showDialog(
context: context,
barrierDismissible: false,
@ -475,7 +466,10 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
}
} else {
if (baseData?.msg?.isNotEmpty ?? false) {
SmartDialog.showToast("${baseData?.msg}", alignment: Alignment.center);
SmartDialog.showToast(
"${baseData?.msg}",
alignment: Alignment.center,
);
}
Navigator.of(context).pop();
}

8
lib/message/main_message_page.dart

@ -12,15 +12,13 @@ class MainMessagePage extends StatefulWidget {
}
}
class _MainMessagePage extends State<MainMessagePage>
with SingleTickerProviderStateMixin {
var tabcontroller;
class _MainMessagePage extends State<MainMessagePage> with SingleTickerProviderStateMixin {
@override
void initState() {
super.initState();
if (tabcontroller == null)
tabcontroller = TabController(length: 2, vsync: this);
}
@override

14
lib/message/real_time_info_page.dart

@ -17,7 +17,8 @@ class _RealTimeInfoPage extends State<RealTimeInfoPage> {
itemBuilder: (context, position) {
return Container(
margin: EdgeInsets.only(
left: 16, right: 16, top: position == 0 ? 32 : 8, bottom: 8),
left: 16, right: 16, top: position == 0 ? 32 : 8, bottom: 8,
),
padding: EdgeInsets.only(top: 16, bottom: 16),
decoration: BoxDecoration(
color: Colors.white,
@ -26,12 +27,17 @@ class _RealTimeInfoPage extends State<RealTimeInfoPage> {
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0)
spreadRadius: 0,
),
],
borderRadius: BorderRadius.all(Radius.circular(8))),
borderRadius: BorderRadius.all(
Radius.circular(8),
),
),
child: MessageItem(0),
);
}),
},
),
);
}
}

23
lib/message/system_details.dart

@ -9,6 +9,7 @@ import 'package:huixiang/data/message.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
@ -50,11 +51,12 @@ class _SystemDetails extends State<SystemDetails> {
super.initState();
msgType = widget.arguments?["msgType"] ?? 0;
SharedPreferences.getInstance().then((value) {
apiService = ApiService(Dio(),
token: value.getString("token"), showLoading: true, context: context);
token: SharedInstance.instance.token,
showLoading: true,
context: context,
);
queryMessage();
});
}
_refresh() {
@ -72,6 +74,7 @@ class _SystemDetails extends State<SystemDetails> {
}).catchError((onError) {
_refreshController.loadFailed();
_refreshController.refreshFailed();
return BaseData<PageInfo<Message>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
if (pageNum == 1) {
@ -98,10 +101,10 @@ class _SystemDetails extends State<SystemDetails> {
if (baseData?.isSuccess ?? false) {
// widget.refresh();
queryMessage();
SmartDialog.showToast(isFollow ? "取关成功" : "关注成功",
alignment: Alignment.center);
} else {
SmartDialog.showToast("${baseData?.msg}", alignment: Alignment.center);
SmartDialog.showToast(
isFollow ? "取关成功" : "关注成功",
alignment: Alignment.center,
);
}
}
@ -120,14 +123,14 @@ class _SystemDetails extends State<SystemDetails> {
"parentId": messageRelational["additionId"].toString(),
"relationalId": messageRelational["businessId"].toString(),
"relationalType": 4
}).catchError((error) {});
}).catchError((error) {
return BaseData()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
commentTextController.text = "";
FocusScope.of(context).unfocus();
Navigator.of(context).pop();
SmartDialog.showToast("发布成功", alignment: Alignment.center);
} else {
SmartDialog.showToast("${baseData?.msg}", alignment: Alignment.center);
}
}

169
lib/message/system_message.dart

@ -10,6 +10,7 @@ import 'package:huixiang/data/page.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:huixiang/view_widget/no_data_view.dart';
@ -41,13 +42,10 @@ class _SystemMessagePage extends State<SystemMessagePage> {
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), token: value.getString("token"), context: context);
ApiService(Dio(), token: SharedInstance.instance.token, context: context);
queryMessage();
queryMsgStats();
});
}
_refresh() {
@ -66,6 +64,7 @@ class _SystemMessagePage extends State<SystemMessagePage> {
}).catchError((onError) {
_refreshController.loadFailed();
_refreshController.refreshFailed();
return BaseData<PageInfo<Message>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
@ -94,8 +93,7 @@ class _SystemMessagePage extends State<SystemMessagePage> {
}
queryMsgStats() async {
BaseListData<MsgStats>? baseData =
await apiService?.stats().catchError((onError) {
BaseListData<MsgStats>? baseData = await apiService?.stats().catchError((onError) {
return BaseListData<MsgStats>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
@ -120,71 +118,11 @@ class _SystemMessagePage extends State<SystemMessagePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
// appBar: MyAppBar(
// background: Colors.white,
// leadingColor: Colors.black,
// title: S.of(context).xiaoxi,
// titleSize: 18.sp,
// titleColor: Colors.black,
// actions: [
// Container(
// margin: EdgeInsets.only(right: 16.w),
// alignment: Alignment.centerRight,
// child: GestureDetector(
// onTap: () {
// setState(() {
// queryMsgStats();
// });
// },
// child: Text(
// S.of(context).biaoweiyidu,
// style: TextStyle(
// fontSize: 16.sp,
// fontWeight:MyFontWeight.semi_bold,
// color: Color(0xFF353535),
// ),
// ),
// ),
// ),
// ],
// ),
backgroundColor: Colors.white,
body: SmartRefresher(
enablePullDown: true,
enablePullUp: true,
header: MyHeader(),
physics: BouncingScrollPhysics(),
footer: CustomFooter(
loadStyle: LoadStyle.ShowWhenLoading,
builder: (BuildContext context, LoadStatus? mode) {
return (messages.length == 0) ? Container() : MyFooter(mode);
},
),
controller: _refreshController,
onRefresh: _refresh,
onLoading: () {
setState(() {
_refresh();
});
},
child: Container(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Container(
padding: EdgeInsets.only(bottom: 30.h),
child: Column(
children: [
Container(
color: Colors.white,
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top + 10.h,
bottom: 15.h,
right: 16.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
GestureDetector(
appBar: AppBar(
backgroundColor: Colors.white,
surfaceTintColor: Colors.white,
leading: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context).pop();
@ -202,15 +140,16 @@ class _SystemMessagePage extends State<SystemMessagePage> {
),
),
),
Expanded(
child: Text(
title: Text(
S.of(context).xiaoxi,
style: TextStyle(
color: Colors.black,
fontSize: 18.sp,
fontWeight: MyFontWeight.bold,
),
)),
),
centerTitle: false,
actions: [
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
@ -219,7 +158,7 @@ class _SystemMessagePage extends State<SystemMessagePage> {
});
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.w),
padding: EdgeInsets.symmetric(horizontal: 18),
child: Text(
S.of(context).biaoweiyidu,
style: TextStyle(
@ -232,19 +171,49 @@ class _SystemMessagePage extends State<SystemMessagePage> {
),
],
),
body: SmartRefresher(
enablePullDown: true,
enablePullUp: true,
header: MyHeader(),
physics: BouncingScrollPhysics(),
footer: CustomFooter(
loadStyle: LoadStyle.ShowWhenLoading,
builder: (BuildContext context, LoadStatus? mode) {
return (messages.length == 0) ? Container() : MyFooter(mode);
},
),
controller: _refreshController,
onRefresh: _refresh,
onLoading: () {
setState(() {
_refresh();
});
},
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Column(
children: [
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context).pushNamed('/router/system_details',
arguments: {"msgType": 6}).then((value) {
Navigator.of(context).pushNamed(
'/router/system_details',
arguments: {"msgType": 6},
).then((value) {
setState(() {
msgNumber["6"] = 0;
});
});
},
child: messageItem("assets/image/icon_pl.webp",
S.of(context).pinglun, msgNumber["6"].toString()),
child: messageItem("assets/image/icon_pl.webp", S.of(context).pinglun, msgNumber["6"].toString()),
),
Container(
width: double.infinity,
height: 1.h,
margin: EdgeInsets.symmetric(
horizontal: 20,
),
color: Color(0xFFF7F7F7),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
@ -259,6 +228,14 @@ class _SystemMessagePage extends State<SystemMessagePage> {
child: messageItem("assets/image/icon_z.webp",
S.of(context).dianzan, msgNumber["5"].toString()),
),
Container(
width: double.infinity,
height: 1.h,
margin: EdgeInsets.symmetric(
horizontal: 20,
),
color: Color(0xFFF7F7F7),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
@ -272,6 +249,14 @@ class _SystemMessagePage extends State<SystemMessagePage> {
child: messageItem("assets/image/icon_gz.webp",
S.of(context).guanzhu, msgNumber["4"].toString()),
),
Container(
width: double.infinity,
height: 1.h,
margin: EdgeInsets.symmetric(
horizontal: 20,
),
color: Color(0xFFF7F7F7),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
@ -285,7 +270,7 @@ class _SystemMessagePage extends State<SystemMessagePage> {
});
},
child: messageItem(
"assets/image/icon_system_message.webp",
"assets/image/icon_system_message_new.webp",
S.of(context).xitongxiaoxi,
"${(msgNumber["2"] ?? 0) + (msgNumber["3"] ?? 0)}"),
),
@ -298,25 +283,19 @@ class _SystemMessagePage extends State<SystemMessagePage> {
),
),
),
),
),
);
}
Widget messageItem(img, title, messageNum) {
return Container(
padding: EdgeInsets.only(
top: 14.h,
left: 14.w,
bottom: 10.h,
right: 14.w,
padding: EdgeInsets.symmetric(
horizontal: 14.w,
vertical: 14,
),
decoration: BoxDecoration(
color: Colors.white,
),
child: Column(
children: [
Row(
child: Row(
children: [
Image.asset(
img,
@ -356,7 +335,8 @@ class _SystemMessagePage extends State<SystemMessagePage> {
)
: Container(
padding: EdgeInsets.symmetric(
horizontal: 4.w, vertical: 2.h),
horizontal: 4.w, vertical: 2.h,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: Color(0xFFFF441A),
@ -377,15 +357,6 @@ class _SystemMessagePage extends State<SystemMessagePage> {
),
],
),
if (title != S.of(context).xitongxiaoxi)
Container(
margin: EdgeInsets.only(top: 12.h),
width: double.infinity,
height: 1.h,
color: Color(0xFFF7F7F7),
),
],
),
);
}

24
lib/message/system_notice.dart

@ -6,6 +6,7 @@ import 'package:huixiang/data/message.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:huixiang/view_widget/no_data_view.dart';
@ -39,12 +40,8 @@ class _SystemNotice extends State<SystemNotice> {
void initState() {
super.initState();
// msgType = widget.arguments["msgType"];
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), token: value.getString("token"), context: context);
apiService = ApiService(Dio(), token: SharedInstance.instance.token, context: context);
queryMessage();
});
}
_refresh() {
@ -62,6 +59,7 @@ class _SystemNotice extends State<SystemNotice> {
}).catchError((onError) {
_refreshController.loadFailed();
_refreshController.refreshFailed();
return BaseData<PageInfo<Message>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
@ -121,7 +119,8 @@ class _SystemNotice extends State<SystemNotice> {
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top + 10.h,
bottom: 10.h,
right: 16.w),
right: 16.w,
),
child: Row(
children: [
GestureDetector(
@ -199,14 +198,18 @@ class _SystemNotice extends State<SystemNotice> {
},
child: buildMessageItem(messages[position]),
);
}),
},
),
],
));
),
);
}
Widget buildMessageItem(Message message) {
return Container(
margin: EdgeInsets.only(top: 8.h, bottom: 8.h, left: 16.w, right: 17.w),
margin: EdgeInsets.only(
top: 8.h, bottom: 8.h, left: 16.w, right: 17.w,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
@ -246,7 +249,8 @@ class _SystemNotice extends State<SystemNotice> {
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF060606),
),
)),
),
),
Text(
message.updateTime ?? "",
style: TextStyle(

8
lib/mine/coupon_page.dart

@ -6,6 +6,7 @@ import 'package:huixiang/data/coupon.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/coupon_details_dialog.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
@ -43,12 +44,8 @@ class _CouponPage extends State<CouponPage> {
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), context: context, token: value.getString('token'));
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token);
queryCard();
});
_refreshController = RefreshController(initialRefresh: false);
}
@ -74,6 +71,7 @@ class _CouponPage extends State<CouponPage> {
setState(() {});
_refreshController.loadFailed();
_refreshController.refreshFailed();
return BaseData<PageInfo<Coupon>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
if (baseData?.data?.list?.isNotEmpty ?? false) {

5
lib/mine/coupons_page.dart

@ -6,6 +6,7 @@ import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/coupon.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/coupon_details_dialog.dart';
import 'package:huixiang/view_widget/my_footer.dart';
@ -38,10 +39,8 @@ class _CouponsPage extends State<CouponsPage> {
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
apiService = ApiService(Dio(), context: context, token: value.getString('token'));
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token);
queryCard();
});
_refreshController = RefreshController(initialRefresh: false);
}

16
lib/mine/fans_page.dart

@ -6,6 +6,7 @@ import 'package:huixiang/data/follow.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_footer.dart';
@ -39,16 +40,13 @@ class _FansPage extends State<FansPage> with SingleTickerProviderStateMixin, Aut
super.initState();
_refreshController = RefreshController();
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), context: context, token: value.getString("token"));
ApiService(Dio(), context: context, token: SharedInstance.instance.token);
_queryFollowList();
});
}
///
_queryFollowList() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
BaseData<PageInfo<Follow>>? baseData = await apiService?.followList({
"isMyFans": true,
"pageNum": 1,
@ -56,7 +54,7 @@ class _FansPage extends State<FansPage> with SingleTickerProviderStateMixin, Aut
}).catchError((error) {
_refreshController.refreshFailed();
_refreshController.loadFailed();
return Future.value(null);
return BaseData<PageInfo<Follow>>()..isSuccess = false;
});
_refreshController.refreshCompleted();
@ -68,7 +66,6 @@ class _FansPage extends State<FansPage> with SingleTickerProviderStateMixin, Aut
}
list.addAll(baseData!.data!.list!);
}
print("list: ${list.length}");
if ((int.tryParse("${baseData?.data?.total}") ?? 0) < (pageNum * 10)) {
_refreshController.loadNoData();
}
@ -79,19 +76,18 @@ class _FansPage extends State<FansPage> with SingleTickerProviderStateMixin, Aut
///
_vipFollow(followId,isFollow) async {
BaseData? baseData = await apiService?.follow(followId).catchError((onError) {
return Future.value(null);
return BaseData()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
widget.refresh();
_queryFollowList();
SmartDialog.showToast(isFollow?"取关成功":"关注成功", alignment: Alignment.center);
} else {
SmartDialog.showToast("${baseData?.msg}", alignment: Alignment.center);
}
}
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
body: Container(
margin: EdgeInsets.only(top: 2),
@ -128,7 +124,7 @@ class _FansPage extends State<FansPage> with SingleTickerProviderStateMixin, Aut
child: fansItem(list[position]),
);
},
)
),
// NoDataView(
// isShowBtn: false,
// text: "共关注0人",

10
lib/mine/follow_page.dart

@ -6,6 +6,7 @@ import 'package:huixiang/data/follow.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_footer.dart';
@ -36,17 +37,13 @@ class _FollowPage extends State<FollowPage>
void initState() {
super.initState();
_refreshController = RefreshController();
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), context: context, token: value.getString("token"));
ApiService(Dio(), context: context, token: SharedInstance.instance.token);
_queryFollowList();
});
}
///
_queryFollowList() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
BaseData<PageInfo<Follow>>? baseData = await apiService?.followList({
"isMyFans": false,
"pageNum": 1,
@ -54,7 +51,7 @@ class _FollowPage extends State<FollowPage>
}).catchError((error) {
_refreshController.refreshFailed();
_refreshController.loadFailed();
return Future.value(null);
return BaseData<PageInfo<Follow>>()..isSuccess = false;
});
_refreshController.refreshCompleted();
@ -88,6 +85,7 @@ class _FollowPage extends State<FollowPage>
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
body: Container(
margin: EdgeInsets.only(top: 2),

23
lib/mine/invitation_record.dart

@ -12,6 +12,7 @@ import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/no_data_view.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -35,12 +36,9 @@ class _InvitationRecord extends State<InvitationRecord>
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
apiService = ApiService(Dio(),
context: context, token: value.getString("token"), pay: true);
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token, pay: true);
queryInviteMember();
queryUserInfo();
});
}
///
@ -52,7 +50,7 @@ class _InvitationRecord extends State<InvitationRecord>
"pageSize": 100,
}).catchError((error) {
_refreshController.refreshFailed();
return Future.value(null);
return BaseData<PageInfo<Invitation>>() ..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
if (baseData?.data?.list?.isNotEmpty ?? false) {
@ -70,20 +68,15 @@ class _InvitationRecord extends State<InvitationRecord>
}
queryUserInfo() async {
BaseData<UserInfo>? baseDate =
await apiService?.queryInfo().catchError((onError) {
BaseData<UserInfo>? baseDate = await apiService?.queryInfo().catchError((onError) {
_refreshController.refreshFailed();
return Future.value(null);
return BaseData<UserInfo>()..isSuccess = false;
});
if (baseDate?.isSuccess ?? false) {
if ((baseDate?.isSuccess ?? false) && baseDate!.data != null) {
setState(() {
userInfo = baseDate!.data;
userInfo = baseDate.data;
});
SharedPreferences.getInstance().then(
(value) => {
value.setString('user', jsonEncode(baseDate!.data)),
},
);
SharedInstance.instance.saveUser(baseDate.data!);
_refreshController.refreshCompleted();
} else {
_refreshController.refreshFailed();

10
lib/mine/manage_address_page.dart

@ -6,6 +6,7 @@ import 'package:huixiang/data/address.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/border_text.dart';
import 'package:huixiang/view_widget/icon_text.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
@ -32,17 +33,14 @@ class _ManageAddressPage extends State<ManageAddressPage> {
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context, token: value.getString('token')),
queryMemberAddress(),
});
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token);
queryMemberAddress();
}
List<Address>? addressList;
queryMemberAddress() async {
BaseListData<Address>? baseData = await apiService?.queryMemberAddress().catchError((){
BaseListData<Address>? baseData = await apiService?.queryMemberAddress().catchError((error){
return BaseListData<Address>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {

10
lib/mine/mine_card_invalid_page.dart

@ -5,11 +5,11 @@ import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/coupon.dart';
import 'package:huixiang/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/coupon_widget.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class MineCardInvalidPage extends StatefulWidget {
@ -34,10 +34,8 @@ class _MineCardInvalidPage extends State<MineCardInvalidPage> {
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(), context: context, token: value.getString('token')),
queryCard(),
});
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token);
queryCard();
_refreshController = RefreshController(initialRefresh: false);
}
@ -60,7 +58,7 @@ class _MineCardInvalidPage extends State<MineCardInvalidPage> {
}).catchError((error) {
_refreshController.loadFailed();
_refreshController.refreshFailed();
return Future.value(null);
return BaseData<PageInfo<Coupon>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
if (baseData?.data?.list?.isNotEmpty ?? false) {

12
lib/mine/mine_greenery.dart

@ -9,6 +9,7 @@ import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_footer.dart';
@ -35,12 +36,9 @@ class _MineGreenery extends State<MineGreenery> {
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context, token: value.getString("token")),
pointGoodsList(),
});
context: context, token: SharedInstance.instance.token);
pointGoodsList();
}
pointGoodsList() async {
@ -56,7 +54,7 @@ class _MineGreenery extends State<MineGreenery> {
await apiService?.creditGoods(param).catchError((onError) {
refreshController.loadFailed();
refreshController.refreshFailed();
return Future.value(null);
return BaseData<PageInfo<Goods>>()..isSuccess = false;
});
SmartDialog.dismiss();
if (pageGoods?.isSuccess ?? false) {
@ -228,7 +226,7 @@ class _MineGreenery extends State<MineGreenery> {
children: [
Expanded(
child: GridView.builder(
itemCount: goods.length ?? 0,
itemCount: goods.length,
padding: EdgeInsets.only(
left: 16.w,
right: 16.w,

57
lib/mine/mine_page.dart

@ -21,11 +21,11 @@ import 'package:huixiang/mine/mine_view/mine_navbar.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/event_type.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/login_tips_dialog.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:retrofit/error_logger.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../data/banner.dart';
import '../data/coupon.dart';
@ -54,18 +54,23 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin,
List<BannerData> activityBannerData = [];
_toUserInfo() async {
SharedPreferences shared = await SharedPreferences.getInstance();
if (shared.getString("token") == null || shared.getString("token") == "") {
if (SharedInstance.instance.token.isEmpty) {
Navigator.of(context).pushReplacementNamed('/router/new_login_page',
arguments: {"login": "login"});
return;
}
(Platform.isAndroid && ExamineInstance.instance.isExamine)
? await Navigator.of(context).pushNamed('/router/user_info_page')
: await Navigator.of(context)
.pushNamed('/router/personal_page', arguments: {
"memberId": "0",
});
if (Platform.isAndroid && ExamineInstance.instance.isExamine) {
await Navigator.of(context).pushNamed('/router/user_info_page');
} else {
if (SharedInstance.instance.userId.isNotEmpty) {
await Navigator.of(context).pushNamed(
'/router/personal_page',
arguments: {
"memberId": SharedInstance.instance.userId,
},
);
}
}
setState(() {});
}
@ -96,18 +101,11 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin,
}
queryUserInfo() async {
// SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai);
final SharedPreferences value = await SharedPreferences.getInstance();
if (value.containsKey('user') &&
value.getString('user') != null &&
value.getString('user') != "") {
userInfo = UserInfo.fromJson(jsonDecode(value.getString('user')!));
}
userInfo = UserInfo.fromJson(jsonDecode(SharedInstance.instance.userJson));
apiService = ApiService(
Dio(),
context: context,
token: value.getString('token'),
token: SharedInstance.instance.token,
showLoading: false,
errorLogger: this,
);
@ -128,13 +126,9 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin,
_refreshController.refreshFailed();
return BaseData<UserInfo>()..isSuccess = false;
});
if (baseDate?.isSuccess ?? false) {
if ((baseDate?.isSuccess ?? false) && baseDate?.data != null) {
userInfo = baseDate?.data;
SharedPreferences.getInstance().then(
(value) => {
value.setString('user', jsonEncode(baseDate?.data)),
},
);
SharedInstance.instance.saveUser(baseDate!.data!);
_refreshController.refreshCompleted();
} else {
_refreshController.refreshFailed();
@ -144,11 +138,10 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin,
///banner
queryActivityBanner() async {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
showLoading: false,
errorLogger: this,
);
@ -163,11 +156,10 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin,
}
queryCoupon() async {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
showLoading: false,
errorLogger: this,
);
@ -199,11 +191,10 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin,
///(//)
querySocialInfo() async {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
token: SharedInstance.instance.token,
showLoading: false,
errorLogger: this,
);
@ -222,8 +213,7 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin,
///
queryMsgStats() async {
BaseListData<MsgStats>? baseData =
await apiService?.stats().catchError((onError) {
BaseListData<MsgStats>? baseData = await apiService?.stats().catchError((onError) {
return BaseListData<MsgStats>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
@ -764,8 +754,7 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin,
}
toIntegralPage() async {
SharedPreferences shared = await SharedPreferences.getInstance();
if (shared.getString("token") == null || shared.getString("token") == "") {
if (SharedInstance.instance.token.isEmpty) {
LoginTipsDialog().show(context);
return;
}

162
lib/mine/mine_shop_details.dart

@ -15,6 +15,7 @@ import 'package:huixiang/store/scan.dart';
import 'package:huixiang/utils/app_util.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/location.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
@ -38,7 +39,6 @@ class _MineShopDetails extends State<MineShopDetails> {
ApiService? apiService;
int selectType = 0;
List<UserBill> userBill = [];
int networkStatus = 0;
@override
void dispose() {
@ -51,11 +51,11 @@ class _MineShopDetails extends State<MineShopDetails> {
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), token: value.getString("token"), context: context);
apiService = ApiService(Dio(),
token: SharedInstance.instance.token,
context: context,
);
vipDetail("", "");
});
startLocation();
}
@ -65,28 +65,30 @@ class _MineShopDetails extends State<MineShopDetails> {
int current = 1;
vipDetail(latitude, longitude) async {
SharedPreferences value = await SharedPreferences.getInstance();
BaseData<VipCard>? baseData = await apiService?.vipDetail({
"id": widget.arguments["id"],
"latitude": "$latitude",
"longitude": "$longitude",
}).catchError((onError) {
networkStatus = -1;
return Future.value(null);
return BaseData<VipCard>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
vipCard = baseData!.data;
if ((vipCard?.storeList?.isNotEmpty ?? false) &&
(vipCard!.storeList!.first.logo?.isNotEmpty ?? false)) {
Color? color = await loadShopColor(vipCard!.storeList!.first.logo!);
if (color != null) {
vipCard!.color = color;
}
}
refreshController.loadComplete();
networkStatus = 1;
} else {
refreshController.loadFailed();
}
print("object:object");
setState(() {});
}
startLocation() async {
// SmartDialog.showLoading(msg: S.current.zhengzaijiazai);
LocationInstance.getInstance().startLocation(context, (Position? result) {
if (result?.latitude != null && result?.longitude != null) {
vipDetail(result?.latitude, result?.longitude);
@ -109,12 +111,11 @@ class _MineShopDetails extends State<MineShopDetails> {
"size": 10,
"sort": "id"
}).catchError((onError) {
networkStatus == -1;
refreshController.refreshFailed();
refreshController.loadFailed();
consumeRefreshController.refreshFailed();
consumeRefreshController.loadFailed();
return Future.value(null);
return BaseData<PageInfo<UserBill>>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
if (current == 1) {
@ -133,7 +134,6 @@ class _MineShopDetails extends State<MineShopDetails> {
} else {
current += 1;
}
networkStatus = 1;
} else {
refreshController.refreshFailed();
refreshController.loadFailed();
@ -153,9 +153,7 @@ class _MineShopDetails extends State<MineShopDetails> {
systemUiOverlayStyle: SystemUiOverlayStyle.dark,
leadingColor: Colors.black,
),
body: networkStatus == 0
? skeletonScreen()
: Column(
body: Column(
children: [
buildVipCard(),
Container(
@ -173,8 +171,8 @@ class _MineShopDetails extends State<MineShopDetails> {
Text(
"适用门店",
style: TextStyle(
color: Color(
selectType == 0 ? 0xFF000000 : 0xFF868686),
color:
Color(selectType == 0 ? 0xFF000000 : 0xFF868686),
fontSize: 15.sp,
fontWeight: MyFontWeight.medium,
),
@ -319,7 +317,15 @@ class _MineShopDetails extends State<MineShopDetails> {
topLeft: Radius.circular(6),
topRight: Radius.circular(6),
),
color: Color(colorByName(vipCard?.tenantName ?? "")),
color: vipCard?.color ?? Color(colorByName(vipCard?.tenantName ?? "")),
boxShadow: [
BoxShadow(
color: (vipCard?.color ?? Color(colorByName(vipCard?.tenantName ?? ""))).withAlpha(80),
offset: Offset(0, -1),
blurRadius: 3,
spreadRadius: 1,
),
],
),
padding: EdgeInsets.only(left: 12.w),
height: 62.h,
@ -355,6 +361,14 @@ class _MineShopDetails extends State<MineShopDetails> {
topRight: Radius.circular(6),
),
color: Colors.white,
boxShadow: [
BoxShadow(
color: (vipCard?.color ?? Color(colorByName(vipCard?.tenantName ?? ""))).withAlpha(10),
offset: Offset(0, 2),
blurRadius: 5,
spreadRadius: 1,
),
],
),
padding: EdgeInsets.all(12.h),
child: Column(
@ -823,58 +837,58 @@ class _MineShopDetails extends State<MineShopDetails> {
bool isRemake = true;
// String totalPrice(orderInfo) {
// if (orderInfo == null) return "";
// double totalPrice = (double.tryParse(orderInfo.orderSum) +
// double.tryParse(orderInfo.postFee));
// if (orderInfo.orderDetail != null &&
// orderInfo.orderDetail.couponDTO != null) {
// totalPrice -= double.tryParse(orderInfo.orderDetail.couponDTO.money);
// }
// return "$totalPrice";
// }
// List<Widget> goodsItem(List<ProductsList> products) {
// if (products.length > 3) {
// products = products.sublist(0, 3);
// }
// return products
// .map(
// (e) => Container(
// margin: EdgeInsets.symmetric(horizontal: 2.w),
// child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// MImage(
// e.skuImg,
// width: 75.w,
// height: 75.h,
// fit: BoxFit.contain,
// errorSrc: "assets/image/default_1.webp",
// fadeSrc: "assets/image/default_1.webp",
// ),
// SizedBox(
// height: 4.h,
// ),
// if (isRemake)
// Container(
// width: 75.w,
// child: Text(
// e.productName,
// maxLines: 1,
// textAlign: TextAlign.center,
// overflow: TextOverflow.ellipsis,
// style: TextStyle(
// fontSize: 10.sp,
// fontWeight: MyFontWeight.regular,
// color: Color(0xFF353535),
// ),
// ),
// ),
// ],
// ),
// ),
// )
// .toList();
// }
// String totalPrice(orderInfo) {
// if (orderInfo == null) return "";
// double totalPrice = (double.tryParse(orderInfo.orderSum) +
// double.tryParse(orderInfo.postFee));
// if (orderInfo.orderDetail != null &&
// orderInfo.orderDetail.couponDTO != null) {
// totalPrice -= double.tryParse(orderInfo.orderDetail.couponDTO.money);
// }
// return "$totalPrice";
// }
// List<Widget> goodsItem(List<ProductsList> products) {
// if (products.length > 3) {
// products = products.sublist(0, 3);
// }
// return products
// .map(
// (e) => Container(
// margin: EdgeInsets.symmetric(horizontal: 2.w),
// child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// MImage(
// e.skuImg,
// width: 75.w,
// height: 75.h,
// fit: BoxFit.contain,
// errorSrc: "assets/image/default_1.webp",
// fadeSrc: "assets/image/default_1.webp",
// ),
// SizedBox(
// height: 4.h,
// ),
// if (isRemake)
// Container(
// width: 75.w,
// child: Text(
// e.productName,
// maxLines: 1,
// textAlign: TextAlign.center,
// overflow: TextOverflow.ellipsis,
// style: TextStyle(
// fontSize: 10.sp,
// fontWeight: MyFontWeight.regular,
// color: Color(0xFF353535),
// ),
// ),
// ),
// ],
// ),
// ),
// )
// .toList();
// }
}

66
lib/mine/mine_shop_page.dart

@ -1,4 +1,10 @@
import 'dart:async';
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:color_thief_dart/color_thief_dart.dart';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@ -6,14 +12,15 @@ import 'package:huixiang/data/base_list_data.dart';
import 'package:huixiang/data/vip_card.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/app_util.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:huixiang/view_widget/no_data_view.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shimmer/shimmer.dart';
class MineShopPage extends StatefulWidget {
@ -42,11 +49,8 @@ class _MineShopPage extends State<MineShopPage> with WidgetsBindingObserver {
void initState() {
super.initState();
refreshController = RefreshController();
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), context: context, token: value.getString("token"));
apiService = ApiService(Dio(), context: context, token: SharedInstance.instance.token);
queryVipCard();
});
_focusNode.addListener(() {
setState(() {
hasFocus = _focusNode.hasFocus;
@ -97,6 +101,7 @@ class _MineShopPage extends State<MineShopPage> with WidgetsBindingObserver {
if (baseData?.isSuccess ?? false) {
coupons.clear();
coupons.addAll(baseData!.data ?? []);
await loadShopColors();
refreshController.refreshCompleted();
networkStatus = 1;
} else {
@ -108,6 +113,19 @@ class _MineShopPage extends State<MineShopPage> with WidgetsBindingObserver {
}
}
Future loadShopColors() async {
await Future.forEach(coupons, (element) async {
if ((element.storeList?[0].logo ?? "").isEmpty) {
return;
}
Color? color = await loadShopColor(element.storeList![0].logo!);
if (color != null) {
element.color = color;
}
});
setState(() {});
}
@override
Widget build(BuildContext context) {
return GestureDetector(
@ -129,7 +147,7 @@ class _MineShopPage extends State<MineShopPage> with WidgetsBindingObserver {
color: Colors.white,
padding: EdgeInsets.only(
top: 10.h,
bottom: 18.h,
bottom: 18,
),
child: searchShop(),
),
@ -157,7 +175,7 @@ class _MineShopPage extends State<MineShopPage> with WidgetsBindingObserver {
)
: ((coupons.length > 0)
? ListView.builder(
padding: EdgeInsets.symmetric(vertical: 8.h),
padding: EdgeInsets.symmetric(vertical: 8),
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
@ -165,11 +183,10 @@ class _MineShopPage extends State<MineShopPage> with WidgetsBindingObserver {
'/router/mine_shop_recharge',
arguments: {
"id": coupons[position].id,
"tenantCode":
coupons[position].tenantCode,
"storeId":
coupons[position].storeList?[0].id
}).then((value) {
"tenantCode": coupons[position].tenantCode,
"storeId": coupons[position].storeList?[0].id
},
).then((value) {
queryVipCard(showLoading: false);
});
},
@ -258,7 +275,6 @@ class _MineShopPage extends State<MineShopPage> with WidgetsBindingObserver {
Widget shopItem(VipCard vipCard) {
return Container(
width: double.infinity,
margin: EdgeInsets.only(bottom: 12.h, top: 14.h, left: 14.w, right: 14.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
@ -269,9 +285,18 @@ class _MineShopPage extends State<MineShopPage> with WidgetsBindingObserver {
topLeft: Radius.circular(6),
topRight: Radius.circular(6),
),
color: Color(colorByName(vipCard.tenantName)),
color: vipCard.color,
boxShadow: [
BoxShadow(
color: vipCard.color.withAlpha(80),
offset: Offset(0, -1),
blurRadius: 3,
spreadRadius: 1,
),
],
),
padding: EdgeInsets.only(left: 12.w),
margin: EdgeInsets.only(top: 12, left: 14.w, right: 14.w),
height: 62.h,
child: Row(
children: [
@ -302,11 +327,22 @@ class _MineShopPage extends State<MineShopPage> with WidgetsBindingObserver {
decoration: BoxDecoration(
borderRadius: new BorderRadius.only(
bottomRight: Radius.circular(6),
topRight: Radius.circular(6),
bottomLeft: Radius.circular(6),
),
color: Colors.white,
boxShadow: [
BoxShadow(
color: vipCard.color.withAlpha(10),
offset: Offset(0, 2),
blurRadius: 5,
spreadRadius: 1,
),
],
),
padding: EdgeInsets.all(12.h),
margin: EdgeInsets.only(
bottom: 12, left: 14.w, right: 14.w,
),
child: Column(
children: [
Row(

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save