From 96dbb8a6e888414042c9ab9ea2b900f0a9d61e74 Mon Sep 17 00:00:00 2001 From: Jolie <412895109@qq.com> Date: Tue, 9 Dec 2025 10:19:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?chore(ios):=20=E6=9B=B4=E6=96=B0iOS?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E9=85=8D=E7=BD=AE=E5=92=8C=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将iOS最低部署版本从13.0提升至14.0 - 优化Flutter构建脚本,支持无额外参数时的默认构建 - 调整Podfile配置,移除重复的平台声明 - 添加pre_install钩子,自动清理AgoraRtm中的aosl.xcframework - 修复Xcode项目文件中的脚本阶段引用 - 统一pubspec.lock中的依赖源为国内镜像站 - 注释掉不必要的tobias插件依赖 --- ios/Podfile | 28 ++++++++---- ios/Runner.xcodeproj/project.pbxproj | 56 ++++++++++------------- location_plugin/example/pubspec.lock | 68 ++++++++++++++-------------- pubspec.yaml | 2 +- scripts/build_android.sh | 6 ++- scripts/build_ios.sh | 20 ++++++-- 6 files changed, 99 insertions(+), 81 deletions(-) diff --git a/ios/Podfile b/ios/Podfile index 5aa1473..a896be8 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '13.0' +platform :ios, '14.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' @@ -27,17 +27,10 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe flutter_ios_podfile_setup -platform :ios, '14.0' - -# 在 target 'Runner' do 之前添加 -install! 'cocoapods', :deterministic_uuids => false - target 'Runner' do use_frameworks! flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) - - target 'RunnerTests' do inherit! :search_paths end @@ -46,9 +39,24 @@ end post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) - + target.build_configurations.each do |config| - config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0' + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0' end end end +pre_install do |installer| + # 定义 AgoraRtm framework 的路径 + rtm_pod_path = File.join(installer.sandbox.root, 'AgoraRtm') + + # aosl.xcframework 的完整路径 + aosl_xcframework_path = File.join(rtm_pod_path, 'aosl.xcframework') + + # 检查文件是否存在,如果存在则删除 + if File.exist?(aosl_xcframework_path) + puts "Deleting aosl.xcframework from #{aosl_xcframework_path}" + FileUtils.rm_rf(aosl_xcframework_path) + else + puts "aosl.xcframework not found, skipping deletion." + end +end diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 93f320e..d3bb9ee 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -197,8 +197,8 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - A36064B7643972D96D7D5F55 /* [CP] Embed Pods Frameworks */, - 60F9142B6626BDFC64679D81 /* [CP] Copy Pods Resources */, + 94D55AE63458DA24E5D71252 /* [CP] Embed Pods Frameworks */, + 02B79A8133218288B832A3BC /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -270,6 +270,23 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 02B79A8133218288B832A3BC /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; 0C02713F79384C47FC4BC013 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -330,25 +347,21 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; - 60F9142B6626BDFC64679D81 /* [CP] Copy Pods Resources */ = { + 94D55AE63458DA24E5D71252 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", - ); - inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Copy Pods Resources"; + name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", - ); - outputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; 9740EEB61CF901F6004384FC /* Run Script */ = { @@ -366,27 +379,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - A36064B7643972D96D7D5F55 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/location_plugin/example/pubspec.lock b/location_plugin/example/pubspec.lock index 678892a..36a3835 100644 --- a/location_plugin/example/pubspec.lock +++ b/location_plugin/example/pubspec.lock @@ -6,7 +6,7 @@ packages: description: name: async sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "2.13.0" boolean_selector: @@ -14,7 +14,7 @@ packages: description: name: boolean_selector sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.2" characters: @@ -22,7 +22,7 @@ packages: description: name: characters sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.4.0" clock: @@ -30,7 +30,7 @@ packages: description: name: clock sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.1.2" collection: @@ -38,7 +38,7 @@ packages: description: name: collection sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.19.1" cupertino_icons: @@ -46,7 +46,7 @@ packages: description: name: cupertino_icons sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.0.8" fake_async: @@ -54,7 +54,7 @@ packages: description: name: fake_async sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.3.3" file: @@ -62,7 +62,7 @@ packages: description: name: file sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "7.0.1" flutter: @@ -80,7 +80,7 @@ packages: description: name: flutter_lints sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "5.0.0" flutter_test: @@ -98,7 +98,7 @@ packages: description: name: http sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.6.0" http_parser: @@ -106,7 +106,7 @@ packages: description: name: http_parser sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "4.1.2" integration_test: @@ -119,7 +119,7 @@ packages: description: name: leak_tracker sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "11.0.2" leak_tracker_flutter_testing: @@ -127,7 +127,7 @@ packages: description: name: leak_tracker_flutter_testing sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "3.0.10" leak_tracker_testing: @@ -135,7 +135,7 @@ packages: description: name: leak_tracker_testing sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "3.0.2" lints: @@ -143,7 +143,7 @@ packages: description: name: lints sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7 - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "5.1.1" location_plugin: @@ -158,7 +158,7 @@ packages: description: name: matcher sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "0.12.17" material_color_utilities: @@ -166,7 +166,7 @@ packages: description: name: material_color_utilities sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "0.11.1" meta: @@ -174,7 +174,7 @@ packages: description: name: meta sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.16.0" path: @@ -182,7 +182,7 @@ packages: description: name: path sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.9.1" platform: @@ -190,7 +190,7 @@ packages: description: name: platform sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "3.1.6" plugin_platform_interface: @@ -198,7 +198,7 @@ packages: description: name: plugin_platform_interface sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.8" process: @@ -206,7 +206,7 @@ packages: description: name: process sha256: c6248e4526673988586e8c00bb22a49210c258dc91df5227d5da9748ecf79744 - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "5.0.5" sky_engine: @@ -219,7 +219,7 @@ packages: description: name: source_span sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.10.1" stack_trace: @@ -227,7 +227,7 @@ packages: description: name: stack_trace sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.12.1" stream_channel: @@ -235,7 +235,7 @@ packages: description: name: stream_channel sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "2.1.4" string_scanner: @@ -243,7 +243,7 @@ packages: description: name: string_scanner sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.4.1" sync_http: @@ -251,7 +251,7 @@ packages: description: name: sync_http sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "0.3.1" term_glyph: @@ -259,7 +259,7 @@ packages: description: name: term_glyph sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.2.2" test_api: @@ -267,7 +267,7 @@ packages: description: name: test_api sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "0.7.6" typed_data: @@ -275,7 +275,7 @@ packages: description: name: typed_data sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.4.0" vector_math: @@ -283,7 +283,7 @@ packages: description: name: vector_math sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "2.2.0" vm_service: @@ -291,7 +291,7 @@ packages: description: name: vm_service sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "15.0.2" web: @@ -299,7 +299,7 @@ packages: description: name: web sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "1.1.1" webdriver: @@ -307,7 +307,7 @@ packages: description: name: webdriver sha256: "2f3a14ca026957870cfd9c635b83507e0e51d8091568e90129fbf805aba7cade" - url: "https://pub.dev" + url: "https://pub.flutter-io.cn" source: hosted version: "3.1.0" sdks: diff --git a/pubspec.yaml b/pubspec.yaml index aab6b80..4b05bbf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -66,7 +66,7 @@ dependencies: audioplayers: ^6.5.1 video_thumbnail: ^0.5.3 # 视频缩略图生成 fluwx: ^5.7.5 - # tobias: ^5.3.1 +# # tobias: ^5.3.1 agora_rtc_engine: ^6.5.3 agora_rtm: ^2.2.5 agora_token_generator: ^1.0.0 diff --git a/scripts/build_android.sh b/scripts/build_android.sh index b700f41..4968b26 100755 --- a/scripts/build_android.sh +++ b/scripts/build_android.sh @@ -42,7 +42,11 @@ echo "📚 获取依赖..." flutter pub get echo "🤖 开始构建 Android APK..." -flutter build apk --release "${EXTRA_ARGS[@]}" +if [[ ${#EXTRA_ARGS[@]} -gt 0 ]]; then + flutter build apk --release "${EXTRA_ARGS[@]}" +else + flutter build apk --release +fi popd >/dev/null ARTIFACT_DIR="$PROJECT_ROOT/build/app/outputs/flutter-apk" diff --git a/scripts/build_ios.sh b/scripts/build_ios.sh index f4b1192..8868128 100755 --- a/scripts/build_ios.sh +++ b/scripts/build_ios.sh @@ -42,8 +42,22 @@ echo "📚 获取依赖..." flutter pub get echo "🚀 开始构建 iOS 安装包..." -flutter build ios --release --build-dir "$OUTPUT_DIR" "${EXTRA_ARGS[@]}" +if [[ ${#EXTRA_ARGS[@]} -gt 0 ]]; then + flutter build ios --release "${EXTRA_ARGS[@]}" +else + flutter build ios --release +fi + +# iOS build output is typically in build/ios/iphoneos/ +BUILD_OUTPUT_DIR="$PROJECT_ROOT/build/ios/iphoneos" +if [[ -d "$BUILD_OUTPUT_DIR" ]]; then + echo "📦 复制构建产物到输出目录..." + mkdir -p "$OUTPUT_DIR" + cp -R "$BUILD_OUTPUT_DIR"/* "$OUTPUT_DIR/" 2>/dev/null || true + echo "✅ 构建完成,产物目录:$OUTPUT_DIR" +else + echo "⚠️ 警告: 未找到预期的构建输出目录 $BUILD_OUTPUT_DIR" + echo "构建产物可能在:$PROJECT_ROOT/build/ios/" +fi popd >/dev/null -echo "✅ 构建完成,产物目录:$OUTPUT_DIR" - From 7cc566fe79270d5826d943a9c31278d40551bb61 Mon Sep 17 00:00:00 2001 From: ZHR007 Date: Tue, 9 Dec 2025 10:22:56 +0800 Subject: [PATCH 2/2] no message --- .../discover/visitor_controller.dart | 40 ++--- lib/pages/discover/visitor_list_page.dart | 167 +++++++++--------- 2 files changed, 98 insertions(+), 109 deletions(-) diff --git a/lib/controller/discover/visitor_controller.dart b/lib/controller/discover/visitor_controller.dart index e3283cd..6547892 100644 --- a/lib/controller/discover/visitor_controller.dart +++ b/lib/controller/discover/visitor_controller.dart @@ -16,8 +16,9 @@ class VisitorController extends GetxController { // 分页参数 var currentPage = 1.obs; - final int pageSize = 15; + final int pageSize = 10; var hasMore = true.obs; + var total = 0.obs; var isLoading = false.obs; late final UserApi _userApi; @@ -81,30 +82,16 @@ class VisitorController extends GetxController { Get.snackbar('成功', '已删除访客记录'); } - // 获取今日访客数量 - int get todayVisitorsCount { - return visitors.length; - } - - // 获取在线访客数量 - int get onlineVisitorsCount { - return visitors.length; - } - Future> _fetchVisitorData({required int pageNum}) async { try { - print('_fetchVisitorData - pageNum: $pageNum, pageSize: $pageSize'); // 调用API获取数据 - var response = await _userApi.getVisitorList( - pageNum: pageNum, - pageSize: pageSize, - ); + var response = await _userApi.getVisitorList(pageNum: pageNum, pageSize: pageSize); if (response.data.isSuccess) { - final paginatedData = response.data.data; + final data = response.data.data; // 检查data是否为空 - if (paginatedData == null) { + if (data == null) { return { 'records': [], 'current': pageNum, @@ -113,18 +100,13 @@ class VisitorController extends GetxController { 'size': pageSize, }; } - - // data 是 PaginatedResponse,直接使用其属性 - // records 中的每个项是 dynamic,需要转换为 MarriageData - final records = paginatedData.records - .map((item) => MarriageData.fromJson(item as Map)) - .toList(); + total.value = data.total; return { - 'records': records, - 'current': paginatedData.current, - 'pages': paginatedData.pages, - 'total': paginatedData.total, - 'size': paginatedData.size, + 'records': data.records, + 'current': data.current, + 'pages': data.pages, + 'total': data.total, + 'size': data.size, }; } else { // 响应失败,抛出异常 diff --git a/lib/pages/discover/visitor_list_page.dart b/lib/pages/discover/visitor_list_page.dart index 056f25f..30cbea1 100644 --- a/lib/pages/discover/visitor_list_page.dart +++ b/lib/pages/discover/visitor_list_page.dart @@ -7,7 +7,10 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../controller/discover/visitor_controller.dart'; +import '../../controller/global.dart'; +import '../../generated/assets.dart'; import '../../model/home/marriage_data.dart'; +import '../home/user_information_page.dart'; class VisitorListPage extends StatefulWidget { const VisitorListPage({super.key}); @@ -26,7 +29,7 @@ class _VisitorListPagePageState extends State { backgroundColor: Color(0xffF5F5F5), appBar: AppBar( title: Obx(() => Text( - '最近访客 (${visitorController.todayVisitorsCount})', + '最近访客 (${visitorController.total.value})', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), )), centerTitle: true, @@ -90,19 +93,18 @@ class _VisitorListPagePageState extends State { noMoreText: '没有更多数据', showMessage: false, ), - child: ListView.separated( - padding: const EdgeInsets.only(top: 10, right: 10, left: 10), + child: GridView.builder( + padding: EdgeInsets.only(top: 8.w, left: 10.w, right: 8.w, bottom: 0.w), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, // 每行2个 + crossAxisSpacing: 4.w, // 左右间距 + mainAxisSpacing: 4.w, // 上下间距 + childAspectRatio: 1, // 宽高比 + ), itemCount: visitorController.visitors.length, itemBuilder: (context, index) { final visitor = visitorController.visitors[index]; - return VisitorListItem(visitor: visitor); - }, - separatorBuilder: (context, index) { - // 空状态或加载状态时不显示分隔符 - if (visitorController.visitors.isEmpty) { - return const SizedBox.shrink(); - } - return const SizedBox(height: 10); + return VisitorItem(visitor: visitor); }, ), ); @@ -112,96 +114,101 @@ class _VisitorListPagePageState extends State { } -class VisitorListItem extends StatelessWidget { +class VisitorItem extends StatelessWidget { final MarriageData visitor; - const VisitorListItem({Key? key, required this.visitor}) : super(key: key); + const VisitorItem({Key? key, required this.visitor}) : super(key: key); @override Widget build(BuildContext context) { - return Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(12), - ), - padding: const EdgeInsets.all(12), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, + return Stack( children: [ - // 左侧图片 - Container( - width: 50, - height: 50, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), - color: Colors.blue[100], - image: DecorationImage( - image: NetworkImage(visitor.profilePhoto), - fit: BoxFit.cover, + ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(10.w)), + child: CachedNetworkImage( + imageUrl: "${visitor.profilePhoto}?x-oss-process=image/format,webp/resize,w_240", + width: 173.w, + height: 173.w, + fit: BoxFit.cover, + placeholder: (context, url) => Container( + color: Colors.white38, + child: Center( + child: CircularProgressIndicator( + strokeWidth: 1.w, + color: Colors.grey, + ), + ), ), + errorWidget: (context, url, error) => + Image.asset( + Assets.imagesUserAvatar, + width: 173.w, + height: 173.w, + fit: BoxFit.cover, + ), ), ), - SizedBox(width: 12), - Expanded( + Positioned( + left: 8.w, + bottom: 12.w, child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - Text( - visitor.nickName, - style: TextStyle( - fontSize: 14, - ), - ), - Spacer(), - // Text( - // _formatTime(visitor.visitTime!), - // style: TextStyle( - // color: Colors.grey[500], - // fontSize: 13, - // ), - // ), - ], - ), - SizedBox(height: 4), - SizedBox( - // height: 20, // 固定高度20 - child: Text( - visitor.describeInfo, + if(visitor.describeInfo.isNotEmpty)SizedBox( + width: 156.w, + child: Text(visitor.describeInfo, + maxLines: 1, + overflow: TextOverflow.ellipsis, style: TextStyle( - fontSize: 13, - color: Color.fromRGBO(51, 51, 51, 0.6), + fontSize: 12.w, + color: Colors.white, + fontWeight: FontWeight.w500, ), - overflow: TextOverflow.ellipsis, // 文本超出显示... - maxLines: 1, // 限制为单行 ), ), + SizedBox(height: 2.w), + SizedBox( + width: 156.w, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "${visitor.cityName.isNotEmpty ? '${visitor.cityName} | ' : ''}${visitor.age}岁", + style: TextStyle( + fontSize: 14.w, + color: Colors.white, + fontWeight: FontWeight.w500, + ), + ), + Text('访问1次', style: TextStyle(color: Color(0xffA799FF), fontSize: 12.w)) + ], + ), + ) ], - ) + ), ) ], - ), ).onTap((){ - // _showVisitorDetail(visitor); + Get.to(() => UserInformationPage(miId: visitor.miId, userId: GlobalData().userId!)); }); } - String _formatTime(String timestamp) { - var time = DateTime.parse(timestamp); - final now = DateTime.now(); - final difference = now.difference(time); - - if (difference.inMinutes < 1) { - return '刚刚'; - } else if (difference.inHours < 1) { - return '${difference.inMinutes}分钟前'; - } else if (difference.inDays < 1) { - return '${difference.inHours}小时前'; - } else if (difference.inDays < 7) { - return '${difference.inDays}天前'; - } else { - return '${time.month}/${time.day}'; - } - } + // String _formatTime(String timestamp) { + // var time = DateTime.parse(timestamp); + // final now = DateTime.now(); + // final difference = now.difference(time); + // + // if (difference.inMinutes < 1) { + // return '刚刚'; + // } else if (difference.inHours < 1) { + // return '${difference.inMinutes}分钟前'; + // } else if (difference.inDays < 1) { + // return '${difference.inHours}小时前'; + // } else if (difference.inDays < 7) { + // return '${difference.inDays}天前'; + // } else { + // return '${time.month}/${time.day}'; + // } + // } } \ No newline at end of file