From fe805f9f2ebbfc03340dd8aae90a59692b412e0b Mon Sep 17 00:00:00 2001 From: Jayesh jain Date: Thu, 25 Jul 2024 23:34:06 +0530 Subject: [PATCH] changes --- lib/core/routes/routes.dart | 3 +- .../domain/model/available_io_model.dart | 315 +++++++----- .../Invest/domain/model/closed_io_model.dart | 315 +++++++----- .../Invest/domain/model/detail_io_model.dart | 465 ++++++++++++++++++ .../Invest/domain/repository/io_api.dart | 6 + .../bloc/io_invest/io_details_bloc.dart | 34 ++ .../bloc/io_invest/io_details_event.dart | 16 + .../bloc/io_invest/io_details_state.dart | 32 ++ .../pages/invest_details_layout.dart | 98 ++-- .../pages/invest_details_screen.dart | 13 +- .../presentation/pages/invest_layout.dart | 14 +- .../invest_detail_details_section.dart | 32 +- .../widgets/invest_detail_image_carousel.dart | 13 +- .../widgets/invest_details_section.dart | 2 +- .../widgets/invest_image_carousel.dart | 16 +- lib/shared/api/api_endpoints.dart | 1 + lib/shared/api/network_api_services.dart | 8 +- 17 files changed, 1052 insertions(+), 331 deletions(-) create mode 100644 lib/features/MainScreens/Invest/domain/model/detail_io_model.dart create mode 100644 lib/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_bloc.dart create mode 100644 lib/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_event.dart create mode 100644 lib/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_state.dart diff --git a/lib/core/routes/routes.dart b/lib/core/routes/routes.dart index ac2674b..414a136 100644 --- a/lib/core/routes/routes.dart +++ b/lib/core/routes/routes.dart @@ -280,10 +280,11 @@ final goRouter = GoRouter( ), GoRoute( name: RouteName.investDetailScreen, - path: "${RouteName.investDetailScreen}/:type", + path: "${RouteName.investDetailScreen}/:type/:id", builder: (context, state) { return InvestDetailsScreen( type: state.pathParameters["type"]!, + id: state.pathParameters["id"]!, ); }, ), diff --git a/lib/features/MainScreens/Invest/domain/model/available_io_model.dart b/lib/features/MainScreens/Invest/domain/model/available_io_model.dart index 981386b..82278a6 100644 --- a/lib/features/MainScreens/Invest/domain/model/available_io_model.dart +++ b/lib/features/MainScreens/Invest/domain/model/available_io_model.dart @@ -8,19 +8,19 @@ class AvailableIOModel { AvailableIOModel.fromJson(Map json) { statusCode = json['statusCode']; - data = json['data'] != null ? Data.fromJson(json['data']) : null; + data = json['data'] != null ? new Data.fromJson(json['data']) : null; message = json['message']; success = json['success']; } Map toJson() { - final Map data = {}; - data['statusCode'] = statusCode; + final Map data = new Map(); + data['statusCode'] = this.statusCode; if (this.data != null) { data['data'] = this.data!.toJson(); } - data['message'] = message; - data['success'] = success; + data['message'] = this.message; + data['success'] = this.success; return data; } } @@ -38,7 +38,7 @@ class Data { if (json['rows'] != null) { rows = []; json['rows'].forEach((v) { - rows!.add(Rows.fromJson(v)); + rows!.add(new Rows.fromJson(v)); }); } totalPages = json['totalPages']; @@ -46,13 +46,13 @@ class Data { } Map toJson() { - final Map data = {}; - data['totalItems'] = totalItems; - if (rows != null) { - data['rows'] = rows!.map((v) => v.toJson()).toList(); + final Map data = new Map(); + data['totalItems'] = this.totalItems; + if (this.rows != null) { + data['rows'] = this.rows!.map((v) => v.toJson()).toList(); } - data['totalPages'] = totalPages; - data['currentPage'] = currentPage; + data['totalPages'] = this.totalPages; + data['currentPage'] = this.currentPage; return data; } } @@ -79,15 +79,15 @@ class Rows { bool? isInvestedAmount; String? amountInvested; bool? isActive; - Null createdBy; - Null modifiedBy; + Null? createdBy; + Null? modifiedBy; String? createdAt; String? updatedAt; - Null deletedAt; + Null? deletedAt; Sponsor? sponsor; IoStatus? ioStatus; InvestmentType? investmentType; - List? artifactsImage; + List? artifactsImage; List? minInvestmentAmt; Rows( @@ -151,69 +151,71 @@ class Rows { updatedAt = json['updatedAt']; deletedAt = json['deletedAt']; sponsor = - json['sponsor'] != null ? Sponsor.fromJson(json['sponsor']) : null; - ioStatus = - json['ioStatus'] != null ? IoStatus.fromJson(json['ioStatus']) : null; + json['sponsor'] != null ? new Sponsor.fromJson(json['sponsor']) : null; + ioStatus = json['ioStatus'] != null + ? new IoStatus.fromJson(json['ioStatus']) + : null; investmentType = json['investmentType'] != null - ? InvestmentType.fromJson(json['investmentType']) + ? new InvestmentType.fromJson(json['investmentType']) : null; if (json['artifactsImage'] != null) { - artifactsImage = []; + artifactsImage = []; json['artifactsImage'].forEach((v) { - artifactsImage!.add(v); + artifactsImage!.add(new ArtifactsImage.fromJson(v)); }); } if (json['minInvestmentAmt'] != null) { minInvestmentAmt = []; json['minInvestmentAmt'].forEach((v) { - minInvestmentAmt!.add(MinInvestmentAmt.fromJson(v)); + minInvestmentAmt!.add(new MinInvestmentAmt.fromJson(v)); }); } } Map toJson() { - final Map data = {}; - data['id'] = id; - data['io_id'] = ioId; - data['investmentType_xid'] = investmentTypeXid; - data['sponsor_xid'] = sponsorXid; - data['ioStatus_xid'] = ioStatusXid; - data['investmentNameEnglish'] = investmentNameEnglish; - data['investmentNameArabic'] = investmentNameArabic; - data['descriptionEnglish'] = descriptionEnglish; - data['descriptionArabic'] = descriptionArabic; - data['goalAmount'] = goalAmount; - data['closingDate'] = closingDate; - data['holdingPeriod'] = holdingPeriod; - data['expectedReturn'] = expectedReturn; - data['originalValuation'] = originalValuation; - data['currentValuation'] = currentValuation; - data['ISIN'] = iSIN; - data['InvestmentDetails'] = investmentDetails; - data['comment'] = comment; - data['isInvestedAmount'] = isInvestedAmount; - data['amountInvested'] = amountInvested; - data['isActive'] = isActive; - data['createdBy'] = createdBy; - data['modifiedBy'] = modifiedBy; - data['createdAt'] = createdAt; - data['updatedAt'] = updatedAt; - data['deletedAt'] = deletedAt; - if (sponsor != null) { - data['sponsor'] = sponsor!.toJson(); + final Map data = new Map(); + data['id'] = this.id; + data['io_id'] = this.ioId; + data['investmentType_xid'] = this.investmentTypeXid; + data['sponsor_xid'] = this.sponsorXid; + data['ioStatus_xid'] = this.ioStatusXid; + data['investmentNameEnglish'] = this.investmentNameEnglish; + data['investmentNameArabic'] = this.investmentNameArabic; + data['descriptionEnglish'] = this.descriptionEnglish; + data['descriptionArabic'] = this.descriptionArabic; + data['goalAmount'] = this.goalAmount; + data['closingDate'] = this.closingDate; + data['holdingPeriod'] = this.holdingPeriod; + data['expectedReturn'] = this.expectedReturn; + data['originalValuation'] = this.originalValuation; + data['currentValuation'] = this.currentValuation; + data['ISIN'] = this.iSIN; + data['InvestmentDetails'] = this.investmentDetails; + data['comment'] = this.comment; + data['isInvestedAmount'] = this.isInvestedAmount; + data['amountInvested'] = this.amountInvested; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; + if (this.sponsor != null) { + data['sponsor'] = this.sponsor!.toJson(); } - if (ioStatus != null) { - data['ioStatus'] = ioStatus!.toJson(); + if (this.ioStatus != null) { + data['ioStatus'] = this.ioStatus!.toJson(); } - if (investmentType != null) { - data['investmentType'] = investmentType!.toJson(); + if (this.investmentType != null) { + data['investmentType'] = this.investmentType!.toJson(); } - if (artifactsImage != null) { - data['artifactsImage'] = artifactsImage!.map((v) => v).toList(); + if (this.artifactsImage != null) { + data['artifactsImage'] = + this.artifactsImage!.map((v) => v.toJson()).toList(); } - if (minInvestmentAmt != null) { + if (this.minInvestmentAmt != null) { data['minInvestmentAmt'] = - minInvestmentAmt!.map((v) => v.toJson()).toList(); + this.minInvestmentAmt!.map((v) => v.toJson()).toList(); } return data; } @@ -224,17 +226,17 @@ class Sponsor { String? sponsorName; String? sponsorNameArabic; String? email; - Null profile; - Null address; - Null mobileNo; - Null bankName; - Null accountNumber; + Null? profile; + Null? address; + Null? mobileNo; + Null? bankName; + Null? accountNumber; bool? isActive; - Null createdBy; - Null modifiedBy; + Null? createdBy; + Null? modifiedBy; String? createdAt; String? updatedAt; - Null deletedAt; + Null? deletedAt; Sponsor( {this.id, @@ -272,22 +274,22 @@ class Sponsor { } Map toJson() { - final Map data = {}; - data['id'] = id; - data['sponsorName'] = sponsorName; - data['sponsorNameArabic'] = sponsorNameArabic; - data['email'] = email; - data['profile'] = profile; - data['address'] = address; - data['mobileNo'] = mobileNo; - data['bankName'] = bankName; - data['accountNumber'] = accountNumber; - data['isActive'] = isActive; - data['createdBy'] = createdBy; - data['modifiedBy'] = modifiedBy; - data['createdAt'] = createdAt; - data['updatedAt'] = updatedAt; - data['deletedAt'] = deletedAt; + final Map data = new Map(); + data['id'] = this.id; + data['sponsorName'] = this.sponsorName; + data['sponsorNameArabic'] = this.sponsorNameArabic; + data['email'] = this.email; + data['profile'] = this.profile; + data['address'] = this.address; + data['mobileNo'] = this.mobileNo; + data['bankName'] = this.bankName; + data['accountNumber'] = this.accountNumber; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; return data; } } @@ -298,11 +300,11 @@ class IoStatus { String? statusInvest; String? statusPortfolio; bool? isActive; - Null createdBy; - Null modifiedBy; + Null? createdBy; + Null? modifiedBy; String? createdAt; String? updatedAt; - Null deletedAt; + Null? deletedAt; IoStatus( {this.id, @@ -330,17 +332,17 @@ class IoStatus { } Map toJson() { - final Map data = {}; - data['id'] = id; - data['statusAdmin'] = statusAdmin; - data['statusInvest'] = statusInvest; - data['statusPortfolio'] = statusPortfolio; - data['isActive'] = isActive; - data['createdBy'] = createdBy; - data['modifiedBy'] = modifiedBy; - data['createdAt'] = createdAt; - data['updatedAt'] = updatedAt; - data['deletedAt'] = deletedAt; + final Map data = new Map(); + data['id'] = this.id; + data['statusAdmin'] = this.statusAdmin; + data['statusInvest'] = this.statusInvest; + data['statusPortfolio'] = this.statusPortfolio; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; return data; } } @@ -352,11 +354,11 @@ class InvestmentType { String? note; String? noteArabic; bool? isActive; - Null createdBy; - Null modifiedBy; + Null? createdBy; + Null? modifiedBy; String? createdAt; String? updatedAt; - Null deletedAt; + Null? deletedAt; InvestmentType( {this.id, @@ -386,18 +388,75 @@ class InvestmentType { } Map toJson() { - final Map data = {}; - data['id'] = id; - data['investmentTypeName'] = investmentTypeName; - data['investmentTypeNameArabic'] = investmentTypeNameArabic; - data['note'] = note; - data['noteArabic'] = noteArabic; - data['isActive'] = isActive; - data['createdBy'] = createdBy; - data['modifiedBy'] = modifiedBy; - data['createdAt'] = createdAt; - data['updatedAt'] = updatedAt; - data['deletedAt'] = deletedAt; + final Map data = new Map(); + data['id'] = this.id; + data['investmentTypeName'] = this.investmentTypeName; + data['investmentTypeNameArabic'] = this.investmentTypeNameArabic; + data['note'] = this.note; + data['noteArabic'] = this.noteArabic; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; + return data; + } +} + +class ArtifactsImage { + int? id; + int? ioXid; + String? artifactName; + String? artifactPathName; + int? displayOrder; + bool? isActive; + Null? createdBy; + Null? modifiedBy; + String? createdAt; + String? updatedAt; + Null? deletedAt; + + ArtifactsImage( + {this.id, + this.ioXid, + this.artifactName, + this.artifactPathName, + this.displayOrder, + this.isActive, + this.createdBy, + this.modifiedBy, + this.createdAt, + this.updatedAt, + this.deletedAt}); + + ArtifactsImage.fromJson(Map json) { + id = json['id']; + ioXid = json['io_xid']; + artifactName = json['artifactName']; + artifactPathName = json['artifactPathName']; + displayOrder = json['displayOrder']; + isActive = json['isActive']; + createdBy = json['createdBy']; + modifiedBy = json['modifiedBy']; + createdAt = json['createdAt']; + updatedAt = json['updatedAt']; + deletedAt = json['deletedAt']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['io_xid'] = this.ioXid; + data['artifactName'] = this.artifactName; + data['artifactPathName'] = this.artifactPathName; + data['displayOrder'] = this.displayOrder; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; return data; } } @@ -409,11 +468,11 @@ class MinInvestmentAmt { String? minInvestmentAmt; String? maxInvestmentAmt; bool? isActive; - Null createdBy; - Null modifiedBy; + Null? createdBy; + Null? modifiedBy; String? createdAt; String? updatedAt; - Null deletedAt; + Null? deletedAt; MinInvestmentAmt( {this.id, @@ -443,18 +502,18 @@ class MinInvestmentAmt { } Map toJson() { - final Map data = {}; - data['id'] = id; - data['io_xid'] = ioXid; - data['country_xid'] = countryXid; - data['minInvestmentAmt'] = minInvestmentAmt; - data['maxInvestmentAmt'] = maxInvestmentAmt; - data['isActive'] = isActive; - data['createdBy'] = createdBy; - data['modifiedBy'] = modifiedBy; - data['createdAt'] = createdAt; - data['updatedAt'] = updatedAt; - data['deletedAt'] = deletedAt; + final Map data = new Map(); + data['id'] = this.id; + data['io_xid'] = this.ioXid; + data['country_xid'] = this.countryXid; + data['minInvestmentAmt'] = this.minInvestmentAmt; + data['maxInvestmentAmt'] = this.maxInvestmentAmt; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; return data; } } diff --git a/lib/features/MainScreens/Invest/domain/model/closed_io_model.dart b/lib/features/MainScreens/Invest/domain/model/closed_io_model.dart index fcd791c..a849a5a 100644 --- a/lib/features/MainScreens/Invest/domain/model/closed_io_model.dart +++ b/lib/features/MainScreens/Invest/domain/model/closed_io_model.dart @@ -8,19 +8,19 @@ class ClosedIOModel { ClosedIOModel.fromJson(Map json) { statusCode = json['statusCode']; - data = json['data'] != null ? Data.fromJson(json['data']) : null; + data = json['data'] != null ? new Data.fromJson(json['data']) : null; message = json['message']; success = json['success']; } Map toJson() { - final Map data = {}; - data['statusCode'] = statusCode; + final Map data = new Map(); + data['statusCode'] = this.statusCode; if (this.data != null) { data['data'] = this.data!.toJson(); } - data['message'] = message; - data['success'] = success; + data['message'] = this.message; + data['success'] = this.success; return data; } } @@ -38,7 +38,7 @@ class Data { if (json['rows'] != null) { rows = []; json['rows'].forEach((v) { - rows!.add(Rows.fromJson(v)); + rows!.add(new Rows.fromJson(v)); }); } totalPages = json['totalPages']; @@ -46,13 +46,13 @@ class Data { } Map toJson() { - final Map data = {}; - data['totalItems'] = totalItems; - if (rows != null) { - data['rows'] = rows!.map((v) => v.toJson()).toList(); + final Map data = new Map(); + data['totalItems'] = this.totalItems; + if (this.rows != null) { + data['rows'] = this.rows!.map((v) => v.toJson()).toList(); } - data['totalPages'] = totalPages; - data['currentPage'] = currentPage; + data['totalPages'] = this.totalPages; + data['currentPage'] = this.currentPage; return data; } } @@ -79,15 +79,15 @@ class Rows { bool? isInvestedAmount; String? amountInvested; bool? isActive; - Null createdBy; - Null modifiedBy; + Null? createdBy; + Null? modifiedBy; String? createdAt; String? updatedAt; - Null deletedAt; + Null? deletedAt; Sponsor? sponsor; IoStatus? ioStatus; InvestmentType? investmentType; - List? artifactsImage; + List? artifactsImage; List? minInvestmentAmt; Rows( @@ -151,90 +151,149 @@ class Rows { updatedAt = json['updatedAt']; deletedAt = json['deletedAt']; sponsor = - json['sponsor'] != null ? Sponsor.fromJson(json['sponsor']) : null; - ioStatus = - json['ioStatus'] != null ? IoStatus.fromJson(json['ioStatus']) : null; + json['sponsor'] != null ? new Sponsor.fromJson(json['sponsor']) : null; + ioStatus = json['ioStatus'] != null + ? new IoStatus.fromJson(json['ioStatus']) + : null; investmentType = json['investmentType'] != null - ? InvestmentType.fromJson(json['investmentType']) + ? new InvestmentType.fromJson(json['investmentType']) : null; if (json['artifactsImage'] != null) { - artifactsImage = []; + artifactsImage = []; json['artifactsImage'].forEach((v) { - artifactsImage!.add(v); + artifactsImage!.add(new ArtifactsImage.fromJson(v)); }); } if (json['minInvestmentAmt'] != null) { minInvestmentAmt = []; json['minInvestmentAmt'].forEach((v) { - minInvestmentAmt!.add(MinInvestmentAmt.fromJson(v)); + minInvestmentAmt!.add(new MinInvestmentAmt.fromJson(v)); }); } } Map toJson() { - final Map data = {}; - data['id'] = id; - data['io_id'] = ioId; - data['investmentType_xid'] = investmentTypeXid; - data['sponsor_xid'] = sponsorXid; - data['ioStatus_xid'] = ioStatusXid; - data['investmentNameEnglish'] = investmentNameEnglish; - data['investmentNameArabic'] = investmentNameArabic; - data['descriptionEnglish'] = descriptionEnglish; - data['descriptionArabic'] = descriptionArabic; - data['goalAmount'] = goalAmount; - data['closingDate'] = closingDate; - data['holdingPeriod'] = holdingPeriod; - data['expectedReturn'] = expectedReturn; - data['originalValuation'] = originalValuation; - data['currentValuation'] = currentValuation; - data['ISIN'] = iSIN; - data['InvestmentDetails'] = investmentDetails; - data['comment'] = comment; - data['isInvestedAmount'] = isInvestedAmount; - data['amountInvested'] = amountInvested; - data['isActive'] = isActive; - data['createdBy'] = createdBy; - data['modifiedBy'] = modifiedBy; - data['createdAt'] = createdAt; - data['updatedAt'] = updatedAt; - data['deletedAt'] = deletedAt; - if (sponsor != null) { - data['sponsor'] = sponsor!.toJson(); + final Map data = new Map(); + data['id'] = this.id; + data['io_id'] = this.ioId; + data['investmentType_xid'] = this.investmentTypeXid; + data['sponsor_xid'] = this.sponsorXid; + data['ioStatus_xid'] = this.ioStatusXid; + data['investmentNameEnglish'] = this.investmentNameEnglish; + data['investmentNameArabic'] = this.investmentNameArabic; + data['descriptionEnglish'] = this.descriptionEnglish; + data['descriptionArabic'] = this.descriptionArabic; + data['goalAmount'] = this.goalAmount; + data['closingDate'] = this.closingDate; + data['holdingPeriod'] = this.holdingPeriod; + data['expectedReturn'] = this.expectedReturn; + data['originalValuation'] = this.originalValuation; + data['currentValuation'] = this.currentValuation; + data['ISIN'] = this.iSIN; + data['InvestmentDetails'] = this.investmentDetails; + data['comment'] = this.comment; + data['isInvestedAmount'] = this.isInvestedAmount; + data['amountInvested'] = this.amountInvested; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; + if (this.sponsor != null) { + data['sponsor'] = this.sponsor!.toJson(); } - if (ioStatus != null) { - data['ioStatus'] = ioStatus!.toJson(); + if (this.ioStatus != null) { + data['ioStatus'] = this.ioStatus!.toJson(); } - if (investmentType != null) { - data['investmentType'] = investmentType!.toJson(); + if (this.investmentType != null) { + data['investmentType'] = this.investmentType!.toJson(); } - if (artifactsImage != null) { - data['artifactsImage'] = artifactsImage!.map((v) => v).toList(); + if (this.artifactsImage != null) { + data['artifactsImage'] = + this.artifactsImage!.map((v) => v.toJson()).toList(); } - if (minInvestmentAmt != null) { + if (this.minInvestmentAmt != null) { data['minInvestmentAmt'] = - minInvestmentAmt!.map((v) => v.toJson()).toList(); + this.minInvestmentAmt!.map((v) => v.toJson()).toList(); } return data; } } +class ArtifactsImage { + int? id; + int? ioXid; + String? artifactName; + String? artifactPathName; + int? displayOrder; + bool? isActive; + Null? createdBy; + Null? modifiedBy; + String? createdAt; + String? updatedAt; + Null? deletedAt; + + ArtifactsImage( + {this.id, + this.ioXid, + this.artifactName, + this.artifactPathName, + this.displayOrder, + this.isActive, + this.createdBy, + this.modifiedBy, + this.createdAt, + this.updatedAt, + this.deletedAt}); + + ArtifactsImage.fromJson(Map json) { + id = json['id']; + ioXid = json['io_xid']; + artifactName = json['artifactName']; + artifactPathName = json['artifactPathName']; + displayOrder = json['displayOrder']; + isActive = json['isActive']; + createdBy = json['createdBy']; + modifiedBy = json['modifiedBy']; + createdAt = json['createdAt']; + updatedAt = json['updatedAt']; + deletedAt = json['deletedAt']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['io_xid'] = this.ioXid; + data['artifactName'] = this.artifactName; + data['artifactPathName'] = this.artifactPathName; + data['displayOrder'] = this.displayOrder; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; + return data; + } +} + class Sponsor { int? id; String? sponsorName; String? sponsorNameArabic; String? email; - Null profile; - Null address; - Null mobileNo; - Null bankName; - Null accountNumber; + Null? profile; + Null? address; + Null? mobileNo; + Null? bankName; + Null? accountNumber; bool? isActive; - Null createdBy; - Null modifiedBy; + Null? createdBy; + Null? modifiedBy; String? createdAt; String? updatedAt; - Null deletedAt; + Null? deletedAt; Sponsor( {this.id, @@ -272,22 +331,22 @@ class Sponsor { } Map toJson() { - final Map data = {}; - data['id'] = id; - data['sponsorName'] = sponsorName; - data['sponsorNameArabic'] = sponsorNameArabic; - data['email'] = email; - data['profile'] = profile; - data['address'] = address; - data['mobileNo'] = mobileNo; - data['bankName'] = bankName; - data['accountNumber'] = accountNumber; - data['isActive'] = isActive; - data['createdBy'] = createdBy; - data['modifiedBy'] = modifiedBy; - data['createdAt'] = createdAt; - data['updatedAt'] = updatedAt; - data['deletedAt'] = deletedAt; + final Map data = new Map(); + data['id'] = this.id; + data['sponsorName'] = this.sponsorName; + data['sponsorNameArabic'] = this.sponsorNameArabic; + data['email'] = this.email; + data['profile'] = this.profile; + data['address'] = this.address; + data['mobileNo'] = this.mobileNo; + data['bankName'] = this.bankName; + data['accountNumber'] = this.accountNumber; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; return data; } } @@ -298,11 +357,11 @@ class IoStatus { String? statusInvest; String? statusPortfolio; bool? isActive; - Null createdBy; - Null modifiedBy; + Null? createdBy; + Null? modifiedBy; String? createdAt; String? updatedAt; - Null deletedAt; + Null? deletedAt; IoStatus( {this.id, @@ -330,17 +389,17 @@ class IoStatus { } Map toJson() { - final Map data = {}; - data['id'] = id; - data['statusAdmin'] = statusAdmin; - data['statusInvest'] = statusInvest; - data['statusPortfolio'] = statusPortfolio; - data['isActive'] = isActive; - data['createdBy'] = createdBy; - data['modifiedBy'] = modifiedBy; - data['createdAt'] = createdAt; - data['updatedAt'] = updatedAt; - data['deletedAt'] = deletedAt; + final Map data = new Map(); + data['id'] = this.id; + data['statusAdmin'] = this.statusAdmin; + data['statusInvest'] = this.statusInvest; + data['statusPortfolio'] = this.statusPortfolio; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; return data; } } @@ -352,11 +411,11 @@ class InvestmentType { String? note; String? noteArabic; bool? isActive; - Null createdBy; - Null modifiedBy; + Null? createdBy; + Null? modifiedBy; String? createdAt; String? updatedAt; - Null deletedAt; + Null? deletedAt; InvestmentType( {this.id, @@ -386,18 +445,18 @@ class InvestmentType { } Map toJson() { - final Map data = {}; - data['id'] = id; - data['investmentTypeName'] = investmentTypeName; - data['investmentTypeNameArabic'] = investmentTypeNameArabic; - data['note'] = note; - data['noteArabic'] = noteArabic; - data['isActive'] = isActive; - data['createdBy'] = createdBy; - data['modifiedBy'] = modifiedBy; - data['createdAt'] = createdAt; - data['updatedAt'] = updatedAt; - data['deletedAt'] = deletedAt; + final Map data = new Map(); + data['id'] = this.id; + data['investmentTypeName'] = this.investmentTypeName; + data['investmentTypeNameArabic'] = this.investmentTypeNameArabic; + data['note'] = this.note; + data['noteArabic'] = this.noteArabic; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; return data; } } @@ -409,11 +468,11 @@ class MinInvestmentAmt { String? minInvestmentAmt; String? maxInvestmentAmt; bool? isActive; - Null createdBy; - Null modifiedBy; + Null? createdBy; + Null? modifiedBy; String? createdAt; String? updatedAt; - Null deletedAt; + Null? deletedAt; MinInvestmentAmt( {this.id, @@ -443,18 +502,18 @@ class MinInvestmentAmt { } Map toJson() { - final Map data = {}; - data['id'] = id; - data['io_xid'] = ioXid; - data['country_xid'] = countryXid; - data['minInvestmentAmt'] = minInvestmentAmt; - data['maxInvestmentAmt'] = maxInvestmentAmt; - data['isActive'] = isActive; - data['createdBy'] = createdBy; - data['modifiedBy'] = modifiedBy; - data['createdAt'] = createdAt; - data['updatedAt'] = updatedAt; - data['deletedAt'] = deletedAt; + final Map data = new Map(); + data['id'] = this.id; + data['io_xid'] = this.ioXid; + data['country_xid'] = this.countryXid; + data['minInvestmentAmt'] = this.minInvestmentAmt; + data['maxInvestmentAmt'] = this.maxInvestmentAmt; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; return data; } } diff --git a/lib/features/MainScreens/Invest/domain/model/detail_io_model.dart b/lib/features/MainScreens/Invest/domain/model/detail_io_model.dart new file mode 100644 index 0000000..009b490 --- /dev/null +++ b/lib/features/MainScreens/Invest/domain/model/detail_io_model.dart @@ -0,0 +1,465 @@ +class DetailIOModel { + int? statusCode; + Data? data; + String? message; + bool? success; + + DetailIOModel({this.statusCode, this.data, this.message, this.success}); + + DetailIOModel.fromJson(Map json) { + statusCode = json['statusCode']; + data = json['data'] != null ? new Data.fromJson(json['data']) : null; + message = json['message']; + success = json['success']; + } + + Map toJson() { + final Map data = new Map(); + data['statusCode'] = this.statusCode; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + data['message'] = this.message; + data['success'] = this.success; + return data; + } +} + +class Data { + int? id; + String? ioId; + int? investmentTypeXid; + int? sponsorXid; + int? ioStatusXid; + String? investmentNameEnglish; + String? investmentNameArabic; + String? descriptionEnglish; + String? descriptionArabic; + String? goalAmount; + String? closingDate; + String? holdingPeriod; + String? expectedReturn; + String? originalValuation; + String? currentValuation; + String? iSIN; + String? investmentDetails; + String? comment; + bool? isInvestedAmount; + String? amountInvested; + bool? isActive; + Null? createdBy; + Null? modifiedBy; + String? createdAt; + String? updatedAt; + Null? deletedAt; + Sponsor? sponsor; + IoStatus? ioStatus; + InvestmentType? investmentType; + // List? documents; + // List? artifactsVideo; + // List? artifactsImage; + List? minInvestmentAmt; + // List? keyMerits; + + Data({ + this.id, + this.ioId, + this.investmentTypeXid, + this.sponsorXid, + this.ioStatusXid, + this.investmentNameEnglish, + this.investmentNameArabic, + this.descriptionEnglish, + this.descriptionArabic, + this.goalAmount, + this.closingDate, + this.holdingPeriod, + this.expectedReturn, + this.originalValuation, + this.currentValuation, + this.iSIN, + this.investmentDetails, + this.comment, + this.isInvestedAmount, + this.amountInvested, + this.isActive, + this.createdBy, + this.modifiedBy, + this.createdAt, + this.updatedAt, + this.deletedAt, + this.sponsor, + this.ioStatus, + this.investmentType, + // this.documents, + // this.artifactsVideo, + // this.artifactsImage, + this.minInvestmentAmt, + // this.keyMerits + }); + + Data.fromJson(Map json) { + id = json['id']; + ioId = json['io_id']; + investmentTypeXid = json['investmentType_xid']; + sponsorXid = json['sponsor_xid']; + ioStatusXid = json['ioStatus_xid']; + investmentNameEnglish = json['investmentNameEnglish']; + investmentNameArabic = json['investmentNameArabic']; + descriptionEnglish = json['descriptionEnglish']; + descriptionArabic = json['descriptionArabic']; + goalAmount = json['goalAmount']; + closingDate = json['closingDate']; + holdingPeriod = json['holdingPeriod']; + expectedReturn = json['expectedReturn']; + originalValuation = json['originalValuation']; + currentValuation = json['currentValuation']; + iSIN = json['ISIN']; + investmentDetails = json['InvestmentDetails']; + comment = json['comment']; + isInvestedAmount = json['isInvestedAmount']; + amountInvested = json['amountInvested']; + isActive = json['isActive']; + createdBy = json['createdBy']; + modifiedBy = json['modifiedBy']; + createdAt = json['createdAt']; + updatedAt = json['updatedAt']; + deletedAt = json['deletedAt']; + sponsor = + json['sponsor'] != null ? new Sponsor.fromJson(json['sponsor']) : null; + ioStatus = json['ioStatus'] != null + ? new IoStatus.fromJson(json['ioStatus']) + : null; + investmentType = json['investmentType'] != null + ? new InvestmentType.fromJson(json['investmentType']) + : null; + // if (json['documents'] != null) { + // documents = []; + // json['documents'].forEach((v) { + // documents!.add(new Null.fromJson(v)); + // }); + // } + // if (json['artifactsVideo'] != null) { + // artifactsVideo = []; + // json['artifactsVideo'].forEach((v) { + // artifactsVideo!.add(new Null.fromJson(v)); + // }); + // } + // if (json['artifactsImage'] != null) { + // artifactsImage = []; + // json['artifactsImage'].forEach((v) { + // artifactsImage!.add(new Null.fromJson(v)); + // }); + // } + if (json['minInvestmentAmt'] != null) { + minInvestmentAmt = []; + json['minInvestmentAmt'].forEach((v) { + minInvestmentAmt!.add(new MinInvestmentAmt.fromJson(v)); + }); + } + // if (json['keyMerits'] != null) { + // keyMerits = []; + // json['keyMerits'].forEach((v) { + // keyMerits!.add(new Null.fromJson(v)); + // }); + // } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['io_id'] = this.ioId; + data['investmentType_xid'] = this.investmentTypeXid; + data['sponsor_xid'] = this.sponsorXid; + data['ioStatus_xid'] = this.ioStatusXid; + data['investmentNameEnglish'] = this.investmentNameEnglish; + data['investmentNameArabic'] = this.investmentNameArabic; + data['descriptionEnglish'] = this.descriptionEnglish; + data['descriptionArabic'] = this.descriptionArabic; + data['goalAmount'] = this.goalAmount; + data['closingDate'] = this.closingDate; + data['holdingPeriod'] = this.holdingPeriod; + data['expectedReturn'] = this.expectedReturn; + data['originalValuation'] = this.originalValuation; + data['currentValuation'] = this.currentValuation; + data['ISIN'] = this.iSIN; + data['InvestmentDetails'] = this.investmentDetails; + data['comment'] = this.comment; + data['isInvestedAmount'] = this.isInvestedAmount; + data['amountInvested'] = this.amountInvested; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; + if (this.sponsor != null) { + data['sponsor'] = this.sponsor!.toJson(); + } + if (this.ioStatus != null) { + data['ioStatus'] = this.ioStatus!.toJson(); + } + if (this.investmentType != null) { + data['investmentType'] = this.investmentType!.toJson(); + } + // if (this.documents != null) { + // data['documents'] = this.documents!.map((v) => v.toJson()).toList(); + // } + // if (this.artifactsVideo != null) { + // data['artifactsVideo'] = + // this.artifactsVideo!.map((v) => v.toJson()).toList(); + // } + // if (this.artifactsImage != null) { + // data['artifactsImage'] = + // this.artifactsImage!.map((v) => v.toJson()).toList(); + // } + if (this.minInvestmentAmt != null) { + data['minInvestmentAmt'] = + this.minInvestmentAmt!.map((v) => v.toJson()).toList(); + } + // if (this.keyMerits != null) { + // data['keyMerits'] = this.keyMerits!.map((v) => v.toJson()).toList(); + // } + return data; + } +} + +class Sponsor { + int? id; + String? sponsorName; + String? sponsorNameArabic; + String? email; + Null? profile; + Null? address; + Null? mobileNo; + Null? bankName; + Null? accountNumber; + bool? isActive; + Null? createdBy; + Null? modifiedBy; + String? createdAt; + String? updatedAt; + Null? deletedAt; + + Sponsor( + {this.id, + this.sponsorName, + this.sponsorNameArabic, + this.email, + this.profile, + this.address, + this.mobileNo, + this.bankName, + this.accountNumber, + this.isActive, + this.createdBy, + this.modifiedBy, + this.createdAt, + this.updatedAt, + this.deletedAt}); + + Sponsor.fromJson(Map json) { + id = json['id']; + sponsorName = json['sponsorName']; + sponsorNameArabic = json['sponsorNameArabic']; + email = json['email']; + profile = json['profile']; + address = json['address']; + mobileNo = json['mobileNo']; + bankName = json['bankName']; + accountNumber = json['accountNumber']; + isActive = json['isActive']; + createdBy = json['createdBy']; + modifiedBy = json['modifiedBy']; + createdAt = json['createdAt']; + updatedAt = json['updatedAt']; + deletedAt = json['deletedAt']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['sponsorName'] = this.sponsorName; + data['sponsorNameArabic'] = this.sponsorNameArabic; + data['email'] = this.email; + data['profile'] = this.profile; + data['address'] = this.address; + data['mobileNo'] = this.mobileNo; + data['bankName'] = this.bankName; + data['accountNumber'] = this.accountNumber; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; + return data; + } +} + +class IoStatus { + int? id; + String? statusAdmin; + String? statusInvest; + String? statusPortfolio; + bool? isActive; + Null? createdBy; + Null? modifiedBy; + String? createdAt; + String? updatedAt; + Null? deletedAt; + + IoStatus( + {this.id, + this.statusAdmin, + this.statusInvest, + this.statusPortfolio, + this.isActive, + this.createdBy, + this.modifiedBy, + this.createdAt, + this.updatedAt, + this.deletedAt}); + + IoStatus.fromJson(Map json) { + id = json['id']; + statusAdmin = json['statusAdmin']; + statusInvest = json['statusInvest']; + statusPortfolio = json['statusPortfolio']; + isActive = json['isActive']; + createdBy = json['createdBy']; + modifiedBy = json['modifiedBy']; + createdAt = json['createdAt']; + updatedAt = json['updatedAt']; + deletedAt = json['deletedAt']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['statusAdmin'] = this.statusAdmin; + data['statusInvest'] = this.statusInvest; + data['statusPortfolio'] = this.statusPortfolio; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; + return data; + } +} + +class InvestmentType { + int? id; + String? investmentTypeName; + String? investmentTypeNameArabic; + String? note; + String? noteArabic; + bool? isActive; + Null? createdBy; + Null? modifiedBy; + String? createdAt; + String? updatedAt; + Null? deletedAt; + + InvestmentType( + {this.id, + this.investmentTypeName, + this.investmentTypeNameArabic, + this.note, + this.noteArabic, + this.isActive, + this.createdBy, + this.modifiedBy, + this.createdAt, + this.updatedAt, + this.deletedAt}); + + InvestmentType.fromJson(Map json) { + id = json['id']; + investmentTypeName = json['investmentTypeName']; + investmentTypeNameArabic = json['investmentTypeNameArabic']; + note = json['note']; + noteArabic = json['noteArabic']; + isActive = json['isActive']; + createdBy = json['createdBy']; + modifiedBy = json['modifiedBy']; + createdAt = json['createdAt']; + updatedAt = json['updatedAt']; + deletedAt = json['deletedAt']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['investmentTypeName'] = this.investmentTypeName; + data['investmentTypeNameArabic'] = this.investmentTypeNameArabic; + data['note'] = this.note; + data['noteArabic'] = this.noteArabic; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; + return data; + } +} + +class MinInvestmentAmt { + int? id; + int? ioXid; + int? countryXid; + String? minInvestmentAmt; + String? maxInvestmentAmt; + bool? isActive; + Null? createdBy; + Null? modifiedBy; + String? createdAt; + String? updatedAt; + Null? deletedAt; + + MinInvestmentAmt( + {this.id, + this.ioXid, + this.countryXid, + this.minInvestmentAmt, + this.maxInvestmentAmt, + this.isActive, + this.createdBy, + this.modifiedBy, + this.createdAt, + this.updatedAt, + this.deletedAt}); + + MinInvestmentAmt.fromJson(Map json) { + id = json['id']; + ioXid = json['io_xid']; + countryXid = json['country_xid']; + minInvestmentAmt = json['minInvestmentAmt']; + maxInvestmentAmt = json['maxInvestmentAmt']; + isActive = json['isActive']; + createdBy = json['createdBy']; + modifiedBy = json['modifiedBy']; + createdAt = json['createdAt']; + updatedAt = json['updatedAt']; + deletedAt = json['deletedAt']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['io_xid'] = this.ioXid; + data['country_xid'] = this.countryXid; + data['minInvestmentAmt'] = this.minInvestmentAmt; + data['maxInvestmentAmt'] = this.maxInvestmentAmt; + data['isActive'] = this.isActive; + data['createdBy'] = this.createdBy; + data['modifiedBy'] = this.modifiedBy; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['deletedAt'] = this.deletedAt; + return data; + } +} diff --git a/lib/features/MainScreens/Invest/domain/repository/io_api.dart b/lib/features/MainScreens/Invest/domain/repository/io_api.dart index 5f344f0..4b3ef68 100644 --- a/lib/features/MainScreens/Invest/domain/repository/io_api.dart +++ b/lib/features/MainScreens/Invest/domain/repository/io_api.dart @@ -14,4 +14,10 @@ class IOApi { final response = await NetworkApiService().get(url); return response; } + + Future iODetailsAPI(int id) async { + String url = "${ApiEndpoints.detailsIOApi}$id"; + final response = await NetworkApiService().get(url); + return response; + } } diff --git a/lib/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_bloc.dart b/lib/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_bloc.dart new file mode 100644 index 0000000..2481c3a --- /dev/null +++ b/lib/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_bloc.dart @@ -0,0 +1,34 @@ +// video_bloc.dart +import 'dart:async'; + +import 'package:bloc/bloc.dart'; +import 'package:tanami_app/features/MainScreens/Invest/domain/model/detail_io_model.dart'; +import 'package:tanami_app/features/MainScreens/Invest/domain/repository/io_api.dart'; + +import '../../../../../../Api_Helper/base_manager.dart'; +import '../../../../../../Globalconst.dart'; +import 'io_details_event.dart'; +import 'io_details_state.dart'; + +class IODetailsBloc extends Bloc { + final int id; + IODetailsBloc({required this.id}) : super(IODetailsStateInitial()) { + on(mapEventToState); + } + + Future mapEventToState( + IODetailsEvent event, Emitter emit) async { + emit(IODetailsStateLoading()); + try { + ResponseData response = await IOApi().iODetailsAPI(id); + if (response.status == ResponseStatus.SUCCESS) { + DetailIOModel detailIOModel = DetailIOModel.fromJson(response.data); + emit(IODetailsStateLoaded(detailIOModel)); + } + } catch (e) { + emit(IODetailsError(Globalconst.languageSelected == "en" + ? 'Oops Something went wrong' + : "تبا شيء ما حدث بشكل خاطئ")); + } + } +} diff --git a/lib/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_event.dart b/lib/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_event.dart new file mode 100644 index 0000000..5106a41 --- /dev/null +++ b/lib/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_event.dart @@ -0,0 +1,16 @@ +// video_event.dart +import 'package:equatable/equatable.dart'; + +abstract class IODetailsEvent extends Equatable { + const IODetailsEvent(); + + @override + List get props => []; +} + +class FetchIODetailsData extends IODetailsEvent { + const FetchIODetailsData(); + + @override + List get props => []; +} diff --git a/lib/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_state.dart b/lib/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_state.dart new file mode 100644 index 0000000..5693706 --- /dev/null +++ b/lib/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_state.dart @@ -0,0 +1,32 @@ +// video_state.dart +import 'package:equatable/equatable.dart'; +import 'package:tanami_app/features/MainScreens/Invest/domain/model/detail_io_model.dart'; + +abstract class IODetailsState extends Equatable { + const IODetailsState(); + + @override + List get props => []; +} + +class IODetailsStateInitial extends IODetailsState {} + +class IODetailsStateLoading extends IODetailsState {} + +class IODetailsStateLoaded extends IODetailsState { + final DetailIOModel detailIOModel; + + const IODetailsStateLoaded(this.detailIOModel); + + @override + List get props => [detailIOModel]; +} + +class IODetailsError extends IODetailsState { + final String message; + + const IODetailsError(this.message); + + @override + List get props => [message]; +} diff --git a/lib/features/MainScreens/Invest/presentation/pages/invest_details_layout.dart b/lib/features/MainScreens/Invest/presentation/pages/invest_details_layout.dart index df9afc4..66c2282 100644 --- a/lib/features/MainScreens/Invest/presentation/pages/invest_details_layout.dart +++ b/lib/features/MainScreens/Invest/presentation/pages/invest_details_layout.dart @@ -1,9 +1,12 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:gap/gap.dart'; import 'package:tanami_app/core/styles/app_color.dart'; +import 'package:tanami_app/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_state.dart'; import 'package:tanami_app/features/MainScreens/Invest/presentation/widgets/invest_video_section.dart'; +import '../bloc/io_invest/io_details_bloc.dart'; import '../widgets/invest_detail_details_section.dart'; import '../widgets/invest_detail_image_carousel.dart'; import '../widgets/invest_included_documents_section.dart'; @@ -17,49 +20,64 @@ class InvestDetailsLayout extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColor.plainWhite, - body: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 20.0), - child: Column( - children: [ - Container( - decoration: BoxDecoration( - color: AppColor.plainWhite, - borderRadius: const BorderRadius.all(Radius.circular(20.0)), - boxShadow: [ - BoxShadow( - color: AppColor.plainBlack.withOpacity(0.15), - spreadRadius: 2, - blurRadius: 10, - offset: const Offset(0, 3), + body: + BlocBuilder(builder: (context, state) { + if (state is IODetailsStateLoading) { + return const Center(child: CircularProgressIndicator()); + } else if (state is IODetailsStateLoaded) { + return SingleChildScrollView( + child: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 16.0, vertical: 20.0), + child: Column( + children: [ + Container( + decoration: BoxDecoration( + color: AppColor.plainWhite, + borderRadius: + const BorderRadius.all(Radius.circular(20.0)), + boxShadow: [ + BoxShadow( + color: AppColor.plainBlack.withOpacity(0.15), + spreadRadius: 2, + blurRadius: 10, + offset: const Offset(0, 3), + ), + ], ), - ], - ), - child: Column( - children: [ - InvestDetailCarouselView( - type: type, + child: Column( + children: [ + InvestDetailCarouselView( + type: type, + detailIOModel: state.detailIOModel, + ), + InvestDetailDetailsSection( + type: type, + detailIOModel: state.detailIOModel, + ), + ], ), - InvestDetailDetailsSection( - type: type, - ), - ], - ), + ), + Gap( + 20.h, + ), + const KeyInvestmentSection(), + type == "closed" ? const SizedBox() : Gap(20.h), + type == "closed" + ? const SizedBox() + : const InvestIncludedDocumentsSection(), + type == "closed" ? const SizedBox() : Gap(20.h), + type == "closed" + ? const SizedBox() + : const InvestVideoSection(), + ], ), - Gap( - 20.h, - ), - const KeyInvestmentSection(), - type == "closed" ? const SizedBox() : Gap(20.h), - type == "closed" - ? const SizedBox() - : const InvestIncludedDocumentsSection(), - type == "closed" ? const SizedBox() : Gap(20.h), - type == "closed" ? const SizedBox() : const InvestVideoSection(), - ], - ), - ), - ), + ), + ); + } else { + return const Center(child: Text('Something went wrong!')); + } + }), ); } } diff --git a/lib/features/MainScreens/Invest/presentation/pages/invest_details_screen.dart b/lib/features/MainScreens/Invest/presentation/pages/invest_details_screen.dart index a7f6f10..bddaf0c 100644 --- a/lib/features/MainScreens/Invest/presentation/pages/invest_details_screen.dart +++ b/lib/features/MainScreens/Invest/presentation/pages/invest_details_screen.dart @@ -5,6 +5,8 @@ import 'package:tanami_app/core/routes/route_name.dart'; import 'package:tanami_app/core/routes/routes.dart'; import 'package:tanami_app/core/styles/app_color.dart'; import 'package:tanami_app/core/styles/app_text.dart'; +import 'package:tanami_app/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_bloc.dart'; +import 'package:tanami_app/features/MainScreens/Invest/presentation/bloc/io_invest/io_details_event.dart'; import 'package:tanami_app/shared/components/button_widget.dart'; import '../../../../../core/utils/language/localizations_delegate.dart'; @@ -14,7 +16,12 @@ import 'invest_details_layout.dart'; class InvestDetailsScreen extends StatelessWidget { final String type; - const InvestDetailsScreen({super.key, required this.type}); + final String id; + const InvestDetailsScreen({ + super.key, + required this.type, + required this.id, + }); @override Widget build(BuildContext context) { @@ -45,6 +52,10 @@ class InvestDetailsScreen extends StatelessWidget { // Create an instance of the OnboardingBloc create: (context) => CarouselBloc(), ), + BlocProvider( + create: (context) => IODetailsBloc(id: int.parse(id)) + ..add(const FetchIODetailsData()), + ) ], child: InvestDetailsLayout( type: type, diff --git a/lib/features/MainScreens/Invest/presentation/pages/invest_layout.dart b/lib/features/MainScreens/Invest/presentation/pages/invest_layout.dart index 57fdb35..d9a4c22 100644 --- a/lib/features/MainScreens/Invest/presentation/pages/invest_layout.dart +++ b/lib/features/MainScreens/Invest/presentation/pages/invest_layout.dart @@ -92,7 +92,12 @@ class AvailableItemsScreen extends StatelessWidget { : GestureDetector( onTap: () { goRouter.pushNamed(RouteName.investDetailScreen, - pathParameters: {"type": "available"}); + pathParameters: { + "type": "available", + "id": state + .availableItems.data!.rows![index - 1].id! + .toString() + }); }, child: Container( margin: const EdgeInsets.symmetric( @@ -155,8 +160,11 @@ class ClosedItemsScreen extends StatelessWidget { itemBuilder: (context, index) { return GestureDetector( onTap: () { - goRouter.pushNamed(RouteName.investDetailScreen, - pathParameters: {"type": "closed"}); + goRouter + .pushNamed(RouteName.investDetailScreen, pathParameters: { + "type": "closed", + "id": state.closedItems.data!.rows![index].id!.toString() + }); }, child: Container( margin: const EdgeInsets.symmetric( diff --git a/lib/features/MainScreens/Invest/presentation/widgets/invest_detail_details_section.dart b/lib/features/MainScreens/Invest/presentation/widgets/invest_detail_details_section.dart index 6a3b8c8..f62d3cd 100644 --- a/lib/features/MainScreens/Invest/presentation/widgets/invest_detail_details_section.dart +++ b/lib/features/MainScreens/Invest/presentation/widgets/invest_detail_details_section.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:gap/gap.dart'; import 'package:tanami_app/core/styles/app_color.dart'; +import 'package:tanami_app/core/utils/date_time_formatter/date_time_formatter.dart'; +import 'package:tanami_app/features/MainScreens/Invest/domain/model/detail_io_model.dart'; import '../../../../../core/styles/app_text.dart'; import '../../../../../core/utils/language/localizations_delegate.dart'; @@ -9,7 +11,9 @@ import '../../../../../shared/components/text_widget.dart'; class InvestDetailDetailsSection extends StatelessWidget { final String type; - const InvestDetailDetailsSection({super.key, required this.type}); + final DetailIOModel detailIOModel; + const InvestDetailDetailsSection( + {super.key, required this.type, required this.detailIOModel}); @override Widget build(BuildContext context) { @@ -24,7 +28,7 @@ class InvestDetailDetailsSection extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ TextWidget().text17W700( - 'Multi Family Residental', + detailIOModel.data!.investmentNameEnglish!, clr: AppColor.plainBlack, ), Gap( @@ -32,13 +36,18 @@ class InvestDetailDetailsSection extends StatelessWidget { ), type == "closed" ? const SizedBox() - : TextWidget().text22W900("SAR 1,478,000", + : TextWidget().text22W900( + "USD ${detailIOModel.data!.goalAmount!}", clr: AppColor.investTextColor), type == "closed" ? const SizedBox() : const Gap(8.0), type == "closed" ? const SizedBox() : LinearProgressIndicator( - value: type == "closed" ? 1 : 0.6, + value: type == "closed" + ? 1 + : (double.parse( + detailIOModel.data!.amountInvested!) / + double.parse(detailIOModel.data!.goalAmount!)), borderRadius: BorderRadius.circular(2), minHeight: 8.0, backgroundColor: AppColor.txtBorderColor, @@ -51,11 +60,11 @@ class InvestDetailDetailsSection extends StatelessWidget { : TextWidget().text11W700( type == "closed" ? "100% ${localizations.translate(AppText.fundedText)}" - : "60% ${localizations.translate(AppText.fundedText)}", + : "${(double.parse(detailIOModel.data!.amountInvested!) / double.parse(detailIOModel.data!.goalAmount!)) * 100}% ${localizations.translate(AppText.fundedText)}", clr: AppColor.portoflioCardTextColor), type == "closed" ? const SizedBox() : const Gap(8.0), TextWidget().text14W400( - 'Forem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vulputate libero et velit interdum, ac aliquet odio mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur tempus urna at turpis condimentum lobortis.', + detailIOModel.data!.descriptionEnglish!, clr: Colors.grey, txtAlign: TextAlign.start, ) @@ -89,7 +98,7 @@ class InvestDetailDetailsSection extends StatelessWidget { ), ), TextWidget().text14W700( - 'Silverlake', + detailIOModel.data!.sponsor!.sponsorName!, clr: AppColor.plainBlack, txtAlign: TextAlign.end, ) @@ -111,7 +120,7 @@ class InvestDetailDetailsSection extends StatelessWidget { ), ), TextWidget().text14W700( - '20.0%', + detailIOModel.data!.expectedReturn!, clr: AppColor.plainBlack, txtAlign: TextAlign.end, ), @@ -166,7 +175,7 @@ class InvestDetailDetailsSection extends StatelessWidget { ), ), TextWidget().text14W700( - '24 Months', + detailIOModel.data!.holdingPeriod!, clr: AppColor.plainBlack, txtAlign: TextAlign.end, ), @@ -188,7 +197,8 @@ class InvestDetailDetailsSection extends StatelessWidget { txtAlign: TextAlign.start, ), TextWidget().text14W700( - 'August 1, 2027', + DateTimeFormatter() + .formatDate(detailIOModel.data!.closingDate!), clr: AppColor.plainBlack, txtAlign: TextAlign.end, ), @@ -204,7 +214,7 @@ class InvestDetailDetailsSection extends StatelessWidget { txtAlign: TextAlign.start, ), TextWidget().text14W700( - 'SAR 1,000', + 'BHR ${detailIOModel.data!.minInvestmentAmt![0].minInvestmentAmt}', clr: AppColor.plainBlack, txtAlign: TextAlign.end, ), diff --git a/lib/features/MainScreens/Invest/presentation/widgets/invest_detail_image_carousel.dart b/lib/features/MainScreens/Invest/presentation/widgets/invest_detail_image_carousel.dart index 2b2873f..3d0acd0 100644 --- a/lib/features/MainScreens/Invest/presentation/widgets/invest_detail_image_carousel.dart +++ b/lib/features/MainScreens/Invest/presentation/widgets/invest_detail_image_carousel.dart @@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:gap/gap.dart'; import 'package:tanami_app/core/styles/app_color.dart'; +import 'package:tanami_app/core/utils/date_time_formatter/date_time_formatter.dart'; import '../../../../../core/styles/app_images.dart'; import '../../../../../core/styles/app_text.dart'; @@ -12,6 +13,7 @@ import '../../../../../shared/components/text_widget.dart'; import '../../../Portfolio/presentation/bloc/carousel/carousel_bloc.dart'; import '../../../Portfolio/presentation/bloc/carousel/carousel_event.dart'; import '../../../Portfolio/presentation/bloc/carousel/carousel_state.dart'; +import '../../domain/model/detail_io_model.dart'; final List imgList = [ {'id': 1, 'img_path': 'assets/images/portfolio_screen/detailsbg.png'}, @@ -24,9 +26,12 @@ final List imgList = [ class InvestDetailCarouselView extends StatelessWidget { final String type; + final DetailIOModel detailIOModel; + final CarouselController _controller = CarouselController(); - InvestDetailCarouselView({super.key, required this.type}); + InvestDetailCarouselView( + {super.key, required this.type, required this.detailIOModel}); @override Widget build(BuildContext context) { @@ -113,7 +118,7 @@ class InvestDetailCarouselView extends StatelessWidget { borderRadius: BorderRadius.circular(30.0), ), child: TextWidget().text11W700( - 'Asset Class', + detailIOModel.data!.investmentType!.investmentTypeName!, clr: AppColor.selectedItemColor, ), ), @@ -140,8 +145,8 @@ class InvestDetailCarouselView extends StatelessWidget { ), TextWidget().text11W500( type == "closed" - ? '${localizations.translate(AppText.closedDateText)} Jul 10 2025' - : '${localizations.translate(AppText.closingDateText)} Jul 10 2025', + ? '${localizations.translate(AppText.closedDateText)} ${DateTimeFormatter().formatDate(detailIOModel.data!.closingDate!)}' + : '${localizations.translate(AppText.closingDateText)} ${DateTimeFormatter().formatDate(detailIOModel.data!.closingDate!)}', clr: AppColor.plainBlack, ), ], diff --git a/lib/features/MainScreens/Invest/presentation/widgets/invest_details_section.dart b/lib/features/MainScreens/Invest/presentation/widgets/invest_details_section.dart index 959d7d3..4fd18d8 100644 --- a/lib/features/MainScreens/Invest/presentation/widgets/invest_details_section.dart +++ b/lib/features/MainScreens/Invest/presentation/widgets/invest_details_section.dart @@ -141,7 +141,7 @@ class InvestDetailsSection extends StatelessWidget { ), ), TextWidget().text14W700( - availableIOModel.sponsor!.sponsorName!, + availableIOModel.sponsor!.sponsorName ?? "", clr: AppColor.plainBlack, txtAlign: TextAlign.end, ) diff --git a/lib/features/MainScreens/Invest/presentation/widgets/invest_image_carousel.dart b/lib/features/MainScreens/Invest/presentation/widgets/invest_image_carousel.dart index 4fb3c96..07d79a8 100644 --- a/lib/features/MainScreens/Invest/presentation/widgets/invest_image_carousel.dart +++ b/lib/features/MainScreens/Invest/presentation/widgets/invest_image_carousel.dart @@ -4,22 +4,16 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:gap/gap.dart'; import 'package:tanami_app/core/styles/app_color.dart'; +import 'package:tanami_app/shared/api/api_endpoints.dart'; import '../../../Portfolio/presentation/bloc/carousel/carousel_bloc.dart'; import '../../../Portfolio/presentation/bloc/carousel/carousel_event.dart'; import '../../../Portfolio/presentation/bloc/carousel/carousel_state.dart'; - -final List imgList = [ - {'id': 1, 'img_path': 'assets/images/portfolio_screen/detailsbg.png'}, - {'id': 2, 'img_path': 'assets/images/portfolio_screen/detailsbg.png'}, - {'id': 3, 'img_path': 'assets/images/portfolio_screen/detailsbg.png'}, - {'id': 4, 'img_path': 'assets/images/portfolio_screen/detailsbg.png'}, - {'id': 5, 'img_path': 'assets/images/portfolio_screen/detailsbg.png'}, -]; +import '../../domain/model/available_io_model.dart'; class InvestCarouselView extends StatelessWidget { final CarouselController _controller = CarouselController(); - final List imageList; + final List imageList; InvestCarouselView({super.key, required this.imageList}); @@ -40,8 +34,8 @@ class InvestCarouselView extends StatelessWidget { child: CarouselSlider( items: imageList .map( - (item) => Image.asset( - item, + (item) => Image.network( + "${ApiEndpoints.base}${item.artifactPathName!}", fit: BoxFit.cover, width: double.infinity, alignment: Alignment.topCenter, diff --git a/lib/shared/api/api_endpoints.dart b/lib/shared/api/api_endpoints.dart index 1514276..da08245 100644 --- a/lib/shared/api/api_endpoints.dart +++ b/lib/shared/api/api_endpoints.dart @@ -45,4 +45,5 @@ class ApiEndpoints { //IO static const availableIOApi = "${baseurl}io/available"; static const closedIOApi = "${baseurl}io/closed"; + static const detailsIOApi = "${baseurl}io/"; } diff --git a/lib/shared/api/network_api_services.dart b/lib/shared/api/network_api_services.dart index c3c2460..830b1a0 100644 --- a/lib/shared/api/network_api_services.dart +++ b/lib/shared/api/network_api_services.dart @@ -30,9 +30,11 @@ class NetworkApiService { response = await _dio.get(url, options: (token == "") ? Options() - : Options(headers: { - "x-auth-token": token, - })); + : Options( + headers: { + "x-auth-token": token, + }, + )); if (response.statusCode == 201 || response.statusCode == 200) { return ResponseData("success", ResponseStatus.SUCCESS, data: response.data);