获取通话记录

This commit is contained in:
GYJ
2024-11-23 15:22:23 +08:00
parent 87c41341fd
commit a82e726d5f
21 changed files with 430 additions and 6 deletions

View File

@@ -0,0 +1,27 @@
import 'package:cashier_reserve/common/print/print.dart';
import 'package:flutter/services.dart';
import 'names.dart';
class MyEventChannel {
static void startListener() {
onGetCallLogResult();
}
static void onGetCallLogResult() {
EventChannel channel = EventChannel(getChannelName(kCallLogCallback));
channel.receiveBroadcastStream().listen((Object? o) {
yjPrint("onGetCallLogResult");
yjPrint(o);
// AlipayPayResultEvent event = AlipayPayResultEvent();
// if (o is int) {
// event.resultStatus = o;
// } else {
// event.resultStatus = int.parse(o as String);
// }
// EventManager.postEvent(event);
}, onError: (Object error) {
yjPrint("onGetCallLogResult error");
});
}
}

View File

@@ -0,0 +1,16 @@
import 'package:flutter/services.dart';
import '../print/print.dart';
import 'names.dart';
class ChannelManager {
static Future<void> getCallLog(String param) async {
MethodChannel channel = MethodChannel(getChannelName(kGetCallLog));
try {
final result = await channel.invokeMethod(kGetCallLog, param);
yjPrint(result);
} on PlatformException catch (e) {
yjPrint('$kGetCallLog 发生异常:$e');
}
}
}

View File

@@ -0,0 +1,9 @@
const String kChannelBaseName = 'com.czg.cashier_reserve/';
const String kGetCallLog = 'getCallLog';
const String kCallLogCallback = 'callLogCallback';
String getChannelName(name) {
return kChannelBaseName + name;
}

View File

@@ -0,0 +1,10 @@
import 'package:flutter/services.dart';
import '../channel/channel_event.dart';
class AppManager {
static Future<void> initThirdPackage() async {
MyEventChannel.startListener();
}
}

View File

@@ -0,0 +1,8 @@
import 'package:flutter/foundation.dart';
void yjPrint(Object? object) {
if (kDebugMode) {
print(object);
}
}

View File

@@ -77,7 +77,9 @@ class ReserveView extends BaseUI {
width: 5,
),
InkWell(
onTap: () {},
onTap: () {
provider.loadCallLog();
},
child: const SizedBox(
width: 40,
height: 40,

View File

@@ -1,4 +1,5 @@
import 'package:cashier_reserve/common/base/ui_model.dart';
import 'package:cashier_reserve/common/channel/channel_manager.dart';
class ReserveViewModel extends BaseUIModel {
Map<int, String> weekdayMap = {
@@ -16,6 +17,14 @@ class ReserveViewModel extends BaseUIModel {
1: "",
2: "",
};
// ReserveViewModel() {
// loadData();
// }
void loadCallLog() {
ChannelManager.getCallLog("getCallLog");
}
String getCurrentDate() {
DateTime now = DateTime.now();

View File

@@ -1,5 +1,6 @@
import 'dart:io';
import 'package:cashier_reserve/common/manager/app_manager.dart';
import 'package:cashier_reserve/root_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -8,7 +9,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'common/base/widgets.dart';
import 'common/local/cupertino_localizations_delegate.dart';
void main() {
void main() async {
WidgetsFlutterBinding.ensureInitialized();
/// 状态栏沉浸
@@ -16,6 +17,9 @@ void main() {
statusBarColor: Colors.transparent,
statusBarIconBrightness: getAppBrightness(false),
statusBarBrightness: getAppBrightness(false)));
await AppManager.initThirdPackage();
runApp(const MyApp());
}