This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
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 #709 from egovernments/develop
Develop
- Loading branch information
Showing
20 changed files
with
595 additions
and
11 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
59 changes: 59 additions & 0 deletions
59
frontend/mgramseva/lib/model/reports/WaterConnectionCount.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,59 @@ | ||
class WaterConnectionCount { | ||
int? count; | ||
int? taxperiodto; | ||
|
||
WaterConnectionCount({this.count, this.taxperiodto}); | ||
|
||
WaterConnectionCount.fromJson(Map<String, dynamic> json) { | ||
count = json['count']??0; | ||
taxperiodto = json['taxperiodto']??0; | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
final Map<String, dynamic> data = new Map<String, dynamic>(); | ||
data['count'] = this.count; | ||
data['taxperiodto'] = this.taxperiodto; | ||
return data; | ||
} | ||
} | ||
class WaterConnectionCountResponse { | ||
List<WaterConnectionCount>? waterConnectionsDemandGenerated; | ||
List<WaterConnectionCount>? waterConnectionsDemandNotGenerated; | ||
|
||
WaterConnectionCountResponse( | ||
{this.waterConnectionsDemandGenerated, | ||
this.waterConnectionsDemandNotGenerated}); | ||
|
||
WaterConnectionCountResponse.fromJson(Map<String, dynamic> json) { | ||
if (json['WaterConnectionsDemandGenerated'] != null) { | ||
waterConnectionsDemandGenerated = <WaterConnectionCount>[]; | ||
json['WaterConnectionsDemandGenerated'].forEach((v) { | ||
waterConnectionsDemandGenerated! | ||
.add(new WaterConnectionCount.fromJson(v)); | ||
}); | ||
} | ||
if (json['WaterConnectionsDemandNotGenerated'] != null) { | ||
waterConnectionsDemandNotGenerated = | ||
<WaterConnectionCount>[]; | ||
json['WaterConnectionsDemandNotGenerated'].forEach((v) { | ||
waterConnectionsDemandNotGenerated! | ||
.add(new WaterConnectionCount.fromJson(v)); | ||
}); | ||
} | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
final Map<String, dynamic> data = new Map<String, dynamic>(); | ||
if (this.waterConnectionsDemandGenerated != null) { | ||
data['WaterConnectionsDemandGenerated'] = | ||
this.waterConnectionsDemandGenerated!.map((v) => v.toJson()).toList(); | ||
} | ||
if (this.waterConnectionsDemandNotGenerated != null) { | ||
data['WaterConnectionsDemandNotGenerated'] = this | ||
.waterConnectionsDemandNotGenerated! | ||
.map((v) => v.toJson()) | ||
.toList(); | ||
} | ||
return data; | ||
} | ||
} |
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
113 changes: 113 additions & 0 deletions
113
frontend/mgramseva/lib/screeens/generate_bill/widgets/count_table_widget.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,113 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:mgramseva/model/reports/WaterConnectionCount.dart'; | ||
import 'package:mgramseva/utils/constants/i18_key_constants.dart'; | ||
import '../../../utils/date_formats.dart'; | ||
import '../../../utils/localization/application_localizations.dart'; | ||
|
||
class CountTableWidget extends StatefulWidget { | ||
final List<WaterConnectionCount>? waterConnectionCount; | ||
|
||
const CountTableWidget({Key? key, this.waterConnectionCount}) | ||
: super(key: key); | ||
|
||
@override | ||
_CountTableWidgetState createState() => _CountTableWidgetState(); | ||
} | ||
|
||
class _CountTableWidgetState extends State<CountTableWidget> { | ||
bool _isCollapsed = true; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final List<WaterConnectionCount>? connectionCount = | ||
widget.waterConnectionCount; | ||
|
||
return Container( | ||
child: Column( | ||
children: [ | ||
LayoutBuilder( | ||
builder: (context, constraints) { | ||
if (constraints.maxWidth <= 760) { | ||
return Container( | ||
width: MediaQuery.of(context).size.width, | ||
child: FittedBox( | ||
child: _buildDataTable(connectionCount!), | ||
), | ||
); | ||
} else { | ||
return Container( | ||
width: MediaQuery.of(context).size.width, | ||
child: _buildDataTable(connectionCount!)); | ||
} | ||
}, | ||
), | ||
if (connectionCount!.length > 5) | ||
Align( | ||
alignment: Alignment.bottomRight, | ||
child: TextButton( | ||
onPressed: () { | ||
setState(() { | ||
_isCollapsed = !_isCollapsed; | ||
}); | ||
}, | ||
child: Text(_isCollapsed | ||
? "${ApplicationLocalizations.of(context).translate(i18.common.VIEW_ALL)}" | ||
: "${ApplicationLocalizations.of(context).translate(i18.common.COLLAPSE)}"), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
|
||
Widget _buildDataTable(List<WaterConnectionCount> connectionCount) { | ||
return DataTable( | ||
border: TableBorder.all( | ||
width: 0.5, | ||
borderRadius: BorderRadius.all(Radius.circular(5)), | ||
color: Colors.grey, // Set border color to grey | ||
),// Set heading row background color to grey | ||
headingTextStyle: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), // Set heading text color to black and bold | ||
columns: [ | ||
DataColumn( | ||
label: FittedBox( | ||
child: Text( | ||
"${ApplicationLocalizations.of(context).translate(i18.common.LAST_BILL_CYCLE_MONTH)}", | ||
), | ||
), | ||
), | ||
DataColumn( | ||
label: FittedBox( | ||
child: Text( | ||
"${ApplicationLocalizations.of(context).translate(i18.common.CONSUMER_COUNT)}", | ||
), | ||
), | ||
) | ||
], | ||
rows: _isCollapsed | ||
? connectionCount.take(5).map((e) => _buildDataRow(e)).toList() | ||
: connectionCount.map((e) => _buildDataRow(e)).toList(), | ||
); | ||
} | ||
|
||
DataRow _buildDataRow(WaterConnectionCount count) { | ||
final bool isEvenRow = widget.waterConnectionCount!.indexOf(count) % 2 == 0; | ||
final Color? rowColor = isEvenRow ? Colors.grey[100] : Colors.white; // Set alternate row background color to grey | ||
|
||
return DataRow( | ||
color: MaterialStateColor.resolveWith((states) => rowColor!), // Apply alternate row background color | ||
cells: [ | ||
DataCell( | ||
Text( | ||
DateFormats.getMonthAndYearFromDateTime( | ||
DateTime.fromMillisecondsSinceEpoch(count.taxperiodto!), | ||
), | ||
), | ||
), | ||
DataCell( | ||
Text(count.count.toString()), | ||
), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.