// Author: fengshengxiong
// Date: 2024/5/17
// Description: 设置壁纸插件

import 'package:flutter/services.dart';
import 'package:hello_wallpaper/common/utils/log_print.dart';

class SetWallpaper {
  static const MethodChannel _channel = MethodChannel('set_wallpaper');

  static Future<String> setWallpaper(String path, int wallpaperType) async {
    try {
      final String result = await _channel.invokeMethod('setWallpaper', {
        "path": path,
        "wallpaperType": wallpaperType // 0 for home screen, 1 for lock screen, 2 for both
      });
      LogPrint.d(result);
      return result;
    } on PlatformException catch (e) {
      LogPrint.e('Failed to set wallpaper: ${e.message}.');
      return 'Failed to set wallpaper: ${e.message}.';
    }
  }
}
