Skip to content

Commit 8b6e24a

Browse files
committed
🐛 fix(server.ts): change port variable case from lowercase port to uppercase PORT
✨ feat(server.ts): add support for process.env.PORT environment variable The port variable is now named PORT, which improves consistency with the naming conventions as PORT is a constant. Support for an environment variable allows the application to be more flexible as it can now run on any available port specified via the process.env.PORT environment variable. 🎨 style(home_controller.dart, useer_progression.dart, home_main_page.dart, home_profile.dart, rugi_laba_export.dart, edit_rugi_laba_view.dart): format code This commit formats the code in the mentioned files to improve readability and maintainability. ✨ feat(home_controller.dart, useer_progression.dart): add targetPlafond and successPercentage variables This commit adds targetPlafond and successPercentage variables to the HomeController and UserStatAndProgression classes, respectively. targetPlafond is a MoneyMask 🌐 chore(rugi_laba_view.dart): add locale to date format The date format in the RugiLabaView and LihatRugiLabaView widgets now includes a locale parameter to format the date in Indonesian. This improves the user experience for Indonesian users who are more familiar with the Indonesian date format.
1 parent 97a4900 commit 8b6e24a

8 files changed

Lines changed: 299 additions & 12 deletions

File tree

lib/app/modules/home/controllers/home_controller.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'dart:io';
55

66
// 🐦 Flutter imports:
77
import 'package:akm/app/widget/dialog_box.dart';
8+
import 'package:extended_masked_text/extended_masked_text.dart';
89
import 'package:flutter/material.dart';
910

