import 'package:hive_ce_flutter/hive_flutter.dart';
import 'package:remever/i18n/strings.g.dart';

class AppLocaleAdapter extends TypeAdapter<AppLocale> {
  @override
  int get typeId => 101;

  @override
  AppLocale read(BinaryReader reader) {
    final int tm = reader.readInt();

    return AppLocale.values.elementAt(tm);
  }

  @override
  void write(BinaryWriter writer, AppLocale obj) {
    writer.writeInt(obj.index);
  }

  @override
  int get hashCode => typeId.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is AppLocaleAdapter &&
          runtimeType == other.runtimeType &&
          typeId == other.typeId;
}
