131 lines
5.1 KiB
Dart
131 lines
5.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import '../controllers/notifikasi_controller.dart';
|
|
|
|
class NotifikasiView extends GetView<NotifikasiController> {
|
|
const NotifikasiView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: const Color.fromARGB(255, 253, 253, 253),
|
|
body: SafeArea(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20.0),
|
|
child: Column(
|
|
children: [
|
|
// Header
|
|
Row(
|
|
children: [
|
|
IconButton(
|
|
icon: const Icon(Icons.arrow_back),
|
|
onPressed: () => Get.back(),
|
|
),
|
|
const SizedBox(width: 8),
|
|
Expanded(
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
|
decoration: BoxDecoration(
|
|
color: Colors.black87,
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
'Notifikasi',
|
|
style: GoogleFonts.poppins(
|
|
color: Colors.white,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 20),
|
|
|
|
// Daftar Notifikasi
|
|
Expanded(
|
|
child: Obx(() {
|
|
final list = controller.notifikasiList;
|
|
if (list.isEmpty) {
|
|
return const Center(
|
|
child: Text("Belum ada notifikasi."),
|
|
);
|
|
}
|
|
|
|
return ListView.builder(
|
|
itemCount: list.length,
|
|
itemBuilder: (context, index) {
|
|
final item = list[index];
|
|
return Dismissible(
|
|
key: Key(item['waktu']),
|
|
background: Container(
|
|
color: Colors.white,
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
alignment: Alignment.centerLeft,
|
|
child: const Icon(Icons.delete, color: Colors.black),
|
|
),
|
|
secondaryBackground: Container(
|
|
color: Colors.white,
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
alignment: Alignment.centerRight,
|
|
child: const Icon(Icons.delete, color: Colors.black),
|
|
),
|
|
onDismissed: (_) => controller.hapusNotifikasi(item['waktu']),
|
|
child: Card(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
elevation: 3,
|
|
margin: const EdgeInsets.only(bottom: 12),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
item['judul'],
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const SizedBox(height: 6),
|
|
Text(
|
|
item['deskripsi'],
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 13,
|
|
color: Colors.grey[700],
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Align(
|
|
alignment: Alignment.bottomRight,
|
|
child: Text(
|
|
item['waktu'],
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 11,
|
|
color: Colors.grey[500],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|