-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from andannn/media_external_link
add media external links
- Loading branch information
Showing
42 changed files
with
1,660 additions
and
576 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'dart:ui'; | ||
|
||
mixin ColorUtil { | ||
/// parse color with format #001100. | ||
static Color? parseColor(String source) { | ||
final colorRegex = RegExp('#\\w{6}'); | ||
if (!colorRegex.hasMatch(source)) { | ||
return null; | ||
} | ||
|
||
final r = int.parse(source.substring(1, 3), radix: 16); | ||
final g = int.parse(source.substring(3, 5), radix: 16); | ||
final b = int.parse(source.substring(5, 7), radix: 16); | ||
return Color.fromARGB(255, r, g, b); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:anime_tracker/core/data/model/media_external_link_type.dart'; | ||
import 'package:anime_tracker/core/database/model/media_external_link_entity.dart'; | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'media_external_link_model.freezed.dart'; | ||
|
||
part 'media_external_link_model.g.dart'; | ||
|
||
@freezed | ||
class MediaExternalLinkModel with _$MediaExternalLinkModel { | ||
factory MediaExternalLinkModel({ | ||
@Default('') String url, | ||
@Default('') String site, | ||
@Default(MediaExternalLinkType.info) MediaExternalLinkType type, | ||
@Default(-1) int siteId, | ||
@Default('') String icon, | ||
@Default('') String color, | ||
}) = _MediaExternalLinkModel; | ||
|
||
factory MediaExternalLinkModel.fromJson(Map<String, dynamic> json) => | ||
_$$_MediaExternalLinkModelFromJson(json); | ||
|
||
static MediaExternalLinkModel fromEntity(MediaExternalLinkEntity entity) { | ||
return MediaExternalLinkModel( | ||
url: entity.url ?? '', | ||
site: entity.site ?? '', | ||
type: $enumDecodeNullable(_$MediaExternalLinkTypeEnumMap, entity.type) ?? | ||
MediaExternalLinkType.info, | ||
siteId: entity.siteId ?? -1, | ||
icon: entity.icon ?? '', | ||
color: entity.color ?? '', | ||
); | ||
} | ||
} |
Oops, something went wrong.