import 'package:flutter_easyloading/flutter_easyloading.dart';
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);
        //提示框
        EasyLoading.showToast("Downloaded");
    }

    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);      
      //给结果提示框
      EasyLoading.showToast("Saved to Photos");
    }

    Future <void> setWallpaper(String imgUrl) async {
      await DownloadManager.setWallpaper(imgUrl);
      EasyLoading.showToast("Wallpaper set successfully");
    }
}