feat(statistics): update district handling and improve dropdown components in statistics view
This commit is contained in:
parent
860481a093
commit
b62c64d36d
|
@ -145,6 +145,7 @@ class StatisticsViewController extends GetxController {
|
||||||
);
|
);
|
||||||
|
|
||||||
currentDistrictId.value = district.id;
|
currentDistrictId.value = district.id;
|
||||||
|
currentDistrict.value = district;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_logger.e('Error loading district data: $e');
|
_logger.e('Error loading district data: $e');
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:sigap/src/features/panic/presentation/controllers/statistics_view_controller.dart';
|
import 'package:sigap/src/features/panic/presentation/controllers/statistics_view_controller.dart';
|
||||||
import 'package:sigap/src/shared/widgets/dropdown/custom_dropdown.dart';
|
|
||||||
|
|
||||||
class CrimeStatsHeader extends StatelessWidget {
|
class CrimeStatsHeader extends StatelessWidget {
|
||||||
final String district;
|
final String district;
|
||||||
|
@ -68,16 +67,14 @@ class CrimeStatsHeader extends StatelessWidget {
|
||||||
|
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
|
|
||||||
// Date picker row with custom dropdowns
|
// Date picker row
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.calendar_month, size: 16, color: Colors.blue),
|
const Icon(Icons.calendar_month, size: 16, color: Colors.blue),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 5),
|
||||||
Expanded(child: _buildMonthDropdownCustom()),
|
_buildMonthDropdown(),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 5),
|
||||||
Expanded(
|
_buildYearDropdown(statsController.availableYears),
|
||||||
child: _buildYearDropdownCustom(statsController.availableYears),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -85,13 +82,15 @@ class CrimeStatsHeader extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom month dropdown using the shared custom dropdown widget
|
Widget _buildMonthDropdown() {
|
||||||
Widget _buildMonthDropdownCustom() {
|
|
||||||
final int currentMonth = int.parse(month);
|
final int currentMonth = int.parse(month);
|
||||||
|
final monthName = DateFormat(
|
||||||
|
'MMMM',
|
||||||
|
).format(DateTime(int.parse(year), currentMonth));
|
||||||
|
|
||||||
return CustomDropdown<int>(
|
return DropdownButton<int>(
|
||||||
label: '',
|
|
||||||
value: currentMonth,
|
value: currentMonth,
|
||||||
|
underline: Container(), // Remove underline
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if (value != null) onMonthChanged(value);
|
if (value != null) onMonthChanged(value);
|
||||||
},
|
},
|
||||||
|
@ -101,7 +100,7 @@ class CrimeStatsHeader extends StatelessWidget {
|
||||||
'MMMM',
|
'MMMM',
|
||||||
).format(DateTime(int.parse(year), monthNum));
|
).format(DateTime(int.parse(year), monthNum));
|
||||||
|
|
||||||
return DropdownMenuItem<int>(
|
return DropdownMenuItem(
|
||||||
value: monthNum,
|
value: monthNum,
|
||||||
child: Text(monthName, style: const TextStyle(fontSize: 14)),
|
child: Text(monthName, style: const TextStyle(fontSize: 14)),
|
||||||
);
|
);
|
||||||
|
@ -109,23 +108,21 @@ class CrimeStatsHeader extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom year dropdown using the shared custom dropdown widget
|
Widget _buildYearDropdown(List<int> availableYears) {
|
||||||
Widget _buildYearDropdownCustom(List<int> availableYears) {
|
|
||||||
final int currentYear = int.parse(year);
|
final int currentYear = int.parse(year);
|
||||||
final selectedYear =
|
|
||||||
availableYears.contains(currentYear)
|
|
||||||
? currentYear
|
|
||||||
: availableYears.last;
|
|
||||||
|
|
||||||
return CustomDropdown<int>(
|
return DropdownButton<int>(
|
||||||
label: '',
|
value:
|
||||||
value: selectedYear,
|
availableYears.contains(currentYear)
|
||||||
|
? currentYear
|
||||||
|
: availableYears.last,
|
||||||
|
underline: Container(), // Remove underline
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if (value != null) onYearChanged(value);
|
if (value != null) onYearChanged(value);
|
||||||
},
|
},
|
||||||
items:
|
items:
|
||||||
availableYears.map((year) {
|
availableYears.map((year) {
|
||||||
return DropdownMenuItem<int>(
|
return DropdownMenuItem(
|
||||||
value: year,
|
value: year,
|
||||||
child: Text(
|
child: Text(
|
||||||
year.toString(),
|
year.toString(),
|
||||||
|
|
|
@ -2,8 +2,6 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:sigap/src/features/panic/presentation/controllers/recovery_indicator_controller.dart';
|
import 'package:sigap/src/features/panic/presentation/controllers/recovery_indicator_controller.dart';
|
||||||
|
|
||||||
import '../widgets/progress_arc_painter.dart';
|
|
||||||
|
|
||||||
class RecoveryIndicator extends StatelessWidget {
|
class RecoveryIndicator extends StatelessWidget {
|
||||||
const RecoveryIndicator({super.key});
|
const RecoveryIndicator({super.key});
|
||||||
|
|
||||||
|
@ -48,63 +46,6 @@ class RecoveryIndicator extends StatelessWidget {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
controller.duration.value,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Text(
|
|
||||||
controller.timeLabel.value,
|
|
||||||
style: TextStyle(fontSize: 14, color: Colors.grey.shade600),
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
Stack(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: Colors.grey.shade100,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 45,
|
|
||||||
height: 45,
|
|
||||||
child: CustomPaint(
|
|
||||||
painter: ProgressArcPainter(
|
|
||||||
progress: controller.progress.value,
|
|
||||||
color: Colors.purple,
|
|
||||||
backgroundColor: Colors.grey.shade200,
|
|
||||||
strokeWidth: 4,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
width: 25,
|
|
||||||
height: 25,
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.security,
|
|
||||||
color: Colors.teal,
|
|
||||||
size: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
|
|
@ -147,8 +147,8 @@ class StatisticsView extends StatelessWidget {
|
||||||
// Helper to get color based on safety level
|
// Helper to get color based on safety level
|
||||||
Color _getSafetyColor(double safety) {
|
Color _getSafetyColor(double safety) {
|
||||||
if (safety >= 0.8) return Colors.green;
|
if (safety >= 0.8) return Colors.green;
|
||||||
if (safety >= 0.6) return Colors.blue;
|
if (safety >= 0.6) return Colors.orange;
|
||||||
if (safety >= 0.3) return Colors.orange;
|
if (safety >= 0.3) return Colors.red;
|
||||||
return Colors.red;
|
return Colors.purple;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue