-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic display type.
- Loading branch information
Showing
20 changed files
with
1,370 additions
and
1,038 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
lib/credential/data/dtos/display_type/basic_display_type.dart
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,78 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'package:polygonid_flutter_sdk/credential/data/dtos/display_type/display_type.dart'; | ||
|
||
part 'basic_display_type.g.dart'; | ||
|
||
@JsonSerializable() | ||
class Iden3BasicDisplayType extends DisplayType { | ||
static const name = "Iden3BasicDisplayMethodV1"; | ||
|
||
final String? title; | ||
final String? description; | ||
final String? issuerName; | ||
final String? titleTextColor; | ||
final String? descriptionTextColor; | ||
final String? issuerTextColor; | ||
final String? backgroundImageUrl; | ||
final String? backgroundColor; | ||
@JsonKey(toJson: _logoToJson, fromJson: _logoFromJson) | ||
final Iden3BasicDisplayTypeLogo? logo; | ||
|
||
Iden3BasicDisplayType( | ||
this.title, | ||
this.description, | ||
this.issuerName, | ||
this.titleTextColor, | ||
this.descriptionTextColor, | ||
this.issuerTextColor, | ||
this.backgroundImageUrl, | ||
this.backgroundColor, | ||
this.logo, | ||
); | ||
|
||
factory Iden3BasicDisplayType.fromJson(Map<String, dynamic> json) => | ||
_$Iden3BasicDisplayTypeFromJson(json); | ||
|
||
@override | ||
Map<String, dynamic> toJson() => _$Iden3BasicDisplayTypeToJson(this); | ||
|
||
@override | ||
String get typeName => name; | ||
|
||
@override | ||
List<Object?> get props => [ | ||
title, | ||
description, | ||
issuerName, | ||
titleTextColor, | ||
descriptionTextColor, | ||
issuerTextColor, | ||
backgroundImageUrl, | ||
backgroundColor, | ||
logo, | ||
]; | ||
} | ||
|
||
@JsonSerializable() | ||
class Iden3BasicDisplayTypeLogo { | ||
final String? uri; | ||
final String? alt; | ||
|
||
Iden3BasicDisplayTypeLogo(this.uri, this.alt); | ||
|
||
factory Iden3BasicDisplayTypeLogo.fromJson(Map<String, dynamic> json) => | ||
_$Iden3BasicDisplayTypeLogoFromJson(json); | ||
|
||
Map<String, dynamic> toJson() => _$Iden3BasicDisplayTypeLogoToJson(this); | ||
|
||
@override | ||
List<Object?> get props => [uri, alt]; | ||
} | ||
|
||
Map<String, dynamic>? _logoToJson(Iden3BasicDisplayTypeLogo? logo) { | ||
return logo?.toJson(); | ||
} | ||
|
||
Iden3BasicDisplayTypeLogo? _logoFromJson(Map<String, dynamic>? json) { | ||
return json == null ? null : Iden3BasicDisplayTypeLogo.fromJson(json); | ||
} |
49 changes: 49 additions & 0 deletions
49
lib/credential/data/dtos/display_type/basic_display_type.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,20 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'package:polygonid_flutter_sdk/credential/data/dtos/display_type/basic_display_type.dart'; | ||
import 'package:polygonid_flutter_sdk/credential/data/dtos/display_type/unknown_display_type.dart'; | ||
|
||
abstract class DisplayType { | ||
const DisplayType(); | ||
|
||
String get typeName; | ||
|
||
factory DisplayType.fromJson(Map<String, dynamic> json) { | ||
switch (json['type']) { | ||
case Iden3BasicDisplayType.name: | ||
return Iden3BasicDisplayType.fromJson(json); | ||
default: | ||
return UnknownDisplayType.fromJson(json); | ||
} | ||
} | ||
|
||
Map<String, dynamic> toJson(); | ||
} |
17 changes: 17 additions & 0 deletions
17
lib/credential/data/dtos/display_type/unknown_display_type.dart
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,17 @@ | ||
import 'package:polygonid_flutter_sdk/credential/data/dtos/display_type/display_type.dart'; | ||
|
||
class UnknownDisplayType extends DisplayType { | ||
final Map<String, dynamic> displayType; | ||
|
||
@override | ||
String get typeName => "UnknownDisplayType"; | ||
|
||
UnknownDisplayType(this.displayType); | ||
|
||
factory UnknownDisplayType.fromJson(Map<String, dynamic> json) { | ||
return UnknownDisplayType(json); | ||
} | ||
|
||
@override | ||
Map<String, dynamic> toJson() => displayType; | ||
} |
Oops, something went wrong.