import 'package:flutter/foundation.dart';
import 'package:guru_utils/audio/audio_effector.dart';
import 'package:guru_utils/datetime/datetime_utils.dart';
import 'package:guru_utils/log/log.dart';
import 'package:guru_utils/property/app_property.dart';
import 'package:guru_utils/property/runtime_property.dart';
import 'package:guru_utils/property/settings/settings_data.dart';
import 'package:guru_utils/vibration/vibrate_model.dart';
import 'package:package_info_plus/package_info_plus.dart';

export 'package:guru_utils/property/settings/settings_data.dart';

part 'utils_settings.dart';

/// Created by Haoyi on 2022/8/25

abstract class Settings with UtilsSettings {
  static late Settings _instance;

  static Settings get() => _instance;

  bool _initialized = false;

  Settings() {
    _instance = this;
  }

  @mustCallSuper
  Future<PropertyBundle> refresh() async {
    final bundle = await AppProperty.getInstance().loadValuesByUsage(PropertyUsage.setting);
    for (var setting in SettingData.settings.values) {
      setting.init(bundle);
    }
    if (!_initialized) {
      await _syncVersion();
      _initialized = true;
    }
    return bundle;
  }
}
