Skip to content

Commit

Permalink
refactor: add proposal_model.g.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
Zied-Dahmani committed Sep 12, 2024
1 parent d09596f commit e0662e1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
6 changes: 3 additions & 3 deletions lib/core/network/models/proposal_details_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 6 additions & 17 deletions lib/core/network/models/proposal_model.dart
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -14,21 +19,5 @@ class ProposalModel extends BaseProposalModel{
super.creator,
super.votes,
});
factory ProposalModel.fromJson(Map<String, dynamic> json) {
return ProposalModel(
id: json['docId'] as String,
creator: json['creator'] == null ? null : ProfileData.fromJson(json['creator'] as Map<String, dynamic>),
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<dynamic>?)
?.map((e) => VoteModel.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
factory ProposalModel.fromJson(Map<String, dynamic> json) => _$ProposalModelFromJson(json);
}
10 changes: 7 additions & 3 deletions lib/core/network/models/proposal_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/ui/proposals/components/proposal_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ProposalHeader extends StatelessWidget {
),
),
),
const SizedBox(width: 4),
const SizedBox(width: 10),
Flexible(
child: Text(
_daoData?.settingsDaoTitle ?? '',
Expand Down

0 comments on commit e0662e1

Please sign in to comment.