Skip to content

Commit

Permalink
hoan thien
Browse files Browse the repository at this point in the history
  • Loading branch information
khang committed Dec 25, 2024
1 parent 96ac6f6 commit e46a2c4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
13 changes: 12 additions & 1 deletion lib/features/admin/presentation/complaints_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ class _ComplaintsPageState extends State<ComplaintsPage> {
uid = await authService.getUserUid(idToken!);
}

void sortComplaintsByDate({bool descending = true}) {
complaints.sort((a, b) {
if (descending) {
return b.date.compareTo(a.date); // Mới nhất trước
} else {
return a.date.compareTo(b.date); // Cũ nhất trước
}
});
}

void toggleSelectAllButton() {
if (chosenList.isEmpty) {
for (Complaint c in complaints) {
Expand Down Expand Up @@ -76,7 +86,7 @@ class _ComplaintsPageState extends State<ComplaintsPage> {
);
getUidAndIdtoken();
_fetchComplaints();

}

@override
Expand Down Expand Up @@ -106,6 +116,7 @@ class _ComplaintsPageState extends State<ComplaintsPage> {
if (mounted) {
setState(() {
complaints = complaintsFetched;
sortComplaintsByDate();
_isLoading = false;
});
}
Expand Down
18 changes: 16 additions & 2 deletions lib/features/resident/presentation/complaints_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
// import 'dart:math';
import 'dart:math';
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import '../domain/r_complaints.dart';
import 'package:intl/intl.dart';
Expand Down Expand Up @@ -89,6 +89,8 @@ class _ComplaintsPageState extends State<ComplaintsPage> {
return formattedDate;
}



TextEditingController titleAddController = TextEditingController();
TextEditingController descriptionController = TextEditingController();
showDialog(
Expand Down Expand Up @@ -211,7 +213,7 @@ class _ComplaintsPageState extends State<ComplaintsPage> {
date: convertTime(),
id: '123',
isFlagged: false,
bgColor:complaints.isEmpty?Colors.green: complaints[0].bgColor);
bgColor:complaints.isEmpty?generateRandomColor(): complaints[0].bgColor);
_addComplaint(complaintData, newComplaint);
Navigator.pop(context); // Thực hiện logic, rồi đóng dialog
},
Expand All @@ -222,6 +224,18 @@ class _ComplaintsPageState extends State<ComplaintsPage> {
},
);
}
final List<Color> colorPalette = [
const Color(0xffd69ca5),
const Color(0xff94c8d4),
const Color(0xffd696c0),
const Color(0xffa6e9ed),
const Color(0xff9ad29a),
const Color(0xffcecccb)
];
Color generateRandomColor() {
final randomColor = colorPalette[Random().nextInt(colorPalette.length)];
return randomColor;
}

@override
void initState() {
Expand Down

0 comments on commit e46a2c4

Please sign in to comment.