import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'keyboard_android_platform_interface.dart';

/// An implementation of [KeyboardAndroidPlatform] that uses method channels.
class MethodChannelKeyboardAndroid extends KeyboardAndroidPlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('keyboard_android');

  @override
  Future<String?> getPlatformVersion() async {
    final version = await methodChannel.invokeMethod<String>(
      'getPlatformVersion',
    );
    return version;
  }

  @override
  Future<void> enableFloatingWindow(bool enable) async {
    await methodChannel.invokeMethod('enableFloatingWindow', {
      'enable': enable,
    });
  }

  @override
  Future<void> openInputMethodSettings() async {
    await methodChannel.invokeMethod('openInputMethodSettings');
  }

  @override
  Future<bool> isTargetKeyboardEnabled() async {
    return await methodChannel.invokeMethod<bool>('isTargetKeyboardEnabled') ??
        false;
  }


  // /// 获取键映射
  // @override
  // Future<List<Map<String, String>>> getKeyMappings() async {
  //   final List<dynamic> mappings =
  //       await methodChannel.invokeMethod<List<dynamic>>('getKeyMappings') ?? [];
  //   return mappings.map<Map<String, String>>((dynamic item) {
  //     final map = item as Map<dynamic, dynamic>;
  //     return map.map<String, String>(
  //           (key, value) => MapEntry(key.toString(), value.toString()),
  //     );
  //   }).toList();
  // }
  //
  // /// 设置键映射
  // @override
  // Future<bool> setKeyMappings(List<Map<String, String>> mappings) async {
  //   return await methodChannel.invokeMethod('setKeyMappings', {
  //     'mappings': mappings,
  //   });
  // }
  //
  // /// 通过方法名获取动态文本
  // @override
  // Future<String?> getDynamicText(String method) async {
  //   return await methodChannel.invokeMethod('getDynamicText', {
  //     'method': method,
  //   });
  // }
}
