/*
 * @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) {
      if (value != null) {
        _cacheList.clear();
        _cacheList.addAll(value);
      }
      return value;
    });
  }

  get cacheList => _cacheList;

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

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

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