import 'package:get/get.dart';
import 'package:wallpaper/models/imgnetodel.dart';
import 'package:wallpaper/routes/app_routes.dart';
import 'package:wallpaper/utils/downloadmanager.dart';
import 'dart:io';
class ImgCategoryPageController extends GetxController {
    var stitle = RxString("");
    // ignore: prefer_typing_uninitialized_variables
    late NetImgCategory dataModel;
    var isAndroid = Platform.isAndroid;

    @override
    void onInit() {
      super.onInit();
      stitle.value = Get.arguments["stitle"];
      dataModel = Get.arguments["dataModel"];
    }

    Future < void> downloadImg(String urlStr) async {
        await DownloadManager.downloadImgWithUrl(urlStr);
        //提示框
        //....已下载
    }

    void goScanView(var index,var dataModel){
      Get.toNamed(AppRoutes.imgscanpage, arguments: {"index":index,"dataModel":dataModel});
    }

    Future < void>  saveImgToAlbum(String imgUrl) async {
      await DownloadManager.saveNetworkImage(imgUrl);

      //如果是android,还应该调用设置壁纸的功能
      // if (Platform.isAndroid) {

      // }
      
      
      //给结果提示框
      //....
    }

    Future <void> setWallpaper(String imgUrl) async {
      await DownloadManager.setWallpaper(imgUrl);
    }
}