import 'package:vitalapp/store/defines.dart';
import 'package:vitalapp/store/store.dart';

class ResidentState extends StateModuleBase {
  String? _residentMedicalData;

  /// 居民检测数据
  String? get residentMedicalData => _residentMedicalData;

  /// 处理居民检测数据缓存
  Future<void> handleSaveMedicalData(
    String residentMedicalData,
  ) async {
    _residentMedicalData = residentMedicalData;
    await Store.persistent();
  }

  @override
  Future<void> acceptPersistenceJson(Map<String, dynamic> map) async {
    // key对应值不为空时，给相应字段赋值
    map.pickPersistentProp(
        'residentMedicalData', (x) => _residentMedicalData = x);
  }

  @override
  Map<String, dynamic> toPersistenceJson() {
    return {
      "residentMedicalData": residentMedicalData,
    };
  }
}
