重构通道名称,在Android和iOS实现中使用统一的命名空间‘app.record_tool’。相应地更新相关的常量和方法通道。增强在录制HUD中的缩放比例显示格式。

This commit is contained in:
2026-07-01 11:19:30 +08:00
parent c8a7494344
commit 90e8966528
7 changed files with 29 additions and 18 deletions
@@ -1,10 +1,10 @@
package com.run.sportsx package com.run.sportsx
object AppConstants { object AppConstants {
const val PACKAGE_NAME = "com.run.sportsx" private const val CHANNEL_NAMESPACE = "app.record_tool"
const val PLATFORM_INFO_CHANNEL = "$PACKAGE_NAME/platform_info" const val PLATFORM_INFO_CHANNEL = "$CHANNEL_NAMESPACE/platform_info"
const val RECORDING_METHOD_CHANNEL = "$PACKAGE_NAME/recording" const val RECORDING_METHOD_CHANNEL = "$CHANNEL_NAMESPACE/recording"
const val RECORDING_EVENT_CHANNEL = "$PACKAGE_NAME/recording_events" const val RECORDING_EVENT_CHANNEL = "$CHANNEL_NAMESPACE/recording_events"
const val RECORDING_ACTION_START = "$PACKAGE_NAME.recording.START" const val RECORDING_ACTION_START = "$CHANNEL_NAMESPACE.recording.START"
const val RECORDING_ACTION_STOP = "$PACKAGE_NAME.recording.STOP" const val RECORDING_ACTION_STOP = "$CHANNEL_NAMESPACE.recording.STOP"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ import UIKit
final class PlatformInfoPlugin: NSObject, FlutterPlugin { final class PlatformInfoPlugin: NSObject, FlutterPlugin {
static func register(with registrar: FlutterPluginRegistrar) { static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel( let channel = FlutterMethodChannel(
name: "com.run.sportsx/platform_info", name: "app.record_tool/platform_info",
binaryMessenger: registrar.messenger() binaryMessenger: registrar.messenger()
) )
let plugin = PlatformInfoPlugin() let plugin = PlatformInfoPlugin()
+3 -3
View File
@@ -633,9 +633,9 @@ private final class RecordingCameraController: NSObject, AVCaptureFileOutputReco
} }
private enum RecordingChannelNames { private enum RecordingChannelNames {
static let packageName = "com.run.sportsx" static let namespace = "app.record_tool"
static let method = "\(packageName)/recording" static let method = "\(namespace)/recording"
static let events = "\(packageName)/recording_events" static let events = "\(namespace)/recording_events"
} }
final class RecordingPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { final class RecordingPlugin: NSObject, FlutterPlugin, FlutterStreamHandler {
+1 -1
View File
@@ -60,7 +60,7 @@ class AppPlatformInfo {
AppPlatformInfo._(); AppPlatformInfo._();
static const MethodChannel _channel = MethodChannel( static const MethodChannel _channel = MethodChannel(
'com.run.sportsx/platform_info', 'app.record_tool/platform_info',
); );
static Future<AppPackageInfo> packageInfo() async { static Future<AppPackageInfo> packageInfo() async {
@@ -1,5 +1,5 @@
abstract final class RecordingChannelNames { abstract final class RecordingChannelNames {
static const packageName = 'com.run.sportsx'; static const namespace = 'app.record_tool';
static const method = '$packageName/recording'; static const method = '$namespace/recording';
static const events = '$packageName/recording_events'; static const events = '$namespace/recording_events';
} }
@@ -308,7 +308,7 @@ class _ZoomPresetButton extends StatelessWidget {
), ),
), ),
child: Text( child: Text(
'${_formatZoomRatio(displayRatio)}x', _formatZoomRatio(displayRatio),
style: TextStyle( style: TextStyle(
fontSize: 13.sp, fontSize: 13.sp,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
@@ -320,9 +320,12 @@ class _ZoomPresetButton extends StatelessWidget {
} }
String _formatZoomRatio(double ratio) { String _formatZoomRatio(double ratio) {
if (ratio == ratio.roundToDouble()) { if (ratio < 1.0) {
return ratio.toStringAsFixed(0); return '广角';
} }
return ratio.toStringAsFixed(1); if (ratio == ratio.roundToDouble()) {
return '${ratio.toStringAsFixed(0)}x';
}
return '${ratio.toStringAsFixed(1)}x';
} }
} }
@@ -1,7 +1,15 @@
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:recording_tool/features/recording/platform/recording_channel_names.dart';
import 'package:recording_tool/features/recording/platform/recording_platform.dart'; import 'package:recording_tool/features/recording/platform/recording_platform.dart';
void main() { void main() {
group('RecordingChannelNames', () {
test('uses stable bridge names without package binding', () {
expect(RecordingChannelNames.method, 'app.record_tool/recording');
expect(RecordingChannelNames.events, 'app.record_tool/recording_events');
});
});
group('RecordingPlatform support', () { group('RecordingPlatform support', () {
test('supports Android and iOS hosts only', () { test('supports Android and iOS hosts only', () {
expect( expect(