-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreferenceNumber
More file actions
250 lines (232 loc) · 8.41 KB
/
referenceNumber
File metadata and controls
250 lines (232 loc) · 8.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
final dropdownProvider = StateProvider<String>((ref) => loanData[0]['referenceNumber'].toString());
final dropdownProviderLoanType = StateProvider<String>((ref) => loanData[0]['loanType'].toString());
final dropdownProviderCurrency = StateProvider<String>((ref) => loanData[0]['currency'].toString());
final loanData = [
{
'referenceNumber': '123456789',
'loanType': 'Home Loan',
'currency': 'USD',
'loanAmount': 100000,
'interestRate': 5.0,
'installmentPaid': 5000,
'dghfds' : 73874,
},
{
'referenceNumber': '987654321',
'loanType': 'Car Loan',
'currency': 'EUR',
'loanAmount': 50000,
'interestRate': 4.0,
'installmentPaid': 2500,
'dghfds' : 73874,
},
{
'referenceNumber': '321456789',
'loanType': 'Personal Loan',
'currency': 'GBP',
'loanAmount': 25000,
'interestRate': 3.0,
'installmentPaid': 1250,
'dghfds' : 73874,
},
];
class LoanSummary extends ConsumerWidget {
const LoanSummary({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
final dropdownValue = ref.watch(dropdownProvider);
final dropdownValueLoanType = ref.watch(dropdownProviderLoanType);
final dropdownValueCurrency = ref.watch(dropdownProviderCurrency);
return Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(width: 18,),
DropdownButton<String>(
value: dropdownValue,
icon: const Icon(Icons.keyboard_arrow_down),
items: getAllReferenceNumbers(ref),
onChanged: (String? newValue) {
ref
.read(dropdownProvider.notifier)
.state = newValue!;
},
),
SizedBox(width: 28,),
DropdownButton<String>(
value: dropdownValueLoanType,
icon: const Icon(Icons.keyboard_arrow_down),
items: getAllLoanTypes(ref),
onChanged: (String? newValue) {
ref
.read(dropdownProviderLoanType.notifier)
.state = newValue!;
},
),
SizedBox(width: 28,),
DropdownButton<String>(
value: dropdownValueCurrency,
icon: const Icon(Icons.keyboard_arrow_down),
items: getAllCurrencyCode(ref),
onChanged: (String? newValue) {
ref
.read(dropdownProviderCurrency.notifier)
.state = newValue!;
},
),
],
),
Container(
width: 200, // Adjust the width here
child: TextField(
decoration: InputDecoration(
hintText: 'Search',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
),
suffixIcon: IconButton(
onPressed: () {
// Handle search button press here
// Perform the search operation
},
icon: Icon(Icons.search),
),
),
),
),
],
),
Row(
children: [
Expanded(
child: DataTable(
columns: [
DataColumn(
label: Container(
constraints: BoxConstraints(
maxWidth: 154,// Adjust the maximum width of the cell
maxHeight: double.infinity, // Allow the cell to expand vertically
),
alignment: Alignment.centerLeft,
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0),
child: Text('Reference Number',softWrap: true, ),
),
),
),
DataColumn(
label: Container(
alignment: Alignment.centerLeft,
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0),
child: Text('Loan Type',softWrap: true, ),
),
),
),
DataColumn(
label: Container(
alignment: Alignment.centerLeft,
child: const Padding(
padding: EdgeInsets.only(right: 200.0),
child: Text('Currency'),
),
),
),
DataColumn(
label: Container(
alignment: Alignment.centerLeft,
child: const Padding(
padding: EdgeInsets.only(right: 8.0),
child: Text('Loan Amount'),
),
),
),
DataColumn(
label: Container(
alignment: Alignment.centerLeft,
child: const Padding(
padding: EdgeInsets.only(right: 8.0),
child: Text('Interest Rate',softWrap: true, ),
),
),
),
DataColumn(
label: Container(
alignment: Alignment.centerLeft,
child: const Padding(
padding: EdgeInsets.only(right: 8.0),
child: Text('Installment Paid'),
),
),
),
DataColumn(
label: Container(
alignment: Alignment.centerLeft,
child: const Padding(
padding: EdgeInsets.only(right: 8.0),
child: Text('dghfds'),
),
),
),
],
rows: loanData.map((loan) {
return DataRow(
cells: [
DataCell(Text(loan['referenceNumber'].toString())),
DataCell(Text(loan['loanType'].toString())),
DataCell(Text(loan['currency'].toString())),
DataCell(Text(loan['loanAmount'].toString())),
DataCell(Text(loan['interestRate'].toString())),
DataCell(Text(loan['installmentPaid'].toString())),
DataCell(Text(loan['dghfds'].toString())),
],
);
}).toList(),
),
),
],
),
],
);
}
List<DropdownMenuItem<String>> getAllReferenceNumbers(WidgetRef ref) {
final List<DropdownMenuItem<String>> items = loanData
.map((loan) => DropdownMenuItem<String>(
value: loan['referenceNumber'].toString(),
child: Text(loan['referenceNumber'].toString()),
))
.toList();
// Sort the list of items.
items.sort((a, b) => a.value!.compareTo(b.value!));
return items;
}
List<DropdownMenuItem<String>> getAllLoanTypes(WidgetRef ref) {
final List<DropdownMenuItem<String>> items = loanData
.map((loan) => DropdownMenuItem<String>(
value: loan['loanType'].toString(),
child: Text(loan['loanType'].toString()),
))
.toList();
// Sort the list of items.
items.sort((a, b) => a.value!.compareTo(b.value!));
return items;
}
List<DropdownMenuItem<String>> getAllCurrencyCode(WidgetRef ref) {
final List<DropdownMenuItem<String>> items = loanData
.map((loan) => DropdownMenuItem<String>(
value: loan['currency'].toString(),
child: Text(loan['currency'].toString()),
))
.toList();
// Sort the list of items.
items.sort((a, b) => a.value!.compareTo(b.value!));
return items;
}
}