1011
// 📦 Package imports:
@@ -247,6 +248,15 @@ class HomeController extends GetxController {
247248
var totalPlafond = 0.obs;
248249
var totalPlafondRejected = 0.obs;
249250

251+
// var targetPlafond = 0.obs;
252+
var targetPlafond = MoneyMaskedTextController(
253+
decimalSeparator: '',
254+
thousandSeparator: '.',
255+
precision: 0,
256+
initialValue: 0,
257+
);
258+
var successPercentage = 0.0.obs;
259+
250260
// Get location
251261
void getLocation() async {
252262
/// Determine the current position of the device.
@@ -433,6 +443,18 @@ class HomeController extends GetxController {
433443
}
434444
}
435445

446+
void calculatePercentage() {
447+
var parseTotalPlafond =
448+
double.parse(totalPlafond.toString().replaceAll('.', ''));
449+
var parseTarget = double.parse(targetPlafond.text.replaceAll('.', ''));
450+
451+
// Calculate percentage
452+
var percentage = parseTotalPlafond / parseTarget * 100;
453+
454+
// Set percentage
455+
successPercentage.value = percentage;
456+
}
457+
436458
// Unlink google account
437459
void unlinkGoogleAccount() async {
438460
try {

lib/app/modules/home/widget/components/home_profile/useer_progression.dart

Lines changed: 196 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
// 🐦 Flutter imports:
22
import 'package:akm/app/common/style.dart';
3+
import 'package:akm/app/widget/dialog_box.dart';
4+
import 'package:extended_masked_text/extended_masked_text.dart';
35
import 'package:flutter/material.dart';
46

57
// 📦 Package imports:
68

79
// 🌎 Project imports:
810
import 'package:akm/app/modules/home/controllers/home_controller.dart';
11+
import 'package:flutter_form_builder/flutter_form_builder.dart';
912
import 'package:get/get.dart';
1013

1114
class UserStatAndProgression extends StatelessWidget {
@@ -59,7 +62,14 @@ class UserStatAndProgression extends StatelessWidget {
5962
),
6063
)
6164
: Text(
62-
controller.totalPlafond.toString(),
65+
MoneyMaskedTextController(
66+
initialValue:
67+
controller.totalPlafond.toDouble(),
68+
thousandSeparator: '.',
69+
decimalSeparator: '',
70+
leftSymbol: 'Rp. ',
71+
precision: 0,
72+
).text,
6373
style: const TextStyle(
6474
fontSize: 20.0,
6575
color: secondaryColor,
@@ -133,7 +143,15 @@ class UserStatAndProgression extends StatelessWidget {
133143
),
134144
)
135145
: Text(
136-
controller.totalPlafondRejected.toString(),
146+
MoneyMaskedTextController(
147+
initialValue: controller
148+
.totalPlafondRejected
149+
.toDouble(),
150+
thousandSeparator: '.',
151+
decimalSeparator: '',
152+
leftSymbol: 'Rp. ',
153+
precision: 0,
154+
).text,
137155
style: const TextStyle(
138156
fontSize: 20.0,
139157
color: secondaryColor,
@@ -166,6 +184,182 @@ class UserStatAndProgression extends StatelessWidget {
166184
),
167185
),
168186
),
187+
const SizedBox(
188+
height: 10.0,
189+
),
190+
Padding(
191+
padding: const EdgeInsets.symmetric(horizontal: 20.0),
192+
child: Card(
193+
color: Colors.blue[900]?.withOpacity(0.9),
194+
elevation: 5,
195+
shape: RoundedRectangleBorder(
196+
borderRadius: BorderRadius.circular(20.0),
197+
),
198+
child: Container(
199+
width: MediaQuery.of(context).size.width,
200+
padding: const EdgeInsets.all(20.0),
201+
child: Row(
202+
children: [
203+
Expanded(
204+
child: Column(
205+
crossAxisAlignment: CrossAxisAlignment.start,
206+
children: [
207+
const Text(
208+
"Target plafond yang disetujui",
209+
style: TextStyle(
210+
fontSize: 15.0,
211+
color: secondaryColor,
212+
),
213+
),
214+
const SizedBox(
215+
height: 6.0,
216+
),
217+
Row(
218+
children: [
219+
Expanded(
220+
child: FormBuilder(
221+
child: FormBuilderTextField(
222+
name: 'targetPlafond',
223+
controller: controller.targetPlafond,
224+
cursorColor: secondaryColor,
225+
keyboardType: TextInputType.number,
226+
decoration: const InputDecoration(
227+
hintText: 'Target plafond',
228+
hintStyle: TextStyle(
229+
color: Colors.white,
230+
),
231+
border: InputBorder.none,
232+
contentPadding: EdgeInsets.symmetric(
233+
vertical: 10,
234+
),
235+
),
236+
onEditingComplete: () {
237+
controller.calculatePercentage();
238+
239+
// Close keyboard
240+
FocusScope.of(context).unfocus();
241+
242+
SuccessDialog(
243+
context: context,
244+
title: 'Sukses',
245+
desc: 'Target plafond berhasil diubah',
246+
btnOkOnPress: () {},
247+
).show();
248+
},
249+
textInputAction: TextInputAction.done,
250+
// Only show number keyboard
251+
style: const TextStyle(
252+
fontSize: 20.0,
253+
color: secondaryColor,
254+
fontWeight: FontWeight.bold,
255+
),
256+
onChanged: (value) {},
257+
),
258+
),
259+
),
260+
],
261+
),
262+
],
263+
),
264+
),
265+
Container(
266+
padding: const EdgeInsets.all(10.0),
267+
decoration: const BoxDecoration(
268+
color: Colors.pinkAccent,
269+
borderRadius: BorderRadius.all(
270+
Radius.circular(
271+
8.0,
272+
),
273+
),
274+
),
275+
child: const Icon(
276+
Icons.sell,
277+
size: 24.0,
278+
color: Colors.white,
279+
),
280+
),
281+
],
282+
),
283+
),
284+
),
285+
),
286+
const SizedBox(
287+
height: 10.0,
288+
),
289+
Padding(
290+
padding: const EdgeInsets.symmetric(horizontal: 20.0),
291+
child: Card(
292+
color: Colors.blue[900]?.withOpacity(0.9),
293+
elevation: 5,
294+
shape: RoundedRectangleBorder(
295+
borderRadius: BorderRadius.circular(20.0),
296+
),
297+
child: Container(
298+
width: MediaQuery.of(context).size.width,
299+
padding: const EdgeInsets.all(20.0),
300+
child: Row(
301+
children: [
302+
Expanded(
303+
child: Column(
304+
crossAxisAlignment: CrossAxisAlignment.start,
305+
children: [
306+
const Text(
307+
"Persentase",
308+
style: TextStyle(
309+
fontSize: 15.0,
310+
color: secondaryColor,
311+
),
312+
),
313+
const SizedBox(
314+
height: 6.0,
315+
),
316+
Row(
317+
children: [
318+
Obx(() => controller.isMyInputProcessing.value
319+
? const SizedBox(
320+
height: 20,
321+
width: 20,
322+
child: CircularProgressIndicator(
323+
color: Colors.white,
324+
),
325+
)
326+
: Text(
327+
"${controller.successPercentage}%",
328+
style: const TextStyle(
329+
fontSize: 20.0,
330+
color: secondaryColor,
331+
fontWeight: FontWeight.bold,
332+
),
333+
)),
334+
],
335+
),
336+
],
337+
),
338+
),
339+
Container(
340+
padding: const EdgeInsets.all(10.0),
341+
decoration: const BoxDecoration(
342+
color: Colors.deepPurpleAccent,
343+
borderRadius: BorderRadius.all(
344+
Radius.circular(
345+
8.0,
346+
),
347+
),
348+
),
349+
child: const Icon(
350+
Icons.pix,
351+
size: 24.0,
352+
color: Colors.white,
353+
),
354+
),
355+
],
356+
),
357+
),
358+
),
359+
),
360+
const SizedBox(
361+
height: 80.0,
362+
),
169363
],
170364
);
171365
}

lib/app/modules/home/widget/home_main_page.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class HomeMainPage extends StatelessWidget {
9292
SizedBox(
9393
height: 280,
9494
child: GridView.builder(
95+
physics: const NeverScrollableScrollPhysics(),
9596
itemCount: menuGridList.length,
9697
gridDelegate:
9798
const SliverGridDelegateWithFixedCrossAxisCount(
@@ -145,6 +146,9 @@ class HomeMainPage extends StatelessWidget {
145146
},
146147
),
147148
),
149+
const SizedBox(
150+
height: 20,
151+
),
148152
],
149153
),
150154
),

