获取通话记录
This commit is contained in:
27
lib/common/channel/channel_event.dart
Normal file
27
lib/common/channel/channel_event.dart
Normal 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");
|
||||
});
|
||||
}
|
||||
}
|
||||
16
lib/common/channel/channel_manager.dart
Normal file
16
lib/common/channel/channel_manager.dart
Normal 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');
|
||||
}
|
||||
}
|
||||
}
|
||||
9
lib/common/channel/names.dart
Normal file
9
lib/common/channel/names.dart
Normal 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;
|
||||
}
|
||||
10
lib/common/manager/app_manager.dart
Normal file
10
lib/common/manager/app_manager.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../channel/channel_event.dart';
|
||||
|
||||
class AppManager {
|
||||
static Future<void> initThirdPackage() async {
|
||||
MyEventChannel.startListener();
|
||||
}
|
||||
}
|
||||
8
lib/common/print/print.dart
Normal file
8
lib/common/print/print.dart
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
void yjPrint(Object? object) {
|
||||
if (kDebugMode) {
|
||||
print(object);
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,9 @@ class ReserveView extends BaseUI {
|
||||
width: 5,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
provider.loadCallLog();
|
||||
},
|
||||
child: const SizedBox(
|
||||
width: 40,
|
||||
height: 40,
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user