/*
 * @author lsy
 * @date   2019-09-09
 **/

import 'package:gengmei_flutter_plugin/ScanImagePlugn.dart';
import 'package:gengmei_flutter_plugin/gengmei_flutter_plugin.dart';
import 'package:rxdart/rxdart.dart';

class AlbumRepository {
  AlbumRepository._();

  static AlbumRepository _instance;

  static AlbumRepository getInstance() {
    if (_instance == null) {
      _instance = AlbumRepository._();
    }
    return _instance;
  }

  Map<String, List<ScanImageItem>> _cacheList = new Map();

  Observable<Map<String, List<ScanImageItem>>> scanPhoneImg() {
    return Observable.fromFuture(GengmeiFlutterPlugin.phoneImages())
        .map((value) {
//      Map<String, List<ScanImageItem>> finalList = new Map();
//      var all = value["IsGengmeiAlbumAllImages"];
//      if (all != null) {
//        value.forEach((k, v) {
//          List<ScanImageItem> newList = List();
//          v.forEach((value) {
//
//          });
//        });
//      }
//
//      if (value != null) {}

      return value;
    });
  }

  void clearMemory() {
    _cacheList.clear();
  }

  Observable<Map> nativeCamera(String provider) {
    return Observable.fromFuture(GengmeiFlutterPlugin.nativeCamera(provider));
  }

  Observable<String> aiCamera() {
//    return Observable.fromFuture(GengmeiFlutterPlugin.aiCamera());
  }
}
