diff --git a/lib/core/network/models/proposal_details_model.g.dart b/lib/core/network/models/proposal_details_model.g.dart index c2d048cf..c0bcf17f 100644 --- a/lib/core/network/models/proposal_details_model.g.dart +++ b/lib/core/network/models/proposal_details_model.g.dart @@ -12,9 +12,6 @@ ProposalDetailsModel _$ProposalDetailsModelFromJson( id: json['docId'] as String, type: json['__typename'] as String, creationDate: DateTime.parse(json['createdDate'] as String), - creator: json['creator'] == null - ? null - : ProfileData.fromJson(json['creator'] as Map), dao: json['dao'] == null ? null : DaoData.fromJson(json['dao'] as Map), @@ -25,6 +22,9 @@ ProposalDetailsModel _$ProposalDetailsModelFromJson( expiration: json['ballot_expiration_t'] == null ? null : DateTime.parse(json['ballot_expiration_t'] as String), + creator: json['creator'] == null + ? null + : ProfileData.fromJson(json['creator'] as Map), votes: (json['vote'] as List?) ?.map((e) => VoteModel.fromJson(e as Map)) .toList(), diff --git a/lib/core/network/models/proposal_model.dart b/lib/core/network/models/proposal_model.dart index b5f10df9..62826eb8 100644 --- a/lib/core/network/models/proposal_model.dart +++ b/lib/core/network/models/proposal_model.dart @@ -1,7 +1,12 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:hypha_wallet/core/network/models/base_proposal_model.dart'; +import 'package:hypha_wallet/core/network/models/dao_data_model.dart'; import 'package:hypha_wallet/core/network/models/vote_model.dart'; import 'package:hypha_wallet/ui/profile/interactor/profile_data.dart'; +part 'proposal_model.g.dart'; + +@JsonSerializable() class ProposalModel extends BaseProposalModel{ ProposalModel({ required super.id, @@ -14,21 +19,5 @@ class ProposalModel extends BaseProposalModel{ super.creator, super.votes, }); - factory ProposalModel.fromJson(Map json) { - return ProposalModel( - id: json['docId'] as String, - creator: json['creator'] == null ? null : ProfileData.fromJson(json['creator'] as Map), - dao: null, - commitment: (json['details_timeShareX100_i'] as num?)?.toInt(), - title: json['details_title_s'] as String?, - unity: (json['details_ballotAlignment_i'] as num?)?.toInt(), - quorum: (json['details_ballotQuorum_i'] as num?)?.toInt(), - expiration: json['ballot_expiration_t'] == null - ? null - : DateTime.parse(json['ballot_expiration_t'] as String), - votes: (json['vote'] as List?) - ?.map((e) => VoteModel.fromJson(e as Map)) - .toList(), - ); - } + factory ProposalModel.fromJson(Map json) => _$ProposalModelFromJson(json); } diff --git a/lib/core/network/models/proposal_model.g.dart b/lib/core/network/models/proposal_model.g.dart index 9b3d0cb0..c93a2761 100644 --- a/lib/core/network/models/proposal_model.g.dart +++ b/lib/core/network/models/proposal_model.g.dart @@ -9,8 +9,9 @@ part of 'proposal_model.dart'; ProposalModel _$ProposalModelFromJson(Map json) => ProposalModel( id: json['docId'] as String, - creator: json['creator'] as String, - daoName: json['dao'] as String?, + dao: json['dao'] == null + ? null + : DaoData.fromJson(json['dao'] as Map), commitment: (json['details_timeShareX100_i'] as num?)?.toInt(), title: json['details_title_s'] as String?, unity: (json['details_ballotAlignment_i'] as num?)?.toInt(), @@ -18,6 +19,9 @@ ProposalModel _$ProposalModelFromJson(Map json) => expiration: json['ballot_expiration_t'] == null ? null : DateTime.parse(json['ballot_expiration_t'] as String), + creator: json['creator'] == null + ? null + : ProfileData.fromJson(json['creator'] as Map), votes: (json['vote'] as List?) ?.map((e) => VoteModel.fromJson(e as Map)) .toList(), @@ -26,7 +30,7 @@ ProposalModel _$ProposalModelFromJson(Map json) => Map _$ProposalModelToJson(ProposalModel instance) => { 'docId': instance.id, - 'dao': instance.daoName, + 'dao': instance.dao, 'details_timeShareX100_i': instance.commitment, 'details_title_s': instance.title, 'details_ballotAlignment_i': instance.unity, diff --git a/lib/ui/proposals/components/proposal_header.dart b/lib/ui/proposals/components/proposal_header.dart index 449fc5ab..e7e1321f 100644 --- a/lib/ui/proposals/components/proposal_header.dart +++ b/lib/ui/proposals/components/proposal_header.dart @@ -26,7 +26,7 @@ class ProposalHeader extends StatelessWidget { ), ), ), - const SizedBox(width: 4), + const SizedBox(width: 10), Flexible( child: Text( _daoData?.settingsDaoTitle ?? '',