- 上游: github.com/OpenIMSDK/openim-flutter-demo tag 3.8.3-patch.3 commit b3dfdb1e8aaeaaf6f0793e10cadd20d5c184a31f - 并行目录 mobile-next/ 原样导入(含 LICENSE),不覆盖现网 mobile/ - 锁定 Flutter 3.24.5 / Dart 3.5.4 / JDK 17 / Gradle 7.6.3 / AGP 7.3.1 - 实测 Android debug 与 release 构建均成功(见 docs/mobile-next-baseline-import.md) - 本提交可单独回退:git revert 1db1229(重写前) Co-authored-by: multica-agent <github@multica.ai>
75 lines
2.1 KiB
Dart
75 lines
2.1 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:collection/collection.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:pull_to_refresh_new/pull_to_refresh.dart';
|
|
|
|
import '../../../core/controller/im_controller.dart';
|
|
|
|
class OANotificationLogic extends GetxController {
|
|
late ConversationInfo info;
|
|
var messageList = <Message>[].obs;
|
|
final pageSize = 40;
|
|
final refreshController = RefreshController(initialRefresh: false);
|
|
final imLogic = Get.find<IMController>();
|
|
int? lastMinSeq;
|
|
bool _isFirstLoad = false;
|
|
|
|
@override
|
|
void onInit() {
|
|
info = Get.arguments;
|
|
|
|
imLogic.onRecvNewMessage = (Message message) {
|
|
if (message.contentType == MessageType.oaNotification) {
|
|
if (!messageList.contains(message)) messageList.add(message);
|
|
}
|
|
};
|
|
super.onInit();
|
|
}
|
|
|
|
@override
|
|
void onReady() {
|
|
loadNotification();
|
|
super.onReady();
|
|
}
|
|
|
|
void loadNotification() async {
|
|
final result = await OpenIM.iMManager.messageManager.getAdvancedHistoryMessageList(
|
|
conversationID: info.conversationID,
|
|
count: 200,
|
|
startMsg: _isFirstLoad ? null : messageList.firstOrNull,
|
|
);
|
|
if (result.messageList == null || result.messageList!.isEmpty) {
|
|
return refreshController.loadNoData();
|
|
}
|
|
final list = result.messageList!;
|
|
lastMinSeq = result.lastMinSeq;
|
|
|
|
if (_isFirstLoad) {
|
|
_isFirstLoad = false;
|
|
messageList.assignAll(list);
|
|
} else {
|
|
messageList.insertAll(0, list);
|
|
}
|
|
if (result.isEnd == true) {
|
|
refreshController.loadNoData();
|
|
} else {
|
|
refreshController.loadComplete();
|
|
}
|
|
}
|
|
|
|
OANotification parse(Message message) => OANotification.fromJson(json.decode(message.notificationElem!.detail!));
|
|
|
|
Size calSize(OANotification oa, double w, double h) {
|
|
final width = 50.w;
|
|
|
|
final height = width * h / w;
|
|
print('----${oa.videoElem?.snapshotWidth}---width:$width');
|
|
print('----${oa.videoElem?.snapshotHeight}---height:$height');
|
|
return Size(width, height);
|
|
}
|
|
}
|