lib/app/modules/home/widget/home_profile.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,19 @@ class FormFirebase extends StatelessWidget {
6060
controller: controller,
6161
auth: auth,
6262
),
63-
UserStatAndProgression(
64-
controller: controller,
63+
const SizedBox(
64+
height: 10.0,
65+
),
66+
SizedBox(
67+
height: MediaQuery.of(context).size.height * 0.3,
68+
child: Scrollbar(
69+
child: SingleChildScrollView(
70+
physics: const BouncingScrollPhysics(),
71+
child: UserStatAndProgression(
72+
controller: controller,
73+
),
74+
),
75+
),
6576
),
6677
],
6778
),

lib/app/modules/insight_debitur/views/components/printing/rugi_laba/rugi_laba_export.dart

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,17 @@ Future<Uint8List> makeRugilabaPdf(DebiturInsight debtor) async {
112112
TableRow(
113113
children: [
114114
headerSmol(
115-
'Per Tanggal ${DateFormat('dd MMMM yyyy').format(DateTime.parse(debtor.inputNeraca!.tanggalInput.toString()).subtract(Duration(days: DateTime.parse(debtor.inputNeraca!.tanggalInput.toString()).day)).add(const Duration(days: 1)).subtract(const Duration(days: 1)))}')
115+
'Per Tanggal ${DateFormat('dd MMMM yyyy', 'id_ID').format(
116+
DateTime.parse(debtor.inputNeraca!.tanggalInput.toString())
117+
.subtract(Duration(
118+
days: DateTime.parse(
119+
debtor.inputNeraca!.tanggalInput.toString())
120+
.day))
121+
.add(const Duration(days: 1))
122+
.subtract(
123+
const Duration(days: 1),
124+
),
125+
)}')
116126
],
117127
)
118128
],
@@ -731,7 +741,17 @@ Future<Uint8List> makeRugilabaPdf(DebiturInsight debtor) async {
731741
TableRow(
732742
children: [
733743
headerSmol(
734-
'Periode Bulan ${DateFormat('MMMM yyyy').format(DateTime.parse(debtor.inputNeraca!.tanggalInput.toString()))}')
744+
'Periode Bulan ${DateFormat('dd MMMM yyyy', 'id_ID').format(
745+
DateTime.parse(debtor.inputNeraca!.tanggalInput.toString())
746+
.subtract(Duration(
747+
days: DateTime.parse(
748+
debtor.inputNeraca!.tanggalInput.toString())
749+
.day))
750+
.add(const Duration(days: 1))
751+
.subtract(
752+
const Duration(days: 1),
753+
),
754+
)}')
735755
],
736756
)
737757
],

lib/app/modules/rugi_laba/views/edit_rugi_laba_view.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ class EditRugiLabaView extends GetView<RugiLabaController> {
139139
const SizedBox(height: 16),
140140
Center(
141141
child: Text(
142-
'Per tanggal : ${DateFormat('dd MMMM yyyy').format(DateTime(data.inputNeraca.tanggalInput.year, data.inputNeraca.tanggalInput.month, 1).subtract(const Duration(days: 1)))}',
142+
'Per tanggal : ${DateFormat('dd MMMM yyyy', 'id_ID').format(
143+
DateTime(data.inputNeraca.tanggalInput.year,
144+
data.inputNeraca.tanggalInput.month, 1)
145+
.subtract(
146+
const Duration(days: 1),
147+
),
148+
)}',
143149
style: subtitle2,
144150
),
145151
),
@@ -163,7 +169,13 @@ class EditRugiLabaView extends GetView<RugiLabaController> {
163169
const SizedBox(height: 16),
164170
Center(
165171
child: Text(
166-
'Periode bulan : ${DateFormat('MMMM yyyy').format(data.inputNeraca.tanggalInput)}',
172+
'Periode bulan : ${DateFormat('dd MMMM yyyy', 'id_ID').format(
173+
DateTime(data.inputNeraca.tanggalInput.year,
174+
data.inputNeraca.tanggalInput.month, 1)
175+
.subtract(
176+
const Duration(days: 1),
177+
),
178+
)}',
167179
style: subtitle2,
168180
),
169181
),

0 commit comments

Comments
 (0)