import 'package:freezed_annotation/freezed_annotation.dart';

part 'teaser_image.freezed.dart';
part 'teaser_image.g.dart';

@freezed
class TeaserImage with _$TeaserImage {
  const factory TeaserImage({
    Map<String, String>? imageVariants,
  }) = _TeaserImage;

  factory TeaserImage.fromJson(Map<String, dynamic> json) =>
      _$TeaserImageFromJson(json);
}

// old manual implementation:

// class TeaserImage {
//   final String? title;
//   final String alttext;
//   final String? copyright;
//   final String type;
//   final Map<String, String> imageVariants;

//   TeaserImage({
//     this.title,
//     required this.alttext,
//     this.copyright,
//     required this.type,
//     required this.imageVariants,
//   });

//   Map<String, dynamic> toMap() {
//     return {
//       'title': title,
//       'alttext': alttext,
//       'copyright': copyright,
//       'type': type,
//       'imageVariants': Map.from(imageVariants),
//     };
//   }

//   factory TeaserImage.fromMap(Map<String, dynamic> map) {
//     return TeaserImage(
//       title: map['title'] ?? '',
//       alttext: map['alttext'] ?? '',
//       copyright: map['copyright'],
//       type: map['type'] ?? '',
//       imageVariants: Map.from(map['imageVariants']),
//     );
//   }

//   String toJson() => json.encode(toMap());

//   factory TeaserImage.fromJson(String source) =>
//       TeaserImage.fromMap(json.decode(source));

//   @override
//   String toString() {
//     return 'TeaserImage(title: $title, alttext: $alttext, copyright: $copyright, type: $type)';
//   }
// }
