import 'package:hive/hive.dart';

part 'user_settings.g.dart';

@HiveType(typeId: 4)
class UserSettings {
  @HiveField(0)
  final int revisitPreventionDays;

  @HiveField(1)
  final bool notificationEnabled;

  @HiveField(2)
  final String notificationTime;

  @HiveField(3)
  final Map<String, double> categoryWeights;

  @HiveField(4)
  final int notificationDelayMinutes;

  UserSettings({
    this.revisitPreventionDays = 7,
    this.notificationEnabled = true,
    this.notificationTime = "14:00",
    Map<String, double>? categoryWeights,
    this.notificationDelayMinutes = 90,
  }) : categoryWeights = categoryWeights ?? {};

  UserSettings copyWith({
    int? revisitPreventionDays,
    bool? notificationEnabled,
    String? notificationTime,
    Map<String, double>? categoryWeights,
    int? notificationDelayMinutes,
  }) {
    return UserSettings(
      revisitPreventionDays:
          revisitPreventionDays ?? this.revisitPreventionDays,
      notificationEnabled: notificationEnabled ?? this.notificationEnabled,
      notificationTime: notificationTime ?? this.notificationTime,
      categoryWeights: categoryWeights ?? this.categoryWeights,
      notificationDelayMinutes:
          notificationDelayMinutes ?? this.notificationDelayMinutes,
    );
  }
}
